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)
| 213 | #----------------------------------------------------------------------------- |
| 214 | |
| 215 | def quick_completer(cmd, completions): |
| 216 | r""" Easily create a trivial completer for a command. |
| 217 | |
| 218 | Takes either a list of completions, or all completions in string (that will |
| 219 | be split on whitespace). |
| 220 | |
| 221 | Example:: |
| 222 | |
| 223 | [d:\ipython]|1> import ipy_completers |
| 224 | [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz']) |
| 225 | [d:\ipython]|3> foo b<TAB> |
| 226 | bar baz |
| 227 | [d:\ipython]|3> foo ba |
| 228 | """ |
| 229 | |
| 230 | if isinstance(completions, str): |
| 231 | completions = completions.split() |
| 232 | |
| 233 | def do_complete(self, event): |
| 234 | return completions |
| 235 | |
| 236 | get_ipython().set_hook('complete_command',do_complete, str_key = cmd) |
| 237 | |
| 238 | def module_completion(line): |
| 239 | """ |
nothing calls this directly
no test coverage detected
searching dependent graphs…