##// END OF EJS Templates
Merge pull request #2854 from minrk/2853b...
Merge pull request #2854 from minrk/2853b Move kernel code into IPython.kernel inprocess Kernel in kernel.inprocess zmq Kernel in kernel.zmq KernelManager stuff and ulities in top-level kernel Main functional change: allow custom kernel Popen command - [x] adds `KernelManager.kernel_cmd` configurable for launching a custom kernel - [x] splits entry_point.base_launch_kernel into two steps: making the launch cmd and launching the subprocess - [x] figure out where the entry_point functions belong, if it should be anywhere else - [x] move IPython.zmq.kernelmanagerabc to IPython.kernel.kernelmanagerabc - [x] move IPython.lib.kernel/IPython/zmq.entry_point to IPython.kernel.launcher / connect - [x] move zmq.ipkernelapp.IPKernelApp to zmq.kernelapp (I'll look at merging the classes, and see if it makes - [x] move IPython.zmq to IPython.kernel.zmq - [x] move IPython.inprocess to IPython.kernel.inprocess - [x] move embed_kernel from zmq.ipkernelapp to zmq.embed - [x] move MultiKernelManager to IPython.kernel.multikernelmanager. - [x] move IPython.zmq.blockingkernelmanager to IPython.kernel.blockingkernelmanager. - [x] move IPython.zmq.kernelmanager to IPython.kernel.kernelmanager. - [x] move IPython.ipkernel.Kernel to IPython.kernel.kernel.

File last commit:

r7787:28b538a9
r9402:5db16721 merge
Show More
ledit.py
98 lines | 3.0 KiB | text/x-python | PythonLexer
Bernardo B. Marques
remove all trailling spaces
r4872 """ Fun magic line editor for ipython
vivainio
merge all from 0.7.3 branch to trunk
r503
Bernardo B. Marques
remove all trailling spaces
r4872 Use this to easily edit lists of strings gradually without crafting long
vivainio
merge all from 0.7.3 branch to trunk
r503 list comprehensions.
Bernardo B. Marques
remove all trailling spaces
r4872 'l' is the magic variable name for every line (array element). Save the current
vivainio
merge all from 0.7.3 branch to trunk
r503 result (or more exactly, retrieve the last ipython computation result into
%led work area) by running '%led s'. Just run '%led' to show the current work
area data.
Example use:
[ipython]|25> setups = !ls *setup*.py
==
['eggsetup.py', 'setup.py', 'setup_bdist_egg.py']
[ipython]|26> setups
<26> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py']
[ipython]|27> %led s
Data set from last result (_)
<27> ['eggsetup.py', 'setup.py', 'setup_bdist_egg.py']
[ipython]|28> %led upper
cmd translated => l.upper()
<28> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY']
[ipython]|29> %led
Magic line editor (for lists of strings)
current data is:
['eggsetup.py', 'setup.py', 'setup_bdist_egg.py']
[ipython]|30> %led upper
cmd translated => l.upper()
<30> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY']
[ipython]|31> %led s
Data set from last result (_)
<31> ['EGGSETUP.PY', 'SETUP.PY', 'SETUP_BDIST_EGG.PY']
[ipython]|32> %led "n:" + l
<32> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY']
[ipython]|33> %led s
Data set from last result (_)
<33> ['n:EGGSETUP.PY', 'n:SETUP.PY', 'n:SETUP_BDIST_EGG.PY']
[ipython]|34> %led l.
l.__add__ l.__gt__ l.__reduce_ex__ l.endswith l.join l.rstrip
l.__class__ l.__hash__ l.__repr__ l.expandtabs l.ljust l.split
... (completions for string variable shown ) ...
"""
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 from IPython.core import ipapi
vivainio
merge all from 0.7.3 branch to trunk
r503 import pprint
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 ip = ipapi.get()
vivainio
merge all from 0.7.3 branch to trunk
r503
curdata = []
def line_edit_f(self, cmd ):
global curdata
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 if not cmd:
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 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
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 if cmd == 's':
curdata = ip.ev('_')
print "Data set from last result (_)"
newlines = curdata
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 else:
# simple method call, e.g. upper
if cmd.isalpha():
cmd = 'l.' + cmd + '()'
print "cmd translated =>",cmd
newlines = []
for l in curdata:
try:
l2 = eval(cmd)
Matthias BUSSONNIER
conform to pep 3110...
r7787 except Exception as e:
vivainio
merge all from 0.7.3 branch to trunk
r503 print "Dropping exception",e,"on line:",l
continue
newlines.append(l2)
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 return newlines
def line_edit_complete_f(self,event):
""" Show all string methods in completions """
if event.symbol.startswith('l.'):
return ['l.' + func for func in dir('')]
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
merge all from 0.7.3 branch to trunk
r503 return dir('') + ['l.' + func for func in dir('')]
ip.set_hook('complete_command', line_edit_complete_f , str_key = '%led')
Bernardo B. Marques
remove all trailling spaces
r4872
Matthias BUSSONNIER
conform to pep 3110...
r7787 ip.define_magic('led', line_edit_f)