home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import IPython.ipapi as IPython
- import pprint
- ip = IPython.ipapi.get()
- curdata = []
-
- def line_edit_f(self, cmd):
- global curdata
- if not cmd:
- print 'Magic line editor (for lists of strings)'
- if curdata:
- print 'current data is:'
- pprint.pprint(curdata)
- else:
- print "No current data, you should set it by running '%led s'"
- print 'When you have your data in _ (result of last computation).'
- return None
- if cmd == 's':
- curdata = ip.ev('_')
- print 'Data set from last result (_)'
- newlines = curdata
- elif cmd.isalpha():
- cmd = 'l.' + cmd + '()'
- print 'cmd translated =>', cmd
-
- newlines = []
- for l in curdata:
-
- try:
- l2 = eval(cmd)
- except Exception:
- cmd
- e = cmd
- print 'Dropping exception', e, 'on line:', l
- continue
- except:
- cmd
-
- newlines.append(l2)
-
- return newlines
-
-
- def line_edit_complete_f(self, event):
- if event.symbol.startswith('l.'):
- return [ 'l.' + func for func in dir('') ]
- return [] + [ 'l.' + func for func in dir('') ]
-
- ip.set_hook('complete_command', line_edit_complete_f, str_key = '%led')
- ip.expose_magic('led', line_edit_f)
-