##// END OF EJS Templates
ipy_completers.quick_completer for easy creation of custom completers
vivainio -
Show More
@@ -37,7 +37,8 b' def clear_f(self,arg):'
37 except AttributeError:
37 except AttributeError:
38 print "Clear array only available in -pylab mode"
38 print "Clear array only available in -pylab mode"
39 gc.collect()
39 gc.collect()
40
40 elif target == 'shadow':
41 api.db.hcompress('shadowhist')
41
42
42 ip.expose_magic("clear",clear_f)
43 ip.expose_magic("clear",clear_f)
43
44
@@ -17,6 +17,29 b' ip = IPython.ipapi.get()'
17 TIMEOUT_STORAGE = 3 #Time in seconds after which the rootmodules will be stored
17 TIMEOUT_STORAGE = 3 #Time in seconds after which the rootmodules will be stored
18 TIMEOUT_GIVEUP = 20 #Time in seconds after which we give up
18 TIMEOUT_GIVEUP = 20 #Time in seconds after which we give up
19
19
20 def quick_completer(cmd, completions):
21 """ Easily create a completer a trivial completer for a command.
22
23 Takes either a list of completions, or all completions in string
24 (that will be split on whitespace)
25
26 Example::
27
28 [d:\ipython]|1> import ipy_completers
29 [d:\ipython]|2> ipy_completers.quick_completer('foo', ['bar','baz'])
30 [d:\ipython]|3> foo boooo
31
32 bar baz
33 [d:\ipython]|3> foo ba
34 """
35 if isinstance(completions, basestring):
36
37 completions = completions.split()
38 def do_complete(self,event):
39 return completions
40
41 ip.set_hook('complete_command',do_complete, str_key = cmd)
42
20 def getRootModules():
43 def getRootModules():
21 """
44 """
22 Returns a list containing the names of all the modules available in the
45 Returns a list containing the names of all the modules available in the
General Comments 0
You need to be logged in to leave comments. Login now