home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import IPython.ipapi as IPython
- from IPython.genutils import *
- ip = IPython.ipapi.get()
- import re
-
- def hnd_magic(line, mo):
- var = mo.group('varname')
- cmd = mo.group('cmd')
- expr = make_quoted_expr(cmd)
- return itpl('$var = _ip.magic($expr)')
-
-
- def hnd_syscmd(line, mo):
- var = mo.group('varname')
- cmd = mo.group('cmd')
- expr = make_quoted_expr(itpl('sc -l =$cmd'))
- return itpl('$var = _ip.magic($expr)')
-
-
- def install_re_handler(pat, hnd):
- ip.meta.re_prefilters.append((re.compile(pat), hnd))
-
-
- def init_handlers():
- ip.meta.re_prefilters = []
- install_re_handler('(?P<varname>[\\w\\.]+)\\s*=\\s*%(?P<cmd>.*)', hnd_magic)
- install_re_handler('(?P<varname>[\\w\\.]+)\\s*=\\s*!(?P<cmd>.*)', hnd_syscmd)
-
- init_handlers()
-
- def regex_prefilter_f(self, line):
- for pat, handler in ip.meta.re_prefilters:
- mo = pat.match(line)
- if mo:
- return handler(line, mo)
-
- raise IPython.ipapi.TryNext
-
- ip.set_hook('input_prefilter', regex_prefilter_f)
-