MCPcopy Create free account
hub / github.com/ipython/ipython / quick_completer

Function quick_completer

IPython/core/completerlib.py:187–208  ·  view source on GitHub ↗

r""" Easily create a trivial completer for a command. Takes either a list of completions, or all completions in string (that will be split on whitespace). Example:: [d:\ipython]|1> import ipy_completers [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz'

(cmd, completions)

Source from the content-addressed store, hash-verified

185#-----------------------------------------------------------------------------
186
187def quick_completer(cmd, completions):
188 r""" Easily create a trivial completer for a command.
189
190 Takes either a list of completions, or all completions in string (that will
191 be split on whitespace).
192
193 Example::
194
195 [d:\ipython]|1> import ipy_completers
196 [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz'])
197 [d:\ipython]|3> foo b<TAB>
198 bar baz
199 [d:\ipython]|3> foo ba
200 """
201
202 if isinstance(completions, str):
203 completions = completions.split()
204
205 def do_complete(self, event):
206 return completions
207
208 get_ipython().set_hook('complete_command',do_complete, str_key = cmd)
209
210def module_completion(line):
211 """

Callers

nothing calls this directly

Calls 2

get_ipythonFunction · 0.90
set_hookMethod · 0.80

Tested by

no test coverage detected