MCPcopy Index your code
hub / github.com/dbcli/pgcli / get_completers

Method get_completers

tests/metadata.py:128–161  ·  view source on GitHub ↗

Returns a function taking three bools `casing`, `filtr`, `aliasing` and the list `qualify`, all defaulting to None. Returns a list of completers. These parameters specify the allowed values for the corresponding completer parameters, `None` meaning any, i.e.

(self, casing)

Source from the content-addressed store, hash-verified

126 return self.get_completer()
127
128 def get_completers(self, casing):
129 """
130 Returns a function taking three bools `casing`, `filtr`, `aliasing` and
131 the list `qualify`, all defaulting to None.
132 Returns a list of completers.
133 These parameters specify the allowed values for the corresponding
134 completer parameters, `None` meaning any, i.e. (None, None, None, None)
135 results in all 24 possible completers, whereas e.g.
136 (True, False, True, ['never']) results in the one completer with
137 casing, without `search_path` filtering of objects, with table
138 aliasing, and without column qualification.
139 """
140
141 def _cfg(_casing, filtr, aliasing, qualify):
142 cfg = {"settings": {}}
143 if _casing:
144 cfg["casing"] = casing
145 cfg["settings"]["search_path_filter"] = filtr
146 cfg["settings"]["generate_aliases"] = aliasing
147 cfg["settings"]["qualify_columns"] = qualify
148 return cfg
149
150 def _cfgs(casing, filtr, aliasing, qualify):
151 casings = [True, False] if casing is None else [casing]
152 filtrs = [True, False] if filtr is None else [filtr]
153 aliases = [True, False] if aliasing is None else [aliasing]
154 qualifys = qualify or ["always", "if_more_than_one_table", "never"]
155 return [_cfg(*p) for p in product(casings, filtrs, aliases, qualifys)]
156
157 def completers(casing=None, filtr=None, aliasing=None, qualify=None):
158 get_comp = self.get_completer
159 return [get_comp(**c) for c in _cfgs(casing, filtr, aliasing, qualify)]
160
161 return completers
162
163 def _make_col(self, sch, tbl, col):
164 defaults = self.metadata.get("defaults", {}).get(sch, {})

Calls

no outgoing calls

Tested by

no test coverage detected