else: return self._prefilter(line,continuation) # Rebind this to be the new IPython prefilter: from IPython.iplib import InteractiveShell InteractiveShell.prefilter = prefilter_shell # Clean up the namespace. del InteractiveShell,prefilter_shell # Provide pysh and further shell-oriented services import os,sys,shutil from IPython.genutils import system,shell,getoutput,getoutputerror # Short aliases for getting shell output as a string and a list sout = getoutput lout = lambda cmd: getoutput(cmd,split=1) # Empty function, meant as a docstring holder so help(pysh) works. def pysh(): """Pysh is a set of modules and extensions to IPython which make shell-like usage with Python syntax more convenient. Keep in mind that pysh is NOT a full-blown shell, so don't try to make it your /etc/passwd entry! In particular, it has no job control, so if you type Ctrl-Z (under Unix), you'll suspend pysh itself, not the process you just started. Since pysh is really nothing but a customized IPython, you should familiarize yourself with IPython's features. This brief help mainly documents areas in which pysh differs from the normal IPython. ALIASES
# module to use temporary files instead of 'inline data' for data # communication. Note that this is the default, so unless you've manually # fiddled with it you should be ok. If you need to make changes, in the # Gnuplot module directory, loook for the gp_unix.py file and make sure the # prefer_inline_data variable is set to 0. If you set it to 1 Gnuplot.py will # try to pass the data to gnuplot via standard input, which completely # confuses the mouse control system (even though it may be a bit faster than # using temp files). # As of Gnuplot.py v1.7, a new option was added to use FIFOs (pipes). This # mechanism, while fast, also breaks the mouse system. You must therefore set # the variable prefer_fifo_data to 0 in gp_unix.py. tmpname = tempfile.mktemp() open(tmpname, 'w').write('set mouse') gnu_out = getoutput('gnuplot ' + tmpname) os.unlink(tmpname) if gnu_out: # Gnuplot won't print anything if it has mouse support print "*** Your version of Gnuplot appears not to have mouse support." gnuplot_mouse = 0 else: gnuplot_mouse = 1 del tmpname, gnu_out # Default state for persistence of new gnuplot instances if os.name in ['nt', 'dos'] or sys.platform == 'cygwin': gnuplot_persist = 0 else: gnuplot_persist = 1 import IPython.Gnuplot2 as Gnuplot
# module to use temporary files instead of 'inline data' for data # communication. Note that this is the default, so unless you've manually # fiddled with it you should be ok. If you need to make changes, in the # Gnuplot module directory, loook for the gp_unix.py file and make sure the # prefer_inline_data variable is set to 0. If you set it to 1 Gnuplot.py will # try to pass the data to gnuplot via standard input, which completely # confuses the mouse control system (even though it may be a bit faster than # using temp files). # As of Gnuplot.py v1.7, a new option was added to use FIFOs (pipes). This # mechanism, while fast, also breaks the mouse system. You must therefore set # the variable prefer_fifo_data to 0 in gp_unix.py. tmpname = tempfile.mktemp() open(tmpname,'w').write('set mouse') gnu_out = getoutput('gnuplot '+ tmpname) os.unlink(tmpname) if gnu_out: # Gnuplot won't print anything if it has mouse support print "*** Your version of Gnuplot appears not to have mouse support." gnuplot_mouse = 0 else: gnuplot_mouse = 1 del tmpname,gnu_out # Default state for persistence of new gnuplot instances if os.name in ['nt','dos'] or sys.platform == 'cygwin': gnuplot_persist = 0 else: gnuplot_persist = 1 import IPython.Gnuplot2 as Gnuplot