Initialize the completion machinery. This creates completion machinery that can be used by client code, either interactively in-process (typically triggered by the readline library), programmatically (such as in test suites) or out-of-process (typically over the netw
(self)
| 2309 | #------------------------------------------------------------------------- |
| 2310 | |
| 2311 | def init_completer(self): |
| 2312 | """Initialize the completion machinery. |
| 2313 | |
| 2314 | This creates completion machinery that can be used by client code, |
| 2315 | either interactively in-process (typically triggered by the readline |
| 2316 | library), programmatically (such as in test suites) or out-of-process |
| 2317 | (typically over the network by remote frontends). |
| 2318 | """ |
| 2319 | from IPython.core.completer import IPCompleter |
| 2320 | from IPython.core.completerlib import ( |
| 2321 | cd_completer, |
| 2322 | magic_run_completer, |
| 2323 | module_completer, |
| 2324 | reset_completer, |
| 2325 | ) |
| 2326 | |
| 2327 | self.Completer = IPCompleter(shell=self, |
| 2328 | namespace=self.user_ns, |
| 2329 | global_namespace=self.user_global_ns, |
| 2330 | parent=self, |
| 2331 | ) |
| 2332 | self.configurables.append(self.Completer) |
| 2333 | |
| 2334 | # Add custom completers to the basic ones built into IPCompleter |
| 2335 | sdisp = self.strdispatchers.get('complete_command', StrDispatch()) |
| 2336 | self.strdispatchers['complete_command'] = sdisp |
| 2337 | self.Completer.custom_completers = sdisp |
| 2338 | |
| 2339 | self.set_hook('complete_command', module_completer, str_key = 'import') |
| 2340 | self.set_hook('complete_command', module_completer, str_key = 'from') |
| 2341 | self.set_hook('complete_command', module_completer, str_key = '%aimport') |
| 2342 | self.set_hook('complete_command', magic_run_completer, str_key = '%run') |
| 2343 | self.set_hook('complete_command', cd_completer, str_key = '%cd') |
| 2344 | self.set_hook('complete_command', reset_completer, str_key = '%reset') |
| 2345 | |
| 2346 | @skip_doctest |
| 2347 | def complete(self, text, line=None, cursor_pos=None): |
no test coverage detected