##// END OF EJS Templates
Moving extensions to either quarantine or deathrow....
Moving extensions to either quarantine or deathrow. When a module is moved to quarantine, it means that while we intend to keep it, it is currently broken or sufficiently untested that it can't be in the main IPython codebase. To be moved back into the main IPython codebase a module must: 1. Work fully. 2. Have a test suite. 3. Be a proper IPython extension and tie into the official APIs. 3. Have members of the IPython dev team who are willing to maintain it. When a module is moved to deathrow, it means that the code is either broken and not worth repairing, deprecated, replaced by newer functionality, or code that should be developed and maintained by a third party.

File last commit:

r2267:928c921b
r2267:928c921b
Show More
ext_rescapture.py
58 lines | 1.3 KiB | text/x-python | PythonLexer
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151 # -*- coding: utf-8 -*-
""" IPython extension: new prefilters for output grabbing
Provides
var = %magic blah blah
var = !ls
"""
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 from IPython.core import ipapi
Brian Granger
Continuing a massive refactor of everything.
r2205 from IPython.core.error import TryNext
Brian Granger
genutils.py => utils/genutils.py and updated imports and tests.
r2023 from IPython.utils.genutils import *
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 ip = ipapi.get()
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
import re
def hnd_magic(line,mo):
""" Handle a = %mymagic blah blah """
var = mo.group('varname')
cmd = mo.group('cmd')
expr = make_quoted_expr(cmd)
Brian Granger
Massive refactoring of of the core....
r2245 return itpl('$var = get_ipython().magic($expr)')
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def hnd_syscmd(line,mo):
""" Handle a = !ls """
var = mo.group('varname')
cmd = mo.group('cmd')
vivainio
var = !cmd is no longer verbose
r902 expr = make_quoted_expr(itpl("sc -l =$cmd"))
Brian Granger
Massive refactoring of of the core....
r2245 return itpl('$var = get_ipython().magic($expr)')
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def install_re_handler(pat, hnd):
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 ip.meta.re_prefilters.append((re.compile(pat), hnd))
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def init_handlers():
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 ip.meta.re_prefilters = []
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
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()
Brian Granger
First go an implementing a=!ls and a=%who syntax....
r2256 def regex_prefilter_f(self,line):
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 for pat, handler in ip.meta.re_prefilters:
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151 mo = pat.match(line)
if mo:
return handler(line,mo)
Brian Granger
Continuing a massive refactor of everything.
r2205 raise TryNext
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 ip.set_hook('input_prefilter', regex_prefilter_f)