It took a little bit to understand the event object.
module_completer
to predict imports from indented lines. importnb
will need this. from IPython.core.completerlib import module_completer
Ø = __name__ == '__main__'
if Ø: ip = get_ipython()
h5py.ipy_completer
helped me understand the events a little better. def event(self, event):
event.line = event.line.lstrip()
return module_completer(self, event)
requests
should show up for unindented lines. if Ø: 'requests' in ip.complete('re', 'import re')[1], """requests is not installed"""
if Ø: 'requests' not in ip.complete('re', '\timport re')[1], """the new complete_command hook was assigned already."""
def load_ipython_extension(ip):
ip.set_hook('complete_command', event, str_key="import")
if Ø: load_ipython_extension(ip)
if Ø: 'requests' in ip.complete('re', '\timport re')[1], """requests still doesn't exist."""
from . import disqus