home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import IPython.ipapi as IPython
- import gc
- ip = IPython.ipapi.get()
-
- def clear_f(self, arg):
- api = self.getapi()
- user_ns = self.user_ns
- for target in arg.split():
- if target == 'out':
- print 'Flushing output cache (%d entries)' % len(user_ns['_oh'])
- self.outputcache.flush()
- continue
- if target == 'in':
- print 'Flushing input history'
- pc = self.outputcache.prompt_count + 1
- for n in range(1, pc):
- key = '_i' + `n`
- user_ns.pop(key, None)
-
- try:
- del user_ns[key]
- continue
- continue
-
-
- self.input_hist[:] = [
- '\n'] * pc
- self.input_hist_raw[:] = [
- '\n'] * pc
- continue
- if target == 'array':
-
- try:
- ndarray = ndarray
- import numpy
- for x, val in user_ns.items():
- if isinstance(val, ndarray):
- del user_ns[x]
- continue
- except AttributeError:
- print 'Clear array only works if Numpy is available.'
- except:
- None<EXCEPTION MATCH>AttributeError
-
-
- None<EXCEPTION MATCH>AttributeError
- if target == 'shadow_compress':
- print 'Compressing shadow history'
- api.db.hcompress('shadowhist')
- continue
- if target == 'shadow_nuke':
- print 'Erased all keys from shadow history '
- for k in ip.db.keys('shadowhist/*'):
- del ip.db[k]
-
- if target == 'dhist':
- print 'Clearing directory history'
- del user_ns['_dh'][:]
- continue
-
- gc.collect()
-
- ip.expose_magic('clear', clear_f)
- import ipy_completers
- ipy_completers.quick_completer('%clear', 'in out shadow_nuke shadow_compress dhist')
-