def init_ipython(ip): ip.expose_magic("rep",rep_f) ip.expose_magic("hist",magic_hist) ip.expose_magic("history",magic_history) import ipy_completers ipy_completers.quick_completer('%hist' ,'-g -t -r -n')
try: from numpy import ndarray # This must be done with items and not iteritems because we're # going to modify the dict in-place. for x,val in user_ns.items(): if isinstance(val,ndarray): del user_ns[x] except AttributeError: print "Clear array only works if Numpy is available." elif target == 'shadow_compress': print "Compressing shadow history" api.db.hcompress('shadowhist') elif target == 'shadow_nuke': print "Erased all keys from shadow history " for k in ip.db.keys('shadowhist/*'): del ip.db[k] elif target == 'dhist': print "Clearing directory history" del user_ns['_dh'][:] gc.collect() # Activate the extension ip.define_magic("clear",clear_f) import ipy_completers ipy_completers.quick_completer( '%clear','in out shadow_nuke shadow_compress dhist')
# must be done in-place self.input_hist[:] = ['\n'] * pc self.input_hist_raw[:] = ['\n'] * pc elif target == 'array': try: pylab = ip.IP.pylab for x in self.user_ns.keys(): if isinstance(self.user_ns[x], pylab.arraytype): del self.user_ns[x] except AttributeError: print "Clear array only available in -pylab mode" gc.collect() elif target == 'shadow_compress': print "Compressing shadow history" api.db.hcompress('shadowhist') elif target == 'shadow_nuke': print "Erased all keys from shadow history " for k in ip.db.keys('shadowhist/*'): del ip.db[k] elif target == 'dhist': print "Clearing directory history" del ip.user_ns['_dh'][:] ip.expose_magic("clear", clear_f) import ipy_completers ipy_completers.quick_completer('%clear', 'in out shadow_nuke shadow_compress dhist')