From e78b53f449cd59066cf3639a5bd9151abf63ed4b 2006-01-24 18:15:27 From: vivainio Date: 2006-01-24 18:15:27 Subject: [PATCH] Merged 1071-1076 from banches/0.7.1 --- diff --git a/IPython/Logger.py b/IPython/Logger.py index 03a3612..b3a58c1 100644 --- a/IPython/Logger.py +++ b/IPython/Logger.py @@ -2,7 +2,7 @@ """ Logger class for IPython's logging facilities. -$Id: Logger.py 994 2006-01-08 08:29:44Z fperez $ +$Id: Logger.py 1077 2006-01-24 18:15:27Z vivainio $ """ #***************************************************************************** @@ -214,6 +214,7 @@ which already exists. But you must first start the logging process with def log_write(self,data,kind='input'): """Write data to the log file, if active""" + #print 'data: %r' % data # dbg if self.log_active and data: write = self.logfile.write if kind=='input': diff --git a/IPython/Magic.py b/IPython/Magic.py index 0c8ddf1..dc01d4d 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1076 2006-01-24 17:27:05Z vivainio $""" +$Id: Magic.py 1077 2006-01-24 18:15:27Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -480,27 +480,42 @@ Currently the magic system has the following functions:\n""" def magic_history(self, parameter_s = ''): """Print input history (_i variables), with most recent last. - %history [-n] -> print at most 40 inputs (some may be multi-line)\\ - %history [-n] n -> print at most n inputs\\ - %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ - + %history -> print at most 40 inputs (some may be multi-line)\\ + %history n -> print at most n inputs\\ + %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\ + Each input's number is shown, and is accessible as the automatically generated variable _i. Multi-line statements are printed starting at a new line for easy copy/paste. + + + Options: - If option -n is used, input numbers are not printed. This is useful if - you want to get a printout of many lines which can be directly pasted - into a text editor. + -n: do NOT print line numbers. This is useful if you want to get a + printout of many lines which can be directly pasted into a text + editor. - This feature is only available if numbered prompts are in use.""" + This feature is only available if numbered prompts are in use. + + -r: print the 'raw' history. IPython filters your input and + converts it all into valid Python source before executing it (things + like magics or aliases are turned into function calls, for + example). With this option, you'll see the unfiltered history + instead of the filtered version: '%cd /' will be seen as '%cd /' + instead of 'ipmagic("%cd /")'. + """ shell = self.shell if not shell.outputcache.do_full_cache: print 'This feature is only available if numbered prompts are in use.' return - opts,args = self.parse_options(parameter_s,'n',mode='list') + opts,args = self.parse_options(parameter_s,'nr',mode='list') + + if opts.has_key('r'): + input_hist = shell.input_hist_raw + else: + input_hist = shell.input_hist - input_hist = shell.input_hist default_length = 40 if len(args) == 0: final = len(input_hist) diff --git a/IPython/Release.py b/IPython/Release.py index 76c1213..1e85185 100644 --- a/IPython/Release.py +++ b/IPython/Release.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Release data for the IPython project. -$Id: Release.py 1058 2006-01-22 14:30:01Z vivainio $""" +$Id: Release.py 1077 2006-01-24 18:15:27Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez @@ -22,9 +22,10 @@ name = 'ipython' # because bdist_rpm does not accept dashes (an RPM) convention, and # bdist_deb does not accept underscores (a Debian convention). + version = '0.7.2.svn' -revision = '$Revision: 1058 $' +revision = '$Revision: 1077 $' description = "An enhanced interactive Python shell." diff --git a/IPython/completer.py b/IPython/completer.py index d64593b..4eef327 100644 --- a/IPython/completer.py +++ b/IPython/completer.py @@ -80,7 +80,7 @@ except NameError: from sets import Set as set -from IPython.genutils import shlex_split,debugp +from IPython.genutils import shlex_split,debugx __all__ = ['Completer','IPCompleter'] diff --git a/IPython/genutils.py b/IPython/genutils.py index 1bb2659..dbd6620 100644 --- a/IPython/genutils.py +++ b/IPython/genutils.py @@ -5,7 +5,7 @@ General purpose utilities. This is a grab-bag of stuff I find useful in most programs I write. Some of these things are also convenient when working at the command line. -$Id: genutils.py 1058 2006-01-22 14:30:01Z vivainio $""" +$Id: genutils.py 1077 2006-01-24 18:15:27Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -207,9 +207,10 @@ def fatal(msg,exit_val=1): warn(msg,exit_val=exit_val,level=4) - -# useful for debugging -def debugp(expr,pre_msg=''): +#--------------------------------------------------------------------------- +# Debugging routines +# +def debugx(expr,pre_msg=''): """Print the value of an expression from the caller's frame. Takes an expression, evaluates it in the caller's frame and prints both @@ -225,7 +226,7 @@ def debugp(expr,pre_msg=''): eval(expr,cf.f_globals,cf.f_locals)) # deactivate it by uncommenting the following line, which makes it a no-op -def debugp(expr,pre_msg=''): pass +#def debugx(expr,pre_msg=''): pass #---------------------------------------------------------------------------- StringTypes = types.StringTypes diff --git a/IPython/ipapi.py b/IPython/ipapi.py index 8355ee7..f9d1ac8 100644 --- a/IPython/ipapi.py +++ b/IPython/ipapi.py @@ -154,7 +154,7 @@ def ev(expr): return eval(expr,user_ns()) def launch_new_instance(): - """ Creata and start a new ipython instance. + """ Create and start a new ipython instance. This can be called even without having an already initialized ipython session running. diff --git a/IPython/iplib.py b/IPython/iplib.py index 532bfdb..84f0188 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 1058 2006-01-22 14:30:01Z vivainio $ +$Id: iplib.py 1077 2006-01-24 18:15:27Z vivainio $ """ #***************************************************************************** @@ -341,6 +341,10 @@ class InteractiveShell(object,Magic): # List of input with multi-line handling. # Fill its zero entry, user counter starts at 1 self.input_hist = InputList(['\n']) + # This one will hold the 'raw' input history, without any + # pre-processing. This will allow users to retrieve the input just as + # it was exactly typed in by the user, with %hist -r. + self.input_hist_raw = InputList(['\n']) # list of visited directories try: @@ -1155,7 +1159,7 @@ want to merge them back into the new files.""" % locals() Currently it handles auto-indent only.""" - #debugp('self.indent_current_nsp','pre_readline:') + #debugx('self.indent_current_nsp','pre_readline:') self.readline.insert_text(self.indent_current_str()) def init_readline(self): @@ -1554,9 +1558,8 @@ want to merge them back into the new files.""" % locals() def autoindent_update(self,line): """Keep track of the indent level.""" - #import traceback; traceback.print_stack() # dbg - debugp('line') - debugp('self.indent_current_nsp') + #debugx('line') + #debugx('self.indent_current_nsp') if self.autoindent: if line: inisp = num_ini_spaces(line) @@ -1755,19 +1758,22 @@ want to merge them back into the new files.""" % locals() # Try to be reasonably smart about not re-indenting pasted input more # than necessary. We do this by trimming out the auto-indent initial # spaces, if the user's actual input started itself with whitespace. - #debugp('self.buffer[-1]') + #debugx('self.buffer[-1]') - debugp('line') - debugp('self.indent_current_nsp') if self.autoindent: if num_ini_spaces(line) > self.indent_current_nsp: line = line[self.indent_current_nsp:] self.indent_current_nsp = 0 - debugp('self.indent_current_nsp') - debugp('line') + # store the unfiltered input before the user has any chance to modify + # it. + if line.strip(): + if continue_prompt: + self.input_hist_raw[-1] += '%s\n' % line + else: + self.input_hist_raw.append('%s\n' % line) + lineout = self.prefilter(line,continue_prompt) - debugp('lineout') return lineout def split_user_input(self,line): @@ -1947,7 +1953,6 @@ want to merge them back into the new files.""" % locals() if (continue_prompt and self.autoindent and line.isspace() and (0 < abs(len(line) - self.indent_current_nsp) <= 2 or (self.buffer[-1]).isspace() )): - #print 'reset line' # dbg line = '' self.log(line,continue_prompt) diff --git a/doc/ChangeLog b/doc/ChangeLog index 151c39f..b83ccf3 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -6,6 +6,31 @@ * ipapi.py: Moved TryNext here from hooks.py, added is_ipython_session() to determine whether we are running inside an ipython session. + + * Merged 1071-1076 from banches/0.7.1 + +2006-01-23 Fernando Perez + + * tools/release (daystamp): Fix build tools to use the new + eggsetup.py script to build lightweight eggs. + + * Applied changesets 1062 and 1064 before 0.7.1 release. + + * IPython/Magic.py (magic_history): Add '-r' option to %hist, to + see the raw input history (without conversions like %ls -> + ipmagic("ls")). After a request from W. Stein, SAGE + (http://modular.ucsd.edu/sage) developer. This information is + stored in the input_hist_raw attribute of the IPython instance, so + developers can access it if needed (it's an InputList instance). + + * Versionstring = 0.7.2.svn + + * eggsetup.py: A separate script for constructing eggs, creates + proper launch scripts even on Windows (an .exe file in + \python24\scripts). + + * ipapi.py: launch_new_instance, launch entry point needed for the + egg. 2006-01-23 Ville Vainio diff --git a/doc/manual_base.lyx b/doc/manual_base.lyx index 0b90abe..0c92b33 100644 --- a/doc/manual_base.lyx +++ b/doc/manual_base.lyx @@ -69,7 +69,7 @@ \quotes_language english \quotes_times 2 \papercolumns 1 -\papersides 1 +\papersides 2 \paperpagestyle fancy \layout Title @@ -87,6 +87,20 @@ User Manual, v. \layout Author Fernando P�rez +\begin_inset Foot +collapsed true + +\layout Standard + + +\size scriptsize +Department of Applied Mathematics, University of Colorado at Boulder. + +\family typewriter + +\end_inset + + \layout Standard @@ -8905,7 +8919,7 @@ status Collapsed rez \family typewriter - + \family default , but the project was born from mixing in Fernando's code with the IPP project by Janko Hauser @@ -8921,7 +8935,7 @@ rez \layout Standard -As of late 2005, the following developers have joined the core team: +As of early 2006, the following developers have joined the core team: \layout List \labelwidthstring 00.00.0000 @@ -8956,7 +8970,7 @@ Vainio \family typewriter \family default -: Ville is the new maintainer for the main trunk of IPython as of version +: Ville is the new maintainer for the main trunk of IPython after version 0.7.1. \layout Standard diff --git a/tools/release b/tools/release index 6060b4c..a993104 100755 --- a/tools/release +++ b/tools/release @@ -51,8 +51,8 @@ python2.3 ./setup.py bdist_rpm --release=py23 --python=/usr/bin/python2.3 python2.4 ./setup.py bdist_rpm --release=py24 --python=/usr/bin/python2.4 # Build eggs -python2.3 ./setup_bdist_egg.py -python2.4 ./setup_bdist_egg.py +python2.3 ./eggsetup.py bdist_egg +python2.4 ./eggsetup.py bdist_egg # Call the windows build separately, so that the extra Windows scripts don't # get pulled into Unix builds (setup.py has code which checks for @@ -64,7 +64,6 @@ python2.4 ./setup_bdist_egg.py $HOME/tmp/local/bin/python2.3 setup.py bdist_wininst \ --install-script=ipython_win_post_install.py - # Register with the Python Package Index (PyPI) echo "Registering with PyPI..." cd $ipdir diff --git a/tools/testrel b/tools/testrel index a2179fa..46afe75 100755 --- a/tools/testrel +++ b/tools/testrel @@ -15,8 +15,8 @@ python2.3 ./setup.py bdist_rpm --release=py23 --python=/usr/bin/python2.3 python2.4 ./setup.py bdist_rpm --release=py24 --python=/usr/bin/python2.4 # Build eggs -python2.3 ./setup_bdist_egg.py -python2.4 ./setup_bdist_egg.py +python2.3 ./eggsetup.py bdist_egg +python2.4 ./eggsetup.py bdist_egg # Call the windows build separately, so that the extra Windows scripts don't # get pulled into Unix builds (setup.py has code which checks for