diff --git a/IPython/Extensions/InterpreterExec.py b/IPython/Extensions/InterpreterExec.py index 943023f..7d0f6b1 100644 --- a/IPython/Extensions/InterpreterExec.py +++ b/IPython/Extensions/InterpreterExec.py @@ -5,7 +5,7 @@ We define a special input line filter to allow typing lines which begin with '~', '/' or '.'. If one of those strings is encountered, it is automatically executed. -$Id: InterpreterExec.py 1041 2006-01-21 09:29:14Z vivainio $""" +$Id: InterpreterExec.py 1121 2006-02-01 21:12:20Z vivainio $""" #***************************************************************************** # Copyright (C) 2004 W.J. van der Laan @@ -20,6 +20,7 @@ __author__ = 'W.J. van der Laan , '\ '%s <%s>' % Release.authors['Fernando'] __license__ = Release.license +# TODO: deprecated def prefilter_shell(self,line,continuation): """Alternate prefilter, modified for shell-like functionality. @@ -234,10 +235,6 @@ def pysh(): # doesn't really expose a clean API for it. Be careful if you start making # many modifications here. -print """\ -Welcome to pysh, a set of extensions to IPython for shell usage. -help(pysh) -> help on the installed shell extensions and syntax. -""" # Set the 'cd' command to quiet mode, a more shell-like behavior __IPYTHON__.default_option('cd','-q') diff --git a/IPython/Magic.py b/IPython/Magic.py index e3611a9..bfad942 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1107 2006-01-30 19:02:20Z vivainio $""" +$Id: Magic.py 1121 2006-02-01 21:12:20Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -2698,8 +2698,19 @@ Defaulting color scheme to 'NoColor'""" This magic is similar to the cat utility, but it will assume the file to be Python source and will show it with syntax highlighting. """ - filename = get_py_filename(parameter_s) - page(self.shell.pycolorize(file_read(filename)), + try: + filename = get_py_filename(parameter_s) + cont = file_read(filename) + except IOError: + try: + cont = eval(parameter_s,self.user_ns) + except NameError: + cont = None + if cont is None: + print "Error: no such file or variable" + return + + page(self.shell.pycolorize(cont), screen_lines=self.shell.rc.screen_length) def magic_cpaste(self, parameter_s=''): diff --git a/IPython/UserConfig/ipy_user_conf.py b/IPython/UserConfig/ipy_user_conf.py index c3cefde..ea593ba 100644 --- a/IPython/UserConfig/ipy_user_conf.py +++ b/IPython/UserConfig/ipy_user_conf.py @@ -3,51 +3,63 @@ This is a more flexible and safe way to configure ipython than *rc files (ipythonrc, ipythonrc-pysh etc.) -This file is always imported on ipython startup. You should import all the +This file is always imported on ipython startup. You can import the ipython extensions you need here (see IPython/Extensions directory). -Feel free to edit this file to customize your ipython experience. If -you wish to only use the old config system, it's perfectly ok to make this file -empty. +Feel free to edit this file to customize your ipython experience. + +Note that as such this file does nothing, for backwards compatibility. +To enable this config file, uncomment the call to main() at the end. + +Try it out! """ # Most of your config files and extensions will probably start with this import from IPython import ipapi -ip = ipapi.get() import os +from IPython import Release -o = ip.options() -# autocall 1 ('smart') is default anyway, this is just an -# example on how to set an option -o.autocall = 1 +import sys -if o.profile == 'pysh': + +def main(): + ip = ipapi.get() + o = ip.options() + # autocall to "full" mode (smart mode is default, I like full mode) + + o.autocall = 1 + # Jason Orendorff's path class is handy to have in user namespace # if you are doing shell-like stuff try: ip.ex("from path import path" ) except ImportError: pass + + # Get prompt with working dir -# Uncomment these lines to get pysh-like prompt for all profiles. - -#o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' -#o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> ' -#o.prompt_out= '<\#> ' - -# make 'd' an alias for ls -F - -ip.magic('alias d ls -F --color=auto') - -# Make available all system commands through "rehashing" immediately. -# You can comment these lines out to speed up startup on very slow -# machines, and to conserve a bit of memory. Note that pysh profile does this -# automatically + o.prompt_in1= '\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' + o.prompt_in2= '\C_Green|\C_LightGreen\D\C_Green> ' + o.prompt_out= '<\#> ' + + # I like my banner minimal. + o.banner = "Py %s IPy %s\n" % (sys.version.split('\n')[0],Release.version) + + # make 'd' an alias for ls -F + + ip.magic('alias d ls -F --color=auto') + + # Make available all system commands through "rehashing" immediately. + # You can comment these lines out to speed up startup on very slow + # machines, and to conserve a bit of memory. Note that pysh profile does this + # automatically + + #if os.name=='posix': + # ip.magic('rehash') + #else: + # #slightly slower, but better results esp. with Windows + # ip.magic('rehashx') -#if os.name=='posix': -# ip.magic('rehash') -#else: -# #slightly slower, but better results esp. with Windows -# ip.magic('rehashx') +#main() \ No newline at end of file diff --git a/IPython/iplib.py b/IPython/iplib.py index 041db4a..1e79a93 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 1117 2006-01-31 21:02:45Z vivainio $ +$Id: iplib.py 1121 2006-02-01 21:12:20Z vivainio $ """ #***************************************************************************** @@ -1320,10 +1320,14 @@ want to merge them back into the new files.""" % locals() if self.rc.c: # Emulate Python's -c option self.exec_init_cmd() if banner is None: - if self.rc.banner: - banner = self.BANNER+self.banner2 - else: + if not self.rc.banner: banner = '' + # banner is string? Use it directly! + elif isinstance(self.rc.banner,basestring): + banner = self.rc.banner + else: + banner = self.BANNER+self.banner2 + self.interact(banner) def exec_init_cmd(self): diff --git a/doc/ChangeLog b/doc/ChangeLog index ec12b66..f4aea45 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,15 @@ 2006-02-01 Ville Vainio - * easy_install ipython==dev works correctly now. + * setup.py, eggsetup.py: easy_install ipython==dev works + correctly now (on Linux) + + * ipy_user_conf,ipmaker: user config changes, removed spurious + warnings + + * iplib: if rc.banner is string, use it as is. + + * Magic: %pycat accepts a string argument and pages it's contents. + 2006-01-30 Ville Vainio