##// END OF EJS Templates
%autocall fixes...
fperez -
Show More
@@ -1,1751 +1,1745 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 General purpose utilities.
3 General purpose utilities.
4
4
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 1007 2006-01-12 17:15:41Z vivainio $"""
8 $Id: genutils.py 1013 2006-01-13 08:33:32Z fperez $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 #
12 #
13 # Distributed under the terms of the BSD License. The full license is in
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
15 #*****************************************************************************
15 #*****************************************************************************
16
16
17 from __future__ import generators # 2.2 compatibility
17 from __future__ import generators # 2.2 compatibility
18
18
19 from IPython import Release
19 from IPython import Release
20 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __author__ = '%s <%s>' % Release.authors['Fernando']
21 __license__ = Release.license
21 __license__ = Release.license
22
22
23 #****************************************************************************
23 #****************************************************************************
24 # required modules from the Python standard library
24 # required modules from the Python standard library
25 import __main__
25 import __main__
26 import commands
26 import commands
27 import os
27 import os
28 import re
28 import re
29 import shlex
29 import shlex
30 import shutil
30 import shutil
31 import sys
31 import sys
32 import tempfile
32 import tempfile
33 import time
33 import time
34 import types
34 import types
35
35
36 # Other IPython utilities
36 # Other IPython utilities
37 from IPython.Itpl import Itpl,itpl,printpl
37 from IPython.Itpl import Itpl,itpl,printpl
38 from IPython import DPyGetOpt
38 from IPython import DPyGetOpt
39
39
40 if os.name == "nt":
40 if os.name == "nt":
41 from IPython.winconsole import get_console_size
41 from IPython.winconsole import get_console_size
42
42
43 # Build objects which appeared in Python 2.3 for 2.2, to make ipython
43 # Build objects which appeared in Python 2.3 for 2.2, to make ipython
44 # 2.2-friendly
44 # 2.2-friendly
45 try:
45 try:
46 basestring
46 basestring
47 except NameError:
47 except NameError:
48 import types
48 import types
49 basestring = (types.StringType, types.UnicodeType)
49 basestring = (types.StringType, types.UnicodeType)
50 True = 1==1
50 True = 1==1
51 False = 1==0
51 False = 1==0
52
52
53 def enumerate(obj):
53 def enumerate(obj):
54 i = -1
54 i = -1
55 for item in obj:
55 for item in obj:
56 i += 1
56 i += 1
57 yield i, item
57 yield i, item
58
58
59 # add these to the builtin namespace, so that all modules find them
59 # add these to the builtin namespace, so that all modules find them
60 import __builtin__
60 import __builtin__
61 __builtin__.basestring = basestring
61 __builtin__.basestring = basestring
62 __builtin__.True = True
62 __builtin__.True = True
63 __builtin__.False = False
63 __builtin__.False = False
64 __builtin__.enumerate = enumerate
64 __builtin__.enumerate = enumerate
65
65
66 # Try to use shlex.split for converting an input string into a sys.argv-type
66 # Try to use shlex.split for converting an input string into a sys.argv-type
67 # list. This appeared in Python 2.3, so here's a quick backport for 2.2.
67 # list. This appeared in Python 2.3, so here's a quick backport for 2.2.
68 try:
68 try:
69 shlex_split = shlex.split
69 shlex_split = shlex.split
70 except AttributeError:
70 except AttributeError:
71 _quotesre = re.compile(r'[\'"](.*)[\'"]')
71 _quotesre = re.compile(r'[\'"](.*)[\'"]')
72 _wordchars = ('abcdfeghijklmnopqrstuvwxyz'
72 _wordchars = ('abcdfeghijklmnopqrstuvwxyz'
73 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?'
73 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?'
74 'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
74 'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
75 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ%s'
75 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ%s'
76 % os.sep)
76 % os.sep)
77
77
78 def shlex_split(s):
78 def shlex_split(s):
79 """Simplified backport to Python 2.2 of shlex.split().
79 """Simplified backport to Python 2.2 of shlex.split().
80
80
81 This is a quick and dirty hack, since the shlex module under 2.2 lacks
81 This is a quick and dirty hack, since the shlex module under 2.2 lacks
82 several of the features needed to really match the functionality of
82 several of the features needed to really match the functionality of
83 shlex.split() in 2.3."""
83 shlex.split() in 2.3."""
84
84
85 lex = shlex.shlex(StringIO(s))
85 lex = shlex.shlex(StringIO(s))
86 # Try to get options, extensions and path separators as characters
86 # Try to get options, extensions and path separators as characters
87 lex.wordchars = _wordchars
87 lex.wordchars = _wordchars
88 lex.commenters = ''
88 lex.commenters = ''
89 # Make a list out of the lexer by hand, since in 2.2 it's not an
89 # Make a list out of the lexer by hand, since in 2.2 it's not an
90 # iterator.
90 # iterator.
91 lout = []
91 lout = []
92 while 1:
92 while 1:
93 token = lex.get_token()
93 token = lex.get_token()
94 if token == '':
94 if token == '':
95 break
95 break
96 # Try to handle quoted tokens correctly
96 # Try to handle quoted tokens correctly
97 quotes = _quotesre.match(token)
97 quotes = _quotesre.match(token)
98 if quotes:
98 if quotes:
99 token = quotes.group(1)
99 token = quotes.group(1)
100 lout.append(token)
100 lout.append(token)
101 return lout
101 return lout
102
102
103 #****************************************************************************
103 #****************************************************************************
104 # Exceptions
104 # Exceptions
105 class Error(Exception):
105 class Error(Exception):
106 """Base class for exceptions in this module."""
106 """Base class for exceptions in this module."""
107 pass
107 pass
108
108
109 #----------------------------------------------------------------------------
109 #----------------------------------------------------------------------------
110 class IOStream:
110 class IOStream:
111 def __init__(self,stream,fallback):
111 def __init__(self,stream,fallback):
112 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
112 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
113 stream = fallback
113 stream = fallback
114 self.stream = stream
114 self.stream = stream
115 self._swrite = stream.write
115 self._swrite = stream.write
116 self.flush = stream.flush
116 self.flush = stream.flush
117
117
118 def write(self,data):
118 def write(self,data):
119 try:
119 try:
120 self._swrite(data)
120 self._swrite(data)
121 except:
121 except:
122 try:
122 try:
123 # print handles some unicode issues which may trip a plain
123 # print handles some unicode issues which may trip a plain
124 # write() call. Attempt to emulate write() by using a
124 # write() call. Attempt to emulate write() by using a
125 # trailing comma
125 # trailing comma
126 print >> self.stream, data,
126 print >> self.stream, data,
127 except:
127 except:
128 # if we get here, something is seriously broken.
128 # if we get here, something is seriously broken.
129 print >> sys.stderr, \
129 print >> sys.stderr, \
130 'ERROR - failed to write data to stream:', stream
130 'ERROR - failed to write data to stream:', stream
131
131
132 class IOTerm:
132 class IOTerm:
133 """ Term holds the file or file-like objects for handling I/O operations.
133 """ Term holds the file or file-like objects for handling I/O operations.
134
134
135 These are normally just sys.stdin, sys.stdout and sys.stderr but for
135 These are normally just sys.stdin, sys.stdout and sys.stderr but for
136 Windows they can can replaced to allow editing the strings before they are
136 Windows they can can replaced to allow editing the strings before they are
137 displayed."""
137 displayed."""
138
138
139 # In the future, having IPython channel all its I/O operations through
139 # In the future, having IPython channel all its I/O operations through
140 # this class will make it easier to embed it into other environments which
140 # this class will make it easier to embed it into other environments which
141 # are not a normal terminal (such as a GUI-based shell)
141 # are not a normal terminal (such as a GUI-based shell)
142 def __init__(self,cin=None,cout=None,cerr=None):
142 def __init__(self,cin=None,cout=None,cerr=None):
143 self.cin = IOStream(cin,sys.stdin)
143 self.cin = IOStream(cin,sys.stdin)
144 self.cout = IOStream(cout,sys.stdout)
144 self.cout = IOStream(cout,sys.stdout)
145 self.cerr = IOStream(cerr,sys.stderr)
145 self.cerr = IOStream(cerr,sys.stderr)
146
146
147 # Global variable to be used for all I/O
147 # Global variable to be used for all I/O
148 Term = IOTerm()
148 Term = IOTerm()
149
149
150 # Windows-specific code to load Gary Bishop's readline and configure it
150 # Windows-specific code to load Gary Bishop's readline and configure it
151 # automatically for the users
151 # automatically for the users
152 # Note: os.name on cygwin returns posix, so this should only pick up 'native'
152 # Note: os.name on cygwin returns posix, so this should only pick up 'native'
153 # windows. Cygwin returns 'cygwin' for sys.platform.
153 # windows. Cygwin returns 'cygwin' for sys.platform.
154 if os.name == 'nt':
154 if os.name == 'nt':
155 try:
155 try:
156 import readline
156 import readline
157 except ImportError:
157 except ImportError:
158 pass
158 pass
159 else:
159 else:
160 try:
160 try:
161 _out = readline.GetOutputFile()
161 _out = readline.GetOutputFile()
162 except AttributeError:
162 except AttributeError:
163 pass
163 pass
164 else:
164 else:
165 # Remake Term to use the readline i/o facilities
165 # Remake Term to use the readline i/o facilities
166 Term = IOTerm(cout=_out,cerr=_out)
166 Term = IOTerm(cout=_out,cerr=_out)
167 del _out
167 del _out
168
168
169 #****************************************************************************
169 #****************************************************************************
170 # Generic warning/error printer, used by everything else
170 # Generic warning/error printer, used by everything else
171 def warn(msg,level=2,exit_val=1):
171 def warn(msg,level=2,exit_val=1):
172 """Standard warning printer. Gives formatting consistency.
172 """Standard warning printer. Gives formatting consistency.
173
173
174 Output is sent to Term.cerr (sys.stderr by default).
174 Output is sent to Term.cerr (sys.stderr by default).
175
175
176 Options:
176 Options:
177
177
178 -level(2): allows finer control:
178 -level(2): allows finer control:
179 0 -> Do nothing, dummy function.
179 0 -> Do nothing, dummy function.
180 1 -> Print message.
180 1 -> Print message.
181 2 -> Print 'WARNING:' + message. (Default level).
181 2 -> Print 'WARNING:' + message. (Default level).
182 3 -> Print 'ERROR:' + message.
182 3 -> Print 'ERROR:' + message.
183 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
183 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
184
184
185 -exit_val (1): exit value returned by sys.exit() for a level 4
185 -exit_val (1): exit value returned by sys.exit() for a level 4
186 warning. Ignored for all other levels."""
186 warning. Ignored for all other levels."""
187
187
188 if level>0:
188 if level>0:
189 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
189 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
190 print >> Term.cerr, '%s%s' % (header[level],msg)
190 print >> Term.cerr, '%s%s' % (header[level],msg)
191 if level == 4:
191 if level == 4:
192 print >> Term.cerr,'Exiting.\n'
192 print >> Term.cerr,'Exiting.\n'
193 sys.exit(exit_val)
193 sys.exit(exit_val)
194
194
195 def info(msg):
195 def info(msg):
196 """Equivalent to warn(msg,level=1)."""
196 """Equivalent to warn(msg,level=1)."""
197
197
198 warn(msg,level=1)
198 warn(msg,level=1)
199
199
200 def error(msg):
200 def error(msg):
201 """Equivalent to warn(msg,level=3)."""
201 """Equivalent to warn(msg,level=3)."""
202
202
203 warn(msg,level=3)
203 warn(msg,level=3)
204
204
205 def fatal(msg,exit_val=1):
205 def fatal(msg,exit_val=1):
206 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
206 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
207
207
208 warn(msg,exit_val=exit_val,level=4)
208 warn(msg,exit_val=exit_val,level=4)
209
209
210
210
211 # useful for debugging
211 # useful for debugging
212 def debugp(expr):
212 def debugp(expr):
213 """Print the value of an expression from the caller's frame.
213 """Print the value of an expression from the caller's frame.
214
214
215 Takes an expression, evaluates it in the caller's frame and prints both
215 Takes an expression, evaluates it in the caller's frame and prints both
216 the given expression and the resulting value. The input must be of a form
216 the given expression and the resulting value. The input must be of a form
217 suitable for eval()."""
217 suitable for eval()."""
218
218
219 cf = sys._getframe(1)
219 cf = sys._getframe(1)
220 print '[DBG] %s -> %r' % (expr,eval(expr,cf.f_globals,cf.f_locals))
220 print '[DBG] %s -> %r' % (expr,eval(expr,cf.f_globals,cf.f_locals))
221
221
222 #----------------------------------------------------------------------------
222 #----------------------------------------------------------------------------
223 StringTypes = types.StringTypes
223 StringTypes = types.StringTypes
224
224
225 # Basic timing functionality
225 # Basic timing functionality
226
226
227 # If possible (Unix), use the resource module instead of time.clock()
227 # If possible (Unix), use the resource module instead of time.clock()
228 try:
228 try:
229 import resource
229 import resource
230 def clock():
230 def clock():
231 """clock() -> floating point number
231 """clock() -> floating point number
232
232
233 Return the CPU time in seconds (user time only, system time is
233 Return the CPU time in seconds (user time only, system time is
234 ignored) since the start of the process. This is done via a call to
234 ignored) since the start of the process. This is done via a call to
235 resource.getrusage, so it avoids the wraparound problems in
235 resource.getrusage, so it avoids the wraparound problems in
236 time.clock()."""
236 time.clock()."""
237
237
238 return resource.getrusage(resource.RUSAGE_SELF)[0]
238 return resource.getrusage(resource.RUSAGE_SELF)[0]
239
239
240 def clock2():
240 def clock2():
241 """clock2() -> (t_user,t_system)
241 """clock2() -> (t_user,t_system)
242
242
243 Similar to clock(), but return a tuple of user/system times."""
243 Similar to clock(), but return a tuple of user/system times."""
244 return resource.getrusage(resource.RUSAGE_SELF)[:2]
244 return resource.getrusage(resource.RUSAGE_SELF)[:2]
245
245
246 except ImportError:
246 except ImportError:
247 clock = time.clock
247 clock = time.clock
248 def clock2():
248 def clock2():
249 """Under windows, system CPU time can't be measured.
249 """Under windows, system CPU time can't be measured.
250
250
251 This just returns clock() and zero."""
251 This just returns clock() and zero."""
252 return time.clock(),0.0
252 return time.clock(),0.0
253
253
254 def timings_out(reps,func,*args,**kw):
254 def timings_out(reps,func,*args,**kw):
255 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
255 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
256
256
257 Execute a function reps times, return a tuple with the elapsed total
257 Execute a function reps times, return a tuple with the elapsed total
258 CPU time in seconds, the time per call and the function's output.
258 CPU time in seconds, the time per call and the function's output.
259
259
260 Under Unix, the return value is the sum of user+system time consumed by
260 Under Unix, the return value is the sum of user+system time consumed by
261 the process, computed via the resource module. This prevents problems
261 the process, computed via the resource module. This prevents problems
262 related to the wraparound effect which the time.clock() function has.
262 related to the wraparound effect which the time.clock() function has.
263
263
264 Under Windows the return value is in wall clock seconds. See the
264 Under Windows the return value is in wall clock seconds. See the
265 documentation for the time module for more details."""
265 documentation for the time module for more details."""
266
266
267 reps = int(reps)
267 reps = int(reps)
268 assert reps >=1, 'reps must be >= 1'
268 assert reps >=1, 'reps must be >= 1'
269 if reps==1:
269 if reps==1:
270 start = clock()
270 start = clock()
271 out = func(*args,**kw)
271 out = func(*args,**kw)
272 tot_time = clock()-start
272 tot_time = clock()-start
273 else:
273 else:
274 rng = xrange(reps-1) # the last time is executed separately to store output
274 rng = xrange(reps-1) # the last time is executed separately to store output
275 start = clock()
275 start = clock()
276 for dummy in rng: func(*args,**kw)
276 for dummy in rng: func(*args,**kw)
277 out = func(*args,**kw) # one last time
277 out = func(*args,**kw) # one last time
278 tot_time = clock()-start
278 tot_time = clock()-start
279 av_time = tot_time / reps
279 av_time = tot_time / reps
280 return tot_time,av_time,out
280 return tot_time,av_time,out
281
281
282 def timings(reps,func,*args,**kw):
282 def timings(reps,func,*args,**kw):
283 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
283 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
284
284
285 Execute a function reps times, return a tuple with the elapsed total CPU
285 Execute a function reps times, return a tuple with the elapsed total CPU
286 time in seconds and the time per call. These are just the first two values
286 time in seconds and the time per call. These are just the first two values
287 in timings_out()."""
287 in timings_out()."""
288
288
289 return timings_out(reps,func,*args,**kw)[0:2]
289 return timings_out(reps,func,*args,**kw)[0:2]
290
290
291 def timing(func,*args,**kw):
291 def timing(func,*args,**kw):
292 """timing(func,*args,**kw) -> t_total
292 """timing(func,*args,**kw) -> t_total
293
293
294 Execute a function once, return the elapsed total CPU time in
294 Execute a function once, return the elapsed total CPU time in
295 seconds. This is just the first value in timings_out()."""
295 seconds. This is just the first value in timings_out()."""
296
296
297 return timings_out(1,func,*args,**kw)[0]
297 return timings_out(1,func,*args,**kw)[0]
298
298
299 #****************************************************************************
299 #****************************************************************************
300 # file and system
300 # file and system
301
301
302 def system(cmd,verbose=0,debug=0,header=''):
302 def system(cmd,verbose=0,debug=0,header=''):
303 """Execute a system command, return its exit status.
303 """Execute a system command, return its exit status.
304
304
305 Options:
305 Options:
306
306
307 - verbose (0): print the command to be executed.
307 - verbose (0): print the command to be executed.
308
308
309 - debug (0): only print, do not actually execute.
309 - debug (0): only print, do not actually execute.
310
310
311 - header (''): Header to print on screen prior to the executed command (it
311 - header (''): Header to print on screen prior to the executed command (it
312 is only prepended to the command, no newlines are added).
312 is only prepended to the command, no newlines are added).
313
313
314 Note: a stateful version of this function is available through the
314 Note: a stateful version of this function is available through the
315 SystemExec class."""
315 SystemExec class."""
316
316
317 stat = 0
317 stat = 0
318 if verbose or debug: print header+cmd
318 if verbose or debug: print header+cmd
319 sys.stdout.flush()
319 sys.stdout.flush()
320 if not debug: stat = os.system(cmd)
320 if not debug: stat = os.system(cmd)
321 return stat
321 return stat
322
322
323 # This function is used by ipython in a lot of places to make system calls.
323 # This function is used by ipython in a lot of places to make system calls.
324 # We need it to be slightly different under win32, due to the vagaries of
324 # We need it to be slightly different under win32, due to the vagaries of
325 # 'network shares'. A win32 override is below.
325 # 'network shares'. A win32 override is below.
326
326
327 def shell(cmd,verbose=0,debug=0,header=''):
327 def shell(cmd,verbose=0,debug=0,header=''):
328 """Execute a command in the system shell, always return None.
328 """Execute a command in the system shell, always return None.
329
329
330 Options:
330 Options:
331
331
332 - verbose (0): print the command to be executed.
332 - verbose (0): print the command to be executed.
333
333
334 - debug (0): only print, do not actually execute.
334 - debug (0): only print, do not actually execute.
335
335
336 - header (''): Header to print on screen prior to the executed command (it
336 - header (''): Header to print on screen prior to the executed command (it
337 is only prepended to the command, no newlines are added).
337 is only prepended to the command, no newlines are added).
338
338
339 Note: this is similar to genutils.system(), but it returns None so it can
339 Note: this is similar to genutils.system(), but it returns None so it can
340 be conveniently used in interactive loops without getting the return value
340 be conveniently used in interactive loops without getting the return value
341 (typically 0) printed many times."""
341 (typically 0) printed many times."""
342
342
343 stat = 0
343 stat = 0
344 if verbose or debug: print header+cmd
344 if verbose or debug: print header+cmd
345 # flush stdout so we don't mangle python's buffering
345 # flush stdout so we don't mangle python's buffering
346 sys.stdout.flush()
346 sys.stdout.flush()
347 if not debug:
347 if not debug:
348 os.system(cmd)
348 os.system(cmd)
349
349
350 # override shell() for win32 to deal with network shares
350 # override shell() for win32 to deal with network shares
351 if os.name in ('nt','dos'):
351 if os.name in ('nt','dos'):
352
352
353 shell_ori = shell
353 shell_ori = shell
354
354
355 def shell(cmd,verbose=0,debug=0,header=''):
355 def shell(cmd,verbose=0,debug=0,header=''):
356 if os.getcwd().startswith(r"\\"):
356 if os.getcwd().startswith(r"\\"):
357 path = os.getcwd()
357 path = os.getcwd()
358 # change to c drive (cannot be on UNC-share when issuing os.system,
358 # change to c drive (cannot be on UNC-share when issuing os.system,
359 # as cmd.exe cannot handle UNC addresses)
359 # as cmd.exe cannot handle UNC addresses)
360 os.chdir("c:")
360 os.chdir("c:")
361 # issue pushd to the UNC-share and then run the command
361 # issue pushd to the UNC-share and then run the command
362 try:
362 try:
363 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
363 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
364 finally:
364 finally:
365 os.chdir(path)
365 os.chdir(path)
366 else:
366 else:
367 shell_ori(cmd,verbose,debug,header)
367 shell_ori(cmd,verbose,debug,header)
368
368
369 shell.__doc__ = shell_ori.__doc__
369 shell.__doc__ = shell_ori.__doc__
370
370
371 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
371 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
372 """Dummy substitute for perl's backquotes.
372 """Dummy substitute for perl's backquotes.
373
373
374 Executes a command and returns the output.
374 Executes a command and returns the output.
375
375
376 Accepts the same arguments as system(), plus:
376 Accepts the same arguments as system(), plus:
377
377
378 - split(0): if true, the output is returned as a list split on newlines.
378 - split(0): if true, the output is returned as a list split on newlines.
379
379
380 Note: a stateful version of this function is available through the
380 Note: a stateful version of this function is available through the
381 SystemExec class."""
381 SystemExec class."""
382
382
383 if verbose or debug: print header+cmd
383 if verbose or debug: print header+cmd
384 if not debug:
384 if not debug:
385 output = commands.getoutput(cmd)
385 output = commands.getoutput(cmd)
386 if split:
386 if split:
387 return output.split('\n')
387 return output.split('\n')
388 else:
388 else:
389 return output
389 return output
390
390
391 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
391 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
392 """Return (standard output,standard error) of executing cmd in a shell.
392 """Return (standard output,standard error) of executing cmd in a shell.
393
393
394 Accepts the same arguments as system(), plus:
394 Accepts the same arguments as system(), plus:
395
395
396 - split(0): if true, each of stdout/err is returned as a list split on
396 - split(0): if true, each of stdout/err is returned as a list split on
397 newlines.
397 newlines.
398
398
399 Note: a stateful version of this function is available through the
399 Note: a stateful version of this function is available through the
400 SystemExec class."""
400 SystemExec class."""
401
401
402 if verbose or debug: print header+cmd
402 if verbose or debug: print header+cmd
403 if not cmd:
403 if not cmd:
404 if split:
404 if split:
405 return [],[]
405 return [],[]
406 else:
406 else:
407 return '',''
407 return '',''
408 if not debug:
408 if not debug:
409 pin,pout,perr = os.popen3(cmd)
409 pin,pout,perr = os.popen3(cmd)
410 tout = pout.read().rstrip()
410 tout = pout.read().rstrip()
411 terr = perr.read().rstrip()
411 terr = perr.read().rstrip()
412 pin.close()
412 pin.close()
413 pout.close()
413 pout.close()
414 perr.close()
414 perr.close()
415 if split:
415 if split:
416 return tout.split('\n'),terr.split('\n')
416 return tout.split('\n'),terr.split('\n')
417 else:
417 else:
418 return tout,terr
418 return tout,terr
419
419
420 # for compatibility with older naming conventions
420 # for compatibility with older naming conventions
421 xsys = system
421 xsys = system
422 bq = getoutput
422 bq = getoutput
423
423
424 class SystemExec:
424 class SystemExec:
425 """Access the system and getoutput functions through a stateful interface.
425 """Access the system and getoutput functions through a stateful interface.
426
426
427 Note: here we refer to the system and getoutput functions from this
427 Note: here we refer to the system and getoutput functions from this
428 library, not the ones from the standard python library.
428 library, not the ones from the standard python library.
429
429
430 This class offers the system and getoutput functions as methods, but the
430 This class offers the system and getoutput functions as methods, but the
431 verbose, debug and header parameters can be set for the instance (at
431 verbose, debug and header parameters can be set for the instance (at
432 creation time or later) so that they don't need to be specified on each
432 creation time or later) so that they don't need to be specified on each
433 call.
433 call.
434
434
435 For efficiency reasons, there's no way to override the parameters on a
435 For efficiency reasons, there's no way to override the parameters on a
436 per-call basis other than by setting instance attributes. If you need
436 per-call basis other than by setting instance attributes. If you need
437 local overrides, it's best to directly call system() or getoutput().
437 local overrides, it's best to directly call system() or getoutput().
438
438
439 The following names are provided as alternate options:
439 The following names are provided as alternate options:
440 - xsys: alias to system
440 - xsys: alias to system
441 - bq: alias to getoutput
441 - bq: alias to getoutput
442
442
443 An instance can then be created as:
443 An instance can then be created as:
444 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
444 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
445
445
446 And used as:
446 And used as:
447 >>> sysexec.xsys('pwd')
447 >>> sysexec.xsys('pwd')
448 >>> dirlist = sysexec.bq('ls -l')
448 >>> dirlist = sysexec.bq('ls -l')
449 """
449 """
450
450
451 def __init__(self,verbose=0,debug=0,header='',split=0):
451 def __init__(self,verbose=0,debug=0,header='',split=0):
452 """Specify the instance's values for verbose, debug and header."""
452 """Specify the instance's values for verbose, debug and header."""
453 setattr_list(self,'verbose debug header split')
453 setattr_list(self,'verbose debug header split')
454
454
455 def system(self,cmd):
455 def system(self,cmd):
456 """Stateful interface to system(), with the same keyword parameters."""
456 """Stateful interface to system(), with the same keyword parameters."""
457
457
458 system(cmd,self.verbose,self.debug,self.header)
458 system(cmd,self.verbose,self.debug,self.header)
459
459
460 def shell(self,cmd):
460 def shell(self,cmd):
461 """Stateful interface to shell(), with the same keyword parameters."""
461 """Stateful interface to shell(), with the same keyword parameters."""
462
462
463 shell(cmd,self.verbose,self.debug,self.header)
463 shell(cmd,self.verbose,self.debug,self.header)
464
464
465 xsys = system # alias
465 xsys = system # alias
466
466
467 def getoutput(self,cmd):
467 def getoutput(self,cmd):
468 """Stateful interface to getoutput()."""
468 """Stateful interface to getoutput()."""
469
469
470 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
470 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
471
471
472 def getoutputerror(self,cmd):
472 def getoutputerror(self,cmd):
473 """Stateful interface to getoutputerror()."""
473 """Stateful interface to getoutputerror()."""
474
474
475 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
475 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
476
476
477 bq = getoutput # alias
477 bq = getoutput # alias
478
478
479 #-----------------------------------------------------------------------------
479 #-----------------------------------------------------------------------------
480 def mutex_opts(dict,ex_op):
480 def mutex_opts(dict,ex_op):
481 """Check for presence of mutually exclusive keys in a dict.
481 """Check for presence of mutually exclusive keys in a dict.
482
482
483 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
483 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
484 for op1,op2 in ex_op:
484 for op1,op2 in ex_op:
485 if op1 in dict and op2 in dict:
485 if op1 in dict and op2 in dict:
486 raise ValueError,'\n*** ERROR in Arguments *** '\
486 raise ValueError,'\n*** ERROR in Arguments *** '\
487 'Options '+op1+' and '+op2+' are mutually exclusive.'
487 'Options '+op1+' and '+op2+' are mutually exclusive.'
488
488
489 #-----------------------------------------------------------------------------
489 #-----------------------------------------------------------------------------
490 def get_py_filename(name):
490 def get_py_filename(name):
491 """Return a valid python filename in the current directory.
491 """Return a valid python filename in the current directory.
492
492
493 If the given name is not a file, it adds '.py' and searches again.
493 If the given name is not a file, it adds '.py' and searches again.
494 Raises IOError with an informative message if the file isn't found."""
494 Raises IOError with an informative message if the file isn't found."""
495
495
496 name = os.path.expanduser(name)
496 name = os.path.expanduser(name)
497 if not os.path.isfile(name) and not name.endswith('.py'):
497 if not os.path.isfile(name) and not name.endswith('.py'):
498 name += '.py'
498 name += '.py'
499 if os.path.isfile(name):
499 if os.path.isfile(name):
500 return name
500 return name
501 else:
501 else:
502 raise IOError,'File `%s` not found.' % name
502 raise IOError,'File `%s` not found.' % name
503
503
504 #-----------------------------------------------------------------------------
504 #-----------------------------------------------------------------------------
505 def filefind(fname,alt_dirs = None):
505 def filefind(fname,alt_dirs = None):
506 """Return the given filename either in the current directory, if it
506 """Return the given filename either in the current directory, if it
507 exists, or in a specified list of directories.
507 exists, or in a specified list of directories.
508
508
509 ~ expansion is done on all file and directory names.
509 ~ expansion is done on all file and directory names.
510
510
511 Upon an unsuccessful search, raise an IOError exception."""
511 Upon an unsuccessful search, raise an IOError exception."""
512
512
513 if alt_dirs is None:
513 if alt_dirs is None:
514 try:
514 try:
515 alt_dirs = get_home_dir()
515 alt_dirs = get_home_dir()
516 except HomeDirError:
516 except HomeDirError:
517 alt_dirs = os.getcwd()
517 alt_dirs = os.getcwd()
518 search = [fname] + list_strings(alt_dirs)
518 search = [fname] + list_strings(alt_dirs)
519 search = map(os.path.expanduser,search)
519 search = map(os.path.expanduser,search)
520 #print 'search list for',fname,'list:',search # dbg
520 #print 'search list for',fname,'list:',search # dbg
521 fname = search[0]
521 fname = search[0]
522 if os.path.isfile(fname):
522 if os.path.isfile(fname):
523 return fname
523 return fname
524 for direc in search[1:]:
524 for direc in search[1:]:
525 testname = os.path.join(direc,fname)
525 testname = os.path.join(direc,fname)
526 #print 'testname',testname # dbg
526 #print 'testname',testname # dbg
527 if os.path.isfile(testname):
527 if os.path.isfile(testname):
528 return testname
528 return testname
529 raise IOError,'File' + `fname` + \
529 raise IOError,'File' + `fname` + \
530 ' not found in current or supplied directories:' + `alt_dirs`
530 ' not found in current or supplied directories:' + `alt_dirs`
531
531
532 #----------------------------------------------------------------------------
532 #----------------------------------------------------------------------------
533 def file_read(filename):
533 def file_read(filename):
534 """Read a file and close it. Returns the file source."""
534 """Read a file and close it. Returns the file source."""
535 fobj=open(filename,'r');
535 fobj=open(filename,'r');
536 source = fobj.read();
536 source = fobj.read();
537 fobj.close()
537 fobj.close()
538 return source
538 return source
539
539
540 #----------------------------------------------------------------------------
540 #----------------------------------------------------------------------------
541 def target_outdated(target,deps):
541 def target_outdated(target,deps):
542 """Determine whether a target is out of date.
542 """Determine whether a target is out of date.
543
543
544 target_outdated(target,deps) -> 1/0
544 target_outdated(target,deps) -> 1/0
545
545
546 deps: list of filenames which MUST exist.
546 deps: list of filenames which MUST exist.
547 target: single filename which may or may not exist.
547 target: single filename which may or may not exist.
548
548
549 If target doesn't exist or is older than any file listed in deps, return
549 If target doesn't exist or is older than any file listed in deps, return
550 true, otherwise return false.
550 true, otherwise return false.
551 """
551 """
552 try:
552 try:
553 target_time = os.path.getmtime(target)
553 target_time = os.path.getmtime(target)
554 except os.error:
554 except os.error:
555 return 1
555 return 1
556 for dep in deps:
556 for dep in deps:
557 dep_time = os.path.getmtime(dep)
557 dep_time = os.path.getmtime(dep)
558 if dep_time > target_time:
558 if dep_time > target_time:
559 #print "For target",target,"Dep failed:",dep # dbg
559 #print "For target",target,"Dep failed:",dep # dbg
560 #print "times (dep,tar):",dep_time,target_time # dbg
560 #print "times (dep,tar):",dep_time,target_time # dbg
561 return 1
561 return 1
562 return 0
562 return 0
563
563
564 #-----------------------------------------------------------------------------
564 #-----------------------------------------------------------------------------
565 def target_update(target,deps,cmd):
565 def target_update(target,deps,cmd):
566 """Update a target with a given command given a list of dependencies.
566 """Update a target with a given command given a list of dependencies.
567
567
568 target_update(target,deps,cmd) -> runs cmd if target is outdated.
568 target_update(target,deps,cmd) -> runs cmd if target is outdated.
569
569
570 This is just a wrapper around target_outdated() which calls the given
570 This is just a wrapper around target_outdated() which calls the given
571 command if target is outdated."""
571 command if target is outdated."""
572
572
573 if target_outdated(target,deps):
573 if target_outdated(target,deps):
574 xsys(cmd)
574 xsys(cmd)
575
575
576 #----------------------------------------------------------------------------
576 #----------------------------------------------------------------------------
577 def unquote_ends(istr):
577 def unquote_ends(istr):
578 """Remove a single pair of quotes from the endpoints of a string."""
578 """Remove a single pair of quotes from the endpoints of a string."""
579
579
580 if not istr:
580 if not istr:
581 return istr
581 return istr
582 if (istr[0]=="'" and istr[-1]=="'") or \
582 if (istr[0]=="'" and istr[-1]=="'") or \
583 (istr[0]=='"' and istr[-1]=='"'):
583 (istr[0]=='"' and istr[-1]=='"'):
584 return istr[1:-1]
584 return istr[1:-1]
585 else:
585 else:
586 return istr
586 return istr
587
587
588 #----------------------------------------------------------------------------
588 #----------------------------------------------------------------------------
589 def process_cmdline(argv,names=[],defaults={},usage=''):
589 def process_cmdline(argv,names=[],defaults={},usage=''):
590 """ Process command-line options and arguments.
590 """ Process command-line options and arguments.
591
591
592 Arguments:
592 Arguments:
593
593
594 - argv: list of arguments, typically sys.argv.
594 - argv: list of arguments, typically sys.argv.
595
595
596 - names: list of option names. See DPyGetOpt docs for details on options
596 - names: list of option names. See DPyGetOpt docs for details on options
597 syntax.
597 syntax.
598
598
599 - defaults: dict of default values.
599 - defaults: dict of default values.
600
600
601 - usage: optional usage notice to print if a wrong argument is passed.
601 - usage: optional usage notice to print if a wrong argument is passed.
602
602
603 Return a dict of options and a list of free arguments."""
603 Return a dict of options and a list of free arguments."""
604
604
605 getopt = DPyGetOpt.DPyGetOpt()
605 getopt = DPyGetOpt.DPyGetOpt()
606 getopt.setIgnoreCase(0)
606 getopt.setIgnoreCase(0)
607 getopt.parseConfiguration(names)
607 getopt.parseConfiguration(names)
608
608
609 try:
609 try:
610 getopt.processArguments(argv)
610 getopt.processArguments(argv)
611 except:
611 except:
612 print usage
612 print usage
613 warn(`sys.exc_value`,level=4)
613 warn(`sys.exc_value`,level=4)
614
614
615 defaults.update(getopt.optionValues)
615 defaults.update(getopt.optionValues)
616 args = getopt.freeValues
616 args = getopt.freeValues
617
617
618 return defaults,args
618 return defaults,args
619
619
620 #----------------------------------------------------------------------------
620 #----------------------------------------------------------------------------
621 def optstr2types(ostr):
621 def optstr2types(ostr):
622 """Convert a string of option names to a dict of type mappings.
622 """Convert a string of option names to a dict of type mappings.
623
623
624 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
624 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
625
625
626 This is used to get the types of all the options in a string formatted
626 This is used to get the types of all the options in a string formatted
627 with the conventions of DPyGetOpt. The 'type' None is used for options
627 with the conventions of DPyGetOpt. The 'type' None is used for options
628 which are strings (they need no further conversion). This function's main
628 which are strings (they need no further conversion). This function's main
629 use is to get a typemap for use with read_dict().
629 use is to get a typemap for use with read_dict().
630 """
630 """
631
631
632 typeconv = {None:'',int:'',float:''}
632 typeconv = {None:'',int:'',float:''}
633 typemap = {'s':None,'i':int,'f':float}
633 typemap = {'s':None,'i':int,'f':float}
634 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
634 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
635
635
636 for w in ostr.split():
636 for w in ostr.split():
637 oname,alias,otype = opt_re.match(w).groups()
637 oname,alias,otype = opt_re.match(w).groups()
638 if otype == '' or alias == '!': # simple switches are integers too
638 if otype == '' or alias == '!': # simple switches are integers too
639 otype = 'i'
639 otype = 'i'
640 typeconv[typemap[otype]] += oname + ' '
640 typeconv[typemap[otype]] += oname + ' '
641 return typeconv
641 return typeconv
642
642
643 #----------------------------------------------------------------------------
643 #----------------------------------------------------------------------------
644 def read_dict(filename,type_conv=None,**opt):
644 def read_dict(filename,type_conv=None,**opt):
645
645
646 """Read a dictionary of key=value pairs from an input file, optionally
646 """Read a dictionary of key=value pairs from an input file, optionally
647 performing conversions on the resulting values.
647 performing conversions on the resulting values.
648
648
649 read_dict(filename,type_conv,**opt) -> dict
649 read_dict(filename,type_conv,**opt) -> dict
650
650
651 Only one value per line is accepted, the format should be
651 Only one value per line is accepted, the format should be
652 # optional comments are ignored
652 # optional comments are ignored
653 key value\n
653 key value\n
654
654
655 Args:
655 Args:
656
656
657 - type_conv: A dictionary specifying which keys need to be converted to
657 - type_conv: A dictionary specifying which keys need to be converted to
658 which types. By default all keys are read as strings. This dictionary
658 which types. By default all keys are read as strings. This dictionary
659 should have as its keys valid conversion functions for strings
659 should have as its keys valid conversion functions for strings
660 (int,long,float,complex, or your own). The value for each key
660 (int,long,float,complex, or your own). The value for each key
661 (converter) should be a whitespace separated string containing the names
661 (converter) should be a whitespace separated string containing the names
662 of all the entries in the file to be converted using that function. For
662 of all the entries in the file to be converted using that function. For
663 keys to be left alone, use None as the conversion function (only needed
663 keys to be left alone, use None as the conversion function (only needed
664 with purge=1, see below).
664 with purge=1, see below).
665
665
666 - opt: dictionary with extra options as below (default in parens)
666 - opt: dictionary with extra options as below (default in parens)
667
667
668 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
668 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
669 of the dictionary to be returned. If purge is going to be used, the
669 of the dictionary to be returned. If purge is going to be used, the
670 set of keys to be left as strings also has to be explicitly specified
670 set of keys to be left as strings also has to be explicitly specified
671 using the (non-existent) conversion function None.
671 using the (non-existent) conversion function None.
672
672
673 fs(None): field separator. This is the key/value separator to be used
673 fs(None): field separator. This is the key/value separator to be used
674 when parsing the file. The None default means any whitespace [behavior
674 when parsing the file. The None default means any whitespace [behavior
675 of string.split()].
675 of string.split()].
676
676
677 strip(0): if 1, strip string values of leading/trailinig whitespace.
677 strip(0): if 1, strip string values of leading/trailinig whitespace.
678
678
679 warn(1): warning level if requested keys are not found in file.
679 warn(1): warning level if requested keys are not found in file.
680 - 0: silently ignore.
680 - 0: silently ignore.
681 - 1: inform but proceed.
681 - 1: inform but proceed.
682 - 2: raise KeyError exception.
682 - 2: raise KeyError exception.
683
683
684 no_empty(0): if 1, remove keys with whitespace strings as a value.
684 no_empty(0): if 1, remove keys with whitespace strings as a value.
685
685
686 unique([]): list of keys (or space separated string) which can't be
686 unique([]): list of keys (or space separated string) which can't be
687 repeated. If one such key is found in the file, each new instance
687 repeated. If one such key is found in the file, each new instance
688 overwrites the previous one. For keys not listed here, the behavior is
688 overwrites the previous one. For keys not listed here, the behavior is
689 to make a list of all appearances.
689 to make a list of all appearances.
690
690
691 Example:
691 Example:
692 If the input file test.ini has:
692 If the input file test.ini has:
693 i 3
693 i 3
694 x 4.5
694 x 4.5
695 y 5.5
695 y 5.5
696 s hi ho
696 s hi ho
697 Then:
697 Then:
698
698
699 >>> type_conv={int:'i',float:'x',None:'s'}
699 >>> type_conv={int:'i',float:'x',None:'s'}
700 >>> read_dict('test.ini')
700 >>> read_dict('test.ini')
701 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
701 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
702 >>> read_dict('test.ini',type_conv)
702 >>> read_dict('test.ini',type_conv)
703 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
703 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
704 >>> read_dict('test.ini',type_conv,purge=1)
704 >>> read_dict('test.ini',type_conv,purge=1)
705 {'i': 3, 's': 'hi ho', 'x': 4.5}
705 {'i': 3, 's': 'hi ho', 'x': 4.5}
706 """
706 """
707
707
708 # starting config
708 # starting config
709 opt.setdefault('purge',0)
709 opt.setdefault('purge',0)
710 opt.setdefault('fs',None) # field sep defaults to any whitespace
710 opt.setdefault('fs',None) # field sep defaults to any whitespace
711 opt.setdefault('strip',0)
711 opt.setdefault('strip',0)
712 opt.setdefault('warn',1)
712 opt.setdefault('warn',1)
713 opt.setdefault('no_empty',0)
713 opt.setdefault('no_empty',0)
714 opt.setdefault('unique','')
714 opt.setdefault('unique','')
715 if type(opt['unique']) in StringTypes:
715 if type(opt['unique']) in StringTypes:
716 unique_keys = qw(opt['unique'])
716 unique_keys = qw(opt['unique'])
717 elif type(opt['unique']) in (types.TupleType,types.ListType):
717 elif type(opt['unique']) in (types.TupleType,types.ListType):
718 unique_keys = opt['unique']
718 unique_keys = opt['unique']
719 else:
719 else:
720 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
720 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
721
721
722 dict = {}
722 dict = {}
723 # first read in table of values as strings
723 # first read in table of values as strings
724 file = open(filename,'r')
724 file = open(filename,'r')
725 for line in file.readlines():
725 for line in file.readlines():
726 line = line.strip()
726 line = line.strip()
727 if len(line) and line[0]=='#': continue
727 if len(line) and line[0]=='#': continue
728 if len(line)>0:
728 if len(line)>0:
729 lsplit = line.split(opt['fs'],1)
729 lsplit = line.split(opt['fs'],1)
730 try:
730 try:
731 key,val = lsplit
731 key,val = lsplit
732 except ValueError:
732 except ValueError:
733 key,val = lsplit[0],''
733 key,val = lsplit[0],''
734 key = key.strip()
734 key = key.strip()
735 if opt['strip']: val = val.strip()
735 if opt['strip']: val = val.strip()
736 if val == "''" or val == '""': val = ''
736 if val == "''" or val == '""': val = ''
737 if opt['no_empty'] and (val=='' or val.isspace()):
737 if opt['no_empty'] and (val=='' or val.isspace()):
738 continue
738 continue
739 # if a key is found more than once in the file, build a list
739 # if a key is found more than once in the file, build a list
740 # unless it's in the 'unique' list. In that case, last found in file
740 # unless it's in the 'unique' list. In that case, last found in file
741 # takes precedence. User beware.
741 # takes precedence. User beware.
742 try:
742 try:
743 if dict[key] and key in unique_keys:
743 if dict[key] and key in unique_keys:
744 dict[key] = val
744 dict[key] = val
745 elif type(dict[key]) is types.ListType:
745 elif type(dict[key]) is types.ListType:
746 dict[key].append(val)
746 dict[key].append(val)
747 else:
747 else:
748 dict[key] = [dict[key],val]
748 dict[key] = [dict[key],val]
749 except KeyError:
749 except KeyError:
750 dict[key] = val
750 dict[key] = val
751 # purge if requested
751 # purge if requested
752 if opt['purge']:
752 if opt['purge']:
753 accepted_keys = qwflat(type_conv.values())
753 accepted_keys = qwflat(type_conv.values())
754 for key in dict.keys():
754 for key in dict.keys():
755 if key in accepted_keys: continue
755 if key in accepted_keys: continue
756 del(dict[key])
756 del(dict[key])
757 # now convert if requested
757 # now convert if requested
758 if type_conv==None: return dict
758 if type_conv==None: return dict
759 conversions = type_conv.keys()
759 conversions = type_conv.keys()
760 try: conversions.remove(None)
760 try: conversions.remove(None)
761 except: pass
761 except: pass
762 for convert in conversions:
762 for convert in conversions:
763 for val in qw(type_conv[convert]):
763 for val in qw(type_conv[convert]):
764 try:
764 try:
765 dict[val] = convert(dict[val])
765 dict[val] = convert(dict[val])
766 except KeyError,e:
766 except KeyError,e:
767 if opt['warn'] == 0:
767 if opt['warn'] == 0:
768 pass
768 pass
769 elif opt['warn'] == 1:
769 elif opt['warn'] == 1:
770 print >>sys.stderr, 'Warning: key',val,\
770 print >>sys.stderr, 'Warning: key',val,\
771 'not found in file',filename
771 'not found in file',filename
772 elif opt['warn'] == 2:
772 elif opt['warn'] == 2:
773 raise KeyError,e
773 raise KeyError,e
774 else:
774 else:
775 raise ValueError,'Warning level must be 0,1 or 2'
775 raise ValueError,'Warning level must be 0,1 or 2'
776
776
777 return dict
777 return dict
778
778
779 #----------------------------------------------------------------------------
779 #----------------------------------------------------------------------------
780 def flag_calls(func):
780 def flag_calls(func):
781 """Wrap a function to detect and flag when it gets called.
781 """Wrap a function to detect and flag when it gets called.
782
782
783 This is a decorator which takes a function and wraps it in a function with
783 This is a decorator which takes a function and wraps it in a function with
784 a 'called' attribute. wrapper.called is initialized to False.
784 a 'called' attribute. wrapper.called is initialized to False.
785
785
786 The wrapper.called attribute is set to False right before each call to the
786 The wrapper.called attribute is set to False right before each call to the
787 wrapped function, so if the call fails it remains False. After the call
787 wrapped function, so if the call fails it remains False. After the call
788 completes, wrapper.called is set to True and the output is returned.
788 completes, wrapper.called is set to True and the output is returned.
789
789
790 Testing for truth in wrapper.called allows you to determine if a call to
790 Testing for truth in wrapper.called allows you to determine if a call to
791 func() was attempted and succeeded."""
791 func() was attempted and succeeded."""
792
792
793 def wrapper(*args,**kw):
793 def wrapper(*args,**kw):
794 wrapper.called = False
794 wrapper.called = False
795 out = func(*args,**kw)
795 out = func(*args,**kw)
796 wrapper.called = True
796 wrapper.called = True
797 return out
797 return out
798
798
799 wrapper.called = False
799 wrapper.called = False
800 wrapper.__doc__ = func.__doc__
800 wrapper.__doc__ = func.__doc__
801 return wrapper
801 return wrapper
802
802
803 #----------------------------------------------------------------------------
803 #----------------------------------------------------------------------------
804 class HomeDirError(Error):
804 class HomeDirError(Error):
805 pass
805 pass
806
806
807 def get_home_dir():
807 def get_home_dir():
808 """Return the closest possible equivalent to a 'home' directory.
808 """Return the closest possible equivalent to a 'home' directory.
809
809
810 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
810 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
811
811
812 Currently only Posix and NT are implemented, a HomeDirError exception is
812 Currently only Posix and NT are implemented, a HomeDirError exception is
813 raised for all other OSes. """
813 raised for all other OSes. """
814
814
815 isdir = os.path.isdir
815 isdir = os.path.isdir
816 env = os.environ
816 env = os.environ
817 try:
817 try:
818 homedir = env['HOME']
818 homedir = env['HOME']
819 if not isdir(homedir):
819 if not isdir(homedir):
820 # in case a user stuck some string which does NOT resolve to a
820 # in case a user stuck some string which does NOT resolve to a
821 # valid path, it's as good as if we hadn't foud it
821 # valid path, it's as good as if we hadn't foud it
822 raise KeyError
822 raise KeyError
823 return homedir
823 return homedir
824 except KeyError:
824 except KeyError:
825 if os.name == 'posix':
825 if os.name == 'posix':
826 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
826 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
827 elif os.name == 'nt':
827 elif os.name == 'nt':
828 # For some strange reason, win9x returns 'nt' for os.name.
828 # For some strange reason, win9x returns 'nt' for os.name.
829 try:
829 try:
830 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
830 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
831 if not isdir(homedir):
831 if not isdir(homedir):
832 homedir = os.path.join(env['USERPROFILE'])
832 homedir = os.path.join(env['USERPROFILE'])
833 if not isdir(homedir):
833 if not isdir(homedir):
834 raise HomeDirError
834 raise HomeDirError
835 return homedir
835 return homedir
836 except:
836 except:
837 try:
837 try:
838 # Use the registry to get the 'My Documents' folder.
838 # Use the registry to get the 'My Documents' folder.
839 import _winreg as wreg
839 import _winreg as wreg
840 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
840 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
841 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
841 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
842 homedir = wreg.QueryValueEx(key,'Personal')[0]
842 homedir = wreg.QueryValueEx(key,'Personal')[0]
843 key.Close()
843 key.Close()
844 if not isdir(homedir):
844 if not isdir(homedir):
845 e = ('Invalid "Personal" folder registry key '
845 e = ('Invalid "Personal" folder registry key '
846 'typically "My Documents".\n'
846 'typically "My Documents".\n'
847 'Value: %s\n'
847 'Value: %s\n'
848 'This is not a valid directory on your system.' %
848 'This is not a valid directory on your system.' %
849 homedir)
849 homedir)
850 raise HomeDirError(e)
850 raise HomeDirError(e)
851 return homedir
851 return homedir
852 except HomeDirError:
852 except HomeDirError:
853 raise
853 raise
854 except:
854 except:
855 return 'C:\\'
855 return 'C:\\'
856 elif os.name == 'dos':
856 elif os.name == 'dos':
857 # Desperate, may do absurd things in classic MacOS. May work under DOS.
857 # Desperate, may do absurd things in classic MacOS. May work under DOS.
858 return 'C:\\'
858 return 'C:\\'
859 else:
859 else:
860 raise HomeDirError,'support for your operating system not implemented.'
860 raise HomeDirError,'support for your operating system not implemented.'
861
861
862 #****************************************************************************
862 #****************************************************************************
863 # strings and text
863 # strings and text
864
864
865 class LSString(str):
865 class LSString(str):
866 """String derivative with a special access attributes.
866 """String derivative with a special access attributes.
867
867
868 These are normal strings, but with the special attributes:
868 These are normal strings, but with the special attributes:
869
869
870 .l (or .list) : value as list (split on newlines).
870 .l (or .list) : value as list (split on newlines).
871 .n (or .nlstr): original value (the string itself).
871 .n (or .nlstr): original value (the string itself).
872 .s (or .spstr): value as whitespace-separated string.
872 .s (or .spstr): value as whitespace-separated string.
873
873
874 Any values which require transformations are computed only once and
874 Any values which require transformations are computed only once and
875 cached.
875 cached.
876
876
877 Such strings are very useful to efficiently interact with the shell, which
877 Such strings are very useful to efficiently interact with the shell, which
878 typically only understands whitespace-separated options for commands."""
878 typically only understands whitespace-separated options for commands."""
879
879
880 def get_list(self):
880 def get_list(self):
881 try:
881 try:
882 return self.__list
882 return self.__list
883 except AttributeError:
883 except AttributeError:
884 self.__list = self.split('\n')
884 self.__list = self.split('\n')
885 return self.__list
885 return self.__list
886
886
887 l = list = property(get_list)
887 l = list = property(get_list)
888
888
889 def get_spstr(self):
889 def get_spstr(self):
890 try:
890 try:
891 return self.__spstr
891 return self.__spstr
892 except AttributeError:
892 except AttributeError:
893 self.__spstr = self.replace('\n',' ')
893 self.__spstr = self.replace('\n',' ')
894 return self.__spstr
894 return self.__spstr
895
895
896 s = spstr = property(get_spstr)
896 s = spstr = property(get_spstr)
897
897
898 def get_nlstr(self):
898 def get_nlstr(self):
899 return self
899 return self
900
900
901 n = nlstr = property(get_nlstr)
901 n = nlstr = property(get_nlstr)
902
902
903 #----------------------------------------------------------------------------
903 #----------------------------------------------------------------------------
904 class SList(list):
904 class SList(list):
905 """List derivative with a special access attributes.
905 """List derivative with a special access attributes.
906
906
907 These are normal lists, but with the special attributes:
907 These are normal lists, but with the special attributes:
908
908
909 .l (or .list) : value as list (the list itself).
909 .l (or .list) : value as list (the list itself).
910 .n (or .nlstr): value as a string, joined on newlines.
910 .n (or .nlstr): value as a string, joined on newlines.
911 .s (or .spstr): value as a string, joined on spaces.
911 .s (or .spstr): value as a string, joined on spaces.
912
912
913 Any values which require transformations are computed only once and
913 Any values which require transformations are computed only once and
914 cached."""
914 cached."""
915
915
916 def get_list(self):
916 def get_list(self):
917 return self
917 return self
918
918
919 l = list = property(get_list)
919 l = list = property(get_list)
920
920
921 def get_spstr(self):
921 def get_spstr(self):
922 try:
922 try:
923 return self.__spstr
923 return self.__spstr
924 except AttributeError:
924 except AttributeError:
925 self.__spstr = ' '.join(self)
925 self.__spstr = ' '.join(self)
926 return self.__spstr
926 return self.__spstr
927
927
928 s = spstr = property(get_spstr)
928 s = spstr = property(get_spstr)
929
929
930 def get_nlstr(self):
930 def get_nlstr(self):
931 try:
931 try:
932 return self.__nlstr
932 return self.__nlstr
933 except AttributeError:
933 except AttributeError:
934 self.__nlstr = '\n'.join(self)
934 self.__nlstr = '\n'.join(self)
935 return self.__nlstr
935 return self.__nlstr
936
936
937 n = nlstr = property(get_nlstr)
937 n = nlstr = property(get_nlstr)
938
938
939 #----------------------------------------------------------------------------
939 #----------------------------------------------------------------------------
940 # This can be replaced with an isspace() call once we drop 2.2 compatibility
941 _isspace_match = re.compile(r'^\s+$').match
942 def isspace(s):
943 return bool(_isspace_match(s))
944
945 #----------------------------------------------------------------------------
946 def esc_quotes(strng):
940 def esc_quotes(strng):
947 """Return the input string with single and double quotes escaped out"""
941 """Return the input string with single and double quotes escaped out"""
948
942
949 return strng.replace('"','\\"').replace("'","\\'")
943 return strng.replace('"','\\"').replace("'","\\'")
950
944
951 #----------------------------------------------------------------------------
945 #----------------------------------------------------------------------------
952 def make_quoted_expr(s):
946 def make_quoted_expr(s):
953 """Return string s in appropriate quotes, using raw string if possible.
947 """Return string s in appropriate quotes, using raw string if possible.
954
948
955 Effectively this turns string: cd \ao\ao\
949 Effectively this turns string: cd \ao\ao\
956 to: r"cd \ao\ao\_"[:-1]
950 to: r"cd \ao\ao\_"[:-1]
957
951
958 Note the use of raw string and padding at the end to allow trailing backslash.
952 Note the use of raw string and padding at the end to allow trailing backslash.
959
953
960 """
954 """
961
955
962 tail = ''
956 tail = ''
963 tailpadding = ''
957 tailpadding = ''
964 raw = ''
958 raw = ''
965 if "\\" in s:
959 if "\\" in s:
966 raw = 'r'
960 raw = 'r'
967 if s.endswith('\\'):
961 if s.endswith('\\'):
968 tail = '[:-1]'
962 tail = '[:-1]'
969 tailpadding = '_'
963 tailpadding = '_'
970 if '"' not in s:
964 if '"' not in s:
971 quote = '"'
965 quote = '"'
972 elif "'" not in s:
966 elif "'" not in s:
973 quote = "'"
967 quote = "'"
974 elif '"""' not in s and not s.endswith('"'):
968 elif '"""' not in s and not s.endswith('"'):
975 quote = '"""'
969 quote = '"""'
976 elif "'''" not in s and not s.endswith("'"):
970 elif "'''" not in s and not s.endswith("'"):
977 quote = "'''"
971 quote = "'''"
978 else:
972 else:
979 # give up, backslash-escaped string will do
973 # give up, backslash-escaped string will do
980 return '"%s"' % esc_quotes(s)
974 return '"%s"' % esc_quotes(s)
981 res = itpl("$raw$quote$s$tailpadding$quote$tail")
975 res = itpl("$raw$quote$s$tailpadding$quote$tail")
982 return res
976 return res
983
977
984
978
985 #----------------------------------------------------------------------------
979 #----------------------------------------------------------------------------
986 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
980 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
987 """Take multiple lines of input.
981 """Take multiple lines of input.
988
982
989 A list with each line of input as a separate element is returned when a
983 A list with each line of input as a separate element is returned when a
990 termination string is entered (defaults to a single '.'). Input can also
984 termination string is entered (defaults to a single '.'). Input can also
991 terminate via EOF (^D in Unix, ^Z-RET in Windows).
985 terminate via EOF (^D in Unix, ^Z-RET in Windows).
992
986
993 Lines of input which end in \\ are joined into single entries (and a
987 Lines of input which end in \\ are joined into single entries (and a
994 secondary continuation prompt is issued as long as the user terminates
988 secondary continuation prompt is issued as long as the user terminates
995 lines with \\). This allows entering very long strings which are still
989 lines with \\). This allows entering very long strings which are still
996 meant to be treated as single entities.
990 meant to be treated as single entities.
997 """
991 """
998
992
999 try:
993 try:
1000 if header:
994 if header:
1001 header += '\n'
995 header += '\n'
1002 lines = [raw_input(header + ps1)]
996 lines = [raw_input(header + ps1)]
1003 except EOFError:
997 except EOFError:
1004 return []
998 return []
1005 terminate = [terminate_str]
999 terminate = [terminate_str]
1006 try:
1000 try:
1007 while lines[-1:] != terminate:
1001 while lines[-1:] != terminate:
1008 new_line = raw_input(ps1)
1002 new_line = raw_input(ps1)
1009 while new_line.endswith('\\'):
1003 while new_line.endswith('\\'):
1010 new_line = new_line[:-1] + raw_input(ps2)
1004 new_line = new_line[:-1] + raw_input(ps2)
1011 lines.append(new_line)
1005 lines.append(new_line)
1012
1006
1013 return lines[:-1] # don't return the termination command
1007 return lines[:-1] # don't return the termination command
1014 except EOFError:
1008 except EOFError:
1015 print
1009 print
1016 return lines
1010 return lines
1017
1011
1018 #----------------------------------------------------------------------------
1012 #----------------------------------------------------------------------------
1019 def raw_input_ext(prompt='', ps2='... '):
1013 def raw_input_ext(prompt='', ps2='... '):
1020 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1014 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1021
1015
1022 line = raw_input(prompt)
1016 line = raw_input(prompt)
1023 while line.endswith('\\'):
1017 while line.endswith('\\'):
1024 line = line[:-1] + raw_input(ps2)
1018 line = line[:-1] + raw_input(ps2)
1025 return line
1019 return line
1026
1020
1027 #----------------------------------------------------------------------------
1021 #----------------------------------------------------------------------------
1028 def ask_yes_no(prompt,default=None):
1022 def ask_yes_no(prompt,default=None):
1029 """Asks a question and returns an integer 1/0 (y/n) answer.
1023 """Asks a question and returns an integer 1/0 (y/n) answer.
1030
1024
1031 If default is given (one of 'y','n'), it is used if the user input is
1025 If default is given (one of 'y','n'), it is used if the user input is
1032 empty. Otherwise the question is repeated until an answer is given.
1026 empty. Otherwise the question is repeated until an answer is given.
1033 If EOF occurs 20 times consecutively, the default answer is assumed,
1027 If EOF occurs 20 times consecutively, the default answer is assumed,
1034 or if there is no default, an exception is raised to prevent infinite
1028 or if there is no default, an exception is raised to prevent infinite
1035 loops.
1029 loops.
1036
1030
1037 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1031 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1038
1032
1039 answers = {'y':True,'n':False,'yes':True,'no':False}
1033 answers = {'y':True,'n':False,'yes':True,'no':False}
1040 ans = None
1034 ans = None
1041 eofs, max_eofs = 0, 20
1035 eofs, max_eofs = 0, 20
1042 while ans not in answers.keys():
1036 while ans not in answers.keys():
1043 try:
1037 try:
1044 ans = raw_input(prompt+' ').lower()
1038 ans = raw_input(prompt+' ').lower()
1045 if not ans: # response was an empty string
1039 if not ans: # response was an empty string
1046 ans = default
1040 ans = default
1047 eofs = 0
1041 eofs = 0
1048 except (EOFError,KeyboardInterrupt):
1042 except (EOFError,KeyboardInterrupt):
1049 eofs = eofs + 1
1043 eofs = eofs + 1
1050 if eofs >= max_eofs:
1044 if eofs >= max_eofs:
1051 if default in answers.keys():
1045 if default in answers.keys():
1052 ans = default
1046 ans = default
1053 else:
1047 else:
1054 raise
1048 raise
1055
1049
1056 return answers[ans]
1050 return answers[ans]
1057
1051
1058 #----------------------------------------------------------------------------
1052 #----------------------------------------------------------------------------
1059 def marquee(txt='',width=78,mark='*'):
1053 def marquee(txt='',width=78,mark='*'):
1060 """Return the input string centered in a 'marquee'."""
1054 """Return the input string centered in a 'marquee'."""
1061 if not txt:
1055 if not txt:
1062 return (mark*width)[:width]
1056 return (mark*width)[:width]
1063 nmark = (width-len(txt)-2)/len(mark)/2
1057 nmark = (width-len(txt)-2)/len(mark)/2
1064 if nmark < 0: nmark =0
1058 if nmark < 0: nmark =0
1065 marks = mark*nmark
1059 marks = mark*nmark
1066 return '%s %s %s' % (marks,txt,marks)
1060 return '%s %s %s' % (marks,txt,marks)
1067
1061
1068 #----------------------------------------------------------------------------
1062 #----------------------------------------------------------------------------
1069 class EvalDict:
1063 class EvalDict:
1070 """
1064 """
1071 Emulate a dict which evaluates its contents in the caller's frame.
1065 Emulate a dict which evaluates its contents in the caller's frame.
1072
1066
1073 Usage:
1067 Usage:
1074 >>>number = 19
1068 >>>number = 19
1075 >>>text = "python"
1069 >>>text = "python"
1076 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1070 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1077 """
1071 """
1078
1072
1079 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1073 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1080 # modified (shorter) version of:
1074 # modified (shorter) version of:
1081 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1075 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1082 # Skip Montanaro (skip@pobox.com).
1076 # Skip Montanaro (skip@pobox.com).
1083
1077
1084 def __getitem__(self, name):
1078 def __getitem__(self, name):
1085 frame = sys._getframe(1)
1079 frame = sys._getframe(1)
1086 return eval(name, frame.f_globals, frame.f_locals)
1080 return eval(name, frame.f_globals, frame.f_locals)
1087
1081
1088 EvalString = EvalDict # for backwards compatibility
1082 EvalString = EvalDict # for backwards compatibility
1089 #----------------------------------------------------------------------------
1083 #----------------------------------------------------------------------------
1090 def qw(words,flat=0,sep=None,maxsplit=-1):
1084 def qw(words,flat=0,sep=None,maxsplit=-1):
1091 """Similar to Perl's qw() operator, but with some more options.
1085 """Similar to Perl's qw() operator, but with some more options.
1092
1086
1093 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1087 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1094
1088
1095 words can also be a list itself, and with flat=1, the output will be
1089 words can also be a list itself, and with flat=1, the output will be
1096 recursively flattened. Examples:
1090 recursively flattened. Examples:
1097
1091
1098 >>> qw('1 2')
1092 >>> qw('1 2')
1099 ['1', '2']
1093 ['1', '2']
1100 >>> qw(['a b','1 2',['m n','p q']])
1094 >>> qw(['a b','1 2',['m n','p q']])
1101 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1095 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1102 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1096 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1103 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1097 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1104
1098
1105 if type(words) in StringTypes:
1099 if type(words) in StringTypes:
1106 return [word.strip() for word in words.split(sep,maxsplit)
1100 return [word.strip() for word in words.split(sep,maxsplit)
1107 if word and not word.isspace() ]
1101 if word and not word.isspace() ]
1108 if flat:
1102 if flat:
1109 return flatten(map(qw,words,[1]*len(words)))
1103 return flatten(map(qw,words,[1]*len(words)))
1110 return map(qw,words)
1104 return map(qw,words)
1111
1105
1112 #----------------------------------------------------------------------------
1106 #----------------------------------------------------------------------------
1113 def qwflat(words,sep=None,maxsplit=-1):
1107 def qwflat(words,sep=None,maxsplit=-1):
1114 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1108 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1115 return qw(words,1,sep,maxsplit)
1109 return qw(words,1,sep,maxsplit)
1116
1110
1117 #----------------------------------------------------------------------------
1111 #----------------------------------------------------------------------------
1118 def qw_lol(indata):
1112 def qw_lol(indata):
1119 """qw_lol('a b') -> [['a','b']],
1113 """qw_lol('a b') -> [['a','b']],
1120 otherwise it's just a call to qw().
1114 otherwise it's just a call to qw().
1121
1115
1122 We need this to make sure the modules_some keys *always* end up as a
1116 We need this to make sure the modules_some keys *always* end up as a
1123 list of lists."""
1117 list of lists."""
1124
1118
1125 if type(indata) in StringTypes:
1119 if type(indata) in StringTypes:
1126 return [qw(indata)]
1120 return [qw(indata)]
1127 else:
1121 else:
1128 return qw(indata)
1122 return qw(indata)
1129
1123
1130 #-----------------------------------------------------------------------------
1124 #-----------------------------------------------------------------------------
1131 def list_strings(arg):
1125 def list_strings(arg):
1132 """Always return a list of strings, given a string or list of strings
1126 """Always return a list of strings, given a string or list of strings
1133 as input."""
1127 as input."""
1134
1128
1135 if type(arg) in StringTypes: return [arg]
1129 if type(arg) in StringTypes: return [arg]
1136 else: return arg
1130 else: return arg
1137
1131
1138 #----------------------------------------------------------------------------
1132 #----------------------------------------------------------------------------
1139 def grep(pat,list,case=1):
1133 def grep(pat,list,case=1):
1140 """Simple minded grep-like function.
1134 """Simple minded grep-like function.
1141 grep(pat,list) returns occurrences of pat in list, None on failure.
1135 grep(pat,list) returns occurrences of pat in list, None on failure.
1142
1136
1143 It only does simple string matching, with no support for regexps. Use the
1137 It only does simple string matching, with no support for regexps. Use the
1144 option case=0 for case-insensitive matching."""
1138 option case=0 for case-insensitive matching."""
1145
1139
1146 # This is pretty crude. At least it should implement copying only references
1140 # This is pretty crude. At least it should implement copying only references
1147 # to the original data in case it's big. Now it copies the data for output.
1141 # to the original data in case it's big. Now it copies the data for output.
1148 out=[]
1142 out=[]
1149 if case:
1143 if case:
1150 for term in list:
1144 for term in list:
1151 if term.find(pat)>-1: out.append(term)
1145 if term.find(pat)>-1: out.append(term)
1152 else:
1146 else:
1153 lpat=pat.lower()
1147 lpat=pat.lower()
1154 for term in list:
1148 for term in list:
1155 if term.lower().find(lpat)>-1: out.append(term)
1149 if term.lower().find(lpat)>-1: out.append(term)
1156
1150
1157 if len(out): return out
1151 if len(out): return out
1158 else: return None
1152 else: return None
1159
1153
1160 #----------------------------------------------------------------------------
1154 #----------------------------------------------------------------------------
1161 def dgrep(pat,*opts):
1155 def dgrep(pat,*opts):
1162 """Return grep() on dir()+dir(__builtins__).
1156 """Return grep() on dir()+dir(__builtins__).
1163
1157
1164 A very common use of grep() when working interactively."""
1158 A very common use of grep() when working interactively."""
1165
1159
1166 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1160 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1167
1161
1168 #----------------------------------------------------------------------------
1162 #----------------------------------------------------------------------------
1169 def idgrep(pat):
1163 def idgrep(pat):
1170 """Case-insensitive dgrep()"""
1164 """Case-insensitive dgrep()"""
1171
1165
1172 return dgrep(pat,0)
1166 return dgrep(pat,0)
1173
1167
1174 #----------------------------------------------------------------------------
1168 #----------------------------------------------------------------------------
1175 def igrep(pat,list):
1169 def igrep(pat,list):
1176 """Synonym for case-insensitive grep."""
1170 """Synonym for case-insensitive grep."""
1177
1171
1178 return grep(pat,list,case=0)
1172 return grep(pat,list,case=0)
1179
1173
1180 #----------------------------------------------------------------------------
1174 #----------------------------------------------------------------------------
1181 def indent(str,nspaces=4,ntabs=0):
1175 def indent(str,nspaces=4,ntabs=0):
1182 """Indent a string a given number of spaces or tabstops.
1176 """Indent a string a given number of spaces or tabstops.
1183
1177
1184 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1178 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1185 """
1179 """
1186 if str is None:
1180 if str is None:
1187 return
1181 return
1188 ind = '\t'*ntabs+' '*nspaces
1182 ind = '\t'*ntabs+' '*nspaces
1189 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1183 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1190 if outstr.endswith(os.linesep+ind):
1184 if outstr.endswith(os.linesep+ind):
1191 return outstr[:-len(ind)]
1185 return outstr[:-len(ind)]
1192 else:
1186 else:
1193 return outstr
1187 return outstr
1194
1188
1195 #-----------------------------------------------------------------------------
1189 #-----------------------------------------------------------------------------
1196 def native_line_ends(filename,backup=1):
1190 def native_line_ends(filename,backup=1):
1197 """Convert (in-place) a file to line-ends native to the current OS.
1191 """Convert (in-place) a file to line-ends native to the current OS.
1198
1192
1199 If the optional backup argument is given as false, no backup of the
1193 If the optional backup argument is given as false, no backup of the
1200 original file is left. """
1194 original file is left. """
1201
1195
1202 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1196 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1203
1197
1204 bak_filename = filename + backup_suffixes[os.name]
1198 bak_filename = filename + backup_suffixes[os.name]
1205
1199
1206 original = open(filename).read()
1200 original = open(filename).read()
1207 shutil.copy2(filename,bak_filename)
1201 shutil.copy2(filename,bak_filename)
1208 try:
1202 try:
1209 new = open(filename,'wb')
1203 new = open(filename,'wb')
1210 new.write(os.linesep.join(original.splitlines()))
1204 new.write(os.linesep.join(original.splitlines()))
1211 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1205 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1212 new.close()
1206 new.close()
1213 except:
1207 except:
1214 os.rename(bak_filename,filename)
1208 os.rename(bak_filename,filename)
1215 if not backup:
1209 if not backup:
1216 try:
1210 try:
1217 os.remove(bak_filename)
1211 os.remove(bak_filename)
1218 except:
1212 except:
1219 pass
1213 pass
1220
1214
1221 #----------------------------------------------------------------------------
1215 #----------------------------------------------------------------------------
1222 def get_pager_cmd(pager_cmd = None):
1216 def get_pager_cmd(pager_cmd = None):
1223 """Return a pager command.
1217 """Return a pager command.
1224
1218
1225 Makes some attempts at finding an OS-correct one."""
1219 Makes some attempts at finding an OS-correct one."""
1226
1220
1227 if os.name == 'posix':
1221 if os.name == 'posix':
1228 default_pager_cmd = 'less -r' # -r for color control sequences
1222 default_pager_cmd = 'less -r' # -r for color control sequences
1229 elif os.name in ['nt','dos']:
1223 elif os.name in ['nt','dos']:
1230 default_pager_cmd = 'type'
1224 default_pager_cmd = 'type'
1231
1225
1232 if pager_cmd is None:
1226 if pager_cmd is None:
1233 try:
1227 try:
1234 pager_cmd = os.environ['PAGER']
1228 pager_cmd = os.environ['PAGER']
1235 except:
1229 except:
1236 pager_cmd = default_pager_cmd
1230 pager_cmd = default_pager_cmd
1237 return pager_cmd
1231 return pager_cmd
1238
1232
1239 #-----------------------------------------------------------------------------
1233 #-----------------------------------------------------------------------------
1240 def get_pager_start(pager,start):
1234 def get_pager_start(pager,start):
1241 """Return the string for paging files with an offset.
1235 """Return the string for paging files with an offset.
1242
1236
1243 This is the '+N' argument which less and more (under Unix) accept.
1237 This is the '+N' argument which less and more (under Unix) accept.
1244 """
1238 """
1245
1239
1246 if pager in ['less','more']:
1240 if pager in ['less','more']:
1247 if start:
1241 if start:
1248 start_string = '+' + str(start)
1242 start_string = '+' + str(start)
1249 else:
1243 else:
1250 start_string = ''
1244 start_string = ''
1251 else:
1245 else:
1252 start_string = ''
1246 start_string = ''
1253 return start_string
1247 return start_string
1254
1248
1255 #----------------------------------------------------------------------------
1249 #----------------------------------------------------------------------------
1256 if os.name == "nt":
1250 if os.name == "nt":
1257 import msvcrt
1251 import msvcrt
1258 def page_more():
1252 def page_more():
1259 """ Smart pausing between pages
1253 """ Smart pausing between pages
1260
1254
1261 @return: True if need print more lines, False if quit
1255 @return: True if need print more lines, False if quit
1262 """
1256 """
1263 Term.cout.write('---Return to continue, q to quit--- ')
1257 Term.cout.write('---Return to continue, q to quit--- ')
1264 ans = msvcrt.getch()
1258 ans = msvcrt.getch()
1265 if ans in ("q", "Q"):
1259 if ans in ("q", "Q"):
1266 result = False
1260 result = False
1267 else:
1261 else:
1268 result = True
1262 result = True
1269 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1263 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1270 return result
1264 return result
1271 else:
1265 else:
1272 def page_more():
1266 def page_more():
1273 ans = raw_input('---Return to continue, q to quit--- ')
1267 ans = raw_input('---Return to continue, q to quit--- ')
1274 if ans.lower().startswith('q'):
1268 if ans.lower().startswith('q'):
1275 return False
1269 return False
1276 else:
1270 else:
1277 return True
1271 return True
1278
1272
1279 esc_re = re.compile(r"(\x1b[^m]+m)")
1273 esc_re = re.compile(r"(\x1b[^m]+m)")
1280
1274
1281 def page_dumb(strng,start=0,screen_lines=25):
1275 def page_dumb(strng,start=0,screen_lines=25):
1282 """Very dumb 'pager' in Python, for when nothing else works.
1276 """Very dumb 'pager' in Python, for when nothing else works.
1283
1277
1284 Only moves forward, same interface as page(), except for pager_cmd and
1278 Only moves forward, same interface as page(), except for pager_cmd and
1285 mode."""
1279 mode."""
1286
1280
1287 out_ln = strng.splitlines()[start:]
1281 out_ln = strng.splitlines()[start:]
1288 screens = chop(out_ln,screen_lines-1)
1282 screens = chop(out_ln,screen_lines-1)
1289 if len(screens) == 1:
1283 if len(screens) == 1:
1290 print >>Term.cout, os.linesep.join(screens[0])
1284 print >>Term.cout, os.linesep.join(screens[0])
1291 else:
1285 else:
1292 last_escape = ""
1286 last_escape = ""
1293 for scr in screens[0:-1]:
1287 for scr in screens[0:-1]:
1294 hunk = os.linesep.join(scr)
1288 hunk = os.linesep.join(scr)
1295 print >>Term.cout, last_escape + hunk
1289 print >>Term.cout, last_escape + hunk
1296 if not page_more():
1290 if not page_more():
1297 return
1291 return
1298 esc_list = esc_re.findall(hunk)
1292 esc_list = esc_re.findall(hunk)
1299 if len(esc_list) > 0:
1293 if len(esc_list) > 0:
1300 last_escape = esc_list[-1]
1294 last_escape = esc_list[-1]
1301 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1295 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1302
1296
1303 #----------------------------------------------------------------------------
1297 #----------------------------------------------------------------------------
1304 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1298 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1305 """Print a string, piping through a pager after a certain length.
1299 """Print a string, piping through a pager after a certain length.
1306
1300
1307 The screen_lines parameter specifies the number of *usable* lines of your
1301 The screen_lines parameter specifies the number of *usable* lines of your
1308 terminal screen (total lines minus lines you need to reserve to show other
1302 terminal screen (total lines minus lines you need to reserve to show other
1309 information).
1303 information).
1310
1304
1311 If you set screen_lines to a number <=0, page() will try to auto-determine
1305 If you set screen_lines to a number <=0, page() will try to auto-determine
1312 your screen size and will only use up to (screen_size+screen_lines) for
1306 your screen size and will only use up to (screen_size+screen_lines) for
1313 printing, paging after that. That is, if you want auto-detection but need
1307 printing, paging after that. That is, if you want auto-detection but need
1314 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1308 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1315 auto-detection without any lines reserved simply use screen_lines = 0.
1309 auto-detection without any lines reserved simply use screen_lines = 0.
1316
1310
1317 If a string won't fit in the allowed lines, it is sent through the
1311 If a string won't fit in the allowed lines, it is sent through the
1318 specified pager command. If none given, look for PAGER in the environment,
1312 specified pager command. If none given, look for PAGER in the environment,
1319 and ultimately default to less.
1313 and ultimately default to less.
1320
1314
1321 If no system pager works, the string is sent through a 'dumb pager'
1315 If no system pager works, the string is sent through a 'dumb pager'
1322 written in python, very simplistic.
1316 written in python, very simplistic.
1323 """
1317 """
1324
1318
1325 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1319 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1326 TERM = os.environ.get('TERM','dumb')
1320 TERM = os.environ.get('TERM','dumb')
1327 if TERM in ['dumb','emacs'] and os.name != 'nt':
1321 if TERM in ['dumb','emacs'] and os.name != 'nt':
1328 print strng
1322 print strng
1329 return
1323 return
1330 # chop off the topmost part of the string we don't want to see
1324 # chop off the topmost part of the string we don't want to see
1331 str_lines = strng.split(os.linesep)[start:]
1325 str_lines = strng.split(os.linesep)[start:]
1332 str_toprint = os.linesep.join(str_lines)
1326 str_toprint = os.linesep.join(str_lines)
1333 num_newlines = len(str_lines)
1327 num_newlines = len(str_lines)
1334 len_str = len(str_toprint)
1328 len_str = len(str_toprint)
1335
1329
1336 # Dumb heuristics to guesstimate number of on-screen lines the string
1330 # Dumb heuristics to guesstimate number of on-screen lines the string
1337 # takes. Very basic, but good enough for docstrings in reasonable
1331 # takes. Very basic, but good enough for docstrings in reasonable
1338 # terminals. If someone later feels like refining it, it's not hard.
1332 # terminals. If someone later feels like refining it, it's not hard.
1339 numlines = max(num_newlines,int(len_str/80)+1)
1333 numlines = max(num_newlines,int(len_str/80)+1)
1340
1334
1341 if os.name == "nt":
1335 if os.name == "nt":
1342 screen_lines_def = get_console_size(defaulty=25)[1]
1336 screen_lines_def = get_console_size(defaulty=25)[1]
1343 else:
1337 else:
1344 screen_lines_def = 25 # default value if we can't auto-determine
1338 screen_lines_def = 25 # default value if we can't auto-determine
1345
1339
1346 # auto-determine screen size
1340 # auto-determine screen size
1347 if screen_lines <= 0:
1341 if screen_lines <= 0:
1348 if TERM=='xterm':
1342 if TERM=='xterm':
1349 try:
1343 try:
1350 import curses
1344 import curses
1351 if hasattr(curses,'initscr'):
1345 if hasattr(curses,'initscr'):
1352 use_curses = 1
1346 use_curses = 1
1353 else:
1347 else:
1354 use_curses = 0
1348 use_curses = 0
1355 except ImportError:
1349 except ImportError:
1356 use_curses = 0
1350 use_curses = 0
1357 else:
1351 else:
1358 # curses causes problems on many terminals other than xterm.
1352 # curses causes problems on many terminals other than xterm.
1359 use_curses = 0
1353 use_curses = 0
1360 if use_curses:
1354 if use_curses:
1361 scr = curses.initscr()
1355 scr = curses.initscr()
1362 screen_lines_real,screen_cols = scr.getmaxyx()
1356 screen_lines_real,screen_cols = scr.getmaxyx()
1363 curses.endwin()
1357 curses.endwin()
1364 screen_lines += screen_lines_real
1358 screen_lines += screen_lines_real
1365 #print '***Screen size:',screen_lines_real,'lines x',\
1359 #print '***Screen size:',screen_lines_real,'lines x',\
1366 #screen_cols,'columns.' # dbg
1360 #screen_cols,'columns.' # dbg
1367 else:
1361 else:
1368 screen_lines += screen_lines_def
1362 screen_lines += screen_lines_def
1369
1363
1370 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1364 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1371 if numlines <= screen_lines :
1365 if numlines <= screen_lines :
1372 #print '*** normal print' # dbg
1366 #print '*** normal print' # dbg
1373 print >>Term.cout, str_toprint
1367 print >>Term.cout, str_toprint
1374 else:
1368 else:
1375 # Try to open pager and default to internal one if that fails.
1369 # Try to open pager and default to internal one if that fails.
1376 # All failure modes are tagged as 'retval=1', to match the return
1370 # All failure modes are tagged as 'retval=1', to match the return
1377 # value of a failed system command. If any intermediate attempt
1371 # value of a failed system command. If any intermediate attempt
1378 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1372 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1379 pager_cmd = get_pager_cmd(pager_cmd)
1373 pager_cmd = get_pager_cmd(pager_cmd)
1380 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1374 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1381 if os.name == 'nt':
1375 if os.name == 'nt':
1382 if pager_cmd.startswith('type'):
1376 if pager_cmd.startswith('type'):
1383 # The default WinXP 'type' command is failing on complex strings.
1377 # The default WinXP 'type' command is failing on complex strings.
1384 retval = 1
1378 retval = 1
1385 else:
1379 else:
1386 tmpname = tempfile.mktemp('.txt')
1380 tmpname = tempfile.mktemp('.txt')
1387 tmpfile = file(tmpname,'wt')
1381 tmpfile = file(tmpname,'wt')
1388 tmpfile.write(strng)
1382 tmpfile.write(strng)
1389 tmpfile.close()
1383 tmpfile.close()
1390 cmd = "%s < %s" % (pager_cmd,tmpname)
1384 cmd = "%s < %s" % (pager_cmd,tmpname)
1391 if os.system(cmd):
1385 if os.system(cmd):
1392 retval = 1
1386 retval = 1
1393 else:
1387 else:
1394 retval = None
1388 retval = None
1395 os.remove(tmpname)
1389 os.remove(tmpname)
1396 else:
1390 else:
1397 try:
1391 try:
1398 retval = None
1392 retval = None
1399 # if I use popen4, things hang. No idea why.
1393 # if I use popen4, things hang. No idea why.
1400 #pager,shell_out = os.popen4(pager_cmd)
1394 #pager,shell_out = os.popen4(pager_cmd)
1401 pager = os.popen(pager_cmd,'w')
1395 pager = os.popen(pager_cmd,'w')
1402 pager.write(strng)
1396 pager.write(strng)
1403 pager.close()
1397 pager.close()
1404 retval = pager.close() # success returns None
1398 retval = pager.close() # success returns None
1405 except IOError,msg: # broken pipe when user quits
1399 except IOError,msg: # broken pipe when user quits
1406 if msg.args == (32,'Broken pipe'):
1400 if msg.args == (32,'Broken pipe'):
1407 retval = None
1401 retval = None
1408 else:
1402 else:
1409 retval = 1
1403 retval = 1
1410 except OSError:
1404 except OSError:
1411 # Other strange problems, sometimes seen in Win2k/cygwin
1405 # Other strange problems, sometimes seen in Win2k/cygwin
1412 retval = 1
1406 retval = 1
1413 if retval is not None:
1407 if retval is not None:
1414 page_dumb(strng,screen_lines=screen_lines)
1408 page_dumb(strng,screen_lines=screen_lines)
1415
1409
1416 #----------------------------------------------------------------------------
1410 #----------------------------------------------------------------------------
1417 def page_file(fname,start = 0, pager_cmd = None):
1411 def page_file(fname,start = 0, pager_cmd = None):
1418 """Page a file, using an optional pager command and starting line.
1412 """Page a file, using an optional pager command and starting line.
1419 """
1413 """
1420
1414
1421 pager_cmd = get_pager_cmd(pager_cmd)
1415 pager_cmd = get_pager_cmd(pager_cmd)
1422 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1416 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1423
1417
1424 try:
1418 try:
1425 if os.environ['TERM'] in ['emacs','dumb']:
1419 if os.environ['TERM'] in ['emacs','dumb']:
1426 raise EnvironmentError
1420 raise EnvironmentError
1427 xsys(pager_cmd + ' ' + fname)
1421 xsys(pager_cmd + ' ' + fname)
1428 except:
1422 except:
1429 try:
1423 try:
1430 if start > 0:
1424 if start > 0:
1431 start -= 1
1425 start -= 1
1432 page(open(fname).read(),start)
1426 page(open(fname).read(),start)
1433 except:
1427 except:
1434 print 'Unable to show file',`fname`
1428 print 'Unable to show file',`fname`
1435
1429
1436 #----------------------------------------------------------------------------
1430 #----------------------------------------------------------------------------
1437 def snip_print(str,width = 75,print_full = 0,header = ''):
1431 def snip_print(str,width = 75,print_full = 0,header = ''):
1438 """Print a string snipping the midsection to fit in width.
1432 """Print a string snipping the midsection to fit in width.
1439
1433
1440 print_full: mode control:
1434 print_full: mode control:
1441 - 0: only snip long strings
1435 - 0: only snip long strings
1442 - 1: send to page() directly.
1436 - 1: send to page() directly.
1443 - 2: snip long strings and ask for full length viewing with page()
1437 - 2: snip long strings and ask for full length viewing with page()
1444 Return 1 if snipping was necessary, 0 otherwise."""
1438 Return 1 if snipping was necessary, 0 otherwise."""
1445
1439
1446 if print_full == 1:
1440 if print_full == 1:
1447 page(header+str)
1441 page(header+str)
1448 return 0
1442 return 0
1449
1443
1450 print header,
1444 print header,
1451 if len(str) < width:
1445 if len(str) < width:
1452 print str
1446 print str
1453 snip = 0
1447 snip = 0
1454 else:
1448 else:
1455 whalf = int((width -5)/2)
1449 whalf = int((width -5)/2)
1456 print str[:whalf] + ' <...> ' + str[-whalf:]
1450 print str[:whalf] + ' <...> ' + str[-whalf:]
1457 snip = 1
1451 snip = 1
1458 if snip and print_full == 2:
1452 if snip and print_full == 2:
1459 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1453 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1460 page(str)
1454 page(str)
1461 return snip
1455 return snip
1462
1456
1463 #****************************************************************************
1457 #****************************************************************************
1464 # lists, dicts and structures
1458 # lists, dicts and structures
1465
1459
1466 def belong(candidates,checklist):
1460 def belong(candidates,checklist):
1467 """Check whether a list of items appear in a given list of options.
1461 """Check whether a list of items appear in a given list of options.
1468
1462
1469 Returns a list of 1 and 0, one for each candidate given."""
1463 Returns a list of 1 and 0, one for each candidate given."""
1470
1464
1471 return [x in checklist for x in candidates]
1465 return [x in checklist for x in candidates]
1472
1466
1473 #----------------------------------------------------------------------------
1467 #----------------------------------------------------------------------------
1474 def uniq_stable(elems):
1468 def uniq_stable(elems):
1475 """uniq_stable(elems) -> list
1469 """uniq_stable(elems) -> list
1476
1470
1477 Return from an iterable, a list of all the unique elements in the input,
1471 Return from an iterable, a list of all the unique elements in the input,
1478 but maintaining the order in which they first appear.
1472 but maintaining the order in which they first appear.
1479
1473
1480 A naive solution to this problem which just makes a dictionary with the
1474 A naive solution to this problem which just makes a dictionary with the
1481 elements as keys fails to respect the stability condition, since
1475 elements as keys fails to respect the stability condition, since
1482 dictionaries are unsorted by nature.
1476 dictionaries are unsorted by nature.
1483
1477
1484 Note: All elements in the input must be valid dictionary keys for this
1478 Note: All elements in the input must be valid dictionary keys for this
1485 routine to work, as it internally uses a dictionary for efficiency
1479 routine to work, as it internally uses a dictionary for efficiency
1486 reasons."""
1480 reasons."""
1487
1481
1488 unique = []
1482 unique = []
1489 unique_dict = {}
1483 unique_dict = {}
1490 for nn in elems:
1484 for nn in elems:
1491 if nn not in unique_dict:
1485 if nn not in unique_dict:
1492 unique.append(nn)
1486 unique.append(nn)
1493 unique_dict[nn] = None
1487 unique_dict[nn] = None
1494 return unique
1488 return unique
1495
1489
1496 #----------------------------------------------------------------------------
1490 #----------------------------------------------------------------------------
1497 class NLprinter:
1491 class NLprinter:
1498 """Print an arbitrarily nested list, indicating index numbers.
1492 """Print an arbitrarily nested list, indicating index numbers.
1499
1493
1500 An instance of this class called nlprint is available and callable as a
1494 An instance of this class called nlprint is available and callable as a
1501 function.
1495 function.
1502
1496
1503 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1497 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1504 and using 'sep' to separate the index from the value. """
1498 and using 'sep' to separate the index from the value. """
1505
1499
1506 def __init__(self):
1500 def __init__(self):
1507 self.depth = 0
1501 self.depth = 0
1508
1502
1509 def __call__(self,lst,pos='',**kw):
1503 def __call__(self,lst,pos='',**kw):
1510 """Prints the nested list numbering levels."""
1504 """Prints the nested list numbering levels."""
1511 kw.setdefault('indent',' ')
1505 kw.setdefault('indent',' ')
1512 kw.setdefault('sep',': ')
1506 kw.setdefault('sep',': ')
1513 kw.setdefault('start',0)
1507 kw.setdefault('start',0)
1514 kw.setdefault('stop',len(lst))
1508 kw.setdefault('stop',len(lst))
1515 # we need to remove start and stop from kw so they don't propagate
1509 # we need to remove start and stop from kw so they don't propagate
1516 # into a recursive call for a nested list.
1510 # into a recursive call for a nested list.
1517 start = kw['start']; del kw['start']
1511 start = kw['start']; del kw['start']
1518 stop = kw['stop']; del kw['stop']
1512 stop = kw['stop']; del kw['stop']
1519 if self.depth == 0 and 'header' in kw.keys():
1513 if self.depth == 0 and 'header' in kw.keys():
1520 print kw['header']
1514 print kw['header']
1521
1515
1522 for idx in range(start,stop):
1516 for idx in range(start,stop):
1523 elem = lst[idx]
1517 elem = lst[idx]
1524 if type(elem)==type([]):
1518 if type(elem)==type([]):
1525 self.depth += 1
1519 self.depth += 1
1526 self.__call__(elem,itpl('$pos$idx,'),**kw)
1520 self.__call__(elem,itpl('$pos$idx,'),**kw)
1527 self.depth -= 1
1521 self.depth -= 1
1528 else:
1522 else:
1529 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1523 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1530
1524
1531 nlprint = NLprinter()
1525 nlprint = NLprinter()
1532 #----------------------------------------------------------------------------
1526 #----------------------------------------------------------------------------
1533 def all_belong(candidates,checklist):
1527 def all_belong(candidates,checklist):
1534 """Check whether a list of items ALL appear in a given list of options.
1528 """Check whether a list of items ALL appear in a given list of options.
1535
1529
1536 Returns a single 1 or 0 value."""
1530 Returns a single 1 or 0 value."""
1537
1531
1538 return 1-(0 in [x in checklist for x in candidates])
1532 return 1-(0 in [x in checklist for x in candidates])
1539
1533
1540 #----------------------------------------------------------------------------
1534 #----------------------------------------------------------------------------
1541 def sort_compare(lst1,lst2,inplace = 1):
1535 def sort_compare(lst1,lst2,inplace = 1):
1542 """Sort and compare two lists.
1536 """Sort and compare two lists.
1543
1537
1544 By default it does it in place, thus modifying the lists. Use inplace = 0
1538 By default it does it in place, thus modifying the lists. Use inplace = 0
1545 to avoid that (at the cost of temporary copy creation)."""
1539 to avoid that (at the cost of temporary copy creation)."""
1546 if not inplace:
1540 if not inplace:
1547 lst1 = lst1[:]
1541 lst1 = lst1[:]
1548 lst2 = lst2[:]
1542 lst2 = lst2[:]
1549 lst1.sort(); lst2.sort()
1543 lst1.sort(); lst2.sort()
1550 return lst1 == lst2
1544 return lst1 == lst2
1551
1545
1552 #----------------------------------------------------------------------------
1546 #----------------------------------------------------------------------------
1553 def mkdict(**kwargs):
1547 def mkdict(**kwargs):
1554 """Return a dict from a keyword list.
1548 """Return a dict from a keyword list.
1555
1549
1556 It's just syntactic sugar for making ditcionary creation more convenient:
1550 It's just syntactic sugar for making ditcionary creation more convenient:
1557 # the standard way
1551 # the standard way
1558 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1552 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1559 # a cleaner way
1553 # a cleaner way
1560 >>>data = dict(red=1, green=2, blue=3)
1554 >>>data = dict(red=1, green=2, blue=3)
1561
1555
1562 If you need more than this, look at the Struct() class."""
1556 If you need more than this, look at the Struct() class."""
1563
1557
1564 return kwargs
1558 return kwargs
1565
1559
1566 #----------------------------------------------------------------------------
1560 #----------------------------------------------------------------------------
1567 def list2dict(lst):
1561 def list2dict(lst):
1568 """Takes a list of (key,value) pairs and turns it into a dict."""
1562 """Takes a list of (key,value) pairs and turns it into a dict."""
1569
1563
1570 dic = {}
1564 dic = {}
1571 for k,v in lst: dic[k] = v
1565 for k,v in lst: dic[k] = v
1572 return dic
1566 return dic
1573
1567
1574 #----------------------------------------------------------------------------
1568 #----------------------------------------------------------------------------
1575 def list2dict2(lst,default=''):
1569 def list2dict2(lst,default=''):
1576 """Takes a list and turns it into a dict.
1570 """Takes a list and turns it into a dict.
1577 Much slower than list2dict, but more versatile. This version can take
1571 Much slower than list2dict, but more versatile. This version can take
1578 lists with sublists of arbitrary length (including sclars)."""
1572 lists with sublists of arbitrary length (including sclars)."""
1579
1573
1580 dic = {}
1574 dic = {}
1581 for elem in lst:
1575 for elem in lst:
1582 if type(elem) in (types.ListType,types.TupleType):
1576 if type(elem) in (types.ListType,types.TupleType):
1583 size = len(elem)
1577 size = len(elem)
1584 if size == 0:
1578 if size == 0:
1585 pass
1579 pass
1586 elif size == 1:
1580 elif size == 1:
1587 dic[elem] = default
1581 dic[elem] = default
1588 else:
1582 else:
1589 k,v = elem[0], elem[1:]
1583 k,v = elem[0], elem[1:]
1590 if len(v) == 1: v = v[0]
1584 if len(v) == 1: v = v[0]
1591 dic[k] = v
1585 dic[k] = v
1592 else:
1586 else:
1593 dic[elem] = default
1587 dic[elem] = default
1594 return dic
1588 return dic
1595
1589
1596 #----------------------------------------------------------------------------
1590 #----------------------------------------------------------------------------
1597 def flatten(seq):
1591 def flatten(seq):
1598 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1592 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1599
1593
1600 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1594 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1601
1595
1602 # if the x=0 isn't made, a *global* variable x is left over after calling
1596 # if the x=0 isn't made, a *global* variable x is left over after calling
1603 # this function, with the value of the last element in the return
1597 # this function, with the value of the last element in the return
1604 # list. This does seem like a bug big time to me.
1598 # list. This does seem like a bug big time to me.
1605
1599
1606 # the problem is fixed with the x=0, which seems to force the creation of
1600 # the problem is fixed with the x=0, which seems to force the creation of
1607 # a local name
1601 # a local name
1608
1602
1609 x = 0
1603 x = 0
1610 return [x for subseq in seq for x in subseq]
1604 return [x for subseq in seq for x in subseq]
1611
1605
1612 #----------------------------------------------------------------------------
1606 #----------------------------------------------------------------------------
1613 def get_slice(seq,start=0,stop=None,step=1):
1607 def get_slice(seq,start=0,stop=None,step=1):
1614 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1608 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1615 if stop == None:
1609 if stop == None:
1616 stop = len(seq)
1610 stop = len(seq)
1617 item = lambda i: seq[i]
1611 item = lambda i: seq[i]
1618 return map(item,xrange(start,stop,step))
1612 return map(item,xrange(start,stop,step))
1619
1613
1620 #----------------------------------------------------------------------------
1614 #----------------------------------------------------------------------------
1621 def chop(seq,size):
1615 def chop(seq,size):
1622 """Chop a sequence into chunks of the given size."""
1616 """Chop a sequence into chunks of the given size."""
1623 chunk = lambda i: seq[i:i+size]
1617 chunk = lambda i: seq[i:i+size]
1624 return map(chunk,xrange(0,len(seq),size))
1618 return map(chunk,xrange(0,len(seq),size))
1625
1619
1626 #----------------------------------------------------------------------------
1620 #----------------------------------------------------------------------------
1627 def with(object, **args):
1621 def with(object, **args):
1628 """Set multiple attributes for an object, similar to Pascal's with.
1622 """Set multiple attributes for an object, similar to Pascal's with.
1629
1623
1630 Example:
1624 Example:
1631 with(jim,
1625 with(jim,
1632 born = 1960,
1626 born = 1960,
1633 haircolour = 'Brown',
1627 haircolour = 'Brown',
1634 eyecolour = 'Green')
1628 eyecolour = 'Green')
1635
1629
1636 Credit: Greg Ewing, in
1630 Credit: Greg Ewing, in
1637 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1631 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1638
1632
1639 object.__dict__.update(args)
1633 object.__dict__.update(args)
1640
1634
1641 #----------------------------------------------------------------------------
1635 #----------------------------------------------------------------------------
1642 def setattr_list(obj,alist,nspace = None):
1636 def setattr_list(obj,alist,nspace = None):
1643 """Set a list of attributes for an object taken from a namespace.
1637 """Set a list of attributes for an object taken from a namespace.
1644
1638
1645 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1639 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1646 alist with their values taken from nspace, which must be a dict (something
1640 alist with their values taken from nspace, which must be a dict (something
1647 like locals() will often do) If nspace isn't given, locals() of the
1641 like locals() will often do) If nspace isn't given, locals() of the
1648 *caller* is used, so in most cases you can omit it.
1642 *caller* is used, so in most cases you can omit it.
1649
1643
1650 Note that alist can be given as a string, which will be automatically
1644 Note that alist can be given as a string, which will be automatically
1651 split into a list on whitespace. If given as a list, it must be a list of
1645 split into a list on whitespace. If given as a list, it must be a list of
1652 *strings* (the variable names themselves), not of variables."""
1646 *strings* (the variable names themselves), not of variables."""
1653
1647
1654 # this grabs the local variables from the *previous* call frame -- that is
1648 # this grabs the local variables from the *previous* call frame -- that is
1655 # the locals from the function that called setattr_list().
1649 # the locals from the function that called setattr_list().
1656 # - snipped from weave.inline()
1650 # - snipped from weave.inline()
1657 if nspace is None:
1651 if nspace is None:
1658 call_frame = sys._getframe().f_back
1652 call_frame = sys._getframe().f_back
1659 nspace = call_frame.f_locals
1653 nspace = call_frame.f_locals
1660
1654
1661 if type(alist) in StringTypes:
1655 if type(alist) in StringTypes:
1662 alist = alist.split()
1656 alist = alist.split()
1663 for attr in alist:
1657 for attr in alist:
1664 val = eval(attr,nspace)
1658 val = eval(attr,nspace)
1665 setattr(obj,attr,val)
1659 setattr(obj,attr,val)
1666
1660
1667 #----------------------------------------------------------------------------
1661 #----------------------------------------------------------------------------
1668 def getattr_list(obj,alist,*args):
1662 def getattr_list(obj,alist,*args):
1669 """getattr_list(obj,alist[, default]) -> attribute list.
1663 """getattr_list(obj,alist[, default]) -> attribute list.
1670
1664
1671 Get a list of named attributes for an object. When a default argument is
1665 Get a list of named attributes for an object. When a default argument is
1672 given, it is returned when the attribute doesn't exist; without it, an
1666 given, it is returned when the attribute doesn't exist; without it, an
1673 exception is raised in that case.
1667 exception is raised in that case.
1674
1668
1675 Note that alist can be given as a string, which will be automatically
1669 Note that alist can be given as a string, which will be automatically
1676 split into a list on whitespace. If given as a list, it must be a list of
1670 split into a list on whitespace. If given as a list, it must be a list of
1677 *strings* (the variable names themselves), not of variables."""
1671 *strings* (the variable names themselves), not of variables."""
1678
1672
1679 if type(alist) in StringTypes:
1673 if type(alist) in StringTypes:
1680 alist = alist.split()
1674 alist = alist.split()
1681 if args:
1675 if args:
1682 if len(args)==1:
1676 if len(args)==1:
1683 default = args[0]
1677 default = args[0]
1684 return map(lambda attr: getattr(obj,attr,default),alist)
1678 return map(lambda attr: getattr(obj,attr,default),alist)
1685 else:
1679 else:
1686 raise ValueError,'getattr_list() takes only one optional argument'
1680 raise ValueError,'getattr_list() takes only one optional argument'
1687 else:
1681 else:
1688 return map(lambda attr: getattr(obj,attr),alist)
1682 return map(lambda attr: getattr(obj,attr),alist)
1689
1683
1690 #----------------------------------------------------------------------------
1684 #----------------------------------------------------------------------------
1691 def map_method(method,object_list,*argseq,**kw):
1685 def map_method(method,object_list,*argseq,**kw):
1692 """map_method(method,object_list,*args,**kw) -> list
1686 """map_method(method,object_list,*args,**kw) -> list
1693
1687
1694 Return a list of the results of applying the methods to the items of the
1688 Return a list of the results of applying the methods to the items of the
1695 argument sequence(s). If more than one sequence is given, the method is
1689 argument sequence(s). If more than one sequence is given, the method is
1696 called with an argument list consisting of the corresponding item of each
1690 called with an argument list consisting of the corresponding item of each
1697 sequence. All sequences must be of the same length.
1691 sequence. All sequences must be of the same length.
1698
1692
1699 Keyword arguments are passed verbatim to all objects called.
1693 Keyword arguments are passed verbatim to all objects called.
1700
1694
1701 This is Python code, so it's not nearly as fast as the builtin map()."""
1695 This is Python code, so it's not nearly as fast as the builtin map()."""
1702
1696
1703 out_list = []
1697 out_list = []
1704 idx = 0
1698 idx = 0
1705 for object in object_list:
1699 for object in object_list:
1706 try:
1700 try:
1707 handler = getattr(object, method)
1701 handler = getattr(object, method)
1708 except AttributeError:
1702 except AttributeError:
1709 out_list.append(None)
1703 out_list.append(None)
1710 else:
1704 else:
1711 if argseq:
1705 if argseq:
1712 args = map(lambda lst:lst[idx],argseq)
1706 args = map(lambda lst:lst[idx],argseq)
1713 #print 'ob',object,'hand',handler,'ar',args # dbg
1707 #print 'ob',object,'hand',handler,'ar',args # dbg
1714 out_list.append(handler(args,**kw))
1708 out_list.append(handler(args,**kw))
1715 else:
1709 else:
1716 out_list.append(handler(**kw))
1710 out_list.append(handler(**kw))
1717 idx += 1
1711 idx += 1
1718 return out_list
1712 return out_list
1719
1713
1720 #----------------------------------------------------------------------------
1714 #----------------------------------------------------------------------------
1721 def import_fail_info(mod_name,fns=None):
1715 def import_fail_info(mod_name,fns=None):
1722 """Inform load failure for a module."""
1716 """Inform load failure for a module."""
1723
1717
1724 if fns == None:
1718 if fns == None:
1725 warn("Loading of %s failed.\n" % (mod_name,))
1719 warn("Loading of %s failed.\n" % (mod_name,))
1726 else:
1720 else:
1727 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1721 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1728
1722
1729 #----------------------------------------------------------------------------
1723 #----------------------------------------------------------------------------
1730 # Proposed popitem() extension, written as a method
1724 # Proposed popitem() extension, written as a method
1731
1725
1732 class NotGiven: pass
1726 class NotGiven: pass
1733
1727
1734 def popkey(dct,key,default=NotGiven):
1728 def popkey(dct,key,default=NotGiven):
1735 """Return dct[key] and delete dct[key].
1729 """Return dct[key] and delete dct[key].
1736
1730
1737 If default is given, return it if dct[key] doesn't exist, otherwise raise
1731 If default is given, return it if dct[key] doesn't exist, otherwise raise
1738 KeyError. """
1732 KeyError. """
1739
1733
1740 try:
1734 try:
1741 val = dct[key]
1735 val = dct[key]
1742 except KeyError:
1736 except KeyError:
1743 if default is NotGiven:
1737 if default is NotGiven:
1744 raise
1738 raise
1745 else:
1739 else:
1746 return default
1740 return default
1747 else:
1741 else:
1748 del dct[key]
1742 del dct[key]
1749 return val
1743 return val
1750 #*************************** end of file <genutils.py> **********************
1744 #*************************** end of file <genutils.py> **********************
1751
1745
@@ -1,2157 +1,2191 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1012 2006-01-12 21:29:37Z vivainio $
9 $Id: iplib.py 1013 2006-01-13 08:33:32Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import tempfile
58 import tempfile
59 import traceback
59 import traceback
60 import types
60 import types
61
61
62 from pprint import pprint, pformat
62 from pprint import pprint, pformat
63
63
64 # IPython's own modules
64 # IPython's own modules
65 import IPython
65 import IPython
66 from IPython import OInspect,PyColorize,ultraTB
66 from IPython import OInspect,PyColorize,ultraTB
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.FakeModule import FakeModule
68 from IPython.FakeModule import FakeModule
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Logger import Logger
70 from IPython.Logger import Logger
71 from IPython.Magic import Magic
71 from IPython.Magic import Magic
72 from IPython.Prompts import CachedOutput
72 from IPython.Prompts import CachedOutput
73 from IPython.ipstruct import Struct
73 from IPython.ipstruct import Struct
74 from IPython.background_jobs import BackgroundJobManager
74 from IPython.background_jobs import BackgroundJobManager
75 from IPython.usage import cmd_line_usage,interactive_usage
75 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.genutils import *
76 from IPython.genutils import *
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 ini_spaces_re = re.compile(r'^(\s+)')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87
86
88
87
89 #****************************************************************************
88 #****************************************************************************
90 # Some utility function definitions
89 # Some utility function definitions
91
90
91 ini_spaces_re = re.compile(r'^(\s+)')
92
93 def num_ini_spaces(strng):
94 """Return the number of initial spaces in a string"""
95
96 ini_spaces = ini_spaces_re.match(strng)
97 if ini_spaces:
98 return ini_spaces.end()
99 else:
100 return 0
101
92 def softspace(file, newvalue):
102 def softspace(file, newvalue):
93 """Copied from code.py, to remove the dependency"""
103 """Copied from code.py, to remove the dependency"""
104
94 oldvalue = 0
105 oldvalue = 0
95 try:
106 try:
96 oldvalue = file.softspace
107 oldvalue = file.softspace
97 except AttributeError:
108 except AttributeError:
98 pass
109 pass
99 try:
110 try:
100 file.softspace = newvalue
111 file.softspace = newvalue
101 except (AttributeError, TypeError):
112 except (AttributeError, TypeError):
102 # "attribute-less object" or "read-only attributes"
113 # "attribute-less object" or "read-only attributes"
103 pass
114 pass
104 return oldvalue
115 return oldvalue
105
116
106
117
107 #****************************************************************************
118 #****************************************************************************
108 # Local use exceptions
119 # Local use exceptions
109 class SpaceInInput(exceptions.Exception): pass
120 class SpaceInInput(exceptions.Exception): pass
110
121
111
122
112 #****************************************************************************
123 #****************************************************************************
113 # Local use classes
124 # Local use classes
114 class Bunch: pass
125 class Bunch: pass
115
126
116 class Undefined: pass
127 class Undefined: pass
117
128
118 class InputList(list):
129 class InputList(list):
119 """Class to store user input.
130 """Class to store user input.
120
131
121 It's basically a list, but slices return a string instead of a list, thus
132 It's basically a list, but slices return a string instead of a list, thus
122 allowing things like (assuming 'In' is an instance):
133 allowing things like (assuming 'In' is an instance):
123
134
124 exec In[4:7]
135 exec In[4:7]
125
136
126 or
137 or
127
138
128 exec In[5:9] + In[14] + In[21:25]"""
139 exec In[5:9] + In[14] + In[21:25]"""
129
140
130 def __getslice__(self,i,j):
141 def __getslice__(self,i,j):
131 return ''.join(list.__getslice__(self,i,j))
142 return ''.join(list.__getslice__(self,i,j))
132
143
133 class SyntaxTB(ultraTB.ListTB):
144 class SyntaxTB(ultraTB.ListTB):
134 """Extension which holds some state: the last exception value"""
145 """Extension which holds some state: the last exception value"""
135
146
136 def __init__(self,color_scheme = 'NoColor'):
147 def __init__(self,color_scheme = 'NoColor'):
137 ultraTB.ListTB.__init__(self,color_scheme)
148 ultraTB.ListTB.__init__(self,color_scheme)
138 self.last_syntax_error = None
149 self.last_syntax_error = None
139
150
140 def __call__(self, etype, value, elist):
151 def __call__(self, etype, value, elist):
141 self.last_syntax_error = value
152 self.last_syntax_error = value
142 ultraTB.ListTB.__call__(self,etype,value,elist)
153 ultraTB.ListTB.__call__(self,etype,value,elist)
143
154
144 def clear_err_state(self):
155 def clear_err_state(self):
145 """Return the current error state and clear it"""
156 """Return the current error state and clear it"""
146 e = self.last_syntax_error
157 e = self.last_syntax_error
147 self.last_syntax_error = None
158 self.last_syntax_error = None
148 return e
159 return e
149
160
150 #****************************************************************************
161 #****************************************************************************
151 # Main IPython class
162 # Main IPython class
152
163
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
164 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
154 # until a full rewrite is made. I've cleaned all cross-class uses of
165 # until a full rewrite is made. I've cleaned all cross-class uses of
155 # attributes and methods, but too much user code out there relies on the
166 # attributes and methods, but too much user code out there relies on the
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
167 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
157 #
168 #
158 # But at least now, all the pieces have been separated and we could, in
169 # But at least now, all the pieces have been separated and we could, in
159 # principle, stop using the mixin. This will ease the transition to the
170 # principle, stop using the mixin. This will ease the transition to the
160 # chainsaw branch.
171 # chainsaw branch.
161
172
162 # For reference, the following is the list of 'self.foo' uses in the Magic
173 # For reference, the following is the list of 'self.foo' uses in the Magic
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
174 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
164 # class, to prevent clashes.
175 # class, to prevent clashes.
165
176
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
177 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
178 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
179 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
169 # 'self.value']
180 # 'self.value']
170
181
171 class InteractiveShell(object,Magic):
182 class InteractiveShell(object,Magic):
172 """An enhanced console for Python."""
183 """An enhanced console for Python."""
173
184
174 # class attribute to indicate whether the class supports threads or not.
185 # class attribute to indicate whether the class supports threads or not.
175 # Subclasses with thread support should override this as needed.
186 # Subclasses with thread support should override this as needed.
176 isthreaded = False
187 isthreaded = False
177
188
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
189 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
179 user_ns = None,user_global_ns=None,banner2='',
190 user_ns = None,user_global_ns=None,banner2='',
180 custom_exceptions=((),None),embedded=False):
191 custom_exceptions=((),None),embedded=False):
181
192
182 # some minimal strict typechecks. For some core data structures, I
193 # some minimal strict typechecks. For some core data structures, I
183 # want actual basic python types, not just anything that looks like
194 # want actual basic python types, not just anything that looks like
184 # one. This is especially true for namespaces.
195 # one. This is especially true for namespaces.
185 for ns in (user_ns,user_global_ns):
196 for ns in (user_ns,user_global_ns):
186 if ns is not None and type(ns) != types.DictType:
197 if ns is not None and type(ns) != types.DictType:
187 raise TypeError,'namespace must be a dictionary'
198 raise TypeError,'namespace must be a dictionary'
188
199
189 # Job manager (for jobs run as background threads)
200 # Job manager (for jobs run as background threads)
190 self.jobs = BackgroundJobManager()
201 self.jobs = BackgroundJobManager()
191
202
192 # track which builtins we add, so we can clean up later
203 # track which builtins we add, so we can clean up later
193 self.builtins_added = {}
204 self.builtins_added = {}
194 # This method will add the necessary builtins for operation, but
205 # This method will add the necessary builtins for operation, but
195 # tracking what it did via the builtins_added dict.
206 # tracking what it did via the builtins_added dict.
196 self.add_builtins()
207 self.add_builtins()
197
208
198 # Do the intuitively correct thing for quit/exit: we remove the
209 # Do the intuitively correct thing for quit/exit: we remove the
199 # builtins if they exist, and our own magics will deal with this
210 # builtins if they exist, and our own magics will deal with this
200 try:
211 try:
201 del __builtin__.exit, __builtin__.quit
212 del __builtin__.exit, __builtin__.quit
202 except AttributeError:
213 except AttributeError:
203 pass
214 pass
204
215
205 # Store the actual shell's name
216 # Store the actual shell's name
206 self.name = name
217 self.name = name
207
218
208 # We need to know whether the instance is meant for embedding, since
219 # We need to know whether the instance is meant for embedding, since
209 # global/local namespaces need to be handled differently in that case
220 # global/local namespaces need to be handled differently in that case
210 self.embedded = embedded
221 self.embedded = embedded
211
222
212 # command compiler
223 # command compiler
213 self.compile = codeop.CommandCompiler()
224 self.compile = codeop.CommandCompiler()
214
225
215 # User input buffer
226 # User input buffer
216 self.buffer = []
227 self.buffer = []
217
228
218 # Default name given in compilation of code
229 # Default name given in compilation of code
219 self.filename = '<ipython console>'
230 self.filename = '<ipython console>'
220
231
221 # Make an empty namespace, which extension writers can rely on both
232 # Make an empty namespace, which extension writers can rely on both
222 # existing and NEVER being used by ipython itself. This gives them a
233 # existing and NEVER being used by ipython itself. This gives them a
223 # convenient location for storing additional information and state
234 # convenient location for storing additional information and state
224 # their extensions may require, without fear of collisions with other
235 # their extensions may require, without fear of collisions with other
225 # ipython names that may develop later.
236 # ipython names that may develop later.
226 self.meta = Bunch()
237 self.meta = Bunch()
227
238
228 # Create the namespace where the user will operate. user_ns is
239 # Create the namespace where the user will operate. user_ns is
229 # normally the only one used, and it is passed to the exec calls as
240 # normally the only one used, and it is passed to the exec calls as
230 # the locals argument. But we do carry a user_global_ns namespace
241 # the locals argument. But we do carry a user_global_ns namespace
231 # given as the exec 'globals' argument, This is useful in embedding
242 # given as the exec 'globals' argument, This is useful in embedding
232 # situations where the ipython shell opens in a context where the
243 # situations where the ipython shell opens in a context where the
233 # distinction between locals and globals is meaningful.
244 # distinction between locals and globals is meaningful.
234
245
235 # FIXME. For some strange reason, __builtins__ is showing up at user
246 # FIXME. For some strange reason, __builtins__ is showing up at user
236 # level as a dict instead of a module. This is a manual fix, but I
247 # level as a dict instead of a module. This is a manual fix, but I
237 # should really track down where the problem is coming from. Alex
248 # should really track down where the problem is coming from. Alex
238 # Schmolck reported this problem first.
249 # Schmolck reported this problem first.
239
250
240 # A useful post by Alex Martelli on this topic:
251 # A useful post by Alex Martelli on this topic:
241 # Re: inconsistent value from __builtins__
252 # Re: inconsistent value from __builtins__
242 # Von: Alex Martelli <aleaxit@yahoo.com>
253 # Von: Alex Martelli <aleaxit@yahoo.com>
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
254 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
244 # Gruppen: comp.lang.python
255 # Gruppen: comp.lang.python
245
256
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
257 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
258 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
248 # > <type 'dict'>
259 # > <type 'dict'>
249 # > >>> print type(__builtins__)
260 # > >>> print type(__builtins__)
250 # > <type 'module'>
261 # > <type 'module'>
251 # > Is this difference in return value intentional?
262 # > Is this difference in return value intentional?
252
263
253 # Well, it's documented that '__builtins__' can be either a dictionary
264 # Well, it's documented that '__builtins__' can be either a dictionary
254 # or a module, and it's been that way for a long time. Whether it's
265 # or a module, and it's been that way for a long time. Whether it's
255 # intentional (or sensible), I don't know. In any case, the idea is
266 # intentional (or sensible), I don't know. In any case, the idea is
256 # that if you need to access the built-in namespace directly, you
267 # that if you need to access the built-in namespace directly, you
257 # should start with "import __builtin__" (note, no 's') which will
268 # should start with "import __builtin__" (note, no 's') which will
258 # definitely give you a module. Yeah, it's somewhat confusing:-(.
269 # definitely give you a module. Yeah, it's somewhat confusing:-(.
259
270
260 if user_ns is None:
271 if user_ns is None:
261 # Set __name__ to __main__ to better match the behavior of the
272 # Set __name__ to __main__ to better match the behavior of the
262 # normal interpreter.
273 # normal interpreter.
263 user_ns = {'__name__' :'__main__',
274 user_ns = {'__name__' :'__main__',
264 '__builtins__' : __builtin__,
275 '__builtins__' : __builtin__,
265 }
276 }
266
277
267 if user_global_ns is None:
278 if user_global_ns is None:
268 user_global_ns = {}
279 user_global_ns = {}
269
280
270 # Assign namespaces
281 # Assign namespaces
271 # This is the namespace where all normal user variables live
282 # This is the namespace where all normal user variables live
272 self.user_ns = user_ns
283 self.user_ns = user_ns
273 # Embedded instances require a separate namespace for globals.
284 # Embedded instances require a separate namespace for globals.
274 # Normally this one is unused by non-embedded instances.
285 # Normally this one is unused by non-embedded instances.
275 self.user_global_ns = user_global_ns
286 self.user_global_ns = user_global_ns
276 # A namespace to keep track of internal data structures to prevent
287 # A namespace to keep track of internal data structures to prevent
277 # them from cluttering user-visible stuff. Will be updated later
288 # them from cluttering user-visible stuff. Will be updated later
278 self.internal_ns = {}
289 self.internal_ns = {}
279
290
280 # Namespace of system aliases. Each entry in the alias
291 # Namespace of system aliases. Each entry in the alias
281 # table must be a 2-tuple of the form (N,name), where N is the number
292 # table must be a 2-tuple of the form (N,name), where N is the number
282 # of positional arguments of the alias.
293 # of positional arguments of the alias.
283 self.alias_table = {}
294 self.alias_table = {}
284
295
285 # A table holding all the namespaces IPython deals with, so that
296 # A table holding all the namespaces IPython deals with, so that
286 # introspection facilities can search easily.
297 # introspection facilities can search easily.
287 self.ns_table = {'user':user_ns,
298 self.ns_table = {'user':user_ns,
288 'user_global':user_global_ns,
299 'user_global':user_global_ns,
289 'alias':self.alias_table,
300 'alias':self.alias_table,
290 'internal':self.internal_ns,
301 'internal':self.internal_ns,
291 'builtin':__builtin__.__dict__
302 'builtin':__builtin__.__dict__
292 }
303 }
293
304
294 # The user namespace MUST have a pointer to the shell itself.
305 # The user namespace MUST have a pointer to the shell itself.
295 self.user_ns[name] = self
306 self.user_ns[name] = self
296
307
297 # We need to insert into sys.modules something that looks like a
308 # We need to insert into sys.modules something that looks like a
298 # module but which accesses the IPython namespace, for shelve and
309 # module but which accesses the IPython namespace, for shelve and
299 # pickle to work interactively. Normally they rely on getting
310 # pickle to work interactively. Normally they rely on getting
300 # everything out of __main__, but for embedding purposes each IPython
311 # everything out of __main__, but for embedding purposes each IPython
301 # instance has its own private namespace, so we can't go shoving
312 # instance has its own private namespace, so we can't go shoving
302 # everything into __main__.
313 # everything into __main__.
303
314
304 # note, however, that we should only do this for non-embedded
315 # note, however, that we should only do this for non-embedded
305 # ipythons, which really mimic the __main__.__dict__ with their own
316 # ipythons, which really mimic the __main__.__dict__ with their own
306 # namespace. Embedded instances, on the other hand, should not do
317 # namespace. Embedded instances, on the other hand, should not do
307 # this because they need to manage the user local/global namespaces
318 # this because they need to manage the user local/global namespaces
308 # only, but they live within a 'normal' __main__ (meaning, they
319 # only, but they live within a 'normal' __main__ (meaning, they
309 # shouldn't overtake the execution environment of the script they're
320 # shouldn't overtake the execution environment of the script they're
310 # embedded in).
321 # embedded in).
311
322
312 if not embedded:
323 if not embedded:
313 try:
324 try:
314 main_name = self.user_ns['__name__']
325 main_name = self.user_ns['__name__']
315 except KeyError:
326 except KeyError:
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
327 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
317 else:
328 else:
318 #print "pickle hack in place" # dbg
329 #print "pickle hack in place" # dbg
319 #print 'main_name:',main_name # dbg
330 #print 'main_name:',main_name # dbg
320 sys.modules[main_name] = FakeModule(self.user_ns)
331 sys.modules[main_name] = FakeModule(self.user_ns)
321
332
322 # List of input with multi-line handling.
333 # List of input with multi-line handling.
323 # Fill its zero entry, user counter starts at 1
334 # Fill its zero entry, user counter starts at 1
324 self.input_hist = InputList(['\n'])
335 self.input_hist = InputList(['\n'])
325
336
326 # list of visited directories
337 # list of visited directories
327 try:
338 try:
328 self.dir_hist = [os.getcwd()]
339 self.dir_hist = [os.getcwd()]
329 except IOError, e:
340 except IOError, e:
330 self.dir_hist = []
341 self.dir_hist = []
331
342
332 # dict of output history
343 # dict of output history
333 self.output_hist = {}
344 self.output_hist = {}
334
345
335 # dict of things NOT to alias (keywords, builtins and some magics)
346 # dict of things NOT to alias (keywords, builtins and some magics)
336 no_alias = {}
347 no_alias = {}
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
348 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
338 for key in keyword.kwlist + no_alias_magics:
349 for key in keyword.kwlist + no_alias_magics:
339 no_alias[key] = 1
350 no_alias[key] = 1
340 no_alias.update(__builtin__.__dict__)
351 no_alias.update(__builtin__.__dict__)
341 self.no_alias = no_alias
352 self.no_alias = no_alias
342
353
343 # make global variables for user access to these
354 # make global variables for user access to these
344 self.user_ns['_ih'] = self.input_hist
355 self.user_ns['_ih'] = self.input_hist
345 self.user_ns['_oh'] = self.output_hist
356 self.user_ns['_oh'] = self.output_hist
346 self.user_ns['_dh'] = self.dir_hist
357 self.user_ns['_dh'] = self.dir_hist
347
358
348 # user aliases to input and output histories
359 # user aliases to input and output histories
349 self.user_ns['In'] = self.input_hist
360 self.user_ns['In'] = self.input_hist
350 self.user_ns['Out'] = self.output_hist
361 self.user_ns['Out'] = self.output_hist
351
362
352 # Object variable to store code object waiting execution. This is
363 # Object variable to store code object waiting execution. This is
353 # used mainly by the multithreaded shells, but it can come in handy in
364 # used mainly by the multithreaded shells, but it can come in handy in
354 # other situations. No need to use a Queue here, since it's a single
365 # other situations. No need to use a Queue here, since it's a single
355 # item which gets cleared once run.
366 # item which gets cleared once run.
356 self.code_to_run = None
367 self.code_to_run = None
357
368
358 # escapes for automatic behavior on the command line
369 # escapes for automatic behavior on the command line
359 self.ESC_SHELL = '!'
370 self.ESC_SHELL = '!'
360 self.ESC_HELP = '?'
371 self.ESC_HELP = '?'
361 self.ESC_MAGIC = '%'
372 self.ESC_MAGIC = '%'
362 self.ESC_QUOTE = ','
373 self.ESC_QUOTE = ','
363 self.ESC_QUOTE2 = ';'
374 self.ESC_QUOTE2 = ';'
364 self.ESC_PAREN = '/'
375 self.ESC_PAREN = '/'
365
376
366 # And their associated handlers
377 # And their associated handlers
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
378 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
379 self.ESC_QUOTE : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
380 self.ESC_QUOTE2 : self.handle_auto,
370 self.ESC_MAGIC : self.handle_magic,
381 self.ESC_MAGIC : self.handle_magic,
371 self.ESC_HELP : self.handle_help,
382 self.ESC_HELP : self.handle_help,
372 self.ESC_SHELL : self.handle_shell_escape,
383 self.ESC_SHELL : self.handle_shell_escape,
373 }
384 }
374
385
375 # class initializations
386 # class initializations
376 Magic.__init__(self,self)
387 Magic.__init__(self,self)
377
388
378 # Python source parser/formatter for syntax highlighting
389 # Python source parser/formatter for syntax highlighting
379 pyformat = PyColorize.Parser().format
390 pyformat = PyColorize.Parser().format
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
391 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
381
392
382 # hooks holds pointers used for user-side customizations
393 # hooks holds pointers used for user-side customizations
383 self.hooks = Struct()
394 self.hooks = Struct()
384
395
385 # Set all default hooks, defined in the IPython.hooks module.
396 # Set all default hooks, defined in the IPython.hooks module.
386 hooks = IPython.hooks
397 hooks = IPython.hooks
387 for hook_name in hooks.__all__:
398 for hook_name in hooks.__all__:
388 self.set_hook(hook_name,getattr(hooks,hook_name))
399 self.set_hook(hook_name,getattr(hooks,hook_name))
389
400
390 # Flag to mark unconditional exit
401 # Flag to mark unconditional exit
391 self.exit_now = False
402 self.exit_now = False
392
403
393 self.usage_min = """\
404 self.usage_min = """\
394 An enhanced console for Python.
405 An enhanced console for Python.
395 Some of its features are:
406 Some of its features are:
396 - Readline support if the readline library is present.
407 - Readline support if the readline library is present.
397 - Tab completion in the local namespace.
408 - Tab completion in the local namespace.
398 - Logging of input, see command-line options.
409 - Logging of input, see command-line options.
399 - System shell escape via ! , eg !ls.
410 - System shell escape via ! , eg !ls.
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
411 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
401 - Keeps track of locally defined variables via %who, %whos.
412 - Keeps track of locally defined variables via %who, %whos.
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
413 - Show object information with a ? eg ?x or x? (use ?? for more info).
403 """
414 """
404 if usage: self.usage = usage
415 if usage: self.usage = usage
405 else: self.usage = self.usage_min
416 else: self.usage = self.usage_min
406
417
407 # Storage
418 # Storage
408 self.rc = rc # This will hold all configuration information
419 self.rc = rc # This will hold all configuration information
409 self.pager = 'less'
420 self.pager = 'less'
410 # temporary files used for various purposes. Deleted at exit.
421 # temporary files used for various purposes. Deleted at exit.
411 self.tempfiles = []
422 self.tempfiles = []
412
423
413 # Keep track of readline usage (later set by init_readline)
424 # Keep track of readline usage (later set by init_readline)
414 self.has_readline = False
425 self.has_readline = False
415
426
416 # template for logfile headers. It gets resolved at runtime by the
427 # template for logfile headers. It gets resolved at runtime by the
417 # logstart method.
428 # logstart method.
418 self.loghead_tpl = \
429 self.loghead_tpl = \
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
430 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
431 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
421 #log# opts = %s
432 #log# opts = %s
422 #log# args = %s
433 #log# args = %s
423 #log# It is safe to make manual edits below here.
434 #log# It is safe to make manual edits below here.
424 #log#-----------------------------------------------------------------------
435 #log#-----------------------------------------------------------------------
425 """
436 """
426 # for pushd/popd management
437 # for pushd/popd management
427 try:
438 try:
428 self.home_dir = get_home_dir()
439 self.home_dir = get_home_dir()
429 except HomeDirError,msg:
440 except HomeDirError,msg:
430 fatal(msg)
441 fatal(msg)
431
442
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
443 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
433
444
434 # Functions to call the underlying shell.
445 # Functions to call the underlying shell.
435
446
436 # utility to expand user variables via Itpl
447 # utility to expand user variables via Itpl
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
448 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
438 self.user_ns))
449 self.user_ns))
439 # The first is similar to os.system, but it doesn't return a value,
450 # The first is similar to os.system, but it doesn't return a value,
440 # and it allows interpolation of variables in the user's namespace.
451 # and it allows interpolation of variables in the user's namespace.
441 self.system = lambda cmd: shell(self.var_expand(cmd),
452 self.system = lambda cmd: shell(self.var_expand(cmd),
442 header='IPython system call: ',
453 header='IPython system call: ',
443 verbose=self.rc.system_verbose)
454 verbose=self.rc.system_verbose)
444 # These are for getoutput and getoutputerror:
455 # These are for getoutput and getoutputerror:
445 self.getoutput = lambda cmd: \
456 self.getoutput = lambda cmd: \
446 getoutput(self.var_expand(cmd),
457 getoutput(self.var_expand(cmd),
447 header='IPython system call: ',
458 header='IPython system call: ',
448 verbose=self.rc.system_verbose)
459 verbose=self.rc.system_verbose)
449 self.getoutputerror = lambda cmd: \
460 self.getoutputerror = lambda cmd: \
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
461 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
451 self.user_ns)),
462 self.user_ns)),
452 header='IPython system call: ',
463 header='IPython system call: ',
453 verbose=self.rc.system_verbose)
464 verbose=self.rc.system_verbose)
454
465
455 # RegExp for splitting line contents into pre-char//first
466 # RegExp for splitting line contents into pre-char//first
456 # word-method//rest. For clarity, each group in on one line.
467 # word-method//rest. For clarity, each group in on one line.
457
468
458 # WARNING: update the regexp if the above escapes are changed, as they
469 # WARNING: update the regexp if the above escapes are changed, as they
459 # are hardwired in.
470 # are hardwired in.
460
471
461 # Don't get carried away with trying to make the autocalling catch too
472 # Don't get carried away with trying to make the autocalling catch too
462 # much: it's better to be conservative rather than to trigger hidden
473 # much: it's better to be conservative rather than to trigger hidden
463 # evals() somewhere and end up causing side effects.
474 # evals() somewhere and end up causing side effects.
464
475
465 self.line_split = re.compile(r'^([\s*,;/])'
476 self.line_split = re.compile(r'^([\s*,;/])'
466 r'([\?\w\.]+\w*\s*)'
477 r'([\?\w\.]+\w*\s*)'
467 r'(\(?.*$)')
478 r'(\(?.*$)')
468
479
469 # Original re, keep around for a while in case changes break something
480 # Original re, keep around for a while in case changes break something
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
481 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
482 # r'(\s*[\?\w\.]+\w*\s*)'
472 # r'(\(?.*$)')
483 # r'(\(?.*$)')
473
484
474 # RegExp to identify potential function names
485 # RegExp to identify potential function names
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
486 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
476 # RegExp to exclude strings with this start from autocalling
487
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
488 # RegExp to exclude strings with this start from autocalling. In
489 # particular, all binary operators should be excluded, so that if foo
490 # is callable, foo OP bar doesn't become foo(OP bar), which is
491 # invalid. The characters '!=()' don't need to be checked for, as the
492 # _prefilter routine explicitely does so, to catch direct calls and
493 # rebindings of existing names.
494
495 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
496 # it affects the rest of the group in square brackets.
497 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
498 '|^is |^not |^in |^and |^or ')
478
499
479 # try to catch also methods for stuff in lists/tuples/dicts: off
500 # try to catch also methods for stuff in lists/tuples/dicts: off
480 # (experimental). For this to work, the line_split regexp would need
501 # (experimental). For this to work, the line_split regexp would need
481 # to be modified so it wouldn't break things at '['. That line is
502 # to be modified so it wouldn't break things at '['. That line is
482 # nasty enough that I shouldn't change it until I can test it _well_.
503 # nasty enough that I shouldn't change it until I can test it _well_.
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
504 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
484
505
485 # keep track of where we started running (mainly for crash post-mortem)
506 # keep track of where we started running (mainly for crash post-mortem)
486 self.starting_dir = os.getcwd()
507 self.starting_dir = os.getcwd()
487
508
488 # Various switches which can be set
509 # Various switches which can be set
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
510 self.CACHELENGTH = 5000 # this is cheap, it's just text
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
511 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
491 self.banner2 = banner2
512 self.banner2 = banner2
492
513
493 # TraceBack handlers:
514 # TraceBack handlers:
494
515
495 # Syntax error handler.
516 # Syntax error handler.
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
517 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
497
518
498 # The interactive one is initialized with an offset, meaning we always
519 # The interactive one is initialized with an offset, meaning we always
499 # want to remove the topmost item in the traceback, which is our own
520 # want to remove the topmost item in the traceback, which is our own
500 # internal code. Valid modes: ['Plain','Context','Verbose']
521 # internal code. Valid modes: ['Plain','Context','Verbose']
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
522 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
502 color_scheme='NoColor',
523 color_scheme='NoColor',
503 tb_offset = 1)
524 tb_offset = 1)
504
525
505 # IPython itself shouldn't crash. This will produce a detailed
526 # IPython itself shouldn't crash. This will produce a detailed
506 # post-mortem if it does. But we only install the crash handler for
527 # post-mortem if it does. But we only install the crash handler for
507 # non-threaded shells, the threaded ones use a normal verbose reporter
528 # non-threaded shells, the threaded ones use a normal verbose reporter
508 # and lose the crash handler. This is because exceptions in the main
529 # and lose the crash handler. This is because exceptions in the main
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
530 # thread (such as in GUI code) propagate directly to sys.excepthook,
510 # and there's no point in printing crash dumps for every user exception.
531 # and there's no point in printing crash dumps for every user exception.
511 if self.isthreaded:
532 if self.isthreaded:
512 sys.excepthook = ultraTB.FormattedTB()
533 sys.excepthook = ultraTB.FormattedTB()
513 else:
534 else:
514 from IPython import CrashHandler
535 from IPython import CrashHandler
515 sys.excepthook = CrashHandler.CrashHandler(self)
536 sys.excepthook = CrashHandler.CrashHandler(self)
516
537
517 # The instance will store a pointer to this, so that runtime code
538 # The instance will store a pointer to this, so that runtime code
518 # (such as magics) can access it. This is because during the
539 # (such as magics) can access it. This is because during the
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
540 # read-eval loop, it gets temporarily overwritten (to deal with GUI
520 # frameworks).
541 # frameworks).
521 self.sys_excepthook = sys.excepthook
542 self.sys_excepthook = sys.excepthook
522
543
523 # and add any custom exception handlers the user may have specified
544 # and add any custom exception handlers the user may have specified
524 self.set_custom_exc(*custom_exceptions)
545 self.set_custom_exc(*custom_exceptions)
525
546
526 # Object inspector
547 # Object inspector
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
548 self.inspector = OInspect.Inspector(OInspect.InspectColors,
528 PyColorize.ANSICodeColors,
549 PyColorize.ANSICodeColors,
529 'NoColor')
550 'NoColor')
530 # indentation management
551 # indentation management
531 self.autoindent = False
552 self.autoindent = False
532 self.indent_current_nsp = 0
553 self.indent_current_nsp = 0
533 self.indent_current = '' # actual indent string
554 self.indent_current = '' # actual indent string
534
555
535 # Make some aliases automatically
556 # Make some aliases automatically
536 # Prepare list of shell aliases to auto-define
557 # Prepare list of shell aliases to auto-define
537 if os.name == 'posix':
558 if os.name == 'posix':
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
559 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
539 'mv mv -i','rm rm -i','cp cp -i',
560 'mv mv -i','rm rm -i','cp cp -i',
540 'cat cat','less less','clear clear',
561 'cat cat','less less','clear clear',
541 # a better ls
562 # a better ls
542 'ls ls -F',
563 'ls ls -F',
543 # long ls
564 # long ls
544 'll ls -lF',
565 'll ls -lF',
545 # color ls
566 # color ls
546 'lc ls -F -o --color',
567 'lc ls -F -o --color',
547 # ls normal files only
568 # ls normal files only
548 'lf ls -F -o --color %l | grep ^-',
569 'lf ls -F -o --color %l | grep ^-',
549 # ls symbolic links
570 # ls symbolic links
550 'lk ls -F -o --color %l | grep ^l',
571 'lk ls -F -o --color %l | grep ^l',
551 # directories or links to directories,
572 # directories or links to directories,
552 'ldir ls -F -o --color %l | grep /$',
573 'ldir ls -F -o --color %l | grep /$',
553 # things which are executable
574 # things which are executable
554 'lx ls -F -o --color %l | grep ^-..x',
575 'lx ls -F -o --color %l | grep ^-..x',
555 )
576 )
556 elif os.name in ['nt','dos']:
577 elif os.name in ['nt','dos']:
557 auto_alias = ('dir dir /on', 'ls dir /on',
578 auto_alias = ('dir dir /on', 'ls dir /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
579 'ddir dir /ad /on', 'ldir dir /ad /on',
559 'mkdir mkdir','rmdir rmdir','echo echo',
580 'mkdir mkdir','rmdir rmdir','echo echo',
560 'ren ren','cls cls','copy copy')
581 'ren ren','cls cls','copy copy')
561 else:
582 else:
562 auto_alias = ()
583 auto_alias = ()
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
584 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
564 # Call the actual (public) initializer
585 # Call the actual (public) initializer
565 self.init_auto_alias()
586 self.init_auto_alias()
566 # end __init__
587 # end __init__
567
588
568 def post_config_initialization(self):
589 def post_config_initialization(self):
569 """Post configuration init method
590 """Post configuration init method
570
591
571 This is called after the configuration files have been processed to
592 This is called after the configuration files have been processed to
572 'finalize' the initialization."""
593 'finalize' the initialization."""
573
594
574 rc = self.rc
595 rc = self.rc
575
596
576 # Load readline proper
597 # Load readline proper
577 if rc.readline:
598 if rc.readline:
578 self.init_readline()
599 self.init_readline()
579
600
580 # log system
601 # log system
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
602 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
582 # local shortcut, this is used a LOT
603 # local shortcut, this is used a LOT
583 self.log = self.logger.log
604 self.log = self.logger.log
584
605
585 # Initialize cache, set in/out prompts and printing system
606 # Initialize cache, set in/out prompts and printing system
586 self.outputcache = CachedOutput(self,
607 self.outputcache = CachedOutput(self,
587 rc.cache_size,
608 rc.cache_size,
588 rc.pprint,
609 rc.pprint,
589 input_sep = rc.separate_in,
610 input_sep = rc.separate_in,
590 output_sep = rc.separate_out,
611 output_sep = rc.separate_out,
591 output_sep2 = rc.separate_out2,
612 output_sep2 = rc.separate_out2,
592 ps1 = rc.prompt_in1,
613 ps1 = rc.prompt_in1,
593 ps2 = rc.prompt_in2,
614 ps2 = rc.prompt_in2,
594 ps_out = rc.prompt_out,
615 ps_out = rc.prompt_out,
595 pad_left = rc.prompts_pad_left)
616 pad_left = rc.prompts_pad_left)
596
617
597 # user may have over-ridden the default print hook:
618 # user may have over-ridden the default print hook:
598 try:
619 try:
599 self.outputcache.__class__.display = self.hooks.display
620 self.outputcache.__class__.display = self.hooks.display
600 except AttributeError:
621 except AttributeError:
601 pass
622 pass
602
623
603 # I don't like assigning globally to sys, because it means when embedding
624 # I don't like assigning globally to sys, because it means when embedding
604 # instances, each embedded instance overrides the previous choice. But
625 # instances, each embedded instance overrides the previous choice. But
605 # sys.displayhook seems to be called internally by exec, so I don't see a
626 # sys.displayhook seems to be called internally by exec, so I don't see a
606 # way around it.
627 # way around it.
607 sys.displayhook = self.outputcache
628 sys.displayhook = self.outputcache
608
629
609 # Set user colors (don't do it in the constructor above so that it
630 # Set user colors (don't do it in the constructor above so that it
610 # doesn't crash if colors option is invalid)
631 # doesn't crash if colors option is invalid)
611 self.magic_colors(rc.colors)
632 self.magic_colors(rc.colors)
612
633
613 # Set calling of pdb on exceptions
634 # Set calling of pdb on exceptions
614 self.call_pdb = rc.pdb
635 self.call_pdb = rc.pdb
615
636
616 # Load user aliases
637 # Load user aliases
617 for alias in rc.alias:
638 for alias in rc.alias:
618 self.magic_alias(alias)
639 self.magic_alias(alias)
619
640
620 # dynamic data that survives through sessions
641 # dynamic data that survives through sessions
621 # XXX make the filename a config option?
642 # XXX make the filename a config option?
622 persist_base = 'persist'
643 persist_base = 'persist'
623 if rc.profile:
644 if rc.profile:
624 persist_base += '_%s' % rc.profile
645 persist_base += '_%s' % rc.profile
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
646 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
626
647
627 try:
648 try:
628 self.persist = pickle.load(file(self.persist_fname))
649 self.persist = pickle.load(file(self.persist_fname))
629 except:
650 except:
630 self.persist = {}
651 self.persist = {}
631
652
632
653
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
654 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
634 try:
655 try:
635 obj = pickle.loads(value)
656 obj = pickle.loads(value)
636 except:
657 except:
637
658
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
659 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
639 print "The error was:",sys.exc_info()[0]
660 print "The error was:",sys.exc_info()[0]
640 continue
661 continue
641
662
642
663
643 self.user_ns[key] = obj
664 self.user_ns[key] = obj
644
665
645 def add_builtins(self):
666 def add_builtins(self):
646 """Store ipython references into the builtin namespace.
667 """Store ipython references into the builtin namespace.
647
668
648 Some parts of ipython operate via builtins injected here, which hold a
669 Some parts of ipython operate via builtins injected here, which hold a
649 reference to IPython itself."""
670 reference to IPython itself."""
650
671
651 builtins_new = dict(__IPYTHON__ = self,
672 builtins_new = dict(__IPYTHON__ = self,
652 ip_set_hook = self.set_hook,
673 ip_set_hook = self.set_hook,
653 jobs = self.jobs,
674 jobs = self.jobs,
654 ipmagic = self.ipmagic,
675 ipmagic = self.ipmagic,
655 ipalias = self.ipalias,
676 ipalias = self.ipalias,
656 ipsystem = self.ipsystem,
677 ipsystem = self.ipsystem,
657 )
678 )
658 for biname,bival in builtins_new.items():
679 for biname,bival in builtins_new.items():
659 try:
680 try:
660 # store the orignal value so we can restore it
681 # store the orignal value so we can restore it
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
682 self.builtins_added[biname] = __builtin__.__dict__[biname]
662 except KeyError:
683 except KeyError:
663 # or mark that it wasn't defined, and we'll just delete it at
684 # or mark that it wasn't defined, and we'll just delete it at
664 # cleanup
685 # cleanup
665 self.builtins_added[biname] = Undefined
686 self.builtins_added[biname] = Undefined
666 __builtin__.__dict__[biname] = bival
687 __builtin__.__dict__[biname] = bival
667
688
668 # Keep in the builtins a flag for when IPython is active. We set it
689 # Keep in the builtins a flag for when IPython is active. We set it
669 # with setdefault so that multiple nested IPythons don't clobber one
690 # with setdefault so that multiple nested IPythons don't clobber one
670 # another. Each will increase its value by one upon being activated,
691 # another. Each will increase its value by one upon being activated,
671 # which also gives us a way to determine the nesting level.
692 # which also gives us a way to determine the nesting level.
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
693 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
673
694
674 def clean_builtins(self):
695 def clean_builtins(self):
675 """Remove any builtins which might have been added by add_builtins, or
696 """Remove any builtins which might have been added by add_builtins, or
676 restore overwritten ones to their previous values."""
697 restore overwritten ones to their previous values."""
677 for biname,bival in self.builtins_added.items():
698 for biname,bival in self.builtins_added.items():
678 if bival is Undefined:
699 if bival is Undefined:
679 del __builtin__.__dict__[biname]
700 del __builtin__.__dict__[biname]
680 else:
701 else:
681 __builtin__.__dict__[biname] = bival
702 __builtin__.__dict__[biname] = bival
682 self.builtins_added.clear()
703 self.builtins_added.clear()
683
704
684 def set_hook(self,name,hook):
705 def set_hook(self,name,hook):
685 """set_hook(name,hook) -> sets an internal IPython hook.
706 """set_hook(name,hook) -> sets an internal IPython hook.
686
707
687 IPython exposes some of its internal API as user-modifiable hooks. By
708 IPython exposes some of its internal API as user-modifiable hooks. By
688 resetting one of these hooks, you can modify IPython's behavior to
709 resetting one of these hooks, you can modify IPython's behavior to
689 call at runtime your own routines."""
710 call at runtime your own routines."""
690
711
691 # At some point in the future, this should validate the hook before it
712 # At some point in the future, this should validate the hook before it
692 # accepts it. Probably at least check that the hook takes the number
713 # accepts it. Probably at least check that the hook takes the number
693 # of args it's supposed to.
714 # of args it's supposed to.
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
715 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
695
716
696 def set_custom_exc(self,exc_tuple,handler):
717 def set_custom_exc(self,exc_tuple,handler):
697 """set_custom_exc(exc_tuple,handler)
718 """set_custom_exc(exc_tuple,handler)
698
719
699 Set a custom exception handler, which will be called if any of the
720 Set a custom exception handler, which will be called if any of the
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
721 exceptions in exc_tuple occur in the mainloop (specifically, in the
701 runcode() method.
722 runcode() method.
702
723
703 Inputs:
724 Inputs:
704
725
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
726 - exc_tuple: a *tuple* of valid exceptions to call the defined
706 handler for. It is very important that you use a tuple, and NOT A
727 handler for. It is very important that you use a tuple, and NOT A
707 LIST here, because of the way Python's except statement works. If
728 LIST here, because of the way Python's except statement works. If
708 you only want to trap a single exception, use a singleton tuple:
729 you only want to trap a single exception, use a singleton tuple:
709
730
710 exc_tuple == (MyCustomException,)
731 exc_tuple == (MyCustomException,)
711
732
712 - handler: this must be defined as a function with the following
733 - handler: this must be defined as a function with the following
713 basic interface: def my_handler(self,etype,value,tb).
734 basic interface: def my_handler(self,etype,value,tb).
714
735
715 This will be made into an instance method (via new.instancemethod)
736 This will be made into an instance method (via new.instancemethod)
716 of IPython itself, and it will be called if any of the exceptions
737 of IPython itself, and it will be called if any of the exceptions
717 listed in the exc_tuple are caught. If the handler is None, an
738 listed in the exc_tuple are caught. If the handler is None, an
718 internal basic one is used, which just prints basic info.
739 internal basic one is used, which just prints basic info.
719
740
720 WARNING: by putting in your own exception handler into IPython's main
741 WARNING: by putting in your own exception handler into IPython's main
721 execution loop, you run a very good chance of nasty crashes. This
742 execution loop, you run a very good chance of nasty crashes. This
722 facility should only be used if you really know what you are doing."""
743 facility should only be used if you really know what you are doing."""
723
744
724 assert type(exc_tuple)==type(()) , \
745 assert type(exc_tuple)==type(()) , \
725 "The custom exceptions must be given AS A TUPLE."
746 "The custom exceptions must be given AS A TUPLE."
726
747
727 def dummy_handler(self,etype,value,tb):
748 def dummy_handler(self,etype,value,tb):
728 print '*** Simple custom exception handler ***'
749 print '*** Simple custom exception handler ***'
729 print 'Exception type :',etype
750 print 'Exception type :',etype
730 print 'Exception value:',value
751 print 'Exception value:',value
731 print 'Traceback :',tb
752 print 'Traceback :',tb
732 print 'Source code :','\n'.join(self.buffer)
753 print 'Source code :','\n'.join(self.buffer)
733
754
734 if handler is None: handler = dummy_handler
755 if handler is None: handler = dummy_handler
735
756
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
757 self.CustomTB = new.instancemethod(handler,self,self.__class__)
737 self.custom_exceptions = exc_tuple
758 self.custom_exceptions = exc_tuple
738
759
739 def set_custom_completer(self,completer,pos=0):
760 def set_custom_completer(self,completer,pos=0):
740 """set_custom_completer(completer,pos=0)
761 """set_custom_completer(completer,pos=0)
741
762
742 Adds a new custom completer function.
763 Adds a new custom completer function.
743
764
744 The position argument (defaults to 0) is the index in the completers
765 The position argument (defaults to 0) is the index in the completers
745 list where you want the completer to be inserted."""
766 list where you want the completer to be inserted."""
746
767
747 newcomp = new.instancemethod(completer,self.Completer,
768 newcomp = new.instancemethod(completer,self.Completer,
748 self.Completer.__class__)
769 self.Completer.__class__)
749 self.Completer.matchers.insert(pos,newcomp)
770 self.Completer.matchers.insert(pos,newcomp)
750
771
751 def _get_call_pdb(self):
772 def _get_call_pdb(self):
752 return self._call_pdb
773 return self._call_pdb
753
774
754 def _set_call_pdb(self,val):
775 def _set_call_pdb(self,val):
755
776
756 if val not in (0,1,False,True):
777 if val not in (0,1,False,True):
757 raise ValueError,'new call_pdb value must be boolean'
778 raise ValueError,'new call_pdb value must be boolean'
758
779
759 # store value in instance
780 # store value in instance
760 self._call_pdb = val
781 self._call_pdb = val
761
782
762 # notify the actual exception handlers
783 # notify the actual exception handlers
763 self.InteractiveTB.call_pdb = val
784 self.InteractiveTB.call_pdb = val
764 if self.isthreaded:
785 if self.isthreaded:
765 try:
786 try:
766 self.sys_excepthook.call_pdb = val
787 self.sys_excepthook.call_pdb = val
767 except:
788 except:
768 warn('Failed to activate pdb for threaded exception handler')
789 warn('Failed to activate pdb for threaded exception handler')
769
790
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
791 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
771 'Control auto-activation of pdb at exceptions')
792 'Control auto-activation of pdb at exceptions')
772
793
773
794
774 # These special functions get installed in the builtin namespace, to
795 # These special functions get installed in the builtin namespace, to
775 # provide programmatic (pure python) access to magics, aliases and system
796 # provide programmatic (pure python) access to magics, aliases and system
776 # calls. This is important for logging, user scripting, and more.
797 # calls. This is important for logging, user scripting, and more.
777
798
778 # We are basically exposing, via normal python functions, the three
799 # We are basically exposing, via normal python functions, the three
779 # mechanisms in which ipython offers special call modes (magics for
800 # mechanisms in which ipython offers special call modes (magics for
780 # internal control, aliases for direct system access via pre-selected
801 # internal control, aliases for direct system access via pre-selected
781 # names, and !cmd for calling arbitrary system commands).
802 # names, and !cmd for calling arbitrary system commands).
782
803
783 def ipmagic(self,arg_s):
804 def ipmagic(self,arg_s):
784 """Call a magic function by name.
805 """Call a magic function by name.
785
806
786 Input: a string containing the name of the magic function to call and any
807 Input: a string containing the name of the magic function to call and any
787 additional arguments to be passed to the magic.
808 additional arguments to be passed to the magic.
788
809
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
810 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
790 prompt:
811 prompt:
791
812
792 In[1]: %name -opt foo bar
813 In[1]: %name -opt foo bar
793
814
794 To call a magic without arguments, simply use ipmagic('name').
815 To call a magic without arguments, simply use ipmagic('name').
795
816
796 This provides a proper Python function to call IPython's magics in any
817 This provides a proper Python function to call IPython's magics in any
797 valid Python code you can type at the interpreter, including loops and
818 valid Python code you can type at the interpreter, including loops and
798 compound statements. It is added by IPython to the Python builtin
819 compound statements. It is added by IPython to the Python builtin
799 namespace upon initialization."""
820 namespace upon initialization."""
800
821
801 args = arg_s.split(' ',1)
822 args = arg_s.split(' ',1)
802 magic_name = args[0]
823 magic_name = args[0]
803 if magic_name.startswith(self.ESC_MAGIC):
824 if magic_name.startswith(self.ESC_MAGIC):
804 magic_name = magic_name[1:]
825 magic_name = magic_name[1:]
805 try:
826 try:
806 magic_args = args[1]
827 magic_args = args[1]
807 except IndexError:
828 except IndexError:
808 magic_args = ''
829 magic_args = ''
809 fn = getattr(self,'magic_'+magic_name,None)
830 fn = getattr(self,'magic_'+magic_name,None)
810 if fn is None:
831 if fn is None:
811 error("Magic function `%s` not found." % magic_name)
832 error("Magic function `%s` not found." % magic_name)
812 else:
833 else:
813 magic_args = self.var_expand(magic_args)
834 magic_args = self.var_expand(magic_args)
814 return fn(magic_args)
835 return fn(magic_args)
815
836
816 def ipalias(self,arg_s):
837 def ipalias(self,arg_s):
817 """Call an alias by name.
838 """Call an alias by name.
818
839
819 Input: a string containing the name of the alias to call and any
840 Input: a string containing the name of the alias to call and any
820 additional arguments to be passed to the magic.
841 additional arguments to be passed to the magic.
821
842
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
843 ipalias('name -opt foo bar') is equivalent to typing at the ipython
823 prompt:
844 prompt:
824
845
825 In[1]: name -opt foo bar
846 In[1]: name -opt foo bar
826
847
827 To call an alias without arguments, simply use ipalias('name').
848 To call an alias without arguments, simply use ipalias('name').
828
849
829 This provides a proper Python function to call IPython's aliases in any
850 This provides a proper Python function to call IPython's aliases in any
830 valid Python code you can type at the interpreter, including loops and
851 valid Python code you can type at the interpreter, including loops and
831 compound statements. It is added by IPython to the Python builtin
852 compound statements. It is added by IPython to the Python builtin
832 namespace upon initialization."""
853 namespace upon initialization."""
833
854
834 args = arg_s.split(' ',1)
855 args = arg_s.split(' ',1)
835 alias_name = args[0]
856 alias_name = args[0]
836 try:
857 try:
837 alias_args = args[1]
858 alias_args = args[1]
838 except IndexError:
859 except IndexError:
839 alias_args = ''
860 alias_args = ''
840 if alias_name in self.alias_table:
861 if alias_name in self.alias_table:
841 self.call_alias(alias_name,alias_args)
862 self.call_alias(alias_name,alias_args)
842 else:
863 else:
843 error("Alias `%s` not found." % alias_name)
864 error("Alias `%s` not found." % alias_name)
844
865
845 def ipsystem(self,arg_s):
866 def ipsystem(self,arg_s):
846 """Make a system call, using IPython."""
867 """Make a system call, using IPython."""
847
868
848 self.system(arg_s)
869 self.system(arg_s)
849
870
850 def complete(self,text):
871 def complete(self,text):
851 """Return a sorted list of all possible completions on text.
872 """Return a sorted list of all possible completions on text.
852
873
853 Inputs:
874 Inputs:
854
875
855 - text: a string of text to be completed on.
876 - text: a string of text to be completed on.
856
877
857 This is a wrapper around the completion mechanism, similar to what
878 This is a wrapper around the completion mechanism, similar to what
858 readline does at the command line when the TAB key is hit. By
879 readline does at the command line when the TAB key is hit. By
859 exposing it as a method, it can be used by other non-readline
880 exposing it as a method, it can be used by other non-readline
860 environments (such as GUIs) for text completion.
881 environments (such as GUIs) for text completion.
861
882
862 Simple usage example:
883 Simple usage example:
863
884
864 In [1]: x = 'hello'
885 In [1]: x = 'hello'
865
886
866 In [2]: __IP.complete('x.l')
887 In [2]: __IP.complete('x.l')
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
888 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
868
889
869 complete = self.Completer.complete
890 complete = self.Completer.complete
870 state = 0
891 state = 0
871 # use a dict so we get unique keys, since ipyhton's multiple
892 # use a dict so we get unique keys, since ipyhton's multiple
872 # completers can return duplicates.
893 # completers can return duplicates.
873 comps = {}
894 comps = {}
874 while True:
895 while True:
875 newcomp = complete(text,state)
896 newcomp = complete(text,state)
876 if newcomp is None:
897 if newcomp is None:
877 break
898 break
878 comps[newcomp] = 1
899 comps[newcomp] = 1
879 state += 1
900 state += 1
880 outcomps = comps.keys()
901 outcomps = comps.keys()
881 outcomps.sort()
902 outcomps.sort()
882 return outcomps
903 return outcomps
883
904
884 def set_completer_frame(self, frame=None):
905 def set_completer_frame(self, frame=None):
885 if frame:
906 if frame:
886 self.Completer.namespace = frame.f_locals
907 self.Completer.namespace = frame.f_locals
887 self.Completer.global_namespace = frame.f_globals
908 self.Completer.global_namespace = frame.f_globals
888 else:
909 else:
889 self.Completer.namespace = self.user_ns
910 self.Completer.namespace = self.user_ns
890 self.Completer.global_namespace = self.user_global_ns
911 self.Completer.global_namespace = self.user_global_ns
891
912
892 def init_auto_alias(self):
913 def init_auto_alias(self):
893 """Define some aliases automatically.
914 """Define some aliases automatically.
894
915
895 These are ALL parameter-less aliases"""
916 These are ALL parameter-less aliases"""
896
917
897 for alias,cmd in self.auto_alias:
918 for alias,cmd in self.auto_alias:
898 self.alias_table[alias] = (0,cmd)
919 self.alias_table[alias] = (0,cmd)
899
920
900 def alias_table_validate(self,verbose=0):
921 def alias_table_validate(self,verbose=0):
901 """Update information about the alias table.
922 """Update information about the alias table.
902
923
903 In particular, make sure no Python keywords/builtins are in it."""
924 In particular, make sure no Python keywords/builtins are in it."""
904
925
905 no_alias = self.no_alias
926 no_alias = self.no_alias
906 for k in self.alias_table.keys():
927 for k in self.alias_table.keys():
907 if k in no_alias:
928 if k in no_alias:
908 del self.alias_table[k]
929 del self.alias_table[k]
909 if verbose:
930 if verbose:
910 print ("Deleting alias <%s>, it's a Python "
931 print ("Deleting alias <%s>, it's a Python "
911 "keyword or builtin." % k)
932 "keyword or builtin." % k)
912
933
913 def set_autoindent(self,value=None):
934 def set_autoindent(self,value=None):
914 """Set the autoindent flag, checking for readline support.
935 """Set the autoindent flag, checking for readline support.
915
936
916 If called with no arguments, it acts as a toggle."""
937 If called with no arguments, it acts as a toggle."""
917
938
918 if not self.has_readline:
939 if not self.has_readline:
919 if os.name == 'posix':
940 if os.name == 'posix':
920 warn("The auto-indent feature requires the readline library")
941 warn("The auto-indent feature requires the readline library")
921 self.autoindent = 0
942 self.autoindent = 0
922 return
943 return
923 if value is None:
944 if value is None:
924 self.autoindent = not self.autoindent
945 self.autoindent = not self.autoindent
925 else:
946 else:
926 self.autoindent = value
947 self.autoindent = value
927
948
928 def rc_set_toggle(self,rc_field,value=None):
949 def rc_set_toggle(self,rc_field,value=None):
929 """Set or toggle a field in IPython's rc config. structure.
950 """Set or toggle a field in IPython's rc config. structure.
930
951
931 If called with no arguments, it acts as a toggle.
952 If called with no arguments, it acts as a toggle.
932
953
933 If called with a non-existent field, the resulting AttributeError
954 If called with a non-existent field, the resulting AttributeError
934 exception will propagate out."""
955 exception will propagate out."""
935
956
936 rc_val = getattr(self.rc,rc_field)
957 rc_val = getattr(self.rc,rc_field)
937 if value is None:
958 if value is None:
938 value = not rc_val
959 value = not rc_val
939 setattr(self.rc,rc_field,value)
960 setattr(self.rc,rc_field,value)
940
961
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
962 def user_setup(self,ipythondir,rc_suffix,mode='install'):
942 """Install the user configuration directory.
963 """Install the user configuration directory.
943
964
944 Can be called when running for the first time or to upgrade the user's
965 Can be called when running for the first time or to upgrade the user's
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
966 .ipython/ directory with the mode parameter. Valid modes are 'install'
946 and 'upgrade'."""
967 and 'upgrade'."""
947
968
948 def wait():
969 def wait():
949 try:
970 try:
950 raw_input("Please press <RETURN> to start IPython.")
971 raw_input("Please press <RETURN> to start IPython.")
951 except EOFError:
972 except EOFError:
952 print >> Term.cout
973 print >> Term.cout
953 print '*'*70
974 print '*'*70
954
975
955 cwd = os.getcwd() # remember where we started
976 cwd = os.getcwd() # remember where we started
956 glb = glob.glob
977 glb = glob.glob
957 print '*'*70
978 print '*'*70
958 if mode == 'install':
979 if mode == 'install':
959 print \
980 print \
960 """Welcome to IPython. I will try to create a personal configuration directory
981 """Welcome to IPython. I will try to create a personal configuration directory
961 where you can customize many aspects of IPython's functionality in:\n"""
982 where you can customize many aspects of IPython's functionality in:\n"""
962 else:
983 else:
963 print 'I am going to upgrade your configuration in:'
984 print 'I am going to upgrade your configuration in:'
964
985
965 print ipythondir
986 print ipythondir
966
987
967 rcdirend = os.path.join('IPython','UserConfig')
988 rcdirend = os.path.join('IPython','UserConfig')
968 cfg = lambda d: os.path.join(d,rcdirend)
989 cfg = lambda d: os.path.join(d,rcdirend)
969 try:
990 try:
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
991 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
971 except IOError:
992 except IOError:
972 warning = """
993 warning = """
973 Installation error. IPython's directory was not found.
994 Installation error. IPython's directory was not found.
974
995
975 Check the following:
996 Check the following:
976
997
977 The ipython/IPython directory should be in a directory belonging to your
998 The ipython/IPython directory should be in a directory belonging to your
978 PYTHONPATH environment variable (that is, it should be in a directory
999 PYTHONPATH environment variable (that is, it should be in a directory
979 belonging to sys.path). You can copy it explicitly there or just link to it.
1000 belonging to sys.path). You can copy it explicitly there or just link to it.
980
1001
981 IPython will proceed with builtin defaults.
1002 IPython will proceed with builtin defaults.
982 """
1003 """
983 warn(warning)
1004 warn(warning)
984 wait()
1005 wait()
985 return
1006 return
986
1007
987 if mode == 'install':
1008 if mode == 'install':
988 try:
1009 try:
989 shutil.copytree(rcdir,ipythondir)
1010 shutil.copytree(rcdir,ipythondir)
990 os.chdir(ipythondir)
1011 os.chdir(ipythondir)
991 rc_files = glb("ipythonrc*")
1012 rc_files = glb("ipythonrc*")
992 for rc_file in rc_files:
1013 for rc_file in rc_files:
993 os.rename(rc_file,rc_file+rc_suffix)
1014 os.rename(rc_file,rc_file+rc_suffix)
994 except:
1015 except:
995 warning = """
1016 warning = """
996
1017
997 There was a problem with the installation:
1018 There was a problem with the installation:
998 %s
1019 %s
999 Try to correct it or contact the developers if you think it's a bug.
1020 Try to correct it or contact the developers if you think it's a bug.
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1021 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1001 warn(warning)
1022 warn(warning)
1002 wait()
1023 wait()
1003 return
1024 return
1004
1025
1005 elif mode == 'upgrade':
1026 elif mode == 'upgrade':
1006 try:
1027 try:
1007 os.chdir(ipythondir)
1028 os.chdir(ipythondir)
1008 except:
1029 except:
1009 print """
1030 print """
1010 Can not upgrade: changing to directory %s failed. Details:
1031 Can not upgrade: changing to directory %s failed. Details:
1011 %s
1032 %s
1012 """ % (ipythondir,sys.exc_info()[1])
1033 """ % (ipythondir,sys.exc_info()[1])
1013 wait()
1034 wait()
1014 return
1035 return
1015 else:
1036 else:
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1037 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1017 for new_full_path in sources:
1038 for new_full_path in sources:
1018 new_filename = os.path.basename(new_full_path)
1039 new_filename = os.path.basename(new_full_path)
1019 if new_filename.startswith('ipythonrc'):
1040 if new_filename.startswith('ipythonrc'):
1020 new_filename = new_filename + rc_suffix
1041 new_filename = new_filename + rc_suffix
1021 # The config directory should only contain files, skip any
1042 # The config directory should only contain files, skip any
1022 # directories which may be there (like CVS)
1043 # directories which may be there (like CVS)
1023 if os.path.isdir(new_full_path):
1044 if os.path.isdir(new_full_path):
1024 continue
1045 continue
1025 if os.path.exists(new_filename):
1046 if os.path.exists(new_filename):
1026 old_file = new_filename+'.old'
1047 old_file = new_filename+'.old'
1027 if os.path.exists(old_file):
1048 if os.path.exists(old_file):
1028 os.remove(old_file)
1049 os.remove(old_file)
1029 os.rename(new_filename,old_file)
1050 os.rename(new_filename,old_file)
1030 shutil.copy(new_full_path,new_filename)
1051 shutil.copy(new_full_path,new_filename)
1031 else:
1052 else:
1032 raise ValueError,'unrecognized mode for install:',`mode`
1053 raise ValueError,'unrecognized mode for install:',`mode`
1033
1054
1034 # Fix line-endings to those native to each platform in the config
1055 # Fix line-endings to those native to each platform in the config
1035 # directory.
1056 # directory.
1036 try:
1057 try:
1037 os.chdir(ipythondir)
1058 os.chdir(ipythondir)
1038 except:
1059 except:
1039 print """
1060 print """
1040 Problem: changing to directory %s failed.
1061 Problem: changing to directory %s failed.
1041 Details:
1062 Details:
1042 %s
1063 %s
1043
1064
1044 Some configuration files may have incorrect line endings. This should not
1065 Some configuration files may have incorrect line endings. This should not
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1066 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1046 wait()
1067 wait()
1047 else:
1068 else:
1048 for fname in glb('ipythonrc*'):
1069 for fname in glb('ipythonrc*'):
1049 try:
1070 try:
1050 native_line_ends(fname,backup=0)
1071 native_line_ends(fname,backup=0)
1051 except IOError:
1072 except IOError:
1052 pass
1073 pass
1053
1074
1054 if mode == 'install':
1075 if mode == 'install':
1055 print """
1076 print """
1056 Successful installation!
1077 Successful installation!
1057
1078
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1079 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1080 IPython manual (there are both HTML and PDF versions supplied with the
1060 distribution) to make sure that your system environment is properly configured
1081 distribution) to make sure that your system environment is properly configured
1061 to take advantage of IPython's features."""
1082 to take advantage of IPython's features."""
1062 else:
1083 else:
1063 print """
1084 print """
1064 Successful upgrade!
1085 Successful upgrade!
1065
1086
1066 All files in your directory:
1087 All files in your directory:
1067 %(ipythondir)s
1088 %(ipythondir)s
1068 which would have been overwritten by the upgrade were backed up with a .old
1089 which would have been overwritten by the upgrade were backed up with a .old
1069 extension. If you had made particular customizations in those files you may
1090 extension. If you had made particular customizations in those files you may
1070 want to merge them back into the new files.""" % locals()
1091 want to merge them back into the new files.""" % locals()
1071 wait()
1092 wait()
1072 os.chdir(cwd)
1093 os.chdir(cwd)
1073 # end user_setup()
1094 # end user_setup()
1074
1095
1075 def atexit_operations(self):
1096 def atexit_operations(self):
1076 """This will be executed at the time of exit.
1097 """This will be executed at the time of exit.
1077
1098
1078 Saving of persistent data should be performed here. """
1099 Saving of persistent data should be performed here. """
1079
1100
1101 #print '*** IPython exit cleanup ***' # dbg
1080 # input history
1102 # input history
1081 self.savehist()
1103 self.savehist()
1082
1104
1083 # Cleanup all tempfiles left around
1105 # Cleanup all tempfiles left around
1084 for tfile in self.tempfiles:
1106 for tfile in self.tempfiles:
1085 try:
1107 try:
1086 os.unlink(tfile)
1108 os.unlink(tfile)
1087 except OSError:
1109 except OSError:
1088 pass
1110 pass
1089
1111
1090 # save the "persistent data" catch-all dictionary
1112 # save the "persistent data" catch-all dictionary
1091 try:
1113 try:
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1114 pickle.dump(self.persist, open(self.persist_fname,"w"))
1093 except:
1115 except:
1094 print "*** ERROR *** persistent data saving failed."
1116 print "*** ERROR *** persistent data saving failed."
1095
1117
1096 def savehist(self):
1118 def savehist(self):
1097 """Save input history to a file (via readline library)."""
1119 """Save input history to a file (via readline library)."""
1098 try:
1120 try:
1099 self.readline.write_history_file(self.histfile)
1121 self.readline.write_history_file(self.histfile)
1100 except:
1122 except:
1101 print 'Unable to save IPython command history to file: ' + \
1123 print 'Unable to save IPython command history to file: ' + \
1102 `self.histfile`
1124 `self.histfile`
1103
1125
1104 def pre_readline(self):
1126 def pre_readline(self):
1105 """readline hook to be used at the start of each line.
1127 """readline hook to be used at the start of each line.
1106
1128
1107 Currently it handles auto-indent only."""
1129 Currently it handles auto-indent only."""
1108
1130
1109 self.readline.insert_text(self.indent_current)
1131 self.readline.insert_text(self.indent_current)
1110
1132
1111 def init_readline(self):
1133 def init_readline(self):
1112 """Command history completion/saving/reloading."""
1134 """Command history completion/saving/reloading."""
1113 try:
1135 try:
1114 import readline
1136 import readline
1115 except ImportError:
1137 except ImportError:
1116 self.has_readline = 0
1138 self.has_readline = 0
1117 self.readline = None
1139 self.readline = None
1118 # no point in bugging windows users with this every time:
1140 # no point in bugging windows users with this every time:
1119 if os.name == 'posix':
1141 if os.name == 'posix':
1120 warn('Readline services not available on this platform.')
1142 warn('Readline services not available on this platform.')
1121 else:
1143 else:
1122 import atexit
1144 import atexit
1123 from IPython.completer import IPCompleter
1145 from IPython.completer import IPCompleter
1124 self.Completer = IPCompleter(self,
1146 self.Completer = IPCompleter(self,
1125 self.user_ns,
1147 self.user_ns,
1126 self.user_global_ns,
1148 self.user_global_ns,
1127 self.rc.readline_omit__names,
1149 self.rc.readline_omit__names,
1128 self.alias_table)
1150 self.alias_table)
1129
1151
1130 # Platform-specific configuration
1152 # Platform-specific configuration
1131 if os.name == 'nt':
1153 if os.name == 'nt':
1132 self.readline_startup_hook = readline.set_pre_input_hook
1154 self.readline_startup_hook = readline.set_pre_input_hook
1133 else:
1155 else:
1134 self.readline_startup_hook = readline.set_startup_hook
1156 self.readline_startup_hook = readline.set_startup_hook
1135
1157
1136 # Load user's initrc file (readline config)
1158 # Load user's initrc file (readline config)
1137 inputrc_name = os.environ.get('INPUTRC')
1159 inputrc_name = os.environ.get('INPUTRC')
1138 if inputrc_name is None:
1160 if inputrc_name is None:
1139 home_dir = get_home_dir()
1161 home_dir = get_home_dir()
1140 if home_dir is not None:
1162 if home_dir is not None:
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1163 inputrc_name = os.path.join(home_dir,'.inputrc')
1142 if os.path.isfile(inputrc_name):
1164 if os.path.isfile(inputrc_name):
1143 try:
1165 try:
1144 readline.read_init_file(inputrc_name)
1166 readline.read_init_file(inputrc_name)
1145 except:
1167 except:
1146 warn('Problems reading readline initialization file <%s>'
1168 warn('Problems reading readline initialization file <%s>'
1147 % inputrc_name)
1169 % inputrc_name)
1148
1170
1149 self.has_readline = 1
1171 self.has_readline = 1
1150 self.readline = readline
1172 self.readline = readline
1151 # save this in sys so embedded copies can restore it properly
1173 # save this in sys so embedded copies can restore it properly
1152 sys.ipcompleter = self.Completer.complete
1174 sys.ipcompleter = self.Completer.complete
1153 readline.set_completer(self.Completer.complete)
1175 readline.set_completer(self.Completer.complete)
1154
1176
1155 # Configure readline according to user's prefs
1177 # Configure readline according to user's prefs
1156 for rlcommand in self.rc.readline_parse_and_bind:
1178 for rlcommand in self.rc.readline_parse_and_bind:
1157 readline.parse_and_bind(rlcommand)
1179 readline.parse_and_bind(rlcommand)
1158
1180
1159 # remove some chars from the delimiters list
1181 # remove some chars from the delimiters list
1160 delims = readline.get_completer_delims()
1182 delims = readline.get_completer_delims()
1161 delims = delims.translate(string._idmap,
1183 delims = delims.translate(string._idmap,
1162 self.rc.readline_remove_delims)
1184 self.rc.readline_remove_delims)
1163 readline.set_completer_delims(delims)
1185 readline.set_completer_delims(delims)
1164 # otherwise we end up with a monster history after a while:
1186 # otherwise we end up with a monster history after a while:
1165 readline.set_history_length(1000)
1187 readline.set_history_length(1000)
1166 try:
1188 try:
1167 #print '*** Reading readline history' # dbg
1189 #print '*** Reading readline history' # dbg
1168 readline.read_history_file(self.histfile)
1190 readline.read_history_file(self.histfile)
1169 except IOError:
1191 except IOError:
1170 pass # It doesn't exist yet.
1192 pass # It doesn't exist yet.
1171
1193
1172 atexit.register(self.atexit_operations)
1194 atexit.register(self.atexit_operations)
1173 del atexit
1195 del atexit
1174
1196
1175 # Configure auto-indent for all platforms
1197 # Configure auto-indent for all platforms
1176 self.set_autoindent(self.rc.autoindent)
1198 self.set_autoindent(self.rc.autoindent)
1177
1199
1178 def _should_recompile(self,e):
1200 def _should_recompile(self,e):
1179 """Utility routine for edit_syntax_error"""
1201 """Utility routine for edit_syntax_error"""
1180
1202
1181 if e.filename in ('<ipython console>','<input>','<string>',
1203 if e.filename in ('<ipython console>','<input>','<string>',
1182 '<console>',None):
1204 '<console>',None):
1183
1205
1184 return False
1206 return False
1185 try:
1207 try:
1186 if not ask_yes_no('Return to editor to correct syntax error? '
1208 if not ask_yes_no('Return to editor to correct syntax error? '
1187 '[Y/n] ','y'):
1209 '[Y/n] ','y'):
1188 return False
1210 return False
1189 except EOFError:
1211 except EOFError:
1190 return False
1212 return False
1191
1213
1192 def int0(x):
1214 def int0(x):
1193 try:
1215 try:
1194 return int(x)
1216 return int(x)
1195 except TypeError:
1217 except TypeError:
1196 return 0
1218 return 0
1197 # always pass integer line and offset values to editor hook
1219 # always pass integer line and offset values to editor hook
1198 self.hooks.fix_error_editor(e.filename,
1220 self.hooks.fix_error_editor(e.filename,
1199 int0(e.lineno),int0(e.offset),e.msg)
1221 int0(e.lineno),int0(e.offset),e.msg)
1200 return True
1222 return True
1201
1223
1202 def edit_syntax_error(self):
1224 def edit_syntax_error(self):
1203 """The bottom half of the syntax error handler called in the main loop.
1225 """The bottom half of the syntax error handler called in the main loop.
1204
1226
1205 Loop until syntax error is fixed or user cancels.
1227 Loop until syntax error is fixed or user cancels.
1206 """
1228 """
1207
1229
1208 while self.SyntaxTB.last_syntax_error:
1230 while self.SyntaxTB.last_syntax_error:
1209 # copy and clear last_syntax_error
1231 # copy and clear last_syntax_error
1210 err = self.SyntaxTB.clear_err_state()
1232 err = self.SyntaxTB.clear_err_state()
1211 if not self._should_recompile(err):
1233 if not self._should_recompile(err):
1212 return
1234 return
1213 try:
1235 try:
1214 # may set last_syntax_error again if a SyntaxError is raised
1236 # may set last_syntax_error again if a SyntaxError is raised
1215 self.safe_execfile(err.filename,self.shell.user_ns)
1237 self.safe_execfile(err.filename,self.shell.user_ns)
1216 except:
1238 except:
1217 self.showtraceback()
1239 self.showtraceback()
1218 else:
1240 else:
1219 f = file(err.filename)
1241 f = file(err.filename)
1220 try:
1242 try:
1221 sys.displayhook(f.read())
1243 sys.displayhook(f.read())
1222 finally:
1244 finally:
1223 f.close()
1245 f.close()
1224
1246
1225 def showsyntaxerror(self, filename=None):
1247 def showsyntaxerror(self, filename=None):
1226 """Display the syntax error that just occurred.
1248 """Display the syntax error that just occurred.
1227
1249
1228 This doesn't display a stack trace because there isn't one.
1250 This doesn't display a stack trace because there isn't one.
1229
1251
1230 If a filename is given, it is stuffed in the exception instead
1252 If a filename is given, it is stuffed in the exception instead
1231 of what was there before (because Python's parser always uses
1253 of what was there before (because Python's parser always uses
1232 "<string>" when reading from a string).
1254 "<string>" when reading from a string).
1233 """
1255 """
1234 etype, value, last_traceback = sys.exc_info()
1256 etype, value, last_traceback = sys.exc_info()
1235 if filename and etype is SyntaxError:
1257 if filename and etype is SyntaxError:
1236 # Work hard to stuff the correct filename in the exception
1258 # Work hard to stuff the correct filename in the exception
1237 try:
1259 try:
1238 msg, (dummy_filename, lineno, offset, line) = value
1260 msg, (dummy_filename, lineno, offset, line) = value
1239 except:
1261 except:
1240 # Not the format we expect; leave it alone
1262 # Not the format we expect; leave it alone
1241 pass
1263 pass
1242 else:
1264 else:
1243 # Stuff in the right filename
1265 # Stuff in the right filename
1244 try:
1266 try:
1245 # Assume SyntaxError is a class exception
1267 # Assume SyntaxError is a class exception
1246 value = SyntaxError(msg, (filename, lineno, offset, line))
1268 value = SyntaxError(msg, (filename, lineno, offset, line))
1247 except:
1269 except:
1248 # If that failed, assume SyntaxError is a string
1270 # If that failed, assume SyntaxError is a string
1249 value = msg, (filename, lineno, offset, line)
1271 value = msg, (filename, lineno, offset, line)
1250 self.SyntaxTB(etype,value,[])
1272 self.SyntaxTB(etype,value,[])
1251
1273
1252 def debugger(self):
1274 def debugger(self):
1253 """Call the pdb debugger."""
1275 """Call the pdb debugger."""
1254
1276
1255 if not self.rc.pdb:
1277 if not self.rc.pdb:
1256 return
1278 return
1257 pdb.pm()
1279 pdb.pm()
1258
1280
1259 def showtraceback(self,exc_tuple = None,filename=None):
1281 def showtraceback(self,exc_tuple = None,filename=None):
1260 """Display the exception that just occurred."""
1282 """Display the exception that just occurred."""
1261
1283
1262 # Though this won't be called by syntax errors in the input line,
1284 # Though this won't be called by syntax errors in the input line,
1263 # there may be SyntaxError cases whith imported code.
1285 # there may be SyntaxError cases whith imported code.
1264 if exc_tuple is None:
1286 if exc_tuple is None:
1265 type, value, tb = sys.exc_info()
1287 type, value, tb = sys.exc_info()
1266 else:
1288 else:
1267 type, value, tb = exc_tuple
1289 type, value, tb = exc_tuple
1268 if type is SyntaxError:
1290 if type is SyntaxError:
1269 self.showsyntaxerror(filename)
1291 self.showsyntaxerror(filename)
1270 else:
1292 else:
1271 self.InteractiveTB()
1293 self.InteractiveTB()
1272 if self.InteractiveTB.call_pdb and self.has_readline:
1294 if self.InteractiveTB.call_pdb and self.has_readline:
1273 # pdb mucks up readline, fix it back
1295 # pdb mucks up readline, fix it back
1274 self.readline.set_completer(self.Completer.complete)
1296 self.readline.set_completer(self.Completer.complete)
1275
1297
1276 def mainloop(self,banner=None):
1298 def mainloop(self,banner=None):
1277 """Creates the local namespace and starts the mainloop.
1299 """Creates the local namespace and starts the mainloop.
1278
1300
1279 If an optional banner argument is given, it will override the
1301 If an optional banner argument is given, it will override the
1280 internally created default banner."""
1302 internally created default banner."""
1281
1303
1282 if self.rc.c: # Emulate Python's -c option
1304 if self.rc.c: # Emulate Python's -c option
1283 self.exec_init_cmd()
1305 self.exec_init_cmd()
1284 if banner is None:
1306 if banner is None:
1285 if self.rc.banner:
1307 if self.rc.banner:
1286 banner = self.BANNER+self.banner2
1308 banner = self.BANNER+self.banner2
1287 else:
1309 else:
1288 banner = ''
1310 banner = ''
1289 self.interact(banner)
1311 self.interact(banner)
1290
1312
1291 def exec_init_cmd(self):
1313 def exec_init_cmd(self):
1292 """Execute a command given at the command line.
1314 """Execute a command given at the command line.
1293
1315
1294 This emulates Python's -c option."""
1316 This emulates Python's -c option."""
1295
1317
1296 sys.argv = ['-c']
1318 sys.argv = ['-c']
1297 self.push(self.rc.c)
1319 self.push(self.rc.c)
1298
1320
1299 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1321 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1300 """Embeds IPython into a running python program.
1322 """Embeds IPython into a running python program.
1301
1323
1302 Input:
1324 Input:
1303
1325
1304 - header: An optional header message can be specified.
1326 - header: An optional header message can be specified.
1305
1327
1306 - local_ns, global_ns: working namespaces. If given as None, the
1328 - local_ns, global_ns: working namespaces. If given as None, the
1307 IPython-initialized one is updated with __main__.__dict__, so that
1329 IPython-initialized one is updated with __main__.__dict__, so that
1308 program variables become visible but user-specific configuration
1330 program variables become visible but user-specific configuration
1309 remains possible.
1331 remains possible.
1310
1332
1311 - stack_depth: specifies how many levels in the stack to go to
1333 - stack_depth: specifies how many levels in the stack to go to
1312 looking for namespaces (when local_ns and global_ns are None). This
1334 looking for namespaces (when local_ns and global_ns are None). This
1313 allows an intermediate caller to make sure that this function gets
1335 allows an intermediate caller to make sure that this function gets
1314 the namespace from the intended level in the stack. By default (0)
1336 the namespace from the intended level in the stack. By default (0)
1315 it will get its locals and globals from the immediate caller.
1337 it will get its locals and globals from the immediate caller.
1316
1338
1317 Warning: it's possible to use this in a program which is being run by
1339 Warning: it's possible to use this in a program which is being run by
1318 IPython itself (via %run), but some funny things will happen (a few
1340 IPython itself (via %run), but some funny things will happen (a few
1319 globals get overwritten). In the future this will be cleaned up, as
1341 globals get overwritten). In the future this will be cleaned up, as
1320 there is no fundamental reason why it can't work perfectly."""
1342 there is no fundamental reason why it can't work perfectly."""
1321
1343
1322 # Get locals and globals from caller
1344 # Get locals and globals from caller
1323 if local_ns is None or global_ns is None:
1345 if local_ns is None or global_ns is None:
1324 call_frame = sys._getframe(stack_depth).f_back
1346 call_frame = sys._getframe(stack_depth).f_back
1325
1347
1326 if local_ns is None:
1348 if local_ns is None:
1327 local_ns = call_frame.f_locals
1349 local_ns = call_frame.f_locals
1328 if global_ns is None:
1350 if global_ns is None:
1329 global_ns = call_frame.f_globals
1351 global_ns = call_frame.f_globals
1330
1352
1331 # Update namespaces and fire up interpreter
1353 # Update namespaces and fire up interpreter
1332
1354
1333 # The global one is easy, we can just throw it in
1355 # The global one is easy, we can just throw it in
1334 self.user_global_ns = global_ns
1356 self.user_global_ns = global_ns
1335
1357
1336 # but the user/local one is tricky: ipython needs it to store internal
1358 # but the user/local one is tricky: ipython needs it to store internal
1337 # data, but we also need the locals. We'll copy locals in the user
1359 # data, but we also need the locals. We'll copy locals in the user
1338 # one, but will track what got copied so we can delete them at exit.
1360 # one, but will track what got copied so we can delete them at exit.
1339 # This is so that a later embedded call doesn't see locals from a
1361 # This is so that a later embedded call doesn't see locals from a
1340 # previous call (which most likely existed in a separate scope).
1362 # previous call (which most likely existed in a separate scope).
1341 local_varnames = local_ns.keys()
1363 local_varnames = local_ns.keys()
1342 self.user_ns.update(local_ns)
1364 self.user_ns.update(local_ns)
1343
1365
1344 # Patch for global embedding to make sure that things don't overwrite
1366 # Patch for global embedding to make sure that things don't overwrite
1345 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1367 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1346 # FIXME. Test this a bit more carefully (the if.. is new)
1368 # FIXME. Test this a bit more carefully (the if.. is new)
1347 if local_ns is None and global_ns is None:
1369 if local_ns is None and global_ns is None:
1348 self.user_global_ns.update(__main__.__dict__)
1370 self.user_global_ns.update(__main__.__dict__)
1349
1371
1350 # make sure the tab-completer has the correct frame information, so it
1372 # make sure the tab-completer has the correct frame information, so it
1351 # actually completes using the frame's locals/globals
1373 # actually completes using the frame's locals/globals
1352 self.set_completer_frame()
1374 self.set_completer_frame()
1353
1375
1354 # before activating the interactive mode, we need to make sure that
1376 # before activating the interactive mode, we need to make sure that
1355 # all names in the builtin namespace needed by ipython point to
1377 # all names in the builtin namespace needed by ipython point to
1356 # ourselves, and not to other instances.
1378 # ourselves, and not to other instances.
1357 self.add_builtins()
1379 self.add_builtins()
1358
1380
1359 self.interact(header)
1381 self.interact(header)
1360
1382
1361 # now, purge out the user namespace from anything we might have added
1383 # now, purge out the user namespace from anything we might have added
1362 # from the caller's local namespace
1384 # from the caller's local namespace
1363 delvar = self.user_ns.pop
1385 delvar = self.user_ns.pop
1364 for var in local_varnames:
1386 for var in local_varnames:
1365 delvar(var,None)
1387 delvar(var,None)
1366 # and clean builtins we may have overridden
1388 # and clean builtins we may have overridden
1367 self.clean_builtins()
1389 self.clean_builtins()
1368
1390
1369 def interact(self, banner=None):
1391 def interact(self, banner=None):
1370 """Closely emulate the interactive Python console.
1392 """Closely emulate the interactive Python console.
1371
1393
1372 The optional banner argument specify the banner to print
1394 The optional banner argument specify the banner to print
1373 before the first interaction; by default it prints a banner
1395 before the first interaction; by default it prints a banner
1374 similar to the one printed by the real Python interpreter,
1396 similar to the one printed by the real Python interpreter,
1375 followed by the current class name in parentheses (so as not
1397 followed by the current class name in parentheses (so as not
1376 to confuse this with the real interpreter -- since it's so
1398 to confuse this with the real interpreter -- since it's so
1377 close!).
1399 close!).
1378
1400
1379 """
1401 """
1380 cprt = 'Type "copyright", "credits" or "license" for more information.'
1402 cprt = 'Type "copyright", "credits" or "license" for more information.'
1381 if banner is None:
1403 if banner is None:
1382 self.write("Python %s on %s\n%s\n(%s)\n" %
1404 self.write("Python %s on %s\n%s\n(%s)\n" %
1383 (sys.version, sys.platform, cprt,
1405 (sys.version, sys.platform, cprt,
1384 self.__class__.__name__))
1406 self.__class__.__name__))
1385 else:
1407 else:
1386 self.write(banner)
1408 self.write(banner)
1387
1409
1388 more = 0
1410 more = 0
1389
1411
1390 # Mark activity in the builtins
1412 # Mark activity in the builtins
1391 __builtin__.__dict__['__IPYTHON__active'] += 1
1413 __builtin__.__dict__['__IPYTHON__active'] += 1
1392
1414
1393 # exit_now is set by a call to %Exit or %Quit
1415 # exit_now is set by a call to %Exit or %Quit
1394 self.exit_now = False
1416 self.exit_now = False
1395 while not self.exit_now:
1417 while not self.exit_now:
1396
1418
1397 try:
1419 try:
1398 if more:
1420 if more:
1399 prompt = self.outputcache.prompt2
1421 prompt = self.outputcache.prompt2
1400 if self.autoindent:
1422 if self.autoindent:
1401 self.readline_startup_hook(self.pre_readline)
1423 self.readline_startup_hook(self.pre_readline)
1402 else:
1424 else:
1403 prompt = self.outputcache.prompt1
1425 prompt = self.outputcache.prompt1
1404 try:
1426 try:
1405 line = self.raw_input(prompt,more)
1427 line = self.raw_input(prompt,more)
1406 if self.autoindent:
1428 if self.autoindent:
1407 self.readline_startup_hook(None)
1429 self.readline_startup_hook(None)
1408 except EOFError:
1430 except EOFError:
1409 if self.autoindent:
1431 if self.autoindent:
1410 self.readline_startup_hook(None)
1432 self.readline_startup_hook(None)
1411 self.write("\n")
1433 self.write("\n")
1412 self.exit()
1434 self.exit()
1413 else:
1435 else:
1414 more = self.push(line)
1436 more = self.push(line)
1415
1437
1416 if (self.SyntaxTB.last_syntax_error and
1438 if (self.SyntaxTB.last_syntax_error and
1417 self.rc.autoedit_syntax):
1439 self.rc.autoedit_syntax):
1418 self.edit_syntax_error()
1440 self.edit_syntax_error()
1419
1441
1420 except KeyboardInterrupt:
1442 except KeyboardInterrupt:
1421 self.write("\nKeyboardInterrupt\n")
1443 self.write("\nKeyboardInterrupt\n")
1422 self.resetbuffer()
1444 self.resetbuffer()
1423 more = 0
1445 more = 0
1424 # keep cache in sync with the prompt counter:
1446 # keep cache in sync with the prompt counter:
1425 self.outputcache.prompt_count -= 1
1447 self.outputcache.prompt_count -= 1
1426
1448
1427 if self.autoindent:
1449 if self.autoindent:
1428 self.indent_current_nsp = 0
1450 self.indent_current_nsp = 0
1429 self.indent_current = ' '* self.indent_current_nsp
1451 self.indent_current = ' '* self.indent_current_nsp
1430
1452
1431 except bdb.BdbQuit:
1453 except bdb.BdbQuit:
1432 warn("The Python debugger has exited with a BdbQuit exception.\n"
1454 warn("The Python debugger has exited with a BdbQuit exception.\n"
1433 "Because of how pdb handles the stack, it is impossible\n"
1455 "Because of how pdb handles the stack, it is impossible\n"
1434 "for IPython to properly format this particular exception.\n"
1456 "for IPython to properly format this particular exception.\n"
1435 "IPython will resume normal operation.")
1457 "IPython will resume normal operation.")
1436
1458
1437 # We are off again...
1459 # We are off again...
1438 __builtin__.__dict__['__IPYTHON__active'] -= 1
1460 __builtin__.__dict__['__IPYTHON__active'] -= 1
1439
1461
1440 def excepthook(self, type, value, tb):
1462 def excepthook(self, type, value, tb):
1441 """One more defense for GUI apps that call sys.excepthook.
1463 """One more defense for GUI apps that call sys.excepthook.
1442
1464
1443 GUI frameworks like wxPython trap exceptions and call
1465 GUI frameworks like wxPython trap exceptions and call
1444 sys.excepthook themselves. I guess this is a feature that
1466 sys.excepthook themselves. I guess this is a feature that
1445 enables them to keep running after exceptions that would
1467 enables them to keep running after exceptions that would
1446 otherwise kill their mainloop. This is a bother for IPython
1468 otherwise kill their mainloop. This is a bother for IPython
1447 which excepts to catch all of the program exceptions with a try:
1469 which excepts to catch all of the program exceptions with a try:
1448 except: statement.
1470 except: statement.
1449
1471
1450 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1472 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1451 any app directly invokes sys.excepthook, it will look to the user like
1473 any app directly invokes sys.excepthook, it will look to the user like
1452 IPython crashed. In order to work around this, we can disable the
1474 IPython crashed. In order to work around this, we can disable the
1453 CrashHandler and replace it with this excepthook instead, which prints a
1475 CrashHandler and replace it with this excepthook instead, which prints a
1454 regular traceback using our InteractiveTB. In this fashion, apps which
1476 regular traceback using our InteractiveTB. In this fashion, apps which
1455 call sys.excepthook will generate a regular-looking exception from
1477 call sys.excepthook will generate a regular-looking exception from
1456 IPython, and the CrashHandler will only be triggered by real IPython
1478 IPython, and the CrashHandler will only be triggered by real IPython
1457 crashes.
1479 crashes.
1458
1480
1459 This hook should be used sparingly, only in places which are not likely
1481 This hook should be used sparingly, only in places which are not likely
1460 to be true IPython errors.
1482 to be true IPython errors.
1461 """
1483 """
1462
1484
1463 self.InteractiveTB(type, value, tb, tb_offset=0)
1485 self.InteractiveTB(type, value, tb, tb_offset=0)
1464 if self.InteractiveTB.call_pdb and self.has_readline:
1486 if self.InteractiveTB.call_pdb and self.has_readline:
1465 self.readline.set_completer(self.Completer.complete)
1487 self.readline.set_completer(self.Completer.complete)
1466
1488
1467 def call_alias(self,alias,rest=''):
1489 def call_alias(self,alias,rest=''):
1468 """Call an alias given its name and the rest of the line.
1490 """Call an alias given its name and the rest of the line.
1469
1491
1470 This function MUST be given a proper alias, because it doesn't make
1492 This function MUST be given a proper alias, because it doesn't make
1471 any checks when looking up into the alias table. The caller is
1493 any checks when looking up into the alias table. The caller is
1472 responsible for invoking it only with a valid alias."""
1494 responsible for invoking it only with a valid alias."""
1473
1495
1474 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1496 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1475 nargs,cmd = self.alias_table[alias]
1497 nargs,cmd = self.alias_table[alias]
1476 # Expand the %l special to be the user's input line
1498 # Expand the %l special to be the user's input line
1477 if cmd.find('%l') >= 0:
1499 if cmd.find('%l') >= 0:
1478 cmd = cmd.replace('%l',rest)
1500 cmd = cmd.replace('%l',rest)
1479 rest = ''
1501 rest = ''
1480 if nargs==0:
1502 if nargs==0:
1481 # Simple, argument-less aliases
1503 # Simple, argument-less aliases
1482 cmd = '%s %s' % (cmd,rest)
1504 cmd = '%s %s' % (cmd,rest)
1483 else:
1505 else:
1484 # Handle aliases with positional arguments
1506 # Handle aliases with positional arguments
1485 args = rest.split(None,nargs)
1507 args = rest.split(None,nargs)
1486 if len(args)< nargs:
1508 if len(args)< nargs:
1487 error('Alias <%s> requires %s arguments, %s given.' %
1509 error('Alias <%s> requires %s arguments, %s given.' %
1488 (alias,nargs,len(args)))
1510 (alias,nargs,len(args)))
1489 return
1511 return
1490 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1512 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1491 # Now call the macro, evaluating in the user's namespace
1513 # Now call the macro, evaluating in the user's namespace
1492 try:
1514 try:
1493 self.system(cmd)
1515 self.system(cmd)
1494 except:
1516 except:
1495 self.showtraceback()
1517 self.showtraceback()
1496
1518
1497 def autoindent_update(self,line):
1519 def autoindent_update(self,line):
1498 """Keep track of the indent level."""
1520 """Keep track of the indent level."""
1521
1499 if self.autoindent:
1522 if self.autoindent:
1500 if line:
1523 if line:
1501 ini_spaces = ini_spaces_re.match(line)
1524 self.indent_current_nsp = num_ini_spaces(line)
1502 if ini_spaces:
1503 nspaces = ini_spaces.end()
1504 else:
1505 nspaces = 0
1506 self.indent_current_nsp = nspaces
1507
1525
1508 if line[-1] == ':':
1526 if line[-1] == ':':
1509 self.indent_current_nsp += 4
1527 self.indent_current_nsp += 4
1510 elif dedent_re.match(line):
1528 elif dedent_re.match(line):
1511 self.indent_current_nsp -= 4
1529 self.indent_current_nsp -= 4
1512 else:
1530 else:
1513 self.indent_current_nsp = 0
1531 self.indent_current_nsp = 0
1514
1532
1515 # indent_current is the actual string to be inserted
1533 # indent_current is the actual string to be inserted
1516 # by the readline hooks for indentation
1534 # by the readline hooks for indentation
1517 self.indent_current = ' '* self.indent_current_nsp
1535 self.indent_current = ' '* self.indent_current_nsp
1518
1536
1519 def runlines(self,lines):
1537 def runlines(self,lines):
1520 """Run a string of one or more lines of source.
1538 """Run a string of one or more lines of source.
1521
1539
1522 This method is capable of running a string containing multiple source
1540 This method is capable of running a string containing multiple source
1523 lines, as if they had been entered at the IPython prompt. Since it
1541 lines, as if they had been entered at the IPython prompt. Since it
1524 exposes IPython's processing machinery, the given strings can contain
1542 exposes IPython's processing machinery, the given strings can contain
1525 magic calls (%magic), special shell access (!cmd), etc."""
1543 magic calls (%magic), special shell access (!cmd), etc."""
1526
1544
1527 # We must start with a clean buffer, in case this is run from an
1545 # We must start with a clean buffer, in case this is run from an
1528 # interactive IPython session (via a magic, for example).
1546 # interactive IPython session (via a magic, for example).
1529 self.resetbuffer()
1547 self.resetbuffer()
1530 lines = lines.split('\n')
1548 lines = lines.split('\n')
1531 more = 0
1549 more = 0
1532 for line in lines:
1550 for line in lines:
1533 # skip blank lines so we don't mess up the prompt counter, but do
1551 # skip blank lines so we don't mess up the prompt counter, but do
1534 # NOT skip even a blank line if we are in a code block (more is
1552 # NOT skip even a blank line if we are in a code block (more is
1535 # true)
1553 # true)
1536 if line or more:
1554 if line or more:
1537 more = self.push(self.prefilter(line,more))
1555 more = self.push(self.prefilter(line,more))
1538 # IPython's runsource returns None if there was an error
1556 # IPython's runsource returns None if there was an error
1539 # compiling the code. This allows us to stop processing right
1557 # compiling the code. This allows us to stop processing right
1540 # away, so the user gets the error message at the right place.
1558 # away, so the user gets the error message at the right place.
1541 if more is None:
1559 if more is None:
1542 break
1560 break
1543 # final newline in case the input didn't have it, so that the code
1561 # final newline in case the input didn't have it, so that the code
1544 # actually does get executed
1562 # actually does get executed
1545 if more:
1563 if more:
1546 self.push('\n')
1564 self.push('\n')
1547
1565
1548 def runsource(self, source, filename='<input>', symbol='single'):
1566 def runsource(self, source, filename='<input>', symbol='single'):
1549 """Compile and run some source in the interpreter.
1567 """Compile and run some source in the interpreter.
1550
1568
1551 Arguments are as for compile_command().
1569 Arguments are as for compile_command().
1552
1570
1553 One several things can happen:
1571 One several things can happen:
1554
1572
1555 1) The input is incorrect; compile_command() raised an
1573 1) The input is incorrect; compile_command() raised an
1556 exception (SyntaxError or OverflowError). A syntax traceback
1574 exception (SyntaxError or OverflowError). A syntax traceback
1557 will be printed by calling the showsyntaxerror() method.
1575 will be printed by calling the showsyntaxerror() method.
1558
1576
1559 2) The input is incomplete, and more input is required;
1577 2) The input is incomplete, and more input is required;
1560 compile_command() returned None. Nothing happens.
1578 compile_command() returned None. Nothing happens.
1561
1579
1562 3) The input is complete; compile_command() returned a code
1580 3) The input is complete; compile_command() returned a code
1563 object. The code is executed by calling self.runcode() (which
1581 object. The code is executed by calling self.runcode() (which
1564 also handles run-time exceptions, except for SystemExit).
1582 also handles run-time exceptions, except for SystemExit).
1565
1583
1566 The return value is:
1584 The return value is:
1567
1585
1568 - True in case 2
1586 - True in case 2
1569
1587
1570 - False in the other cases, unless an exception is raised, where
1588 - False in the other cases, unless an exception is raised, where
1571 None is returned instead. This can be used by external callers to
1589 None is returned instead. This can be used by external callers to
1572 know whether to continue feeding input or not.
1590 know whether to continue feeding input or not.
1573
1591
1574 The return value can be used to decide whether to use sys.ps1 or
1592 The return value can be used to decide whether to use sys.ps1 or
1575 sys.ps2 to prompt the next line."""
1593 sys.ps2 to prompt the next line."""
1576
1594
1577 try:
1595 try:
1578 code = self.compile(source,filename,symbol)
1596 code = self.compile(source,filename,symbol)
1579 except (OverflowError, SyntaxError, ValueError):
1597 except (OverflowError, SyntaxError, ValueError):
1580 # Case 1
1598 # Case 1
1581 self.showsyntaxerror(filename)
1599 self.showsyntaxerror(filename)
1582 return None
1600 return None
1583
1601
1584 if code is None:
1602 if code is None:
1585 # Case 2
1603 # Case 2
1586 return True
1604 return True
1587
1605
1588 # Case 3
1606 # Case 3
1589 # We store the code object so that threaded shells and
1607 # We store the code object so that threaded shells and
1590 # custom exception handlers can access all this info if needed.
1608 # custom exception handlers can access all this info if needed.
1591 # The source corresponding to this can be obtained from the
1609 # The source corresponding to this can be obtained from the
1592 # buffer attribute as '\n'.join(self.buffer).
1610 # buffer attribute as '\n'.join(self.buffer).
1593 self.code_to_run = code
1611 self.code_to_run = code
1594 # now actually execute the code object
1612 # now actually execute the code object
1595 if self.runcode(code) == 0:
1613 if self.runcode(code) == 0:
1596 return False
1614 return False
1597 else:
1615 else:
1598 return None
1616 return None
1599
1617
1600 def runcode(self,code_obj):
1618 def runcode(self,code_obj):
1601 """Execute a code object.
1619 """Execute a code object.
1602
1620
1603 When an exception occurs, self.showtraceback() is called to display a
1621 When an exception occurs, self.showtraceback() is called to display a
1604 traceback.
1622 traceback.
1605
1623
1606 Return value: a flag indicating whether the code to be run completed
1624 Return value: a flag indicating whether the code to be run completed
1607 successfully:
1625 successfully:
1608
1626
1609 - 0: successful execution.
1627 - 0: successful execution.
1610 - 1: an error occurred.
1628 - 1: an error occurred.
1611 """
1629 """
1612
1630
1613 # Set our own excepthook in case the user code tries to call it
1631 # Set our own excepthook in case the user code tries to call it
1614 # directly, so that the IPython crash handler doesn't get triggered
1632 # directly, so that the IPython crash handler doesn't get triggered
1615 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1633 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1616
1634
1617 # we save the original sys.excepthook in the instance, in case config
1635 # we save the original sys.excepthook in the instance, in case config
1618 # code (such as magics) needs access to it.
1636 # code (such as magics) needs access to it.
1619 self.sys_excepthook = old_excepthook
1637 self.sys_excepthook = old_excepthook
1620 outflag = 1 # happens in more places, so it's easier as default
1638 outflag = 1 # happens in more places, so it's easier as default
1621 try:
1639 try:
1622 try:
1640 try:
1623 # Embedded instances require separate global/local namespaces
1641 # Embedded instances require separate global/local namespaces
1624 # so they can see both the surrounding (local) namespace and
1642 # so they can see both the surrounding (local) namespace and
1625 # the module-level globals when called inside another function.
1643 # the module-level globals when called inside another function.
1626 if self.embedded:
1644 if self.embedded:
1627 exec code_obj in self.user_global_ns, self.user_ns
1645 exec code_obj in self.user_global_ns, self.user_ns
1628 # Normal (non-embedded) instances should only have a single
1646 # Normal (non-embedded) instances should only have a single
1629 # namespace for user code execution, otherwise functions won't
1647 # namespace for user code execution, otherwise functions won't
1630 # see interactive top-level globals.
1648 # see interactive top-level globals.
1631 else:
1649 else:
1632 exec code_obj in self.user_ns
1650 exec code_obj in self.user_ns
1633 finally:
1651 finally:
1634 # Reset our crash handler in place
1652 # Reset our crash handler in place
1635 sys.excepthook = old_excepthook
1653 sys.excepthook = old_excepthook
1636 except SystemExit:
1654 except SystemExit:
1637 self.resetbuffer()
1655 self.resetbuffer()
1638 self.showtraceback()
1656 self.showtraceback()
1639 warn("Type exit or quit to exit IPython "
1657 warn("Type exit or quit to exit IPython "
1640 "(%Exit or %Quit do so unconditionally).",level=1)
1658 "(%Exit or %Quit do so unconditionally).",level=1)
1641 except self.custom_exceptions:
1659 except self.custom_exceptions:
1642 etype,value,tb = sys.exc_info()
1660 etype,value,tb = sys.exc_info()
1643 self.CustomTB(etype,value,tb)
1661 self.CustomTB(etype,value,tb)
1644 except:
1662 except:
1645 self.showtraceback()
1663 self.showtraceback()
1646 else:
1664 else:
1647 outflag = 0
1665 outflag = 0
1648 if softspace(sys.stdout, 0):
1666 if softspace(sys.stdout, 0):
1649 print
1667 print
1650 # Flush out code object which has been run (and source)
1668 # Flush out code object which has been run (and source)
1651 self.code_to_run = None
1669 self.code_to_run = None
1652 return outflag
1670 return outflag
1653
1671
1654 def push(self, line):
1672 def push(self, line):
1655 """Push a line to the interpreter.
1673 """Push a line to the interpreter.
1656
1674
1657 The line should not have a trailing newline; it may have
1675 The line should not have a trailing newline; it may have
1658 internal newlines. The line is appended to a buffer and the
1676 internal newlines. The line is appended to a buffer and the
1659 interpreter's runsource() method is called with the
1677 interpreter's runsource() method is called with the
1660 concatenated contents of the buffer as source. If this
1678 concatenated contents of the buffer as source. If this
1661 indicates that the command was executed or invalid, the buffer
1679 indicates that the command was executed or invalid, the buffer
1662 is reset; otherwise, the command is incomplete, and the buffer
1680 is reset; otherwise, the command is incomplete, and the buffer
1663 is left as it was after the line was appended. The return
1681 is left as it was after the line was appended. The return
1664 value is 1 if more input is required, 0 if the line was dealt
1682 value is 1 if more input is required, 0 if the line was dealt
1665 with in some way (this is the same as runsource()).
1683 with in some way (this is the same as runsource()).
1666 """
1684 """
1667
1685
1668 # autoindent management should be done here, and not in the
1686 # autoindent management should be done here, and not in the
1669 # interactive loop, since that one is only seen by keyboard input. We
1687 # interactive loop, since that one is only seen by keyboard input. We
1670 # need this done correctly even for code run via runlines (which uses
1688 # need this done correctly even for code run via runlines (which uses
1671 # push).
1689 # push).
1672
1690
1673 #print 'push line: <%s>' % line # dbg
1691 #print 'push line: <%s>' % line # dbg
1674 self.autoindent_update(line)
1692 self.autoindent_update(line)
1675
1693
1676 self.buffer.append(line)
1694 self.buffer.append(line)
1677 more = self.runsource('\n'.join(self.buffer), self.filename)
1695 more = self.runsource('\n'.join(self.buffer), self.filename)
1678 if not more:
1696 if not more:
1679 self.resetbuffer()
1697 self.resetbuffer()
1680 return more
1698 return more
1681
1699
1682 def resetbuffer(self):
1700 def resetbuffer(self):
1683 """Reset the input buffer."""
1701 """Reset the input buffer."""
1684 self.buffer[:] = []
1702 self.buffer[:] = []
1685
1703
1686 def raw_input(self,prompt='',continue_prompt=False):
1704 def raw_input(self,prompt='',continue_prompt=False):
1687 """Write a prompt and read a line.
1705 """Write a prompt and read a line.
1688
1706
1689 The returned line does not include the trailing newline.
1707 The returned line does not include the trailing newline.
1690 When the user enters the EOF key sequence, EOFError is raised.
1708 When the user enters the EOF key sequence, EOFError is raised.
1691
1709
1692 Optional inputs:
1710 Optional inputs:
1693
1711
1694 - prompt(''): a string to be printed to prompt the user.
1712 - prompt(''): a string to be printed to prompt the user.
1695
1713
1696 - continue_prompt(False): whether this line is the first one or a
1714 - continue_prompt(False): whether this line is the first one or a
1697 continuation in a sequence of inputs.
1715 continuation in a sequence of inputs.
1698 """
1716 """
1699
1717
1700 line = raw_input_original(prompt)
1718 line = raw_input_original(prompt)
1701 # Try to be reasonably smart about not re-indenting pasted input more
1719 # Try to be reasonably smart about not re-indenting pasted input more
1702 # than necessary. We do this by trimming out the auto-indent initial
1720 # than necessary. We do this by trimming out the auto-indent initial
1703 # spaces, if the user's actual input started itself with whitespace.
1721 # spaces, if the user's actual input started itself with whitespace.
1704 if self.autoindent:
1722 #debugp('self.buffer[-1]')
1705 line2 = line[self.indent_current_nsp:]
1723 ## if self.autoindent:
1706 if line2[0:1] in (' ','\t'):
1724 ## try:
1707 line = line2
1725 ## prev_line = self.buffer[-1]
1726 ## except IndexError:
1727 ## prev_line = ''
1728 ## prev_indent = num_ini_spaces(prev_line)
1729 ## debugp('prev_indent')
1730 ## # Split the user's input
1731 ## line1 = line[:self.indent_current_nsp]
1732 ## line2 = line[self.indent_current_nsp:]
1733 ## if line1.isspace() and line2 and \
1734 ## num_ini_spaces(line2)==prev_indent:
1735 ## line = line2
1736 #debugp('line')
1737 #debugp('line1')
1738 #debugp('line2')
1739 ## if line1.isspace() and line2 and line2[0:1] in (' ','\t'):
1740 ## line = line2
1741 ## debugp('line')
1708 return self.prefilter(line,continue_prompt)
1742 return self.prefilter(line,continue_prompt)
1709
1743
1710 def split_user_input(self,line):
1744 def split_user_input(self,line):
1711 """Split user input into pre-char, function part and rest."""
1745 """Split user input into pre-char, function part and rest."""
1712
1746
1713 lsplit = self.line_split.match(line)
1747 lsplit = self.line_split.match(line)
1714 if lsplit is None: # no regexp match returns None
1748 if lsplit is None: # no regexp match returns None
1715 try:
1749 try:
1716 iFun,theRest = line.split(None,1)
1750 iFun,theRest = line.split(None,1)
1717 except ValueError:
1751 except ValueError:
1718 iFun,theRest = line,''
1752 iFun,theRest = line,''
1719 pre = re.match('^(\s*)(.*)',line).groups()[0]
1753 pre = re.match('^(\s*)(.*)',line).groups()[0]
1720 else:
1754 else:
1721 pre,iFun,theRest = lsplit.groups()
1755 pre,iFun,theRest = lsplit.groups()
1722
1756
1723 #print 'line:<%s>' % line # dbg
1757 #print 'line:<%s>' % line # dbg
1724 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1758 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1725 return pre,iFun.strip(),theRest
1759 return pre,iFun.strip(),theRest
1726
1760
1727 def _prefilter(self, line, continue_prompt):
1761 def _prefilter(self, line, continue_prompt):
1728 """Calls different preprocessors, depending on the form of line."""
1762 """Calls different preprocessors, depending on the form of line."""
1729
1763
1730 # All handlers *must* return a value, even if it's blank ('').
1764 # All handlers *must* return a value, even if it's blank ('').
1731
1765
1732 # Lines are NOT logged here. Handlers should process the line as
1766 # Lines are NOT logged here. Handlers should process the line as
1733 # needed, update the cache AND log it (so that the input cache array
1767 # needed, update the cache AND log it (so that the input cache array
1734 # stays synced).
1768 # stays synced).
1735
1769
1736 # This function is _very_ delicate, and since it's also the one which
1770 # This function is _very_ delicate, and since it's also the one which
1737 # determines IPython's response to user input, it must be as efficient
1771 # determines IPython's response to user input, it must be as efficient
1738 # as possible. For this reason it has _many_ returns in it, trying
1772 # as possible. For this reason it has _many_ returns in it, trying
1739 # always to exit as quickly as it can figure out what it needs to do.
1773 # always to exit as quickly as it can figure out what it needs to do.
1740
1774
1741 # This function is the main responsible for maintaining IPython's
1775 # This function is the main responsible for maintaining IPython's
1742 # behavior respectful of Python's semantics. So be _very_ careful if
1776 # behavior respectful of Python's semantics. So be _very_ careful if
1743 # making changes to anything here.
1777 # making changes to anything here.
1744
1778
1745 #.....................................................................
1779 #.....................................................................
1746 # Code begins
1780 # Code begins
1747
1781
1748 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1782 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1749
1783
1750 # save the line away in case we crash, so the post-mortem handler can
1784 # save the line away in case we crash, so the post-mortem handler can
1751 # record it
1785 # record it
1752 self._last_input_line = line
1786 self._last_input_line = line
1753
1787
1754 #print '***line: <%s>' % line # dbg
1788 #print '***line: <%s>' % line # dbg
1755
1789
1756 # the input history needs to track even empty lines
1790 # the input history needs to track even empty lines
1757 if not line.strip():
1791 if not line.strip():
1758 if not continue_prompt:
1792 if not continue_prompt:
1759 self.outputcache.prompt_count -= 1
1793 self.outputcache.prompt_count -= 1
1760 return self.handle_normal(line,continue_prompt)
1794 return self.handle_normal(line,continue_prompt)
1761 #return self.handle_normal('',continue_prompt)
1795 #return self.handle_normal('',continue_prompt)
1762
1796
1763 # print '***cont',continue_prompt # dbg
1797 # print '***cont',continue_prompt # dbg
1764 # special handlers are only allowed for single line statements
1798 # special handlers are only allowed for single line statements
1765 if continue_prompt and not self.rc.multi_line_specials:
1799 if continue_prompt and not self.rc.multi_line_specials:
1766 return self.handle_normal(line,continue_prompt)
1800 return self.handle_normal(line,continue_prompt)
1767
1801
1768 # For the rest, we need the structure of the input
1802 # For the rest, we need the structure of the input
1769 pre,iFun,theRest = self.split_user_input(line)
1803 pre,iFun,theRest = self.split_user_input(line)
1770 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1804 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1771
1805
1772 # First check for explicit escapes in the last/first character
1806 # First check for explicit escapes in the last/first character
1773 handler = None
1807 handler = None
1774 if line[-1] == self.ESC_HELP:
1808 if line[-1] == self.ESC_HELP:
1775 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1809 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1776 if handler is None:
1810 if handler is None:
1777 # look at the first character of iFun, NOT of line, so we skip
1811 # look at the first character of iFun, NOT of line, so we skip
1778 # leading whitespace in multiline input
1812 # leading whitespace in multiline input
1779 handler = self.esc_handlers.get(iFun[0:1])
1813 handler = self.esc_handlers.get(iFun[0:1])
1780 if handler is not None:
1814 if handler is not None:
1781 return handler(line,continue_prompt,pre,iFun,theRest)
1815 return handler(line,continue_prompt,pre,iFun,theRest)
1782 # Emacs ipython-mode tags certain input lines
1816 # Emacs ipython-mode tags certain input lines
1783 if line.endswith('# PYTHON-MODE'):
1817 if line.endswith('# PYTHON-MODE'):
1784 return self.handle_emacs(line,continue_prompt)
1818 return self.handle_emacs(line,continue_prompt)
1785
1819
1786 # Next, check if we can automatically execute this thing
1820 # Next, check if we can automatically execute this thing
1787
1821
1788 # Allow ! in multi-line statements if multi_line_specials is on:
1822 # Allow ! in multi-line statements if multi_line_specials is on:
1789 if continue_prompt and self.rc.multi_line_specials and \
1823 if continue_prompt and self.rc.multi_line_specials and \
1790 iFun.startswith(self.ESC_SHELL):
1824 iFun.startswith(self.ESC_SHELL):
1791 return self.handle_shell_escape(line,continue_prompt,
1825 return self.handle_shell_escape(line,continue_prompt,
1792 pre=pre,iFun=iFun,
1826 pre=pre,iFun=iFun,
1793 theRest=theRest)
1827 theRest=theRest)
1794
1828
1795 # Let's try to find if the input line is a magic fn
1829 # Let's try to find if the input line is a magic fn
1796 oinfo = None
1830 oinfo = None
1797 if hasattr(self,'magic_'+iFun):
1831 if hasattr(self,'magic_'+iFun):
1798 # WARNING: _ofind uses getattr(), so it can consume generators and
1832 # WARNING: _ofind uses getattr(), so it can consume generators and
1799 # cause other side effects.
1833 # cause other side effects.
1800 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1834 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1801 if oinfo['ismagic']:
1835 if oinfo['ismagic']:
1802 # Be careful not to call magics when a variable assignment is
1836 # Be careful not to call magics when a variable assignment is
1803 # being made (ls='hi', for example)
1837 # being made (ls='hi', for example)
1804 if self.rc.automagic and \
1838 if self.rc.automagic and \
1805 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1839 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1806 (self.rc.multi_line_specials or not continue_prompt):
1840 (self.rc.multi_line_specials or not continue_prompt):
1807 return self.handle_magic(line,continue_prompt,
1841 return self.handle_magic(line,continue_prompt,
1808 pre,iFun,theRest)
1842 pre,iFun,theRest)
1809 else:
1843 else:
1810 return self.handle_normal(line,continue_prompt)
1844 return self.handle_normal(line,continue_prompt)
1811
1845
1812 # If the rest of the line begins with an (in)equality, assginment or
1846 # If the rest of the line begins with an (in)equality, assginment or
1813 # function call, we should not call _ofind but simply execute it.
1847 # function call, we should not call _ofind but simply execute it.
1814 # This avoids spurious geattr() accesses on objects upon assignment.
1848 # This avoids spurious geattr() accesses on objects upon assignment.
1815 #
1849 #
1816 # It also allows users to assign to either alias or magic names true
1850 # It also allows users to assign to either alias or magic names true
1817 # python variables (the magic/alias systems always take second seat to
1851 # python variables (the magic/alias systems always take second seat to
1818 # true python code).
1852 # true python code).
1819 if theRest and theRest[0] in '!=()':
1853 if theRest and theRest[0] in '!=()':
1820 return self.handle_normal(line,continue_prompt)
1854 return self.handle_normal(line,continue_prompt)
1821
1855
1822 if oinfo is None:
1856 if oinfo is None:
1823 # let's try to ensure that _oinfo is ONLY called when autocall is
1857 # let's try to ensure that _oinfo is ONLY called when autocall is
1824 # on. Since it has inevitable potential side effects, at least
1858 # on. Since it has inevitable potential side effects, at least
1825 # having autocall off should be a guarantee to the user that no
1859 # having autocall off should be a guarantee to the user that no
1826 # weird things will happen.
1860 # weird things will happen.
1827
1861
1828 if self.rc.autocall:
1862 if self.rc.autocall:
1829 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1863 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1830 else:
1864 else:
1831 # in this case, all that's left is either an alias or
1865 # in this case, all that's left is either an alias or
1832 # processing the line normally.
1866 # processing the line normally.
1833 if iFun in self.alias_table:
1867 if iFun in self.alias_table:
1834 return self.handle_alias(line,continue_prompt,
1868 return self.handle_alias(line,continue_prompt,
1835 pre,iFun,theRest)
1869 pre,iFun,theRest)
1836 else:
1870 else:
1837 return self.handle_normal(line,continue_prompt)
1871 return self.handle_normal(line,continue_prompt)
1838
1872
1839 if not oinfo['found']:
1873 if not oinfo['found']:
1840 return self.handle_normal(line,continue_prompt)
1874 return self.handle_normal(line,continue_prompt)
1841 else:
1875 else:
1842 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1876 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1843 if oinfo['isalias']:
1877 if oinfo['isalias']:
1844 return self.handle_alias(line,continue_prompt,
1878 return self.handle_alias(line,continue_prompt,
1845 pre,iFun,theRest)
1879 pre,iFun,theRest)
1846
1880
1847 if self.rc.autocall and \
1881 if self.rc.autocall and \
1848 not self.re_exclude_auto.match(theRest) and \
1882 not self.re_exclude_auto.match(theRest) and \
1849 self.re_fun_name.match(iFun) and \
1883 self.re_fun_name.match(iFun) and \
1850 callable(oinfo['obj']) :
1884 callable(oinfo['obj']) :
1851 #print 'going auto' # dbg
1885 #print 'going auto' # dbg
1852 return self.handle_auto(line,continue_prompt,
1886 return self.handle_auto(line,continue_prompt,
1853 pre,iFun,theRest,oinfo['obj'])
1887 pre,iFun,theRest,oinfo['obj'])
1854 else:
1888 else:
1855 #print 'was callable?', callable(oinfo['obj']) # dbg
1889 #print 'was callable?', callable(oinfo['obj']) # dbg
1856 return self.handle_normal(line,continue_prompt)
1890 return self.handle_normal(line,continue_prompt)
1857
1891
1858 # If we get here, we have a normal Python line. Log and return.
1892 # If we get here, we have a normal Python line. Log and return.
1859 return self.handle_normal(line,continue_prompt)
1893 return self.handle_normal(line,continue_prompt)
1860
1894
1861 def _prefilter_dumb(self, line, continue_prompt):
1895 def _prefilter_dumb(self, line, continue_prompt):
1862 """simple prefilter function, for debugging"""
1896 """simple prefilter function, for debugging"""
1863 return self.handle_normal(line,continue_prompt)
1897 return self.handle_normal(line,continue_prompt)
1864
1898
1865 # Set the default prefilter() function (this can be user-overridden)
1899 # Set the default prefilter() function (this can be user-overridden)
1866 prefilter = _prefilter
1900 prefilter = _prefilter
1867
1901
1868 def handle_normal(self,line,continue_prompt=None,
1902 def handle_normal(self,line,continue_prompt=None,
1869 pre=None,iFun=None,theRest=None):
1903 pre=None,iFun=None,theRest=None):
1870 """Handle normal input lines. Use as a template for handlers."""
1904 """Handle normal input lines. Use as a template for handlers."""
1871
1905
1872 # With autoindent on, we need some way to exit the input loop, and I
1906 # With autoindent on, we need some way to exit the input loop, and I
1873 # don't want to force the user to have to backspace all the way to
1907 # don't want to force the user to have to backspace all the way to
1874 # clear the line. The rule will be in this case, that either two
1908 # clear the line. The rule will be in this case, that either two
1875 # lines of pure whitespace in a row, or a line of pure whitespace but
1909 # lines of pure whitespace in a row, or a line of pure whitespace but
1876 # of a size different to the indent level, will exit the input loop.
1910 # of a size different to the indent level, will exit the input loop.
1877
1911
1878 if (continue_prompt and self.autoindent and isspace(line) and
1912 if (continue_prompt and self.autoindent and line.isspace() and
1879 (line != self.indent_current or isspace(self.buffer[-1]))):
1913 (line != self.indent_current or (self.buffer[-1]).isspace() )):
1880 line = ''
1914 line = ''
1881
1915
1882 self.log(line,continue_prompt)
1916 self.log(line,continue_prompt)
1883 return line
1917 return line
1884
1918
1885 def handle_alias(self,line,continue_prompt=None,
1919 def handle_alias(self,line,continue_prompt=None,
1886 pre=None,iFun=None,theRest=None):
1920 pre=None,iFun=None,theRest=None):
1887 """Handle alias input lines. """
1921 """Handle alias input lines. """
1888
1922
1889 # pre is needed, because it carries the leading whitespace. Otherwise
1923 # pre is needed, because it carries the leading whitespace. Otherwise
1890 # aliases won't work in indented sections.
1924 # aliases won't work in indented sections.
1891 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1925 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1892 self.log(line_out,continue_prompt)
1926 self.log(line_out,continue_prompt)
1893 return line_out
1927 return line_out
1894
1928
1895 def handle_shell_escape(self, line, continue_prompt=None,
1929 def handle_shell_escape(self, line, continue_prompt=None,
1896 pre=None,iFun=None,theRest=None):
1930 pre=None,iFun=None,theRest=None):
1897 """Execute the line in a shell, empty return value"""
1931 """Execute the line in a shell, empty return value"""
1898
1932
1899 #print 'line in :', `line` # dbg
1933 #print 'line in :', `line` # dbg
1900 # Example of a special handler. Others follow a similar pattern.
1934 # Example of a special handler. Others follow a similar pattern.
1901 if line.lstrip().startswith('!!'):
1935 if line.lstrip().startswith('!!'):
1902 # rewrite iFun/theRest to properly hold the call to %sx and
1936 # rewrite iFun/theRest to properly hold the call to %sx and
1903 # the actual command to be executed, so handle_magic can work
1937 # the actual command to be executed, so handle_magic can work
1904 # correctly
1938 # correctly
1905 theRest = '%s %s' % (iFun[2:],theRest)
1939 theRest = '%s %s' % (iFun[2:],theRest)
1906 iFun = 'sx'
1940 iFun = 'sx'
1907 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1941 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1908 continue_prompt,pre,iFun,theRest)
1942 continue_prompt,pre,iFun,theRest)
1909 else:
1943 else:
1910 cmd=line.lstrip()[1:]
1944 cmd=line.lstrip()[1:]
1911 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1945 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1912 # update cache/log and return
1946 # update cache/log and return
1913 self.log(line_out,continue_prompt)
1947 self.log(line_out,continue_prompt)
1914 return line_out
1948 return line_out
1915
1949
1916 def handle_magic(self, line, continue_prompt=None,
1950 def handle_magic(self, line, continue_prompt=None,
1917 pre=None,iFun=None,theRest=None):
1951 pre=None,iFun=None,theRest=None):
1918 """Execute magic functions."""
1952 """Execute magic functions."""
1919
1953
1920
1954
1921 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1955 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1922 self.log(cmd,continue_prompt)
1956 self.log(cmd,continue_prompt)
1923 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1957 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1924 return cmd
1958 return cmd
1925
1959
1926 def handle_auto(self, line, continue_prompt=None,
1960 def handle_auto(self, line, continue_prompt=None,
1927 pre=None,iFun=None,theRest=None,obj=None):
1961 pre=None,iFun=None,theRest=None,obj=None):
1928 """Hande lines which can be auto-executed, quoting if requested."""
1962 """Hande lines which can be auto-executed, quoting if requested."""
1929
1963
1930 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1964 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1931
1965
1932 # This should only be active for single-line input!
1966 # This should only be active for single-line input!
1933 if continue_prompt:
1967 if continue_prompt:
1934 self.log(line,continue_prompt)
1968 self.log(line,continue_prompt)
1935 return line
1969 return line
1936
1970
1937 auto_rewrite = True
1971 auto_rewrite = True
1938 if pre == self.ESC_QUOTE:
1972 if pre == self.ESC_QUOTE:
1939 # Auto-quote splitting on whitespace
1973 # Auto-quote splitting on whitespace
1940 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1974 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1941 elif pre == self.ESC_QUOTE2:
1975 elif pre == self.ESC_QUOTE2:
1942 # Auto-quote whole string
1976 # Auto-quote whole string
1943 newcmd = '%s("%s")' % (iFun,theRest)
1977 newcmd = '%s("%s")' % (iFun,theRest)
1944 else:
1978 else:
1945 # Auto-paren.
1979 # Auto-paren.
1946 # We only apply it to argument-less calls if the autocall
1980 # We only apply it to argument-less calls if the autocall
1947 # parameter is set to 2. We only need to check that autocall is <
1981 # parameter is set to 2. We only need to check that autocall is <
1948 # 2, since this function isn't called unless it's at least 1.
1982 # 2, since this function isn't called unless it's at least 1.
1949 if not theRest and (self.rc.autocall < 2):
1983 if not theRest and (self.rc.autocall < 2):
1950 newcmd = '%s %s' % (iFun,theRest)
1984 newcmd = '%s %s' % (iFun,theRest)
1951 auto_rewrite = False
1985 auto_rewrite = False
1952 else:
1986 else:
1953 if theRest.startswith('['):
1987 if theRest.startswith('['):
1954 if hasattr(obj,'__getitem__'):
1988 if hasattr(obj,'__getitem__'):
1955 # Don't autocall in this case: item access for an object
1989 # Don't autocall in this case: item access for an object
1956 # which is BOTH callable and implements __getitem__.
1990 # which is BOTH callable and implements __getitem__.
1957 newcmd = '%s %s' % (iFun,theRest)
1991 newcmd = '%s %s' % (iFun,theRest)
1958 auto_rewrite = False
1992 auto_rewrite = False
1959 else:
1993 else:
1960 # if the object doesn't support [] access, go ahead and
1994 # if the object doesn't support [] access, go ahead and
1961 # autocall
1995 # autocall
1962 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1996 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1963 elif theRest.endswith(';'):
1997 elif theRest.endswith(';'):
1964 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1998 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1965 else:
1999 else:
1966 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2000 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1967
2001
1968 if auto_rewrite:
2002 if auto_rewrite:
1969 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2003 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1970 # log what is now valid Python, not the actual user input (without the
2004 # log what is now valid Python, not the actual user input (without the
1971 # final newline)
2005 # final newline)
1972 self.log(newcmd,continue_prompt)
2006 self.log(newcmd,continue_prompt)
1973 return newcmd
2007 return newcmd
1974
2008
1975 def handle_help(self, line, continue_prompt=None,
2009 def handle_help(self, line, continue_prompt=None,
1976 pre=None,iFun=None,theRest=None):
2010 pre=None,iFun=None,theRest=None):
1977 """Try to get some help for the object.
2011 """Try to get some help for the object.
1978
2012
1979 obj? or ?obj -> basic information.
2013 obj? or ?obj -> basic information.
1980 obj?? or ??obj -> more details.
2014 obj?? or ??obj -> more details.
1981 """
2015 """
1982
2016
1983 # We need to make sure that we don't process lines which would be
2017 # We need to make sure that we don't process lines which would be
1984 # otherwise valid python, such as "x=1 # what?"
2018 # otherwise valid python, such as "x=1 # what?"
1985 try:
2019 try:
1986 codeop.compile_command(line)
2020 codeop.compile_command(line)
1987 except SyntaxError:
2021 except SyntaxError:
1988 # We should only handle as help stuff which is NOT valid syntax
2022 # We should only handle as help stuff which is NOT valid syntax
1989 if line[0]==self.ESC_HELP:
2023 if line[0]==self.ESC_HELP:
1990 line = line[1:]
2024 line = line[1:]
1991 elif line[-1]==self.ESC_HELP:
2025 elif line[-1]==self.ESC_HELP:
1992 line = line[:-1]
2026 line = line[:-1]
1993 self.log('#?'+line)
2027 self.log('#?'+line)
1994 if line:
2028 if line:
1995 self.magic_pinfo(line)
2029 self.magic_pinfo(line)
1996 else:
2030 else:
1997 page(self.usage,screen_lines=self.rc.screen_length)
2031 page(self.usage,screen_lines=self.rc.screen_length)
1998 return '' # Empty string is needed here!
2032 return '' # Empty string is needed here!
1999 except:
2033 except:
2000 # Pass any other exceptions through to the normal handler
2034 # Pass any other exceptions through to the normal handler
2001 return self.handle_normal(line,continue_prompt)
2035 return self.handle_normal(line,continue_prompt)
2002 else:
2036 else:
2003 # If the code compiles ok, we should handle it normally
2037 # If the code compiles ok, we should handle it normally
2004 return self.handle_normal(line,continue_prompt)
2038 return self.handle_normal(line,continue_prompt)
2005
2039
2006 def handle_emacs(self,line,continue_prompt=None,
2040 def handle_emacs(self,line,continue_prompt=None,
2007 pre=None,iFun=None,theRest=None):
2041 pre=None,iFun=None,theRest=None):
2008 """Handle input lines marked by python-mode."""
2042 """Handle input lines marked by python-mode."""
2009
2043
2010 # Currently, nothing is done. Later more functionality can be added
2044 # Currently, nothing is done. Later more functionality can be added
2011 # here if needed.
2045 # here if needed.
2012
2046
2013 # The input cache shouldn't be updated
2047 # The input cache shouldn't be updated
2014
2048
2015 return line
2049 return line
2016
2050
2017 def mktempfile(self,data=None):
2051 def mktempfile(self,data=None):
2018 """Make a new tempfile and return its filename.
2052 """Make a new tempfile and return its filename.
2019
2053
2020 This makes a call to tempfile.mktemp, but it registers the created
2054 This makes a call to tempfile.mktemp, but it registers the created
2021 filename internally so ipython cleans it up at exit time.
2055 filename internally so ipython cleans it up at exit time.
2022
2056
2023 Optional inputs:
2057 Optional inputs:
2024
2058
2025 - data(None): if data is given, it gets written out to the temp file
2059 - data(None): if data is given, it gets written out to the temp file
2026 immediately, and the file is closed again."""
2060 immediately, and the file is closed again."""
2027
2061
2028 filename = tempfile.mktemp('.py','ipython_edit_')
2062 filename = tempfile.mktemp('.py','ipython_edit_')
2029 self.tempfiles.append(filename)
2063 self.tempfiles.append(filename)
2030
2064
2031 if data:
2065 if data:
2032 tmp_file = open(filename,'w')
2066 tmp_file = open(filename,'w')
2033 tmp_file.write(data)
2067 tmp_file.write(data)
2034 tmp_file.close()
2068 tmp_file.close()
2035 return filename
2069 return filename
2036
2070
2037 def write(self,data):
2071 def write(self,data):
2038 """Write a string to the default output"""
2072 """Write a string to the default output"""
2039 Term.cout.write(data)
2073 Term.cout.write(data)
2040
2074
2041 def write_err(self,data):
2075 def write_err(self,data):
2042 """Write a string to the default error output"""
2076 """Write a string to the default error output"""
2043 Term.cerr.write(data)
2077 Term.cerr.write(data)
2044
2078
2045 def exit(self):
2079 def exit(self):
2046 """Handle interactive exit.
2080 """Handle interactive exit.
2047
2081
2048 This method sets the exit_now attribute."""
2082 This method sets the exit_now attribute."""
2049
2083
2050 if self.rc.confirm_exit:
2084 if self.rc.confirm_exit:
2051 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2085 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2052 self.exit_now = True
2086 self.exit_now = True
2053 else:
2087 else:
2054 self.exit_now = True
2088 self.exit_now = True
2055 return self.exit_now
2089 return self.exit_now
2056
2090
2057 def safe_execfile(self,fname,*where,**kw):
2091 def safe_execfile(self,fname,*where,**kw):
2058 fname = os.path.expanduser(fname)
2092 fname = os.path.expanduser(fname)
2059
2093
2060 # find things also in current directory
2094 # find things also in current directory
2061 dname = os.path.dirname(fname)
2095 dname = os.path.dirname(fname)
2062 if not sys.path.count(dname):
2096 if not sys.path.count(dname):
2063 sys.path.append(dname)
2097 sys.path.append(dname)
2064
2098
2065 try:
2099 try:
2066 xfile = open(fname)
2100 xfile = open(fname)
2067 except:
2101 except:
2068 print >> Term.cerr, \
2102 print >> Term.cerr, \
2069 'Could not open file <%s> for safe execution.' % fname
2103 'Could not open file <%s> for safe execution.' % fname
2070 return None
2104 return None
2071
2105
2072 kw.setdefault('islog',0)
2106 kw.setdefault('islog',0)
2073 kw.setdefault('quiet',1)
2107 kw.setdefault('quiet',1)
2074 kw.setdefault('exit_ignore',0)
2108 kw.setdefault('exit_ignore',0)
2075 first = xfile.readline()
2109 first = xfile.readline()
2076 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2110 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2077 xfile.close()
2111 xfile.close()
2078 # line by line execution
2112 # line by line execution
2079 if first.startswith(loghead) or kw['islog']:
2113 if first.startswith(loghead) or kw['islog']:
2080 print 'Loading log file <%s> one line at a time...' % fname
2114 print 'Loading log file <%s> one line at a time...' % fname
2081 if kw['quiet']:
2115 if kw['quiet']:
2082 stdout_save = sys.stdout
2116 stdout_save = sys.stdout
2083 sys.stdout = StringIO.StringIO()
2117 sys.stdout = StringIO.StringIO()
2084 try:
2118 try:
2085 globs,locs = where[0:2]
2119 globs,locs = where[0:2]
2086 except:
2120 except:
2087 try:
2121 try:
2088 globs = locs = where[0]
2122 globs = locs = where[0]
2089 except:
2123 except:
2090 globs = locs = globals()
2124 globs = locs = globals()
2091 badblocks = []
2125 badblocks = []
2092
2126
2093 # we also need to identify indented blocks of code when replaying
2127 # we also need to identify indented blocks of code when replaying
2094 # logs and put them together before passing them to an exec
2128 # logs and put them together before passing them to an exec
2095 # statement. This takes a bit of regexp and look-ahead work in the
2129 # statement. This takes a bit of regexp and look-ahead work in the
2096 # file. It's easiest if we swallow the whole thing in memory
2130 # file. It's easiest if we swallow the whole thing in memory
2097 # first, and manually walk through the lines list moving the
2131 # first, and manually walk through the lines list moving the
2098 # counter ourselves.
2132 # counter ourselves.
2099 indent_re = re.compile('\s+\S')
2133 indent_re = re.compile('\s+\S')
2100 xfile = open(fname)
2134 xfile = open(fname)
2101 filelines = xfile.readlines()
2135 filelines = xfile.readlines()
2102 xfile.close()
2136 xfile.close()
2103 nlines = len(filelines)
2137 nlines = len(filelines)
2104 lnum = 0
2138 lnum = 0
2105 while lnum < nlines:
2139 while lnum < nlines:
2106 line = filelines[lnum]
2140 line = filelines[lnum]
2107 lnum += 1
2141 lnum += 1
2108 # don't re-insert logger status info into cache
2142 # don't re-insert logger status info into cache
2109 if line.startswith('#log#'):
2143 if line.startswith('#log#'):
2110 continue
2144 continue
2111 else:
2145 else:
2112 # build a block of code (maybe a single line) for execution
2146 # build a block of code (maybe a single line) for execution
2113 block = line
2147 block = line
2114 try:
2148 try:
2115 next = filelines[lnum] # lnum has already incremented
2149 next = filelines[lnum] # lnum has already incremented
2116 except:
2150 except:
2117 next = None
2151 next = None
2118 while next and indent_re.match(next):
2152 while next and indent_re.match(next):
2119 block += next
2153 block += next
2120 lnum += 1
2154 lnum += 1
2121 try:
2155 try:
2122 next = filelines[lnum]
2156 next = filelines[lnum]
2123 except:
2157 except:
2124 next = None
2158 next = None
2125 # now execute the block of one or more lines
2159 # now execute the block of one or more lines
2126 try:
2160 try:
2127 exec block in globs,locs
2161 exec block in globs,locs
2128 except SystemExit:
2162 except SystemExit:
2129 pass
2163 pass
2130 except:
2164 except:
2131 badblocks.append(block.rstrip())
2165 badblocks.append(block.rstrip())
2132 if kw['quiet']: # restore stdout
2166 if kw['quiet']: # restore stdout
2133 sys.stdout.close()
2167 sys.stdout.close()
2134 sys.stdout = stdout_save
2168 sys.stdout = stdout_save
2135 print 'Finished replaying log file <%s>' % fname
2169 print 'Finished replaying log file <%s>' % fname
2136 if badblocks:
2170 if badblocks:
2137 print >> sys.stderr, ('\nThe following lines/blocks in file '
2171 print >> sys.stderr, ('\nThe following lines/blocks in file '
2138 '<%s> reported errors:' % fname)
2172 '<%s> reported errors:' % fname)
2139
2173
2140 for badline in badblocks:
2174 for badline in badblocks:
2141 print >> sys.stderr, badline
2175 print >> sys.stderr, badline
2142 else: # regular file execution
2176 else: # regular file execution
2143 try:
2177 try:
2144 execfile(fname,*where)
2178 execfile(fname,*where)
2145 except SyntaxError:
2179 except SyntaxError:
2146 etype,evalue = sys.exc_info()[:2]
2180 etype,evalue = sys.exc_info()[:2]
2147 self.SyntaxTB(etype,evalue,[])
2181 self.SyntaxTB(etype,evalue,[])
2148 warn('Failure executing file: <%s>' % fname)
2182 warn('Failure executing file: <%s>' % fname)
2149 except SystemExit,status:
2183 except SystemExit,status:
2150 if not kw['exit_ignore']:
2184 if not kw['exit_ignore']:
2151 self.InteractiveTB()
2185 self.InteractiveTB()
2152 warn('Failure executing file: <%s>' % fname)
2186 warn('Failure executing file: <%s>' % fname)
2153 except:
2187 except:
2154 self.InteractiveTB()
2188 self.InteractiveTB()
2155 warn('Failure executing file: <%s>' % fname)
2189 warn('Failure executing file: <%s>' % fname)
2156
2190
2157 #************************* end of file <iplib.py> *****************************
2191 #************************* end of file <iplib.py> *****************************
@@ -1,4861 +1,4881 b''
1 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/iplib.py (raw_input): temporarily deactivate all
4 attempts at allowing pasting of code with autoindent on. It
5 introduced bugs (reported by Prabhu) and I can't seem to find a
6 robust combination which works in all cases. Will have to revisit
7 later.
8
9 * IPython/genutils.py: remove isspace() function. We've dropped
10 2.2 compatibility, so it's OK to use the string method.
11
12 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
13
14 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
15 matching what NOT to autocall on, to include all python binary
16 operators (including things like 'and', 'or', 'is' and 'in').
17 Prompted by a bug report on 'foo & bar', but I realized we had
18 many more potential bug cases with other operators. The regexp is
19 self.re_exclude_auto, it's fairly commented.
20
1 2006-01-12 Ville Vainio <vivainio@gmail.com>
21 2006-01-12 Ville Vainio <vivainio@gmail.com>
2
22
3 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
23 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
4 Prettified and hardened string/backslash quoting with ipsystem(),
24 Prettified and hardened string/backslash quoting with ipsystem(),
5 ipalias() and ipmagic(). Now even \ characters are passed to
25 ipalias() and ipmagic(). Now even \ characters are passed to
6 %magics, !shell escapes and aliases exactly as they are in the
26 %magics, !shell escapes and aliases exactly as they are in the
7 ipython command line. Should improve backslash experience,
27 ipython command line. Should improve backslash experience,
8 particularly in Windows (path delimiter for some commands that
28 particularly in Windows (path delimiter for some commands that
9 won't understand '/'), but Unix benefits as well (regexps). %cd
29 won't understand '/'), but Unix benefits as well (regexps). %cd
10 magic still doesn't support backslash path delimiters, though. Also
30 magic still doesn't support backslash path delimiters, though. Also
11 deleted all pretense of supporting multiline command strings in
31 deleted all pretense of supporting multiline command strings in
12 !system or %magic commands. Thanks to Jerry McRae for suggestions.
32 !system or %magic commands. Thanks to Jerry McRae for suggestions.
13
33
14 * doc/build_doc_instructions.txt added. Documentation on how to use
34 * doc/build_doc_instructions.txt added. Documentation on how to
15 doc/update_manual.py, added yesterday. Both files contributed by
35 use doc/update_manual.py, added yesterday. Both files contributed
16 Jörgen Stenarson <jorgen.stenarson@bostream.nu>. This slates
36 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
17 doc/*.sh for deprecation at a later date.
37 doc/*.sh for deprecation at a later date.
18
38
19 * /ipython.py Added ipython.py to root directory for
39 * /ipython.py Added ipython.py to root directory for
20 zero-installation (tar xzvf ipython.tgz; cd ipython; python
40 zero-installation (tar xzvf ipython.tgz; cd ipython; python
21 ipython.py) and development convenience (no need to kee doing
41 ipython.py) and development convenience (no need to kee doing
22 "setup.py install" between changes).
42 "setup.py install" between changes).
23
43
24 * Made ! and !! shell escapes work (again) in multiline expressions:
44 * Made ! and !! shell escapes work (again) in multiline expressions:
25 if 1:
45 if 1:
26 !ls
46 !ls
27 !!ls
47 !!ls
28
48
29 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
49 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
30
50
31 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
51 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
32 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
52 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
33 module in case-insensitive installation. Was causing crashes
53 module in case-insensitive installation. Was causing crashes
34 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
54 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
35
55
36 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
56 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
37 <marienz-AT-gentoo.org>, closes
57 <marienz-AT-gentoo.org>, closes
38 http://www.scipy.net/roundup/ipython/issue51.
58 http://www.scipy.net/roundup/ipython/issue51.
39
59
40 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
60 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
41
61
42 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
62 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
43 problem of excessive CPU usage under *nix and keyboard lag under
63 problem of excessive CPU usage under *nix and keyboard lag under
44 win32.
64 win32.
45
65
46 2006-01-10 *** Released version 0.7.0
66 2006-01-10 *** Released version 0.7.0
47
67
48 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
68 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
49
69
50 * IPython/Release.py (revision): tag version number to 0.7.0,
70 * IPython/Release.py (revision): tag version number to 0.7.0,
51 ready for release.
71 ready for release.
52
72
53 * IPython/Magic.py (magic_edit): Add print statement to %edit so
73 * IPython/Magic.py (magic_edit): Add print statement to %edit so
54 it informs the user of the name of the temp. file used. This can
74 it informs the user of the name of the temp. file used. This can
55 help if you decide later to reuse that same file, so you know
75 help if you decide later to reuse that same file, so you know
56 where to copy the info from.
76 where to copy the info from.
57
77
58 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
78 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
59
79
60 * setup_bdist_egg.py: little script to build an egg. Added
80 * setup_bdist_egg.py: little script to build an egg. Added
61 support in the release tools as well.
81 support in the release tools as well.
62
82
63 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
83 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
64
84
65 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
85 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
66 version selection (new -wxversion command line and ipythonrc
86 version selection (new -wxversion command line and ipythonrc
67 parameter). Patch contributed by Arnd Baecker
87 parameter). Patch contributed by Arnd Baecker
68 <arnd.baecker-AT-web.de>.
88 <arnd.baecker-AT-web.de>.
69
89
70 * IPython/iplib.py (embed_mainloop): fix tab-completion in
90 * IPython/iplib.py (embed_mainloop): fix tab-completion in
71 embedded instances, for variables defined at the interactive
91 embedded instances, for variables defined at the interactive
72 prompt of the embedded ipython. Reported by Arnd.
92 prompt of the embedded ipython. Reported by Arnd.
73
93
74 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
94 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
75 it can be used as a (stateful) toggle, or with a direct parameter.
95 it can be used as a (stateful) toggle, or with a direct parameter.
76
96
77 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
97 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
78 could be triggered in certain cases and cause the traceback
98 could be triggered in certain cases and cause the traceback
79 printer not to work.
99 printer not to work.
80
100
81 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
101 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
82
102
83 * IPython/iplib.py (_should_recompile): Small fix, closes
103 * IPython/iplib.py (_should_recompile): Small fix, closes
84 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
104 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
85
105
86 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
106 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
87
107
88 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
108 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
89 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
109 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
90 Moad for help with tracking it down.
110 Moad for help with tracking it down.
91
111
92 * IPython/iplib.py (handle_auto): fix autocall handling for
112 * IPython/iplib.py (handle_auto): fix autocall handling for
93 objects which support BOTH __getitem__ and __call__ (so that f [x]
113 objects which support BOTH __getitem__ and __call__ (so that f [x]
94 is left alone, instead of becoming f([x]) automatically).
114 is left alone, instead of becoming f([x]) automatically).
95
115
96 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
116 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
97 Ville's patch.
117 Ville's patch.
98
118
99 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
119 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
100
120
101 * IPython/iplib.py (handle_auto): changed autocall semantics to
121 * IPython/iplib.py (handle_auto): changed autocall semantics to
102 include 'smart' mode, where the autocall transformation is NOT
122 include 'smart' mode, where the autocall transformation is NOT
103 applied if there are no arguments on the line. This allows you to
123 applied if there are no arguments on the line. This allows you to
104 just type 'foo' if foo is a callable to see its internal form,
124 just type 'foo' if foo is a callable to see its internal form,
105 instead of having it called with no arguments (typically a
125 instead of having it called with no arguments (typically a
106 mistake). The old 'full' autocall still exists: for that, you
126 mistake). The old 'full' autocall still exists: for that, you
107 need to set the 'autocall' parameter to 2 in your ipythonrc file.
127 need to set the 'autocall' parameter to 2 in your ipythonrc file.
108
128
109 * IPython/completer.py (Completer.attr_matches): add
129 * IPython/completer.py (Completer.attr_matches): add
110 tab-completion support for Enthoughts' traits. After a report by
130 tab-completion support for Enthoughts' traits. After a report by
111 Arnd and a patch by Prabhu.
131 Arnd and a patch by Prabhu.
112
132
113 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
133 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
114
134
115 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
135 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
116 Schmolck's patch to fix inspect.getinnerframes().
136 Schmolck's patch to fix inspect.getinnerframes().
117
137
118 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
138 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
119 for embedded instances, regarding handling of namespaces and items
139 for embedded instances, regarding handling of namespaces and items
120 added to the __builtin__ one. Multiple embedded instances and
140 added to the __builtin__ one. Multiple embedded instances and
121 recursive embeddings should work better now (though I'm not sure
141 recursive embeddings should work better now (though I'm not sure
122 I've got all the corner cases fixed, that code is a bit of a brain
142 I've got all the corner cases fixed, that code is a bit of a brain
123 twister).
143 twister).
124
144
125 * IPython/Magic.py (magic_edit): added support to edit in-memory
145 * IPython/Magic.py (magic_edit): added support to edit in-memory
126 macros (automatically creates the necessary temp files). %edit
146 macros (automatically creates the necessary temp files). %edit
127 also doesn't return the file contents anymore, it's just noise.
147 also doesn't return the file contents anymore, it's just noise.
128
148
129 * IPython/completer.py (Completer.attr_matches): revert change to
149 * IPython/completer.py (Completer.attr_matches): revert change to
130 complete only on attributes listed in __all__. I realized it
150 complete only on attributes listed in __all__. I realized it
131 cripples the tab-completion system as a tool for exploring the
151 cripples the tab-completion system as a tool for exploring the
132 internals of unknown libraries (it renders any non-__all__
152 internals of unknown libraries (it renders any non-__all__
133 attribute off-limits). I got bit by this when trying to see
153 attribute off-limits). I got bit by this when trying to see
134 something inside the dis module.
154 something inside the dis module.
135
155
136 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
156 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
137
157
138 * IPython/iplib.py (InteractiveShell.__init__): add .meta
158 * IPython/iplib.py (InteractiveShell.__init__): add .meta
139 namespace for users and extension writers to hold data in. This
159 namespace for users and extension writers to hold data in. This
140 follows the discussion in
160 follows the discussion in
141 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
161 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
142
162
143 * IPython/completer.py (IPCompleter.complete): small patch to help
163 * IPython/completer.py (IPCompleter.complete): small patch to help
144 tab-completion under Emacs, after a suggestion by John Barnard
164 tab-completion under Emacs, after a suggestion by John Barnard
145 <barnarj-AT-ccf.org>.
165 <barnarj-AT-ccf.org>.
146
166
147 * IPython/Magic.py (Magic.extract_input_slices): added support for
167 * IPython/Magic.py (Magic.extract_input_slices): added support for
148 the slice notation in magics to use N-M to represent numbers N...M
168 the slice notation in magics to use N-M to represent numbers N...M
149 (closed endpoints). This is used by %macro and %save.
169 (closed endpoints). This is used by %macro and %save.
150
170
151 * IPython/completer.py (Completer.attr_matches): for modules which
171 * IPython/completer.py (Completer.attr_matches): for modules which
152 define __all__, complete only on those. After a patch by Jeffrey
172 define __all__, complete only on those. After a patch by Jeffrey
153 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
173 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
154 speed up this routine.
174 speed up this routine.
155
175
156 * IPython/Logger.py (Logger.log): fix a history handling bug. I
176 * IPython/Logger.py (Logger.log): fix a history handling bug. I
157 don't know if this is the end of it, but the behavior now is
177 don't know if this is the end of it, but the behavior now is
158 certainly much more correct. Note that coupled with macros,
178 certainly much more correct. Note that coupled with macros,
159 slightly surprising (at first) behavior may occur: a macro will in
179 slightly surprising (at first) behavior may occur: a macro will in
160 general expand to multiple lines of input, so upon exiting, the
180 general expand to multiple lines of input, so upon exiting, the
161 in/out counters will both be bumped by the corresponding amount
181 in/out counters will both be bumped by the corresponding amount
162 (as if the macro's contents had been typed interactively). Typing
182 (as if the macro's contents had been typed interactively). Typing
163 %hist will reveal the intermediate (silently processed) lines.
183 %hist will reveal the intermediate (silently processed) lines.
164
184
165 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
185 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
166 pickle to fail (%run was overwriting __main__ and not restoring
186 pickle to fail (%run was overwriting __main__ and not restoring
167 it, but pickle relies on __main__ to operate).
187 it, but pickle relies on __main__ to operate).
168
188
169 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
189 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
170 using properties, but forgot to make the main InteractiveShell
190 using properties, but forgot to make the main InteractiveShell
171 class a new-style class. Properties fail silently, and
191 class a new-style class. Properties fail silently, and
172 misteriously, with old-style class (getters work, but
192 misteriously, with old-style class (getters work, but
173 setters don't do anything).
193 setters don't do anything).
174
194
175 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
195 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
176
196
177 * IPython/Magic.py (magic_history): fix history reporting bug (I
197 * IPython/Magic.py (magic_history): fix history reporting bug (I
178 know some nasties are still there, I just can't seem to find a
198 know some nasties are still there, I just can't seem to find a
179 reproducible test case to track them down; the input history is
199 reproducible test case to track them down; the input history is
180 falling out of sync...)
200 falling out of sync...)
181
201
182 * IPython/iplib.py (handle_shell_escape): fix bug where both
202 * IPython/iplib.py (handle_shell_escape): fix bug where both
183 aliases and system accesses where broken for indented code (such
203 aliases and system accesses where broken for indented code (such
184 as loops).
204 as loops).
185
205
186 * IPython/genutils.py (shell): fix small but critical bug for
206 * IPython/genutils.py (shell): fix small but critical bug for
187 win32 system access.
207 win32 system access.
188
208
189 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
209 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
190
210
191 * IPython/iplib.py (showtraceback): remove use of the
211 * IPython/iplib.py (showtraceback): remove use of the
192 sys.last_{type/value/traceback} structures, which are non
212 sys.last_{type/value/traceback} structures, which are non
193 thread-safe.
213 thread-safe.
194 (_prefilter): change control flow to ensure that we NEVER
214 (_prefilter): change control flow to ensure that we NEVER
195 introspect objects when autocall is off. This will guarantee that
215 introspect objects when autocall is off. This will guarantee that
196 having an input line of the form 'x.y', where access to attribute
216 having an input line of the form 'x.y', where access to attribute
197 'y' has side effects, doesn't trigger the side effect TWICE. It
217 'y' has side effects, doesn't trigger the side effect TWICE. It
198 is important to note that, with autocall on, these side effects
218 is important to note that, with autocall on, these side effects
199 can still happen.
219 can still happen.
200 (ipsystem): new builtin, to complete the ip{magic/alias/system}
220 (ipsystem): new builtin, to complete the ip{magic/alias/system}
201 trio. IPython offers these three kinds of special calls which are
221 trio. IPython offers these three kinds of special calls which are
202 not python code, and it's a good thing to have their call method
222 not python code, and it's a good thing to have their call method
203 be accessible as pure python functions (not just special syntax at
223 be accessible as pure python functions (not just special syntax at
204 the command line). It gives us a better internal implementation
224 the command line). It gives us a better internal implementation
205 structure, as well as exposing these for user scripting more
225 structure, as well as exposing these for user scripting more
206 cleanly.
226 cleanly.
207
227
208 * IPython/macro.py (Macro.__init__): moved macros to a standalone
228 * IPython/macro.py (Macro.__init__): moved macros to a standalone
209 file. Now that they'll be more likely to be used with the
229 file. Now that they'll be more likely to be used with the
210 persistance system (%store), I want to make sure their module path
230 persistance system (%store), I want to make sure their module path
211 doesn't change in the future, so that we don't break things for
231 doesn't change in the future, so that we don't break things for
212 users' persisted data.
232 users' persisted data.
213
233
214 * IPython/iplib.py (autoindent_update): move indentation
234 * IPython/iplib.py (autoindent_update): move indentation
215 management into the _text_ processing loop, not the keyboard
235 management into the _text_ processing loop, not the keyboard
216 interactive one. This is necessary to correctly process non-typed
236 interactive one. This is necessary to correctly process non-typed
217 multiline input (such as macros).
237 multiline input (such as macros).
218
238
219 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
239 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
220 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
240 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
221 which was producing problems in the resulting manual.
241 which was producing problems in the resulting manual.
222 (magic_whos): improve reporting of instances (show their class,
242 (magic_whos): improve reporting of instances (show their class,
223 instead of simply printing 'instance' which isn't terribly
243 instead of simply printing 'instance' which isn't terribly
224 informative).
244 informative).
225
245
226 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
246 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
227 (minor mods) to support network shares under win32.
247 (minor mods) to support network shares under win32.
228
248
229 * IPython/winconsole.py (get_console_size): add new winconsole
249 * IPython/winconsole.py (get_console_size): add new winconsole
230 module and fixes to page_dumb() to improve its behavior under
250 module and fixes to page_dumb() to improve its behavior under
231 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
251 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
232
252
233 * IPython/Magic.py (Macro): simplified Macro class to just
253 * IPython/Magic.py (Macro): simplified Macro class to just
234 subclass list. We've had only 2.2 compatibility for a very long
254 subclass list. We've had only 2.2 compatibility for a very long
235 time, yet I was still avoiding subclassing the builtin types. No
255 time, yet I was still avoiding subclassing the builtin types. No
236 more (I'm also starting to use properties, though I won't shift to
256 more (I'm also starting to use properties, though I won't shift to
237 2.3-specific features quite yet).
257 2.3-specific features quite yet).
238 (magic_store): added Ville's patch for lightweight variable
258 (magic_store): added Ville's patch for lightweight variable
239 persistence, after a request on the user list by Matt Wilkie
259 persistence, after a request on the user list by Matt Wilkie
240 <maphew-AT-gmail.com>. The new %store magic's docstring has full
260 <maphew-AT-gmail.com>. The new %store magic's docstring has full
241 details.
261 details.
242
262
243 * IPython/iplib.py (InteractiveShell.post_config_initialization):
263 * IPython/iplib.py (InteractiveShell.post_config_initialization):
244 changed the default logfile name from 'ipython.log' to
264 changed the default logfile name from 'ipython.log' to
245 'ipython_log.py'. These logs are real python files, and now that
265 'ipython_log.py'. These logs are real python files, and now that
246 we have much better multiline support, people are more likely to
266 we have much better multiline support, people are more likely to
247 want to use them as such. Might as well name them correctly.
267 want to use them as such. Might as well name them correctly.
248
268
249 * IPython/Magic.py: substantial cleanup. While we can't stop
269 * IPython/Magic.py: substantial cleanup. While we can't stop
250 using magics as mixins, due to the existing customizations 'out
270 using magics as mixins, due to the existing customizations 'out
251 there' which rely on the mixin naming conventions, at least I
271 there' which rely on the mixin naming conventions, at least I
252 cleaned out all cross-class name usage. So once we are OK with
272 cleaned out all cross-class name usage. So once we are OK with
253 breaking compatibility, the two systems can be separated.
273 breaking compatibility, the two systems can be separated.
254
274
255 * IPython/Logger.py: major cleanup. This one is NOT a mixin
275 * IPython/Logger.py: major cleanup. This one is NOT a mixin
256 anymore, and the class is a fair bit less hideous as well. New
276 anymore, and the class is a fair bit less hideous as well. New
257 features were also introduced: timestamping of input, and logging
277 features were also introduced: timestamping of input, and logging
258 of output results. These are user-visible with the -t and -o
278 of output results. These are user-visible with the -t and -o
259 options to %logstart. Closes
279 options to %logstart. Closes
260 http://www.scipy.net/roundup/ipython/issue11 and a request by
280 http://www.scipy.net/roundup/ipython/issue11 and a request by
261 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
281 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
262
282
263 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
283 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
264
284
265 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
285 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
266 better hadnle backslashes in paths. See the thread 'More Windows
286 better hadnle backslashes in paths. See the thread 'More Windows
267 questions part 2 - \/ characters revisited' on the iypthon user
287 questions part 2 - \/ characters revisited' on the iypthon user
268 list:
288 list:
269 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
289 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
270
290
271 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
291 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
272
292
273 (InteractiveShell.__init__): change threaded shells to not use the
293 (InteractiveShell.__init__): change threaded shells to not use the
274 ipython crash handler. This was causing more problems than not,
294 ipython crash handler. This was causing more problems than not,
275 as exceptions in the main thread (GUI code, typically) would
295 as exceptions in the main thread (GUI code, typically) would
276 always show up as a 'crash', when they really weren't.
296 always show up as a 'crash', when they really weren't.
277
297
278 The colors and exception mode commands (%colors/%xmode) have been
298 The colors and exception mode commands (%colors/%xmode) have been
279 synchronized to also take this into account, so users can get
299 synchronized to also take this into account, so users can get
280 verbose exceptions for their threaded code as well. I also added
300 verbose exceptions for their threaded code as well. I also added
281 support for activating pdb inside this exception handler as well,
301 support for activating pdb inside this exception handler as well,
282 so now GUI authors can use IPython's enhanced pdb at runtime.
302 so now GUI authors can use IPython's enhanced pdb at runtime.
283
303
284 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
304 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
285 true by default, and add it to the shipped ipythonrc file. Since
305 true by default, and add it to the shipped ipythonrc file. Since
286 this asks the user before proceeding, I think it's OK to make it
306 this asks the user before proceeding, I think it's OK to make it
287 true by default.
307 true by default.
288
308
289 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
309 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
290 of the previous special-casing of input in the eval loop. I think
310 of the previous special-casing of input in the eval loop. I think
291 this is cleaner, as they really are commands and shouldn't have
311 this is cleaner, as they really are commands and shouldn't have
292 a special role in the middle of the core code.
312 a special role in the middle of the core code.
293
313
294 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
314 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
295
315
296 * IPython/iplib.py (edit_syntax_error): added support for
316 * IPython/iplib.py (edit_syntax_error): added support for
297 automatically reopening the editor if the file had a syntax error
317 automatically reopening the editor if the file had a syntax error
298 in it. Thanks to scottt who provided the patch at:
318 in it. Thanks to scottt who provided the patch at:
299 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
319 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
300 version committed).
320 version committed).
301
321
302 * IPython/iplib.py (handle_normal): add suport for multi-line
322 * IPython/iplib.py (handle_normal): add suport for multi-line
303 input with emtpy lines. This fixes
323 input with emtpy lines. This fixes
304 http://www.scipy.net/roundup/ipython/issue43 and a similar
324 http://www.scipy.net/roundup/ipython/issue43 and a similar
305 discussion on the user list.
325 discussion on the user list.
306
326
307 WARNING: a behavior change is necessarily introduced to support
327 WARNING: a behavior change is necessarily introduced to support
308 blank lines: now a single blank line with whitespace does NOT
328 blank lines: now a single blank line with whitespace does NOT
309 break the input loop, which means that when autoindent is on, by
329 break the input loop, which means that when autoindent is on, by
310 default hitting return on the next (indented) line does NOT exit.
330 default hitting return on the next (indented) line does NOT exit.
311
331
312 Instead, to exit a multiline input you can either have:
332 Instead, to exit a multiline input you can either have:
313
333
314 - TWO whitespace lines (just hit return again), or
334 - TWO whitespace lines (just hit return again), or
315 - a single whitespace line of a different length than provided
335 - a single whitespace line of a different length than provided
316 by the autoindent (add or remove a space).
336 by the autoindent (add or remove a space).
317
337
318 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
338 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
319 module to better organize all readline-related functionality.
339 module to better organize all readline-related functionality.
320 I've deleted FlexCompleter and put all completion clases here.
340 I've deleted FlexCompleter and put all completion clases here.
321
341
322 * IPython/iplib.py (raw_input): improve indentation management.
342 * IPython/iplib.py (raw_input): improve indentation management.
323 It is now possible to paste indented code with autoindent on, and
343 It is now possible to paste indented code with autoindent on, and
324 the code is interpreted correctly (though it still looks bad on
344 the code is interpreted correctly (though it still looks bad on
325 screen, due to the line-oriented nature of ipython).
345 screen, due to the line-oriented nature of ipython).
326 (MagicCompleter.complete): change behavior so that a TAB key on an
346 (MagicCompleter.complete): change behavior so that a TAB key on an
327 otherwise empty line actually inserts a tab, instead of completing
347 otherwise empty line actually inserts a tab, instead of completing
328 on the entire global namespace. This makes it easier to use the
348 on the entire global namespace. This makes it easier to use the
329 TAB key for indentation. After a request by Hans Meine
349 TAB key for indentation. After a request by Hans Meine
330 <hans_meine-AT-gmx.net>
350 <hans_meine-AT-gmx.net>
331 (_prefilter): add support so that typing plain 'exit' or 'quit'
351 (_prefilter): add support so that typing plain 'exit' or 'quit'
332 does a sensible thing. Originally I tried to deviate as little as
352 does a sensible thing. Originally I tried to deviate as little as
333 possible from the default python behavior, but even that one may
353 possible from the default python behavior, but even that one may
334 change in this direction (thread on python-dev to that effect).
354 change in this direction (thread on python-dev to that effect).
335 Regardless, ipython should do the right thing even if CPython's
355 Regardless, ipython should do the right thing even if CPython's
336 '>>>' prompt doesn't.
356 '>>>' prompt doesn't.
337 (InteractiveShell): removed subclassing code.InteractiveConsole
357 (InteractiveShell): removed subclassing code.InteractiveConsole
338 class. By now we'd overridden just about all of its methods: I've
358 class. By now we'd overridden just about all of its methods: I've
339 copied the remaining two over, and now ipython is a standalone
359 copied the remaining two over, and now ipython is a standalone
340 class. This will provide a clearer picture for the chainsaw
360 class. This will provide a clearer picture for the chainsaw
341 branch refactoring.
361 branch refactoring.
342
362
343 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
363 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
344
364
345 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
365 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
346 failures for objects which break when dir() is called on them.
366 failures for objects which break when dir() is called on them.
347
367
348 * IPython/FlexCompleter.py (Completer.__init__): Added support for
368 * IPython/FlexCompleter.py (Completer.__init__): Added support for
349 distinct local and global namespaces in the completer API. This
369 distinct local and global namespaces in the completer API. This
350 change allows us top properly handle completion with distinct
370 change allows us top properly handle completion with distinct
351 scopes, including in embedded instances (this had never really
371 scopes, including in embedded instances (this had never really
352 worked correctly).
372 worked correctly).
353
373
354 Note: this introduces a change in the constructor for
374 Note: this introduces a change in the constructor for
355 MagicCompleter, as a new global_namespace parameter is now the
375 MagicCompleter, as a new global_namespace parameter is now the
356 second argument (the others were bumped one position).
376 second argument (the others were bumped one position).
357
377
358 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
378 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
359
379
360 * IPython/iplib.py (embed_mainloop): fix tab-completion in
380 * IPython/iplib.py (embed_mainloop): fix tab-completion in
361 embedded instances (which can be done now thanks to Vivian's
381 embedded instances (which can be done now thanks to Vivian's
362 frame-handling fixes for pdb).
382 frame-handling fixes for pdb).
363 (InteractiveShell.__init__): Fix namespace handling problem in
383 (InteractiveShell.__init__): Fix namespace handling problem in
364 embedded instances. We were overwriting __main__ unconditionally,
384 embedded instances. We were overwriting __main__ unconditionally,
365 and this should only be done for 'full' (non-embedded) IPython;
385 and this should only be done for 'full' (non-embedded) IPython;
366 embedded instances must respect the caller's __main__. Thanks to
386 embedded instances must respect the caller's __main__. Thanks to
367 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
387 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
368
388
369 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
389 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
370
390
371 * setup.py: added download_url to setup(). This registers the
391 * setup.py: added download_url to setup(). This registers the
372 download address at PyPI, which is not only useful to humans
392 download address at PyPI, which is not only useful to humans
373 browsing the site, but is also picked up by setuptools (the Eggs
393 browsing the site, but is also picked up by setuptools (the Eggs
374 machinery). Thanks to Ville and R. Kern for the info/discussion
394 machinery). Thanks to Ville and R. Kern for the info/discussion
375 on this.
395 on this.
376
396
377 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
397 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
378
398
379 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
399 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
380 This brings a lot of nice functionality to the pdb mode, which now
400 This brings a lot of nice functionality to the pdb mode, which now
381 has tab-completion, syntax highlighting, and better stack handling
401 has tab-completion, syntax highlighting, and better stack handling
382 than before. Many thanks to Vivian De Smedt
402 than before. Many thanks to Vivian De Smedt
383 <vivian-AT-vdesmedt.com> for the original patches.
403 <vivian-AT-vdesmedt.com> for the original patches.
384
404
385 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
405 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
386
406
387 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
407 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
388 sequence to consistently accept the banner argument. The
408 sequence to consistently accept the banner argument. The
389 inconsistency was tripping SAGE, thanks to Gary Zablackis
409 inconsistency was tripping SAGE, thanks to Gary Zablackis
390 <gzabl-AT-yahoo.com> for the report.
410 <gzabl-AT-yahoo.com> for the report.
391
411
392 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
412 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
393
413
394 * IPython/iplib.py (InteractiveShell.post_config_initialization):
414 * IPython/iplib.py (InteractiveShell.post_config_initialization):
395 Fix bug where a naked 'alias' call in the ipythonrc file would
415 Fix bug where a naked 'alias' call in the ipythonrc file would
396 cause a crash. Bug reported by Jorgen Stenarson.
416 cause a crash. Bug reported by Jorgen Stenarson.
397
417
398 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
418 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
399
419
400 * IPython/ipmaker.py (make_IPython): cleanups which should improve
420 * IPython/ipmaker.py (make_IPython): cleanups which should improve
401 startup time.
421 startup time.
402
422
403 * IPython/iplib.py (runcode): my globals 'fix' for embedded
423 * IPython/iplib.py (runcode): my globals 'fix' for embedded
404 instances had introduced a bug with globals in normal code. Now
424 instances had introduced a bug with globals in normal code. Now
405 it's working in all cases.
425 it's working in all cases.
406
426
407 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
427 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
408 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
428 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
409 has been introduced to set the default case sensitivity of the
429 has been introduced to set the default case sensitivity of the
410 searches. Users can still select either mode at runtime on a
430 searches. Users can still select either mode at runtime on a
411 per-search basis.
431 per-search basis.
412
432
413 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
433 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
414
434
415 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
435 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
416 attributes in wildcard searches for subclasses. Modified version
436 attributes in wildcard searches for subclasses. Modified version
417 of a patch by Jorgen.
437 of a patch by Jorgen.
418
438
419 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
439 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
420
440
421 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
441 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
422 embedded instances. I added a user_global_ns attribute to the
442 embedded instances. I added a user_global_ns attribute to the
423 InteractiveShell class to handle this.
443 InteractiveShell class to handle this.
424
444
425 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
445 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
426
446
427 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
447 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
428 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
448 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
429 (reported under win32, but may happen also in other platforms).
449 (reported under win32, but may happen also in other platforms).
430 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
450 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
431
451
432 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
452 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
433
453
434 * IPython/Magic.py (magic_psearch): new support for wildcard
454 * IPython/Magic.py (magic_psearch): new support for wildcard
435 patterns. Now, typing ?a*b will list all names which begin with a
455 patterns. Now, typing ?a*b will list all names which begin with a
436 and end in b, for example. The %psearch magic has full
456 and end in b, for example. The %psearch magic has full
437 docstrings. Many thanks to Jörgen Stenarson
457 docstrings. Many thanks to Jörgen Stenarson
438 <jorgen.stenarson-AT-bostream.nu>, author of the patches
458 <jorgen.stenarson-AT-bostream.nu>, author of the patches
439 implementing this functionality.
459 implementing this functionality.
440
460
441 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
461 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
442
462
443 * Manual: fixed long-standing annoyance of double-dashes (as in
463 * Manual: fixed long-standing annoyance of double-dashes (as in
444 --prefix=~, for example) being stripped in the HTML version. This
464 --prefix=~, for example) being stripped in the HTML version. This
445 is a latex2html bug, but a workaround was provided. Many thanks
465 is a latex2html bug, but a workaround was provided. Many thanks
446 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
466 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
447 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
467 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
448 rolling. This seemingly small issue had tripped a number of users
468 rolling. This seemingly small issue had tripped a number of users
449 when first installing, so I'm glad to see it gone.
469 when first installing, so I'm glad to see it gone.
450
470
451 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
471 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
452
472
453 * IPython/Extensions/numeric_formats.py: fix missing import,
473 * IPython/Extensions/numeric_formats.py: fix missing import,
454 reported by Stephen Walton.
474 reported by Stephen Walton.
455
475
456 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
476 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
457
477
458 * IPython/demo.py: finish demo module, fully documented now.
478 * IPython/demo.py: finish demo module, fully documented now.
459
479
460 * IPython/genutils.py (file_read): simple little utility to read a
480 * IPython/genutils.py (file_read): simple little utility to read a
461 file and ensure it's closed afterwards.
481 file and ensure it's closed afterwards.
462
482
463 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
483 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
464
484
465 * IPython/demo.py (Demo.__init__): added support for individually
485 * IPython/demo.py (Demo.__init__): added support for individually
466 tagging blocks for automatic execution.
486 tagging blocks for automatic execution.
467
487
468 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
488 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
469 syntax-highlighted python sources, requested by John.
489 syntax-highlighted python sources, requested by John.
470
490
471 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
491 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
472
492
473 * IPython/demo.py (Demo.again): fix bug where again() blocks after
493 * IPython/demo.py (Demo.again): fix bug where again() blocks after
474 finishing.
494 finishing.
475
495
476 * IPython/genutils.py (shlex_split): moved from Magic to here,
496 * IPython/genutils.py (shlex_split): moved from Magic to here,
477 where all 2.2 compatibility stuff lives. I needed it for demo.py.
497 where all 2.2 compatibility stuff lives. I needed it for demo.py.
478
498
479 * IPython/demo.py (Demo.__init__): added support for silent
499 * IPython/demo.py (Demo.__init__): added support for silent
480 blocks, improved marks as regexps, docstrings written.
500 blocks, improved marks as regexps, docstrings written.
481 (Demo.__init__): better docstring, added support for sys.argv.
501 (Demo.__init__): better docstring, added support for sys.argv.
482
502
483 * IPython/genutils.py (marquee): little utility used by the demo
503 * IPython/genutils.py (marquee): little utility used by the demo
484 code, handy in general.
504 code, handy in general.
485
505
486 * IPython/demo.py (Demo.__init__): new class for interactive
506 * IPython/demo.py (Demo.__init__): new class for interactive
487 demos. Not documented yet, I just wrote it in a hurry for
507 demos. Not documented yet, I just wrote it in a hurry for
488 scipy'05. Will docstring later.
508 scipy'05. Will docstring later.
489
509
490 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
510 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
491
511
492 * IPython/Shell.py (sigint_handler): Drastic simplification which
512 * IPython/Shell.py (sigint_handler): Drastic simplification which
493 also seems to make Ctrl-C work correctly across threads! This is
513 also seems to make Ctrl-C work correctly across threads! This is
494 so simple, that I can't beleive I'd missed it before. Needs more
514 so simple, that I can't beleive I'd missed it before. Needs more
495 testing, though.
515 testing, though.
496 (KBINT): Never mind, revert changes. I'm sure I'd tried something
516 (KBINT): Never mind, revert changes. I'm sure I'd tried something
497 like this before...
517 like this before...
498
518
499 * IPython/genutils.py (get_home_dir): add protection against
519 * IPython/genutils.py (get_home_dir): add protection against
500 non-dirs in win32 registry.
520 non-dirs in win32 registry.
501
521
502 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
522 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
503 bug where dict was mutated while iterating (pysh crash).
523 bug where dict was mutated while iterating (pysh crash).
504
524
505 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
525 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
506
526
507 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
527 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
508 spurious newlines added by this routine. After a report by
528 spurious newlines added by this routine. After a report by
509 F. Mantegazza.
529 F. Mantegazza.
510
530
511 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
531 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
512
532
513 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
533 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
514 calls. These were a leftover from the GTK 1.x days, and can cause
534 calls. These were a leftover from the GTK 1.x days, and can cause
515 problems in certain cases (after a report by John Hunter).
535 problems in certain cases (after a report by John Hunter).
516
536
517 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
537 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
518 os.getcwd() fails at init time. Thanks to patch from David Remahl
538 os.getcwd() fails at init time. Thanks to patch from David Remahl
519 <chmod007-AT-mac.com>.
539 <chmod007-AT-mac.com>.
520 (InteractiveShell.__init__): prevent certain special magics from
540 (InteractiveShell.__init__): prevent certain special magics from
521 being shadowed by aliases. Closes
541 being shadowed by aliases. Closes
522 http://www.scipy.net/roundup/ipython/issue41.
542 http://www.scipy.net/roundup/ipython/issue41.
523
543
524 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
544 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
525
545
526 * IPython/iplib.py (InteractiveShell.complete): Added new
546 * IPython/iplib.py (InteractiveShell.complete): Added new
527 top-level completion method to expose the completion mechanism
547 top-level completion method to expose the completion mechanism
528 beyond readline-based environments.
548 beyond readline-based environments.
529
549
530 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
550 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
531
551
532 * tools/ipsvnc (svnversion): fix svnversion capture.
552 * tools/ipsvnc (svnversion): fix svnversion capture.
533
553
534 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
554 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
535 attribute to self, which was missing. Before, it was set by a
555 attribute to self, which was missing. Before, it was set by a
536 routine which in certain cases wasn't being called, so the
556 routine which in certain cases wasn't being called, so the
537 instance could end up missing the attribute. This caused a crash.
557 instance could end up missing the attribute. This caused a crash.
538 Closes http://www.scipy.net/roundup/ipython/issue40.
558 Closes http://www.scipy.net/roundup/ipython/issue40.
539
559
540 2005-08-16 Fernando Perez <fperez@colorado.edu>
560 2005-08-16 Fernando Perez <fperez@colorado.edu>
541
561
542 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
562 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
543 contains non-string attribute. Closes
563 contains non-string attribute. Closes
544 http://www.scipy.net/roundup/ipython/issue38.
564 http://www.scipy.net/roundup/ipython/issue38.
545
565
546 2005-08-14 Fernando Perez <fperez@colorado.edu>
566 2005-08-14 Fernando Perez <fperez@colorado.edu>
547
567
548 * tools/ipsvnc: Minor improvements, to add changeset info.
568 * tools/ipsvnc: Minor improvements, to add changeset info.
549
569
550 2005-08-12 Fernando Perez <fperez@colorado.edu>
570 2005-08-12 Fernando Perez <fperez@colorado.edu>
551
571
552 * IPython/iplib.py (runsource): remove self.code_to_run_src
572 * IPython/iplib.py (runsource): remove self.code_to_run_src
553 attribute. I realized this is nothing more than
573 attribute. I realized this is nothing more than
554 '\n'.join(self.buffer), and having the same data in two different
574 '\n'.join(self.buffer), and having the same data in two different
555 places is just asking for synchronization bugs. This may impact
575 places is just asking for synchronization bugs. This may impact
556 people who have custom exception handlers, so I need to warn
576 people who have custom exception handlers, so I need to warn
557 ipython-dev about it (F. Mantegazza may use them).
577 ipython-dev about it (F. Mantegazza may use them).
558
578
559 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
579 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
560
580
561 * IPython/genutils.py: fix 2.2 compatibility (generators)
581 * IPython/genutils.py: fix 2.2 compatibility (generators)
562
582
563 2005-07-18 Fernando Perez <fperez@colorado.edu>
583 2005-07-18 Fernando Perez <fperez@colorado.edu>
564
584
565 * IPython/genutils.py (get_home_dir): fix to help users with
585 * IPython/genutils.py (get_home_dir): fix to help users with
566 invalid $HOME under win32.
586 invalid $HOME under win32.
567
587
568 2005-07-17 Fernando Perez <fperez@colorado.edu>
588 2005-07-17 Fernando Perez <fperez@colorado.edu>
569
589
570 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
590 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
571 some old hacks and clean up a bit other routines; code should be
591 some old hacks and clean up a bit other routines; code should be
572 simpler and a bit faster.
592 simpler and a bit faster.
573
593
574 * IPython/iplib.py (interact): removed some last-resort attempts
594 * IPython/iplib.py (interact): removed some last-resort attempts
575 to survive broken stdout/stderr. That code was only making it
595 to survive broken stdout/stderr. That code was only making it
576 harder to abstract out the i/o (necessary for gui integration),
596 harder to abstract out the i/o (necessary for gui integration),
577 and the crashes it could prevent were extremely rare in practice
597 and the crashes it could prevent were extremely rare in practice
578 (besides being fully user-induced in a pretty violent manner).
598 (besides being fully user-induced in a pretty violent manner).
579
599
580 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
600 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
581 Nothing major yet, but the code is simpler to read; this should
601 Nothing major yet, but the code is simpler to read; this should
582 make it easier to do more serious modifications in the future.
602 make it easier to do more serious modifications in the future.
583
603
584 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
604 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
585 which broke in .15 (thanks to a report by Ville).
605 which broke in .15 (thanks to a report by Ville).
586
606
587 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
607 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
588 be quite correct, I know next to nothing about unicode). This
608 be quite correct, I know next to nothing about unicode). This
589 will allow unicode strings to be used in prompts, amongst other
609 will allow unicode strings to be used in prompts, amongst other
590 cases. It also will prevent ipython from crashing when unicode
610 cases. It also will prevent ipython from crashing when unicode
591 shows up unexpectedly in many places. If ascii encoding fails, we
611 shows up unexpectedly in many places. If ascii encoding fails, we
592 assume utf_8. Currently the encoding is not a user-visible
612 assume utf_8. Currently the encoding is not a user-visible
593 setting, though it could be made so if there is demand for it.
613 setting, though it could be made so if there is demand for it.
594
614
595 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
615 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
596
616
597 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
617 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
598
618
599 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
619 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
600
620
601 * IPython/genutils.py: Add 2.2 compatibility here, so all other
621 * IPython/genutils.py: Add 2.2 compatibility here, so all other
602 code can work transparently for 2.2/2.3.
622 code can work transparently for 2.2/2.3.
603
623
604 2005-07-16 Fernando Perez <fperez@colorado.edu>
624 2005-07-16 Fernando Perez <fperez@colorado.edu>
605
625
606 * IPython/ultraTB.py (ExceptionColors): Make a global variable
626 * IPython/ultraTB.py (ExceptionColors): Make a global variable
607 out of the color scheme table used for coloring exception
627 out of the color scheme table used for coloring exception
608 tracebacks. This allows user code to add new schemes at runtime.
628 tracebacks. This allows user code to add new schemes at runtime.
609 This is a minimally modified version of the patch at
629 This is a minimally modified version of the patch at
610 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
630 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
611 for the contribution.
631 for the contribution.
612
632
613 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
633 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
614 slightly modified version of the patch in
634 slightly modified version of the patch in
615 http://www.scipy.net/roundup/ipython/issue34, which also allows me
635 http://www.scipy.net/roundup/ipython/issue34, which also allows me
616 to remove the previous try/except solution (which was costlier).
636 to remove the previous try/except solution (which was costlier).
617 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
637 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
618
638
619 2005-06-08 Fernando Perez <fperez@colorado.edu>
639 2005-06-08 Fernando Perez <fperez@colorado.edu>
620
640
621 * IPython/iplib.py (write/write_err): Add methods to abstract all
641 * IPython/iplib.py (write/write_err): Add methods to abstract all
622 I/O a bit more.
642 I/O a bit more.
623
643
624 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
644 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
625 warning, reported by Aric Hagberg, fix by JD Hunter.
645 warning, reported by Aric Hagberg, fix by JD Hunter.
626
646
627 2005-06-02 *** Released version 0.6.15
647 2005-06-02 *** Released version 0.6.15
628
648
629 2005-06-01 Fernando Perez <fperez@colorado.edu>
649 2005-06-01 Fernando Perez <fperez@colorado.edu>
630
650
631 * IPython/iplib.py (MagicCompleter.file_matches): Fix
651 * IPython/iplib.py (MagicCompleter.file_matches): Fix
632 tab-completion of filenames within open-quoted strings. Note that
652 tab-completion of filenames within open-quoted strings. Note that
633 this requires that in ~/.ipython/ipythonrc, users change the
653 this requires that in ~/.ipython/ipythonrc, users change the
634 readline delimiters configuration to read:
654 readline delimiters configuration to read:
635
655
636 readline_remove_delims -/~
656 readline_remove_delims -/~
637
657
638
658
639 2005-05-31 *** Released version 0.6.14
659 2005-05-31 *** Released version 0.6.14
640
660
641 2005-05-29 Fernando Perez <fperez@colorado.edu>
661 2005-05-29 Fernando Perez <fperez@colorado.edu>
642
662
643 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
663 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
644 with files not on the filesystem. Reported by Eliyahu Sandler
664 with files not on the filesystem. Reported by Eliyahu Sandler
645 <eli@gondolin.net>
665 <eli@gondolin.net>
646
666
647 2005-05-22 Fernando Perez <fperez@colorado.edu>
667 2005-05-22 Fernando Perez <fperez@colorado.edu>
648
668
649 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
669 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
650 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
670 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
651
671
652 2005-05-19 Fernando Perez <fperez@colorado.edu>
672 2005-05-19 Fernando Perez <fperez@colorado.edu>
653
673
654 * IPython/iplib.py (safe_execfile): close a file which could be
674 * IPython/iplib.py (safe_execfile): close a file which could be
655 left open (causing problems in win32, which locks open files).
675 left open (causing problems in win32, which locks open files).
656 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
676 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
657
677
658 2005-05-18 Fernando Perez <fperez@colorado.edu>
678 2005-05-18 Fernando Perez <fperez@colorado.edu>
659
679
660 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
680 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
661 keyword arguments correctly to safe_execfile().
681 keyword arguments correctly to safe_execfile().
662
682
663 2005-05-13 Fernando Perez <fperez@colorado.edu>
683 2005-05-13 Fernando Perez <fperez@colorado.edu>
664
684
665 * ipython.1: Added info about Qt to manpage, and threads warning
685 * ipython.1: Added info about Qt to manpage, and threads warning
666 to usage page (invoked with --help).
686 to usage page (invoked with --help).
667
687
668 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
688 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
669 new matcher (it goes at the end of the priority list) to do
689 new matcher (it goes at the end of the priority list) to do
670 tab-completion on named function arguments. Submitted by George
690 tab-completion on named function arguments. Submitted by George
671 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
691 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
672 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
692 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
673 for more details.
693 for more details.
674
694
675 * IPython/Magic.py (magic_run): Added new -e flag to ignore
695 * IPython/Magic.py (magic_run): Added new -e flag to ignore
676 SystemExit exceptions in the script being run. Thanks to a report
696 SystemExit exceptions in the script being run. Thanks to a report
677 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
697 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
678 producing very annoying behavior when running unit tests.
698 producing very annoying behavior when running unit tests.
679
699
680 2005-05-12 Fernando Perez <fperez@colorado.edu>
700 2005-05-12 Fernando Perez <fperez@colorado.edu>
681
701
682 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
702 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
683 which I'd broken (again) due to a changed regexp. In the process,
703 which I'd broken (again) due to a changed regexp. In the process,
684 added ';' as an escape to auto-quote the whole line without
704 added ';' as an escape to auto-quote the whole line without
685 splitting its arguments. Thanks to a report by Jerry McRae
705 splitting its arguments. Thanks to a report by Jerry McRae
686 <qrs0xyc02-AT-sneakemail.com>.
706 <qrs0xyc02-AT-sneakemail.com>.
687
707
688 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
708 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
689 possible crashes caused by a TokenError. Reported by Ed Schofield
709 possible crashes caused by a TokenError. Reported by Ed Schofield
690 <schofield-AT-ftw.at>.
710 <schofield-AT-ftw.at>.
691
711
692 2005-05-06 Fernando Perez <fperez@colorado.edu>
712 2005-05-06 Fernando Perez <fperez@colorado.edu>
693
713
694 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
714 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
695
715
696 2005-04-29 Fernando Perez <fperez@colorado.edu>
716 2005-04-29 Fernando Perez <fperez@colorado.edu>
697
717
698 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
718 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
699 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
719 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
700 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
720 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
701 which provides support for Qt interactive usage (similar to the
721 which provides support for Qt interactive usage (similar to the
702 existing one for WX and GTK). This had been often requested.
722 existing one for WX and GTK). This had been often requested.
703
723
704 2005-04-14 *** Released version 0.6.13
724 2005-04-14 *** Released version 0.6.13
705
725
706 2005-04-08 Fernando Perez <fperez@colorado.edu>
726 2005-04-08 Fernando Perez <fperez@colorado.edu>
707
727
708 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
728 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
709 from _ofind, which gets called on almost every input line. Now,
729 from _ofind, which gets called on almost every input line. Now,
710 we only try to get docstrings if they are actually going to be
730 we only try to get docstrings if they are actually going to be
711 used (the overhead of fetching unnecessary docstrings can be
731 used (the overhead of fetching unnecessary docstrings can be
712 noticeable for certain objects, such as Pyro proxies).
732 noticeable for certain objects, such as Pyro proxies).
713
733
714 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
734 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
715 for completers. For some reason I had been passing them the state
735 for completers. For some reason I had been passing them the state
716 variable, which completers never actually need, and was in
736 variable, which completers never actually need, and was in
717 conflict with the rlcompleter API. Custom completers ONLY need to
737 conflict with the rlcompleter API. Custom completers ONLY need to
718 take the text parameter.
738 take the text parameter.
719
739
720 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
740 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
721 work correctly in pysh. I've also moved all the logic which used
741 work correctly in pysh. I've also moved all the logic which used
722 to be in pysh.py here, which will prevent problems with future
742 to be in pysh.py here, which will prevent problems with future
723 upgrades. However, this time I must warn users to update their
743 upgrades. However, this time I must warn users to update their
724 pysh profile to include the line
744 pysh profile to include the line
725
745
726 import_all IPython.Extensions.InterpreterExec
746 import_all IPython.Extensions.InterpreterExec
727
747
728 because otherwise things won't work for them. They MUST also
748 because otherwise things won't work for them. They MUST also
729 delete pysh.py and the line
749 delete pysh.py and the line
730
750
731 execfile pysh.py
751 execfile pysh.py
732
752
733 from their ipythonrc-pysh.
753 from their ipythonrc-pysh.
734
754
735 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
755 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
736 robust in the face of objects whose dir() returns non-strings
756 robust in the face of objects whose dir() returns non-strings
737 (which it shouldn't, but some broken libs like ITK do). Thanks to
757 (which it shouldn't, but some broken libs like ITK do). Thanks to
738 a patch by John Hunter (implemented differently, though). Also
758 a patch by John Hunter (implemented differently, though). Also
739 minor improvements by using .extend instead of + on lists.
759 minor improvements by using .extend instead of + on lists.
740
760
741 * pysh.py:
761 * pysh.py:
742
762
743 2005-04-06 Fernando Perez <fperez@colorado.edu>
763 2005-04-06 Fernando Perez <fperez@colorado.edu>
744
764
745 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
765 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
746 by default, so that all users benefit from it. Those who don't
766 by default, so that all users benefit from it. Those who don't
747 want it can still turn it off.
767 want it can still turn it off.
748
768
749 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
769 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
750 config file, I'd forgotten about this, so users were getting it
770 config file, I'd forgotten about this, so users were getting it
751 off by default.
771 off by default.
752
772
753 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
773 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
754 consistency. Now magics can be called in multiline statements,
774 consistency. Now magics can be called in multiline statements,
755 and python variables can be expanded in magic calls via $var.
775 and python variables can be expanded in magic calls via $var.
756 This makes the magic system behave just like aliases or !system
776 This makes the magic system behave just like aliases or !system
757 calls.
777 calls.
758
778
759 2005-03-28 Fernando Perez <fperez@colorado.edu>
779 2005-03-28 Fernando Perez <fperez@colorado.edu>
760
780
761 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
781 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
762 expensive string additions for building command. Add support for
782 expensive string additions for building command. Add support for
763 trailing ';' when autocall is used.
783 trailing ';' when autocall is used.
764
784
765 2005-03-26 Fernando Perez <fperez@colorado.edu>
785 2005-03-26 Fernando Perez <fperez@colorado.edu>
766
786
767 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
787 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
768 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
788 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
769 ipython.el robust against prompts with any number of spaces
789 ipython.el robust against prompts with any number of spaces
770 (including 0) after the ':' character.
790 (including 0) after the ':' character.
771
791
772 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
792 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
773 continuation prompt, which misled users to think the line was
793 continuation prompt, which misled users to think the line was
774 already indented. Closes debian Bug#300847, reported to me by
794 already indented. Closes debian Bug#300847, reported to me by
775 Norbert Tretkowski <tretkowski-AT-inittab.de>.
795 Norbert Tretkowski <tretkowski-AT-inittab.de>.
776
796
777 2005-03-23 Fernando Perez <fperez@colorado.edu>
797 2005-03-23 Fernando Perez <fperez@colorado.edu>
778
798
779 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
799 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
780 properly aligned if they have embedded newlines.
800 properly aligned if they have embedded newlines.
781
801
782 * IPython/iplib.py (runlines): Add a public method to expose
802 * IPython/iplib.py (runlines): Add a public method to expose
783 IPython's code execution machinery, so that users can run strings
803 IPython's code execution machinery, so that users can run strings
784 as if they had been typed at the prompt interactively.
804 as if they had been typed at the prompt interactively.
785 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
805 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
786 methods which can call the system shell, but with python variable
806 methods which can call the system shell, but with python variable
787 expansion. The three such methods are: __IPYTHON__.system,
807 expansion. The three such methods are: __IPYTHON__.system,
788 .getoutput and .getoutputerror. These need to be documented in a
808 .getoutput and .getoutputerror. These need to be documented in a
789 'public API' section (to be written) of the manual.
809 'public API' section (to be written) of the manual.
790
810
791 2005-03-20 Fernando Perez <fperez@colorado.edu>
811 2005-03-20 Fernando Perez <fperez@colorado.edu>
792
812
793 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
813 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
794 for custom exception handling. This is quite powerful, and it
814 for custom exception handling. This is quite powerful, and it
795 allows for user-installable exception handlers which can trap
815 allows for user-installable exception handlers which can trap
796 custom exceptions at runtime and treat them separately from
816 custom exceptions at runtime and treat them separately from
797 IPython's default mechanisms. At the request of Frédéric
817 IPython's default mechanisms. At the request of Frédéric
798 Mantegazza <mantegazza-AT-ill.fr>.
818 Mantegazza <mantegazza-AT-ill.fr>.
799 (InteractiveShell.set_custom_completer): public API function to
819 (InteractiveShell.set_custom_completer): public API function to
800 add new completers at runtime.
820 add new completers at runtime.
801
821
802 2005-03-19 Fernando Perez <fperez@colorado.edu>
822 2005-03-19 Fernando Perez <fperez@colorado.edu>
803
823
804 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
824 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
805 allow objects which provide their docstrings via non-standard
825 allow objects which provide their docstrings via non-standard
806 mechanisms (like Pyro proxies) to still be inspected by ipython's
826 mechanisms (like Pyro proxies) to still be inspected by ipython's
807 ? system.
827 ? system.
808
828
809 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
829 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
810 automatic capture system. I tried quite hard to make it work
830 automatic capture system. I tried quite hard to make it work
811 reliably, and simply failed. I tried many combinations with the
831 reliably, and simply failed. I tried many combinations with the
812 subprocess module, but eventually nothing worked in all needed
832 subprocess module, but eventually nothing worked in all needed
813 cases (not blocking stdin for the child, duplicating stdout
833 cases (not blocking stdin for the child, duplicating stdout
814 without blocking, etc). The new %sc/%sx still do capture to these
834 without blocking, etc). The new %sc/%sx still do capture to these
815 magical list/string objects which make shell use much more
835 magical list/string objects which make shell use much more
816 conveninent, so not all is lost.
836 conveninent, so not all is lost.
817
837
818 XXX - FIX MANUAL for the change above!
838 XXX - FIX MANUAL for the change above!
819
839
820 (runsource): I copied code.py's runsource() into ipython to modify
840 (runsource): I copied code.py's runsource() into ipython to modify
821 it a bit. Now the code object and source to be executed are
841 it a bit. Now the code object and source to be executed are
822 stored in ipython. This makes this info accessible to third-party
842 stored in ipython. This makes this info accessible to third-party
823 tools, like custom exception handlers. After a request by Frédéric
843 tools, like custom exception handlers. After a request by Frédéric
824 Mantegazza <mantegazza-AT-ill.fr>.
844 Mantegazza <mantegazza-AT-ill.fr>.
825
845
826 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
846 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
827 history-search via readline (like C-p/C-n). I'd wanted this for a
847 history-search via readline (like C-p/C-n). I'd wanted this for a
828 long time, but only recently found out how to do it. For users
848 long time, but only recently found out how to do it. For users
829 who already have their ipythonrc files made and want this, just
849 who already have their ipythonrc files made and want this, just
830 add:
850 add:
831
851
832 readline_parse_and_bind "\e[A": history-search-backward
852 readline_parse_and_bind "\e[A": history-search-backward
833 readline_parse_and_bind "\e[B": history-search-forward
853 readline_parse_and_bind "\e[B": history-search-forward
834
854
835 2005-03-18 Fernando Perez <fperez@colorado.edu>
855 2005-03-18 Fernando Perez <fperez@colorado.edu>
836
856
837 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
857 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
838 LSString and SList classes which allow transparent conversions
858 LSString and SList classes which allow transparent conversions
839 between list mode and whitespace-separated string.
859 between list mode and whitespace-separated string.
840 (magic_r): Fix recursion problem in %r.
860 (magic_r): Fix recursion problem in %r.
841
861
842 * IPython/genutils.py (LSString): New class to be used for
862 * IPython/genutils.py (LSString): New class to be used for
843 automatic storage of the results of all alias/system calls in _o
863 automatic storage of the results of all alias/system calls in _o
844 and _e (stdout/err). These provide a .l/.list attribute which
864 and _e (stdout/err). These provide a .l/.list attribute which
845 does automatic splitting on newlines. This means that for most
865 does automatic splitting on newlines. This means that for most
846 uses, you'll never need to do capturing of output with %sc/%sx
866 uses, you'll never need to do capturing of output with %sc/%sx
847 anymore, since ipython keeps this always done for you. Note that
867 anymore, since ipython keeps this always done for you. Note that
848 only the LAST results are stored, the _o/e variables are
868 only the LAST results are stored, the _o/e variables are
849 overwritten on each call. If you need to save their contents
869 overwritten on each call. If you need to save their contents
850 further, simply bind them to any other name.
870 further, simply bind them to any other name.
851
871
852 2005-03-17 Fernando Perez <fperez@colorado.edu>
872 2005-03-17 Fernando Perez <fperez@colorado.edu>
853
873
854 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
874 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
855 prompt namespace handling.
875 prompt namespace handling.
856
876
857 2005-03-16 Fernando Perez <fperez@colorado.edu>
877 2005-03-16 Fernando Perez <fperez@colorado.edu>
858
878
859 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
879 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
860 classic prompts to be '>>> ' (final space was missing, and it
880 classic prompts to be '>>> ' (final space was missing, and it
861 trips the emacs python mode).
881 trips the emacs python mode).
862 (BasePrompt.__str__): Added safe support for dynamic prompt
882 (BasePrompt.__str__): Added safe support for dynamic prompt
863 strings. Now you can set your prompt string to be '$x', and the
883 strings. Now you can set your prompt string to be '$x', and the
864 value of x will be printed from your interactive namespace. The
884 value of x will be printed from your interactive namespace. The
865 interpolation syntax includes the full Itpl support, so
885 interpolation syntax includes the full Itpl support, so
866 ${foo()+x+bar()} is a valid prompt string now, and the function
886 ${foo()+x+bar()} is a valid prompt string now, and the function
867 calls will be made at runtime.
887 calls will be made at runtime.
868
888
869 2005-03-15 Fernando Perez <fperez@colorado.edu>
889 2005-03-15 Fernando Perez <fperez@colorado.edu>
870
890
871 * IPython/Magic.py (magic_history): renamed %hist to %history, to
891 * IPython/Magic.py (magic_history): renamed %hist to %history, to
872 avoid name clashes in pylab. %hist still works, it just forwards
892 avoid name clashes in pylab. %hist still works, it just forwards
873 the call to %history.
893 the call to %history.
874
894
875 2005-03-02 *** Released version 0.6.12
895 2005-03-02 *** Released version 0.6.12
876
896
877 2005-03-02 Fernando Perez <fperez@colorado.edu>
897 2005-03-02 Fernando Perez <fperez@colorado.edu>
878
898
879 * IPython/iplib.py (handle_magic): log magic calls properly as
899 * IPython/iplib.py (handle_magic): log magic calls properly as
880 ipmagic() function calls.
900 ipmagic() function calls.
881
901
882 * IPython/Magic.py (magic_time): Improved %time to support
902 * IPython/Magic.py (magic_time): Improved %time to support
883 statements and provide wall-clock as well as CPU time.
903 statements and provide wall-clock as well as CPU time.
884
904
885 2005-02-27 Fernando Perez <fperez@colorado.edu>
905 2005-02-27 Fernando Perez <fperez@colorado.edu>
886
906
887 * IPython/hooks.py: New hooks module, to expose user-modifiable
907 * IPython/hooks.py: New hooks module, to expose user-modifiable
888 IPython functionality in a clean manner. For now only the editor
908 IPython functionality in a clean manner. For now only the editor
889 hook is actually written, and other thigns which I intend to turn
909 hook is actually written, and other thigns which I intend to turn
890 into proper hooks aren't yet there. The display and prefilter
910 into proper hooks aren't yet there. The display and prefilter
891 stuff, for example, should be hooks. But at least now the
911 stuff, for example, should be hooks. But at least now the
892 framework is in place, and the rest can be moved here with more
912 framework is in place, and the rest can be moved here with more
893 time later. IPython had had a .hooks variable for a long time for
913 time later. IPython had had a .hooks variable for a long time for
894 this purpose, but I'd never actually used it for anything.
914 this purpose, but I'd never actually used it for anything.
895
915
896 2005-02-26 Fernando Perez <fperez@colorado.edu>
916 2005-02-26 Fernando Perez <fperez@colorado.edu>
897
917
898 * IPython/ipmaker.py (make_IPython): make the default ipython
918 * IPython/ipmaker.py (make_IPython): make the default ipython
899 directory be called _ipython under win32, to follow more the
919 directory be called _ipython under win32, to follow more the
900 naming peculiarities of that platform (where buggy software like
920 naming peculiarities of that platform (where buggy software like
901 Visual Sourcesafe breaks with .named directories). Reported by
921 Visual Sourcesafe breaks with .named directories). Reported by
902 Ville Vainio.
922 Ville Vainio.
903
923
904 2005-02-23 Fernando Perez <fperez@colorado.edu>
924 2005-02-23 Fernando Perez <fperez@colorado.edu>
905
925
906 * IPython/iplib.py (InteractiveShell.__init__): removed a few
926 * IPython/iplib.py (InteractiveShell.__init__): removed a few
907 auto_aliases for win32 which were causing problems. Users can
927 auto_aliases for win32 which were causing problems. Users can
908 define the ones they personally like.
928 define the ones they personally like.
909
929
910 2005-02-21 Fernando Perez <fperez@colorado.edu>
930 2005-02-21 Fernando Perez <fperez@colorado.edu>
911
931
912 * IPython/Magic.py (magic_time): new magic to time execution of
932 * IPython/Magic.py (magic_time): new magic to time execution of
913 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
933 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
914
934
915 2005-02-19 Fernando Perez <fperez@colorado.edu>
935 2005-02-19 Fernando Perez <fperez@colorado.edu>
916
936
917 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
937 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
918 into keys (for prompts, for example).
938 into keys (for prompts, for example).
919
939
920 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
940 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
921 prompts in case users want them. This introduces a small behavior
941 prompts in case users want them. This introduces a small behavior
922 change: ipython does not automatically add a space to all prompts
942 change: ipython does not automatically add a space to all prompts
923 anymore. To get the old prompts with a space, users should add it
943 anymore. To get the old prompts with a space, users should add it
924 manually to their ipythonrc file, so for example prompt_in1 should
944 manually to their ipythonrc file, so for example prompt_in1 should
925 now read 'In [\#]: ' instead of 'In [\#]:'.
945 now read 'In [\#]: ' instead of 'In [\#]:'.
926 (BasePrompt.__init__): New option prompts_pad_left (only in rc
946 (BasePrompt.__init__): New option prompts_pad_left (only in rc
927 file) to control left-padding of secondary prompts.
947 file) to control left-padding of secondary prompts.
928
948
929 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
949 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
930 the profiler can't be imported. Fix for Debian, which removed
950 the profiler can't be imported. Fix for Debian, which removed
931 profile.py because of License issues. I applied a slightly
951 profile.py because of License issues. I applied a slightly
932 modified version of the original Debian patch at
952 modified version of the original Debian patch at
933 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
953 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
934
954
935 2005-02-17 Fernando Perez <fperez@colorado.edu>
955 2005-02-17 Fernando Perez <fperez@colorado.edu>
936
956
937 * IPython/genutils.py (native_line_ends): Fix bug which would
957 * IPython/genutils.py (native_line_ends): Fix bug which would
938 cause improper line-ends under win32 b/c I was not opening files
958 cause improper line-ends under win32 b/c I was not opening files
939 in binary mode. Bug report and fix thanks to Ville.
959 in binary mode. Bug report and fix thanks to Ville.
940
960
941 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
961 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
942 trying to catch spurious foo[1] autocalls. My fix actually broke
962 trying to catch spurious foo[1] autocalls. My fix actually broke
943 ',/' autoquote/call with explicit escape (bad regexp).
963 ',/' autoquote/call with explicit escape (bad regexp).
944
964
945 2005-02-15 *** Released version 0.6.11
965 2005-02-15 *** Released version 0.6.11
946
966
947 2005-02-14 Fernando Perez <fperez@colorado.edu>
967 2005-02-14 Fernando Perez <fperez@colorado.edu>
948
968
949 * IPython/background_jobs.py: New background job management
969 * IPython/background_jobs.py: New background job management
950 subsystem. This is implemented via a new set of classes, and
970 subsystem. This is implemented via a new set of classes, and
951 IPython now provides a builtin 'jobs' object for background job
971 IPython now provides a builtin 'jobs' object for background job
952 execution. A convenience %bg magic serves as a lightweight
972 execution. A convenience %bg magic serves as a lightweight
953 frontend for starting the more common type of calls. This was
973 frontend for starting the more common type of calls. This was
954 inspired by discussions with B. Granger and the BackgroundCommand
974 inspired by discussions with B. Granger and the BackgroundCommand
955 class described in the book Python Scripting for Computational
975 class described in the book Python Scripting for Computational
956 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
976 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
957 (although ultimately no code from this text was used, as IPython's
977 (although ultimately no code from this text was used, as IPython's
958 system is a separate implementation).
978 system is a separate implementation).
959
979
960 * IPython/iplib.py (MagicCompleter.python_matches): add new option
980 * IPython/iplib.py (MagicCompleter.python_matches): add new option
961 to control the completion of single/double underscore names
981 to control the completion of single/double underscore names
962 separately. As documented in the example ipytonrc file, the
982 separately. As documented in the example ipytonrc file, the
963 readline_omit__names variable can now be set to 2, to omit even
983 readline_omit__names variable can now be set to 2, to omit even
964 single underscore names. Thanks to a patch by Brian Wong
984 single underscore names. Thanks to a patch by Brian Wong
965 <BrianWong-AT-AirgoNetworks.Com>.
985 <BrianWong-AT-AirgoNetworks.Com>.
966 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
986 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
967 be autocalled as foo([1]) if foo were callable. A problem for
987 be autocalled as foo([1]) if foo were callable. A problem for
968 things which are both callable and implement __getitem__.
988 things which are both callable and implement __getitem__.
969 (init_readline): Fix autoindentation for win32. Thanks to a patch
989 (init_readline): Fix autoindentation for win32. Thanks to a patch
970 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
990 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
971
991
972 2005-02-12 Fernando Perez <fperez@colorado.edu>
992 2005-02-12 Fernando Perez <fperez@colorado.edu>
973
993
974 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
994 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
975 which I had written long ago to sort out user error messages which
995 which I had written long ago to sort out user error messages which
976 may occur during startup. This seemed like a good idea initially,
996 may occur during startup. This seemed like a good idea initially,
977 but it has proven a disaster in retrospect. I don't want to
997 but it has proven a disaster in retrospect. I don't want to
978 change much code for now, so my fix is to set the internal 'debug'
998 change much code for now, so my fix is to set the internal 'debug'
979 flag to true everywhere, whose only job was precisely to control
999 flag to true everywhere, whose only job was precisely to control
980 this subsystem. This closes issue 28 (as well as avoiding all
1000 this subsystem. This closes issue 28 (as well as avoiding all
981 sorts of strange hangups which occur from time to time).
1001 sorts of strange hangups which occur from time to time).
982
1002
983 2005-02-07 Fernando Perez <fperez@colorado.edu>
1003 2005-02-07 Fernando Perez <fperez@colorado.edu>
984
1004
985 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1005 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
986 previous call produced a syntax error.
1006 previous call produced a syntax error.
987
1007
988 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1008 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
989 classes without constructor.
1009 classes without constructor.
990
1010
991 2005-02-06 Fernando Perez <fperez@colorado.edu>
1011 2005-02-06 Fernando Perez <fperez@colorado.edu>
992
1012
993 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1013 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
994 completions with the results of each matcher, so we return results
1014 completions with the results of each matcher, so we return results
995 to the user from all namespaces. This breaks with ipython
1015 to the user from all namespaces. This breaks with ipython
996 tradition, but I think it's a nicer behavior. Now you get all
1016 tradition, but I think it's a nicer behavior. Now you get all
997 possible completions listed, from all possible namespaces (python,
1017 possible completions listed, from all possible namespaces (python,
998 filesystem, magics...) After a request by John Hunter
1018 filesystem, magics...) After a request by John Hunter
999 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1019 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1000
1020
1001 2005-02-05 Fernando Perez <fperez@colorado.edu>
1021 2005-02-05 Fernando Perez <fperez@colorado.edu>
1002
1022
1003 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1023 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1004 the call had quote characters in it (the quotes were stripped).
1024 the call had quote characters in it (the quotes were stripped).
1005
1025
1006 2005-01-31 Fernando Perez <fperez@colorado.edu>
1026 2005-01-31 Fernando Perez <fperez@colorado.edu>
1007
1027
1008 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1028 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1009 Itpl.itpl() to make the code more robust against psyco
1029 Itpl.itpl() to make the code more robust against psyco
1010 optimizations.
1030 optimizations.
1011
1031
1012 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1032 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1013 of causing an exception. Quicker, cleaner.
1033 of causing an exception. Quicker, cleaner.
1014
1034
1015 2005-01-28 Fernando Perez <fperez@colorado.edu>
1035 2005-01-28 Fernando Perez <fperez@colorado.edu>
1016
1036
1017 * scripts/ipython_win_post_install.py (install): hardcode
1037 * scripts/ipython_win_post_install.py (install): hardcode
1018 sys.prefix+'python.exe' as the executable path. It turns out that
1038 sys.prefix+'python.exe' as the executable path. It turns out that
1019 during the post-installation run, sys.executable resolves to the
1039 during the post-installation run, sys.executable resolves to the
1020 name of the binary installer! I should report this as a distutils
1040 name of the binary installer! I should report this as a distutils
1021 bug, I think. I updated the .10 release with this tiny fix, to
1041 bug, I think. I updated the .10 release with this tiny fix, to
1022 avoid annoying the lists further.
1042 avoid annoying the lists further.
1023
1043
1024 2005-01-27 *** Released version 0.6.10
1044 2005-01-27 *** Released version 0.6.10
1025
1045
1026 2005-01-27 Fernando Perez <fperez@colorado.edu>
1046 2005-01-27 Fernando Perez <fperez@colorado.edu>
1027
1047
1028 * IPython/numutils.py (norm): Added 'inf' as optional name for
1048 * IPython/numutils.py (norm): Added 'inf' as optional name for
1029 L-infinity norm, included references to mathworld.com for vector
1049 L-infinity norm, included references to mathworld.com for vector
1030 norm definitions.
1050 norm definitions.
1031 (amin/amax): added amin/amax for array min/max. Similar to what
1051 (amin/amax): added amin/amax for array min/max. Similar to what
1032 pylab ships with after the recent reorganization of names.
1052 pylab ships with after the recent reorganization of names.
1033 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1053 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1034
1054
1035 * ipython.el: committed Alex's recent fixes and improvements.
1055 * ipython.el: committed Alex's recent fixes and improvements.
1036 Tested with python-mode from CVS, and it looks excellent. Since
1056 Tested with python-mode from CVS, and it looks excellent. Since
1037 python-mode hasn't released anything in a while, I'm temporarily
1057 python-mode hasn't released anything in a while, I'm temporarily
1038 putting a copy of today's CVS (v 4.70) of python-mode in:
1058 putting a copy of today's CVS (v 4.70) of python-mode in:
1039 http://ipython.scipy.org/tmp/python-mode.el
1059 http://ipython.scipy.org/tmp/python-mode.el
1040
1060
1041 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1061 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1042 sys.executable for the executable name, instead of assuming it's
1062 sys.executable for the executable name, instead of assuming it's
1043 called 'python.exe' (the post-installer would have produced broken
1063 called 'python.exe' (the post-installer would have produced broken
1044 setups on systems with a differently named python binary).
1064 setups on systems with a differently named python binary).
1045
1065
1046 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1066 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1047 references to os.linesep, to make the code more
1067 references to os.linesep, to make the code more
1048 platform-independent. This is also part of the win32 coloring
1068 platform-independent. This is also part of the win32 coloring
1049 fixes.
1069 fixes.
1050
1070
1051 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1071 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1052 lines, which actually cause coloring bugs because the length of
1072 lines, which actually cause coloring bugs because the length of
1053 the line is very difficult to correctly compute with embedded
1073 the line is very difficult to correctly compute with embedded
1054 escapes. This was the source of all the coloring problems under
1074 escapes. This was the source of all the coloring problems under
1055 Win32. I think that _finally_, Win32 users have a properly
1075 Win32. I think that _finally_, Win32 users have a properly
1056 working ipython in all respects. This would never have happened
1076 working ipython in all respects. This would never have happened
1057 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1077 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1058
1078
1059 2005-01-26 *** Released version 0.6.9
1079 2005-01-26 *** Released version 0.6.9
1060
1080
1061 2005-01-25 Fernando Perez <fperez@colorado.edu>
1081 2005-01-25 Fernando Perez <fperez@colorado.edu>
1062
1082
1063 * setup.py: finally, we have a true Windows installer, thanks to
1083 * setup.py: finally, we have a true Windows installer, thanks to
1064 the excellent work of Viktor Ransmayr
1084 the excellent work of Viktor Ransmayr
1065 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1085 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1066 Windows users. The setup routine is quite a bit cleaner thanks to
1086 Windows users. The setup routine is quite a bit cleaner thanks to
1067 this, and the post-install script uses the proper functions to
1087 this, and the post-install script uses the proper functions to
1068 allow a clean de-installation using the standard Windows Control
1088 allow a clean de-installation using the standard Windows Control
1069 Panel.
1089 Panel.
1070
1090
1071 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1091 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1072 environment variable under all OSes (including win32) if
1092 environment variable under all OSes (including win32) if
1073 available. This will give consistency to win32 users who have set
1093 available. This will give consistency to win32 users who have set
1074 this variable for any reason. If os.environ['HOME'] fails, the
1094 this variable for any reason. If os.environ['HOME'] fails, the
1075 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1095 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1076
1096
1077 2005-01-24 Fernando Perez <fperez@colorado.edu>
1097 2005-01-24 Fernando Perez <fperez@colorado.edu>
1078
1098
1079 * IPython/numutils.py (empty_like): add empty_like(), similar to
1099 * IPython/numutils.py (empty_like): add empty_like(), similar to
1080 zeros_like() but taking advantage of the new empty() Numeric routine.
1100 zeros_like() but taking advantage of the new empty() Numeric routine.
1081
1101
1082 2005-01-23 *** Released version 0.6.8
1102 2005-01-23 *** Released version 0.6.8
1083
1103
1084 2005-01-22 Fernando Perez <fperez@colorado.edu>
1104 2005-01-22 Fernando Perez <fperez@colorado.edu>
1085
1105
1086 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1106 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1087 automatic show() calls. After discussing things with JDH, it
1107 automatic show() calls. After discussing things with JDH, it
1088 turns out there are too many corner cases where this can go wrong.
1108 turns out there are too many corner cases where this can go wrong.
1089 It's best not to try to be 'too smart', and simply have ipython
1109 It's best not to try to be 'too smart', and simply have ipython
1090 reproduce as much as possible the default behavior of a normal
1110 reproduce as much as possible the default behavior of a normal
1091 python shell.
1111 python shell.
1092
1112
1093 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1113 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1094 line-splitting regexp and _prefilter() to avoid calling getattr()
1114 line-splitting regexp and _prefilter() to avoid calling getattr()
1095 on assignments. This closes
1115 on assignments. This closes
1096 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1116 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1097 readline uses getattr(), so a simple <TAB> keypress is still
1117 readline uses getattr(), so a simple <TAB> keypress is still
1098 enough to trigger getattr() calls on an object.
1118 enough to trigger getattr() calls on an object.
1099
1119
1100 2005-01-21 Fernando Perez <fperez@colorado.edu>
1120 2005-01-21 Fernando Perez <fperez@colorado.edu>
1101
1121
1102 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1122 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1103 docstring under pylab so it doesn't mask the original.
1123 docstring under pylab so it doesn't mask the original.
1104
1124
1105 2005-01-21 *** Released version 0.6.7
1125 2005-01-21 *** Released version 0.6.7
1106
1126
1107 2005-01-21 Fernando Perez <fperez@colorado.edu>
1127 2005-01-21 Fernando Perez <fperez@colorado.edu>
1108
1128
1109 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1129 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1110 signal handling for win32 users in multithreaded mode.
1130 signal handling for win32 users in multithreaded mode.
1111
1131
1112 2005-01-17 Fernando Perez <fperez@colorado.edu>
1132 2005-01-17 Fernando Perez <fperez@colorado.edu>
1113
1133
1114 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1134 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1115 instances with no __init__. After a crash report by Norbert Nemec
1135 instances with no __init__. After a crash report by Norbert Nemec
1116 <Norbert-AT-nemec-online.de>.
1136 <Norbert-AT-nemec-online.de>.
1117
1137
1118 2005-01-14 Fernando Perez <fperez@colorado.edu>
1138 2005-01-14 Fernando Perez <fperez@colorado.edu>
1119
1139
1120 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1140 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1121 names for verbose exceptions, when multiple dotted names and the
1141 names for verbose exceptions, when multiple dotted names and the
1122 'parent' object were present on the same line.
1142 'parent' object were present on the same line.
1123
1143
1124 2005-01-11 Fernando Perez <fperez@colorado.edu>
1144 2005-01-11 Fernando Perez <fperez@colorado.edu>
1125
1145
1126 * IPython/genutils.py (flag_calls): new utility to trap and flag
1146 * IPython/genutils.py (flag_calls): new utility to trap and flag
1127 calls in functions. I need it to clean up matplotlib support.
1147 calls in functions. I need it to clean up matplotlib support.
1128 Also removed some deprecated code in genutils.
1148 Also removed some deprecated code in genutils.
1129
1149
1130 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1150 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1131 that matplotlib scripts called with %run, which don't call show()
1151 that matplotlib scripts called with %run, which don't call show()
1132 themselves, still have their plotting windows open.
1152 themselves, still have their plotting windows open.
1133
1153
1134 2005-01-05 Fernando Perez <fperez@colorado.edu>
1154 2005-01-05 Fernando Perez <fperez@colorado.edu>
1135
1155
1136 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1156 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1137 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1157 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1138
1158
1139 2004-12-19 Fernando Perez <fperez@colorado.edu>
1159 2004-12-19 Fernando Perez <fperez@colorado.edu>
1140
1160
1141 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1161 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1142 parent_runcode, which was an eyesore. The same result can be
1162 parent_runcode, which was an eyesore. The same result can be
1143 obtained with Python's regular superclass mechanisms.
1163 obtained with Python's regular superclass mechanisms.
1144
1164
1145 2004-12-17 Fernando Perez <fperez@colorado.edu>
1165 2004-12-17 Fernando Perez <fperez@colorado.edu>
1146
1166
1147 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1167 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1148 reported by Prabhu.
1168 reported by Prabhu.
1149 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1169 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1150 sys.stderr) instead of explicitly calling sys.stderr. This helps
1170 sys.stderr) instead of explicitly calling sys.stderr. This helps
1151 maintain our I/O abstractions clean, for future GUI embeddings.
1171 maintain our I/O abstractions clean, for future GUI embeddings.
1152
1172
1153 * IPython/genutils.py (info): added new utility for sys.stderr
1173 * IPython/genutils.py (info): added new utility for sys.stderr
1154 unified info message handling (thin wrapper around warn()).
1174 unified info message handling (thin wrapper around warn()).
1155
1175
1156 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1176 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1157 composite (dotted) names on verbose exceptions.
1177 composite (dotted) names on verbose exceptions.
1158 (VerboseTB.nullrepr): harden against another kind of errors which
1178 (VerboseTB.nullrepr): harden against another kind of errors which
1159 Python's inspect module can trigger, and which were crashing
1179 Python's inspect module can trigger, and which were crashing
1160 IPython. Thanks to a report by Marco Lombardi
1180 IPython. Thanks to a report by Marco Lombardi
1161 <mlombard-AT-ma010192.hq.eso.org>.
1181 <mlombard-AT-ma010192.hq.eso.org>.
1162
1182
1163 2004-12-13 *** Released version 0.6.6
1183 2004-12-13 *** Released version 0.6.6
1164
1184
1165 2004-12-12 Fernando Perez <fperez@colorado.edu>
1185 2004-12-12 Fernando Perez <fperez@colorado.edu>
1166
1186
1167 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1187 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1168 generated by pygtk upon initialization if it was built without
1188 generated by pygtk upon initialization if it was built without
1169 threads (for matplotlib users). After a crash reported by
1189 threads (for matplotlib users). After a crash reported by
1170 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1190 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1171
1191
1172 * IPython/ipmaker.py (make_IPython): fix small bug in the
1192 * IPython/ipmaker.py (make_IPython): fix small bug in the
1173 import_some parameter for multiple imports.
1193 import_some parameter for multiple imports.
1174
1194
1175 * IPython/iplib.py (ipmagic): simplified the interface of
1195 * IPython/iplib.py (ipmagic): simplified the interface of
1176 ipmagic() to take a single string argument, just as it would be
1196 ipmagic() to take a single string argument, just as it would be
1177 typed at the IPython cmd line.
1197 typed at the IPython cmd line.
1178 (ipalias): Added new ipalias() with an interface identical to
1198 (ipalias): Added new ipalias() with an interface identical to
1179 ipmagic(). This completes exposing a pure python interface to the
1199 ipmagic(). This completes exposing a pure python interface to the
1180 alias and magic system, which can be used in loops or more complex
1200 alias and magic system, which can be used in loops or more complex
1181 code where IPython's automatic line mangling is not active.
1201 code where IPython's automatic line mangling is not active.
1182
1202
1183 * IPython/genutils.py (timing): changed interface of timing to
1203 * IPython/genutils.py (timing): changed interface of timing to
1184 simply run code once, which is the most common case. timings()
1204 simply run code once, which is the most common case. timings()
1185 remains unchanged, for the cases where you want multiple runs.
1205 remains unchanged, for the cases where you want multiple runs.
1186
1206
1187 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1207 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1188 bug where Python2.2 crashes with exec'ing code which does not end
1208 bug where Python2.2 crashes with exec'ing code which does not end
1189 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1209 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1190 before.
1210 before.
1191
1211
1192 2004-12-10 Fernando Perez <fperez@colorado.edu>
1212 2004-12-10 Fernando Perez <fperez@colorado.edu>
1193
1213
1194 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1214 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1195 -t to -T, to accomodate the new -t flag in %run (the %run and
1215 -t to -T, to accomodate the new -t flag in %run (the %run and
1196 %prun options are kind of intermixed, and it's not easy to change
1216 %prun options are kind of intermixed, and it's not easy to change
1197 this with the limitations of python's getopt).
1217 this with the limitations of python's getopt).
1198
1218
1199 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1219 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1200 the execution of scripts. It's not as fine-tuned as timeit.py,
1220 the execution of scripts. It's not as fine-tuned as timeit.py,
1201 but it works from inside ipython (and under 2.2, which lacks
1221 but it works from inside ipython (and under 2.2, which lacks
1202 timeit.py). Optionally a number of runs > 1 can be given for
1222 timeit.py). Optionally a number of runs > 1 can be given for
1203 timing very short-running code.
1223 timing very short-running code.
1204
1224
1205 * IPython/genutils.py (uniq_stable): new routine which returns a
1225 * IPython/genutils.py (uniq_stable): new routine which returns a
1206 list of unique elements in any iterable, but in stable order of
1226 list of unique elements in any iterable, but in stable order of
1207 appearance. I needed this for the ultraTB fixes, and it's a handy
1227 appearance. I needed this for the ultraTB fixes, and it's a handy
1208 utility.
1228 utility.
1209
1229
1210 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1230 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1211 dotted names in Verbose exceptions. This had been broken since
1231 dotted names in Verbose exceptions. This had been broken since
1212 the very start, now x.y will properly be printed in a Verbose
1232 the very start, now x.y will properly be printed in a Verbose
1213 traceback, instead of x being shown and y appearing always as an
1233 traceback, instead of x being shown and y appearing always as an
1214 'undefined global'. Getting this to work was a bit tricky,
1234 'undefined global'. Getting this to work was a bit tricky,
1215 because by default python tokenizers are stateless. Saved by
1235 because by default python tokenizers are stateless. Saved by
1216 python's ability to easily add a bit of state to an arbitrary
1236 python's ability to easily add a bit of state to an arbitrary
1217 function (without needing to build a full-blown callable object).
1237 function (without needing to build a full-blown callable object).
1218
1238
1219 Also big cleanup of this code, which had horrendous runtime
1239 Also big cleanup of this code, which had horrendous runtime
1220 lookups of zillions of attributes for colorization. Moved all
1240 lookups of zillions of attributes for colorization. Moved all
1221 this code into a few templates, which make it cleaner and quicker.
1241 this code into a few templates, which make it cleaner and quicker.
1222
1242
1223 Printout quality was also improved for Verbose exceptions: one
1243 Printout quality was also improved for Verbose exceptions: one
1224 variable per line, and memory addresses are printed (this can be
1244 variable per line, and memory addresses are printed (this can be
1225 quite handy in nasty debugging situations, which is what Verbose
1245 quite handy in nasty debugging situations, which is what Verbose
1226 is for).
1246 is for).
1227
1247
1228 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1248 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1229 the command line as scripts to be loaded by embedded instances.
1249 the command line as scripts to be loaded by embedded instances.
1230 Doing so has the potential for an infinite recursion if there are
1250 Doing so has the potential for an infinite recursion if there are
1231 exceptions thrown in the process. This fixes a strange crash
1251 exceptions thrown in the process. This fixes a strange crash
1232 reported by Philippe MULLER <muller-AT-irit.fr>.
1252 reported by Philippe MULLER <muller-AT-irit.fr>.
1233
1253
1234 2004-12-09 Fernando Perez <fperez@colorado.edu>
1254 2004-12-09 Fernando Perez <fperez@colorado.edu>
1235
1255
1236 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1256 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1237 to reflect new names in matplotlib, which now expose the
1257 to reflect new names in matplotlib, which now expose the
1238 matlab-compatible interface via a pylab module instead of the
1258 matlab-compatible interface via a pylab module instead of the
1239 'matlab' name. The new code is backwards compatible, so users of
1259 'matlab' name. The new code is backwards compatible, so users of
1240 all matplotlib versions are OK. Patch by J. Hunter.
1260 all matplotlib versions are OK. Patch by J. Hunter.
1241
1261
1242 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1262 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1243 of __init__ docstrings for instances (class docstrings are already
1263 of __init__ docstrings for instances (class docstrings are already
1244 automatically printed). Instances with customized docstrings
1264 automatically printed). Instances with customized docstrings
1245 (indep. of the class) are also recognized and all 3 separate
1265 (indep. of the class) are also recognized and all 3 separate
1246 docstrings are printed (instance, class, constructor). After some
1266 docstrings are printed (instance, class, constructor). After some
1247 comments/suggestions by J. Hunter.
1267 comments/suggestions by J. Hunter.
1248
1268
1249 2004-12-05 Fernando Perez <fperez@colorado.edu>
1269 2004-12-05 Fernando Perez <fperez@colorado.edu>
1250
1270
1251 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1271 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1252 warnings when tab-completion fails and triggers an exception.
1272 warnings when tab-completion fails and triggers an exception.
1253
1273
1254 2004-12-03 Fernando Perez <fperez@colorado.edu>
1274 2004-12-03 Fernando Perez <fperez@colorado.edu>
1255
1275
1256 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1276 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1257 be triggered when using 'run -p'. An incorrect option flag was
1277 be triggered when using 'run -p'. An incorrect option flag was
1258 being set ('d' instead of 'D').
1278 being set ('d' instead of 'D').
1259 (manpage): fix missing escaped \- sign.
1279 (manpage): fix missing escaped \- sign.
1260
1280
1261 2004-11-30 *** Released version 0.6.5
1281 2004-11-30 *** Released version 0.6.5
1262
1282
1263 2004-11-30 Fernando Perez <fperez@colorado.edu>
1283 2004-11-30 Fernando Perez <fperez@colorado.edu>
1264
1284
1265 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1285 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1266 setting with -d option.
1286 setting with -d option.
1267
1287
1268 * setup.py (docfiles): Fix problem where the doc glob I was using
1288 * setup.py (docfiles): Fix problem where the doc glob I was using
1269 was COMPLETELY BROKEN. It was giving the right files by pure
1289 was COMPLETELY BROKEN. It was giving the right files by pure
1270 accident, but failed once I tried to include ipython.el. Note:
1290 accident, but failed once I tried to include ipython.el. Note:
1271 glob() does NOT allow you to do exclusion on multiple endings!
1291 glob() does NOT allow you to do exclusion on multiple endings!
1272
1292
1273 2004-11-29 Fernando Perez <fperez@colorado.edu>
1293 2004-11-29 Fernando Perez <fperez@colorado.edu>
1274
1294
1275 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1295 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1276 the manpage as the source. Better formatting & consistency.
1296 the manpage as the source. Better formatting & consistency.
1277
1297
1278 * IPython/Magic.py (magic_run): Added new -d option, to run
1298 * IPython/Magic.py (magic_run): Added new -d option, to run
1279 scripts under the control of the python pdb debugger. Note that
1299 scripts under the control of the python pdb debugger. Note that
1280 this required changing the %prun option -d to -D, to avoid a clash
1300 this required changing the %prun option -d to -D, to avoid a clash
1281 (since %run must pass options to %prun, and getopt is too dumb to
1301 (since %run must pass options to %prun, and getopt is too dumb to
1282 handle options with string values with embedded spaces). Thanks
1302 handle options with string values with embedded spaces). Thanks
1283 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1303 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1284 (magic_who_ls): added type matching to %who and %whos, so that one
1304 (magic_who_ls): added type matching to %who and %whos, so that one
1285 can filter their output to only include variables of certain
1305 can filter their output to only include variables of certain
1286 types. Another suggestion by Matthew.
1306 types. Another suggestion by Matthew.
1287 (magic_whos): Added memory summaries in kb and Mb for arrays.
1307 (magic_whos): Added memory summaries in kb and Mb for arrays.
1288 (magic_who): Improve formatting (break lines every 9 vars).
1308 (magic_who): Improve formatting (break lines every 9 vars).
1289
1309
1290 2004-11-28 Fernando Perez <fperez@colorado.edu>
1310 2004-11-28 Fernando Perez <fperez@colorado.edu>
1291
1311
1292 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1312 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1293 cache when empty lines were present.
1313 cache when empty lines were present.
1294
1314
1295 2004-11-24 Fernando Perez <fperez@colorado.edu>
1315 2004-11-24 Fernando Perez <fperez@colorado.edu>
1296
1316
1297 * IPython/usage.py (__doc__): document the re-activated threading
1317 * IPython/usage.py (__doc__): document the re-activated threading
1298 options for WX and GTK.
1318 options for WX and GTK.
1299
1319
1300 2004-11-23 Fernando Perez <fperez@colorado.edu>
1320 2004-11-23 Fernando Perez <fperez@colorado.edu>
1301
1321
1302 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1322 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1303 the -wthread and -gthread options, along with a new -tk one to try
1323 the -wthread and -gthread options, along with a new -tk one to try
1304 and coordinate Tk threading with wx/gtk. The tk support is very
1324 and coordinate Tk threading with wx/gtk. The tk support is very
1305 platform dependent, since it seems to require Tcl and Tk to be
1325 platform dependent, since it seems to require Tcl and Tk to be
1306 built with threads (Fedora1/2 appears NOT to have it, but in
1326 built with threads (Fedora1/2 appears NOT to have it, but in
1307 Prabhu's Debian boxes it works OK). But even with some Tk
1327 Prabhu's Debian boxes it works OK). But even with some Tk
1308 limitations, this is a great improvement.
1328 limitations, this is a great improvement.
1309
1329
1310 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1330 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1311 info in user prompts. Patch by Prabhu.
1331 info in user prompts. Patch by Prabhu.
1312
1332
1313 2004-11-18 Fernando Perez <fperez@colorado.edu>
1333 2004-11-18 Fernando Perez <fperez@colorado.edu>
1314
1334
1315 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1335 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1316 EOFErrors and bail, to avoid infinite loops if a non-terminating
1336 EOFErrors and bail, to avoid infinite loops if a non-terminating
1317 file is fed into ipython. Patch submitted in issue 19 by user,
1337 file is fed into ipython. Patch submitted in issue 19 by user,
1318 many thanks.
1338 many thanks.
1319
1339
1320 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1340 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1321 autoquote/parens in continuation prompts, which can cause lots of
1341 autoquote/parens in continuation prompts, which can cause lots of
1322 problems. Closes roundup issue 20.
1342 problems. Closes roundup issue 20.
1323
1343
1324 2004-11-17 Fernando Perez <fperez@colorado.edu>
1344 2004-11-17 Fernando Perez <fperez@colorado.edu>
1325
1345
1326 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1346 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1327 reported as debian bug #280505. I'm not sure my local changelog
1347 reported as debian bug #280505. I'm not sure my local changelog
1328 entry has the proper debian format (Jack?).
1348 entry has the proper debian format (Jack?).
1329
1349
1330 2004-11-08 *** Released version 0.6.4
1350 2004-11-08 *** Released version 0.6.4
1331
1351
1332 2004-11-08 Fernando Perez <fperez@colorado.edu>
1352 2004-11-08 Fernando Perez <fperez@colorado.edu>
1333
1353
1334 * IPython/iplib.py (init_readline): Fix exit message for Windows
1354 * IPython/iplib.py (init_readline): Fix exit message for Windows
1335 when readline is active. Thanks to a report by Eric Jones
1355 when readline is active. Thanks to a report by Eric Jones
1336 <eric-AT-enthought.com>.
1356 <eric-AT-enthought.com>.
1337
1357
1338 2004-11-07 Fernando Perez <fperez@colorado.edu>
1358 2004-11-07 Fernando Perez <fperez@colorado.edu>
1339
1359
1340 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1360 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1341 sometimes seen by win2k/cygwin users.
1361 sometimes seen by win2k/cygwin users.
1342
1362
1343 2004-11-06 Fernando Perez <fperez@colorado.edu>
1363 2004-11-06 Fernando Perez <fperez@colorado.edu>
1344
1364
1345 * IPython/iplib.py (interact): Change the handling of %Exit from
1365 * IPython/iplib.py (interact): Change the handling of %Exit from
1346 trying to propagate a SystemExit to an internal ipython flag.
1366 trying to propagate a SystemExit to an internal ipython flag.
1347 This is less elegant than using Python's exception mechanism, but
1367 This is less elegant than using Python's exception mechanism, but
1348 I can't get that to work reliably with threads, so under -pylab
1368 I can't get that to work reliably with threads, so under -pylab
1349 %Exit was hanging IPython. Cross-thread exception handling is
1369 %Exit was hanging IPython. Cross-thread exception handling is
1350 really a bitch. Thaks to a bug report by Stephen Walton
1370 really a bitch. Thaks to a bug report by Stephen Walton
1351 <stephen.walton-AT-csun.edu>.
1371 <stephen.walton-AT-csun.edu>.
1352
1372
1353 2004-11-04 Fernando Perez <fperez@colorado.edu>
1373 2004-11-04 Fernando Perez <fperez@colorado.edu>
1354
1374
1355 * IPython/iplib.py (raw_input_original): store a pointer to the
1375 * IPython/iplib.py (raw_input_original): store a pointer to the
1356 true raw_input to harden against code which can modify it
1376 true raw_input to harden against code which can modify it
1357 (wx.py.PyShell does this and would otherwise crash ipython).
1377 (wx.py.PyShell does this and would otherwise crash ipython).
1358 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1378 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1359
1379
1360 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1380 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1361 Ctrl-C problem, which does not mess up the input line.
1381 Ctrl-C problem, which does not mess up the input line.
1362
1382
1363 2004-11-03 Fernando Perez <fperez@colorado.edu>
1383 2004-11-03 Fernando Perez <fperez@colorado.edu>
1364
1384
1365 * IPython/Release.py: Changed licensing to BSD, in all files.
1385 * IPython/Release.py: Changed licensing to BSD, in all files.
1366 (name): lowercase name for tarball/RPM release.
1386 (name): lowercase name for tarball/RPM release.
1367
1387
1368 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1388 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1369 use throughout ipython.
1389 use throughout ipython.
1370
1390
1371 * IPython/Magic.py (Magic._ofind): Switch to using the new
1391 * IPython/Magic.py (Magic._ofind): Switch to using the new
1372 OInspect.getdoc() function.
1392 OInspect.getdoc() function.
1373
1393
1374 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1394 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1375 of the line currently being canceled via Ctrl-C. It's extremely
1395 of the line currently being canceled via Ctrl-C. It's extremely
1376 ugly, but I don't know how to do it better (the problem is one of
1396 ugly, but I don't know how to do it better (the problem is one of
1377 handling cross-thread exceptions).
1397 handling cross-thread exceptions).
1378
1398
1379 2004-10-28 Fernando Perez <fperez@colorado.edu>
1399 2004-10-28 Fernando Perez <fperez@colorado.edu>
1380
1400
1381 * IPython/Shell.py (signal_handler): add signal handlers to trap
1401 * IPython/Shell.py (signal_handler): add signal handlers to trap
1382 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1402 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1383 report by Francesc Alted.
1403 report by Francesc Alted.
1384
1404
1385 2004-10-21 Fernando Perez <fperez@colorado.edu>
1405 2004-10-21 Fernando Perez <fperez@colorado.edu>
1386
1406
1387 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1407 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1388 to % for pysh syntax extensions.
1408 to % for pysh syntax extensions.
1389
1409
1390 2004-10-09 Fernando Perez <fperez@colorado.edu>
1410 2004-10-09 Fernando Perez <fperez@colorado.edu>
1391
1411
1392 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1412 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1393 arrays to print a more useful summary, without calling str(arr).
1413 arrays to print a more useful summary, without calling str(arr).
1394 This avoids the problem of extremely lengthy computations which
1414 This avoids the problem of extremely lengthy computations which
1395 occur if arr is large, and appear to the user as a system lockup
1415 occur if arr is large, and appear to the user as a system lockup
1396 with 100% cpu activity. After a suggestion by Kristian Sandberg
1416 with 100% cpu activity. After a suggestion by Kristian Sandberg
1397 <Kristian.Sandberg@colorado.edu>.
1417 <Kristian.Sandberg@colorado.edu>.
1398 (Magic.__init__): fix bug in global magic escapes not being
1418 (Magic.__init__): fix bug in global magic escapes not being
1399 correctly set.
1419 correctly set.
1400
1420
1401 2004-10-08 Fernando Perez <fperez@colorado.edu>
1421 2004-10-08 Fernando Perez <fperez@colorado.edu>
1402
1422
1403 * IPython/Magic.py (__license__): change to absolute imports of
1423 * IPython/Magic.py (__license__): change to absolute imports of
1404 ipython's own internal packages, to start adapting to the absolute
1424 ipython's own internal packages, to start adapting to the absolute
1405 import requirement of PEP-328.
1425 import requirement of PEP-328.
1406
1426
1407 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1427 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1408 files, and standardize author/license marks through the Release
1428 files, and standardize author/license marks through the Release
1409 module instead of having per/file stuff (except for files with
1429 module instead of having per/file stuff (except for files with
1410 particular licenses, like the MIT/PSF-licensed codes).
1430 particular licenses, like the MIT/PSF-licensed codes).
1411
1431
1412 * IPython/Debugger.py: remove dead code for python 2.1
1432 * IPython/Debugger.py: remove dead code for python 2.1
1413
1433
1414 2004-10-04 Fernando Perez <fperez@colorado.edu>
1434 2004-10-04 Fernando Perez <fperez@colorado.edu>
1415
1435
1416 * IPython/iplib.py (ipmagic): New function for accessing magics
1436 * IPython/iplib.py (ipmagic): New function for accessing magics
1417 via a normal python function call.
1437 via a normal python function call.
1418
1438
1419 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1439 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1420 from '@' to '%', to accomodate the new @decorator syntax of python
1440 from '@' to '%', to accomodate the new @decorator syntax of python
1421 2.4.
1441 2.4.
1422
1442
1423 2004-09-29 Fernando Perez <fperez@colorado.edu>
1443 2004-09-29 Fernando Perez <fperez@colorado.edu>
1424
1444
1425 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1445 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1426 matplotlib.use to prevent running scripts which try to switch
1446 matplotlib.use to prevent running scripts which try to switch
1427 interactive backends from within ipython. This will just crash
1447 interactive backends from within ipython. This will just crash
1428 the python interpreter, so we can't allow it (but a detailed error
1448 the python interpreter, so we can't allow it (but a detailed error
1429 is given to the user).
1449 is given to the user).
1430
1450
1431 2004-09-28 Fernando Perez <fperez@colorado.edu>
1451 2004-09-28 Fernando Perez <fperez@colorado.edu>
1432
1452
1433 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1453 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1434 matplotlib-related fixes so that using @run with non-matplotlib
1454 matplotlib-related fixes so that using @run with non-matplotlib
1435 scripts doesn't pop up spurious plot windows. This requires
1455 scripts doesn't pop up spurious plot windows. This requires
1436 matplotlib >= 0.63, where I had to make some changes as well.
1456 matplotlib >= 0.63, where I had to make some changes as well.
1437
1457
1438 * IPython/ipmaker.py (make_IPython): update version requirement to
1458 * IPython/ipmaker.py (make_IPython): update version requirement to
1439 python 2.2.
1459 python 2.2.
1440
1460
1441 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1461 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1442 banner arg for embedded customization.
1462 banner arg for embedded customization.
1443
1463
1444 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1464 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1445 explicit uses of __IP as the IPython's instance name. Now things
1465 explicit uses of __IP as the IPython's instance name. Now things
1446 are properly handled via the shell.name value. The actual code
1466 are properly handled via the shell.name value. The actual code
1447 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1467 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1448 is much better than before. I'll clean things completely when the
1468 is much better than before. I'll clean things completely when the
1449 magic stuff gets a real overhaul.
1469 magic stuff gets a real overhaul.
1450
1470
1451 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1471 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1452 minor changes to debian dir.
1472 minor changes to debian dir.
1453
1473
1454 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1474 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1455 pointer to the shell itself in the interactive namespace even when
1475 pointer to the shell itself in the interactive namespace even when
1456 a user-supplied dict is provided. This is needed for embedding
1476 a user-supplied dict is provided. This is needed for embedding
1457 purposes (found by tests with Michel Sanner).
1477 purposes (found by tests with Michel Sanner).
1458
1478
1459 2004-09-27 Fernando Perez <fperez@colorado.edu>
1479 2004-09-27 Fernando Perez <fperez@colorado.edu>
1460
1480
1461 * IPython/UserConfig/ipythonrc: remove []{} from
1481 * IPython/UserConfig/ipythonrc: remove []{} from
1462 readline_remove_delims, so that things like [modname.<TAB> do
1482 readline_remove_delims, so that things like [modname.<TAB> do
1463 proper completion. This disables [].TAB, but that's a less common
1483 proper completion. This disables [].TAB, but that's a less common
1464 case than module names in list comprehensions, for example.
1484 case than module names in list comprehensions, for example.
1465 Thanks to a report by Andrea Riciputi.
1485 Thanks to a report by Andrea Riciputi.
1466
1486
1467 2004-09-09 Fernando Perez <fperez@colorado.edu>
1487 2004-09-09 Fernando Perez <fperez@colorado.edu>
1468
1488
1469 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1489 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1470 blocking problems in win32 and osx. Fix by John.
1490 blocking problems in win32 and osx. Fix by John.
1471
1491
1472 2004-09-08 Fernando Perez <fperez@colorado.edu>
1492 2004-09-08 Fernando Perez <fperez@colorado.edu>
1473
1493
1474 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1494 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1475 for Win32 and OSX. Fix by John Hunter.
1495 for Win32 and OSX. Fix by John Hunter.
1476
1496
1477 2004-08-30 *** Released version 0.6.3
1497 2004-08-30 *** Released version 0.6.3
1478
1498
1479 2004-08-30 Fernando Perez <fperez@colorado.edu>
1499 2004-08-30 Fernando Perez <fperez@colorado.edu>
1480
1500
1481 * setup.py (isfile): Add manpages to list of dependent files to be
1501 * setup.py (isfile): Add manpages to list of dependent files to be
1482 updated.
1502 updated.
1483
1503
1484 2004-08-27 Fernando Perez <fperez@colorado.edu>
1504 2004-08-27 Fernando Perez <fperez@colorado.edu>
1485
1505
1486 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1506 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1487 for now. They don't really work with standalone WX/GTK code
1507 for now. They don't really work with standalone WX/GTK code
1488 (though matplotlib IS working fine with both of those backends).
1508 (though matplotlib IS working fine with both of those backends).
1489 This will neeed much more testing. I disabled most things with
1509 This will neeed much more testing. I disabled most things with
1490 comments, so turning it back on later should be pretty easy.
1510 comments, so turning it back on later should be pretty easy.
1491
1511
1492 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1512 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1493 autocalling of expressions like r'foo', by modifying the line
1513 autocalling of expressions like r'foo', by modifying the line
1494 split regexp. Closes
1514 split regexp. Closes
1495 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1515 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1496 Riley <ipythonbugs-AT-sabi.net>.
1516 Riley <ipythonbugs-AT-sabi.net>.
1497 (InteractiveShell.mainloop): honor --nobanner with banner
1517 (InteractiveShell.mainloop): honor --nobanner with banner
1498 extensions.
1518 extensions.
1499
1519
1500 * IPython/Shell.py: Significant refactoring of all classes, so
1520 * IPython/Shell.py: Significant refactoring of all classes, so
1501 that we can really support ALL matplotlib backends and threading
1521 that we can really support ALL matplotlib backends and threading
1502 models (John spotted a bug with Tk which required this). Now we
1522 models (John spotted a bug with Tk which required this). Now we
1503 should support single-threaded, WX-threads and GTK-threads, both
1523 should support single-threaded, WX-threads and GTK-threads, both
1504 for generic code and for matplotlib.
1524 for generic code and for matplotlib.
1505
1525
1506 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1526 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1507 -pylab, to simplify things for users. Will also remove the pylab
1527 -pylab, to simplify things for users. Will also remove the pylab
1508 profile, since now all of matplotlib configuration is directly
1528 profile, since now all of matplotlib configuration is directly
1509 handled here. This also reduces startup time.
1529 handled here. This also reduces startup time.
1510
1530
1511 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1531 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1512 shell wasn't being correctly called. Also in IPShellWX.
1532 shell wasn't being correctly called. Also in IPShellWX.
1513
1533
1514 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1534 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1515 fine-tune banner.
1535 fine-tune banner.
1516
1536
1517 * IPython/numutils.py (spike): Deprecate these spike functions,
1537 * IPython/numutils.py (spike): Deprecate these spike functions,
1518 delete (long deprecated) gnuplot_exec handler.
1538 delete (long deprecated) gnuplot_exec handler.
1519
1539
1520 2004-08-26 Fernando Perez <fperez@colorado.edu>
1540 2004-08-26 Fernando Perez <fperez@colorado.edu>
1521
1541
1522 * ipython.1: Update for threading options, plus some others which
1542 * ipython.1: Update for threading options, plus some others which
1523 were missing.
1543 were missing.
1524
1544
1525 * IPython/ipmaker.py (__call__): Added -wthread option for
1545 * IPython/ipmaker.py (__call__): Added -wthread option for
1526 wxpython thread handling. Make sure threading options are only
1546 wxpython thread handling. Make sure threading options are only
1527 valid at the command line.
1547 valid at the command line.
1528
1548
1529 * scripts/ipython: moved shell selection into a factory function
1549 * scripts/ipython: moved shell selection into a factory function
1530 in Shell.py, to keep the starter script to a minimum.
1550 in Shell.py, to keep the starter script to a minimum.
1531
1551
1532 2004-08-25 Fernando Perez <fperez@colorado.edu>
1552 2004-08-25 Fernando Perez <fperez@colorado.edu>
1533
1553
1534 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1554 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1535 John. Along with some recent changes he made to matplotlib, the
1555 John. Along with some recent changes he made to matplotlib, the
1536 next versions of both systems should work very well together.
1556 next versions of both systems should work very well together.
1537
1557
1538 2004-08-24 Fernando Perez <fperez@colorado.edu>
1558 2004-08-24 Fernando Perez <fperez@colorado.edu>
1539
1559
1540 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1560 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1541 tried to switch the profiling to using hotshot, but I'm getting
1561 tried to switch the profiling to using hotshot, but I'm getting
1542 strange errors from prof.runctx() there. I may be misreading the
1562 strange errors from prof.runctx() there. I may be misreading the
1543 docs, but it looks weird. For now the profiling code will
1563 docs, but it looks weird. For now the profiling code will
1544 continue to use the standard profiler.
1564 continue to use the standard profiler.
1545
1565
1546 2004-08-23 Fernando Perez <fperez@colorado.edu>
1566 2004-08-23 Fernando Perez <fperez@colorado.edu>
1547
1567
1548 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1568 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1549 threaded shell, by John Hunter. It's not quite ready yet, but
1569 threaded shell, by John Hunter. It's not quite ready yet, but
1550 close.
1570 close.
1551
1571
1552 2004-08-22 Fernando Perez <fperez@colorado.edu>
1572 2004-08-22 Fernando Perez <fperez@colorado.edu>
1553
1573
1554 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1574 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1555 in Magic and ultraTB.
1575 in Magic and ultraTB.
1556
1576
1557 * ipython.1: document threading options in manpage.
1577 * ipython.1: document threading options in manpage.
1558
1578
1559 * scripts/ipython: Changed name of -thread option to -gthread,
1579 * scripts/ipython: Changed name of -thread option to -gthread,
1560 since this is GTK specific. I want to leave the door open for a
1580 since this is GTK specific. I want to leave the door open for a
1561 -wthread option for WX, which will most likely be necessary. This
1581 -wthread option for WX, which will most likely be necessary. This
1562 change affects usage and ipmaker as well.
1582 change affects usage and ipmaker as well.
1563
1583
1564 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1584 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1565 handle the matplotlib shell issues. Code by John Hunter
1585 handle the matplotlib shell issues. Code by John Hunter
1566 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1586 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1567 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1587 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1568 broken (and disabled for end users) for now, but it puts the
1588 broken (and disabled for end users) for now, but it puts the
1569 infrastructure in place.
1589 infrastructure in place.
1570
1590
1571 2004-08-21 Fernando Perez <fperez@colorado.edu>
1591 2004-08-21 Fernando Perez <fperez@colorado.edu>
1572
1592
1573 * ipythonrc-pylab: Add matplotlib support.
1593 * ipythonrc-pylab: Add matplotlib support.
1574
1594
1575 * matplotlib_config.py: new files for matplotlib support, part of
1595 * matplotlib_config.py: new files for matplotlib support, part of
1576 the pylab profile.
1596 the pylab profile.
1577
1597
1578 * IPython/usage.py (__doc__): documented the threading options.
1598 * IPython/usage.py (__doc__): documented the threading options.
1579
1599
1580 2004-08-20 Fernando Perez <fperez@colorado.edu>
1600 2004-08-20 Fernando Perez <fperez@colorado.edu>
1581
1601
1582 * ipython: Modified the main calling routine to handle the -thread
1602 * ipython: Modified the main calling routine to handle the -thread
1583 and -mpthread options. This needs to be done as a top-level hack,
1603 and -mpthread options. This needs to be done as a top-level hack,
1584 because it determines which class to instantiate for IPython
1604 because it determines which class to instantiate for IPython
1585 itself.
1605 itself.
1586
1606
1587 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1607 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1588 classes to support multithreaded GTK operation without blocking,
1608 classes to support multithreaded GTK operation without blocking,
1589 and matplotlib with all backends. This is a lot of still very
1609 and matplotlib with all backends. This is a lot of still very
1590 experimental code, and threads are tricky. So it may still have a
1610 experimental code, and threads are tricky. So it may still have a
1591 few rough edges... This code owes a lot to
1611 few rough edges... This code owes a lot to
1592 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1612 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1593 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1613 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1594 to John Hunter for all the matplotlib work.
1614 to John Hunter for all the matplotlib work.
1595
1615
1596 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1616 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1597 options for gtk thread and matplotlib support.
1617 options for gtk thread and matplotlib support.
1598
1618
1599 2004-08-16 Fernando Perez <fperez@colorado.edu>
1619 2004-08-16 Fernando Perez <fperez@colorado.edu>
1600
1620
1601 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1621 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1602 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1622 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1603 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1623 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1604
1624
1605 2004-08-11 Fernando Perez <fperez@colorado.edu>
1625 2004-08-11 Fernando Perez <fperez@colorado.edu>
1606
1626
1607 * setup.py (isfile): Fix build so documentation gets updated for
1627 * setup.py (isfile): Fix build so documentation gets updated for
1608 rpms (it was only done for .tgz builds).
1628 rpms (it was only done for .tgz builds).
1609
1629
1610 2004-08-10 Fernando Perez <fperez@colorado.edu>
1630 2004-08-10 Fernando Perez <fperez@colorado.edu>
1611
1631
1612 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1632 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1613
1633
1614 * iplib.py : Silence syntax error exceptions in tab-completion.
1634 * iplib.py : Silence syntax error exceptions in tab-completion.
1615
1635
1616 2004-08-05 Fernando Perez <fperez@colorado.edu>
1636 2004-08-05 Fernando Perez <fperez@colorado.edu>
1617
1637
1618 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1638 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1619 'color off' mark for continuation prompts. This was causing long
1639 'color off' mark for continuation prompts. This was causing long
1620 continuation lines to mis-wrap.
1640 continuation lines to mis-wrap.
1621
1641
1622 2004-08-01 Fernando Perez <fperez@colorado.edu>
1642 2004-08-01 Fernando Perez <fperez@colorado.edu>
1623
1643
1624 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1644 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1625 for building ipython to be a parameter. All this is necessary
1645 for building ipython to be a parameter. All this is necessary
1626 right now to have a multithreaded version, but this insane
1646 right now to have a multithreaded version, but this insane
1627 non-design will be cleaned up soon. For now, it's a hack that
1647 non-design will be cleaned up soon. For now, it's a hack that
1628 works.
1648 works.
1629
1649
1630 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1650 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1631 args in various places. No bugs so far, but it's a dangerous
1651 args in various places. No bugs so far, but it's a dangerous
1632 practice.
1652 practice.
1633
1653
1634 2004-07-31 Fernando Perez <fperez@colorado.edu>
1654 2004-07-31 Fernando Perez <fperez@colorado.edu>
1635
1655
1636 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1656 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1637 fix completion of files with dots in their names under most
1657 fix completion of files with dots in their names under most
1638 profiles (pysh was OK because the completion order is different).
1658 profiles (pysh was OK because the completion order is different).
1639
1659
1640 2004-07-27 Fernando Perez <fperez@colorado.edu>
1660 2004-07-27 Fernando Perez <fperez@colorado.edu>
1641
1661
1642 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1662 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1643 keywords manually, b/c the one in keyword.py was removed in python
1663 keywords manually, b/c the one in keyword.py was removed in python
1644 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1664 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1645 This is NOT a bug under python 2.3 and earlier.
1665 This is NOT a bug under python 2.3 and earlier.
1646
1666
1647 2004-07-26 Fernando Perez <fperez@colorado.edu>
1667 2004-07-26 Fernando Perez <fperez@colorado.edu>
1648
1668
1649 * IPython/ultraTB.py (VerboseTB.text): Add another
1669 * IPython/ultraTB.py (VerboseTB.text): Add another
1650 linecache.checkcache() call to try to prevent inspect.py from
1670 linecache.checkcache() call to try to prevent inspect.py from
1651 crashing under python 2.3. I think this fixes
1671 crashing under python 2.3. I think this fixes
1652 http://www.scipy.net/roundup/ipython/issue17.
1672 http://www.scipy.net/roundup/ipython/issue17.
1653
1673
1654 2004-07-26 *** Released version 0.6.2
1674 2004-07-26 *** Released version 0.6.2
1655
1675
1656 2004-07-26 Fernando Perez <fperez@colorado.edu>
1676 2004-07-26 Fernando Perez <fperez@colorado.edu>
1657
1677
1658 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1678 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1659 fail for any number.
1679 fail for any number.
1660 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1680 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1661 empty bookmarks.
1681 empty bookmarks.
1662
1682
1663 2004-07-26 *** Released version 0.6.1
1683 2004-07-26 *** Released version 0.6.1
1664
1684
1665 2004-07-26 Fernando Perez <fperez@colorado.edu>
1685 2004-07-26 Fernando Perez <fperez@colorado.edu>
1666
1686
1667 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1687 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1668
1688
1669 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1689 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1670 escaping '()[]{}' in filenames.
1690 escaping '()[]{}' in filenames.
1671
1691
1672 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1692 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1673 Python 2.2 users who lack a proper shlex.split.
1693 Python 2.2 users who lack a proper shlex.split.
1674
1694
1675 2004-07-19 Fernando Perez <fperez@colorado.edu>
1695 2004-07-19 Fernando Perez <fperez@colorado.edu>
1676
1696
1677 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1697 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1678 for reading readline's init file. I follow the normal chain:
1698 for reading readline's init file. I follow the normal chain:
1679 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1699 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1680 report by Mike Heeter. This closes
1700 report by Mike Heeter. This closes
1681 http://www.scipy.net/roundup/ipython/issue16.
1701 http://www.scipy.net/roundup/ipython/issue16.
1682
1702
1683 2004-07-18 Fernando Perez <fperez@colorado.edu>
1703 2004-07-18 Fernando Perez <fperez@colorado.edu>
1684
1704
1685 * IPython/iplib.py (__init__): Add better handling of '\' under
1705 * IPython/iplib.py (__init__): Add better handling of '\' under
1686 Win32 for filenames. After a patch by Ville.
1706 Win32 for filenames. After a patch by Ville.
1687
1707
1688 2004-07-17 Fernando Perez <fperez@colorado.edu>
1708 2004-07-17 Fernando Perez <fperez@colorado.edu>
1689
1709
1690 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1710 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1691 autocalling would be triggered for 'foo is bar' if foo is
1711 autocalling would be triggered for 'foo is bar' if foo is
1692 callable. I also cleaned up the autocall detection code to use a
1712 callable. I also cleaned up the autocall detection code to use a
1693 regexp, which is faster. Bug reported by Alexander Schmolck.
1713 regexp, which is faster. Bug reported by Alexander Schmolck.
1694
1714
1695 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1715 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1696 '?' in them would confuse the help system. Reported by Alex
1716 '?' in them would confuse the help system. Reported by Alex
1697 Schmolck.
1717 Schmolck.
1698
1718
1699 2004-07-16 Fernando Perez <fperez@colorado.edu>
1719 2004-07-16 Fernando Perez <fperez@colorado.edu>
1700
1720
1701 * IPython/GnuplotInteractive.py (__all__): added plot2.
1721 * IPython/GnuplotInteractive.py (__all__): added plot2.
1702
1722
1703 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1723 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1704 plotting dictionaries, lists or tuples of 1d arrays.
1724 plotting dictionaries, lists or tuples of 1d arrays.
1705
1725
1706 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1726 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1707 optimizations.
1727 optimizations.
1708
1728
1709 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1729 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1710 the information which was there from Janko's original IPP code:
1730 the information which was there from Janko's original IPP code:
1711
1731
1712 03.05.99 20:53 porto.ifm.uni-kiel.de
1732 03.05.99 20:53 porto.ifm.uni-kiel.de
1713 --Started changelog.
1733 --Started changelog.
1714 --make clear do what it say it does
1734 --make clear do what it say it does
1715 --added pretty output of lines from inputcache
1735 --added pretty output of lines from inputcache
1716 --Made Logger a mixin class, simplifies handling of switches
1736 --Made Logger a mixin class, simplifies handling of switches
1717 --Added own completer class. .string<TAB> expands to last history
1737 --Added own completer class. .string<TAB> expands to last history
1718 line which starts with string. The new expansion is also present
1738 line which starts with string. The new expansion is also present
1719 with Ctrl-r from the readline library. But this shows, who this
1739 with Ctrl-r from the readline library. But this shows, who this
1720 can be done for other cases.
1740 can be done for other cases.
1721 --Added convention that all shell functions should accept a
1741 --Added convention that all shell functions should accept a
1722 parameter_string This opens the door for different behaviour for
1742 parameter_string This opens the door for different behaviour for
1723 each function. @cd is a good example of this.
1743 each function. @cd is a good example of this.
1724
1744
1725 04.05.99 12:12 porto.ifm.uni-kiel.de
1745 04.05.99 12:12 porto.ifm.uni-kiel.de
1726 --added logfile rotation
1746 --added logfile rotation
1727 --added new mainloop method which freezes first the namespace
1747 --added new mainloop method which freezes first the namespace
1728
1748
1729 07.05.99 21:24 porto.ifm.uni-kiel.de
1749 07.05.99 21:24 porto.ifm.uni-kiel.de
1730 --added the docreader classes. Now there is a help system.
1750 --added the docreader classes. Now there is a help system.
1731 -This is only a first try. Currently it's not easy to put new
1751 -This is only a first try. Currently it's not easy to put new
1732 stuff in the indices. But this is the way to go. Info would be
1752 stuff in the indices. But this is the way to go. Info would be
1733 better, but HTML is every where and not everybody has an info
1753 better, but HTML is every where and not everybody has an info
1734 system installed and it's not so easy to change html-docs to info.
1754 system installed and it's not so easy to change html-docs to info.
1735 --added global logfile option
1755 --added global logfile option
1736 --there is now a hook for object inspection method pinfo needs to
1756 --there is now a hook for object inspection method pinfo needs to
1737 be provided for this. Can be reached by two '??'.
1757 be provided for this. Can be reached by two '??'.
1738
1758
1739 08.05.99 20:51 porto.ifm.uni-kiel.de
1759 08.05.99 20:51 porto.ifm.uni-kiel.de
1740 --added a README
1760 --added a README
1741 --bug in rc file. Something has changed so functions in the rc
1761 --bug in rc file. Something has changed so functions in the rc
1742 file need to reference the shell and not self. Not clear if it's a
1762 file need to reference the shell and not self. Not clear if it's a
1743 bug or feature.
1763 bug or feature.
1744 --changed rc file for new behavior
1764 --changed rc file for new behavior
1745
1765
1746 2004-07-15 Fernando Perez <fperez@colorado.edu>
1766 2004-07-15 Fernando Perez <fperez@colorado.edu>
1747
1767
1748 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1768 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1749 cache was falling out of sync in bizarre manners when multi-line
1769 cache was falling out of sync in bizarre manners when multi-line
1750 input was present. Minor optimizations and cleanup.
1770 input was present. Minor optimizations and cleanup.
1751
1771
1752 (Logger): Remove old Changelog info for cleanup. This is the
1772 (Logger): Remove old Changelog info for cleanup. This is the
1753 information which was there from Janko's original code:
1773 information which was there from Janko's original code:
1754
1774
1755 Changes to Logger: - made the default log filename a parameter
1775 Changes to Logger: - made the default log filename a parameter
1756
1776
1757 - put a check for lines beginning with !@? in log(). Needed
1777 - put a check for lines beginning with !@? in log(). Needed
1758 (even if the handlers properly log their lines) for mid-session
1778 (even if the handlers properly log their lines) for mid-session
1759 logging activation to work properly. Without this, lines logged
1779 logging activation to work properly. Without this, lines logged
1760 in mid session, which get read from the cache, would end up
1780 in mid session, which get read from the cache, would end up
1761 'bare' (with !@? in the open) in the log. Now they are caught
1781 'bare' (with !@? in the open) in the log. Now they are caught
1762 and prepended with a #.
1782 and prepended with a #.
1763
1783
1764 * IPython/iplib.py (InteractiveShell.init_readline): added check
1784 * IPython/iplib.py (InteractiveShell.init_readline): added check
1765 in case MagicCompleter fails to be defined, so we don't crash.
1785 in case MagicCompleter fails to be defined, so we don't crash.
1766
1786
1767 2004-07-13 Fernando Perez <fperez@colorado.edu>
1787 2004-07-13 Fernando Perez <fperez@colorado.edu>
1768
1788
1769 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1789 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1770 of EPS if the requested filename ends in '.eps'.
1790 of EPS if the requested filename ends in '.eps'.
1771
1791
1772 2004-07-04 Fernando Perez <fperez@colorado.edu>
1792 2004-07-04 Fernando Perez <fperez@colorado.edu>
1773
1793
1774 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1794 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1775 escaping of quotes when calling the shell.
1795 escaping of quotes when calling the shell.
1776
1796
1777 2004-07-02 Fernando Perez <fperez@colorado.edu>
1797 2004-07-02 Fernando Perez <fperez@colorado.edu>
1778
1798
1779 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1799 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1780 gettext not working because we were clobbering '_'. Fixes
1800 gettext not working because we were clobbering '_'. Fixes
1781 http://www.scipy.net/roundup/ipython/issue6.
1801 http://www.scipy.net/roundup/ipython/issue6.
1782
1802
1783 2004-07-01 Fernando Perez <fperez@colorado.edu>
1803 2004-07-01 Fernando Perez <fperez@colorado.edu>
1784
1804
1785 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1805 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1786 into @cd. Patch by Ville.
1806 into @cd. Patch by Ville.
1787
1807
1788 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1808 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1789 new function to store things after ipmaker runs. Patch by Ville.
1809 new function to store things after ipmaker runs. Patch by Ville.
1790 Eventually this will go away once ipmaker is removed and the class
1810 Eventually this will go away once ipmaker is removed and the class
1791 gets cleaned up, but for now it's ok. Key functionality here is
1811 gets cleaned up, but for now it's ok. Key functionality here is
1792 the addition of the persistent storage mechanism, a dict for
1812 the addition of the persistent storage mechanism, a dict for
1793 keeping data across sessions (for now just bookmarks, but more can
1813 keeping data across sessions (for now just bookmarks, but more can
1794 be implemented later).
1814 be implemented later).
1795
1815
1796 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1816 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1797 persistent across sections. Patch by Ville, I modified it
1817 persistent across sections. Patch by Ville, I modified it
1798 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1818 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1799 added a '-l' option to list all bookmarks.
1819 added a '-l' option to list all bookmarks.
1800
1820
1801 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1821 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1802 center for cleanup. Registered with atexit.register(). I moved
1822 center for cleanup. Registered with atexit.register(). I moved
1803 here the old exit_cleanup(). After a patch by Ville.
1823 here the old exit_cleanup(). After a patch by Ville.
1804
1824
1805 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1825 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1806 characters in the hacked shlex_split for python 2.2.
1826 characters in the hacked shlex_split for python 2.2.
1807
1827
1808 * IPython/iplib.py (file_matches): more fixes to filenames with
1828 * IPython/iplib.py (file_matches): more fixes to filenames with
1809 whitespace in them. It's not perfect, but limitations in python's
1829 whitespace in them. It's not perfect, but limitations in python's
1810 readline make it impossible to go further.
1830 readline make it impossible to go further.
1811
1831
1812 2004-06-29 Fernando Perez <fperez@colorado.edu>
1832 2004-06-29 Fernando Perez <fperez@colorado.edu>
1813
1833
1814 * IPython/iplib.py (file_matches): escape whitespace correctly in
1834 * IPython/iplib.py (file_matches): escape whitespace correctly in
1815 filename completions. Bug reported by Ville.
1835 filename completions. Bug reported by Ville.
1816
1836
1817 2004-06-28 Fernando Perez <fperez@colorado.edu>
1837 2004-06-28 Fernando Perez <fperez@colorado.edu>
1818
1838
1819 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1839 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1820 the history file will be called 'history-PROFNAME' (or just
1840 the history file will be called 'history-PROFNAME' (or just
1821 'history' if no profile is loaded). I was getting annoyed at
1841 'history' if no profile is loaded). I was getting annoyed at
1822 getting my Numerical work history clobbered by pysh sessions.
1842 getting my Numerical work history clobbered by pysh sessions.
1823
1843
1824 * IPython/iplib.py (InteractiveShell.__init__): Internal
1844 * IPython/iplib.py (InteractiveShell.__init__): Internal
1825 getoutputerror() function so that we can honor the system_verbose
1845 getoutputerror() function so that we can honor the system_verbose
1826 flag for _all_ system calls. I also added escaping of #
1846 flag for _all_ system calls. I also added escaping of #
1827 characters here to avoid confusing Itpl.
1847 characters here to avoid confusing Itpl.
1828
1848
1829 * IPython/Magic.py (shlex_split): removed call to shell in
1849 * IPython/Magic.py (shlex_split): removed call to shell in
1830 parse_options and replaced it with shlex.split(). The annoying
1850 parse_options and replaced it with shlex.split(). The annoying
1831 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1851 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1832 to backport it from 2.3, with several frail hacks (the shlex
1852 to backport it from 2.3, with several frail hacks (the shlex
1833 module is rather limited in 2.2). Thanks to a suggestion by Ville
1853 module is rather limited in 2.2). Thanks to a suggestion by Ville
1834 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1854 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1835 problem.
1855 problem.
1836
1856
1837 (Magic.magic_system_verbose): new toggle to print the actual
1857 (Magic.magic_system_verbose): new toggle to print the actual
1838 system calls made by ipython. Mainly for debugging purposes.
1858 system calls made by ipython. Mainly for debugging purposes.
1839
1859
1840 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1860 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1841 doesn't support persistence. Reported (and fix suggested) by
1861 doesn't support persistence. Reported (and fix suggested) by
1842 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1862 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1843
1863
1844 2004-06-26 Fernando Perez <fperez@colorado.edu>
1864 2004-06-26 Fernando Perez <fperez@colorado.edu>
1845
1865
1846 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1866 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1847 continue prompts.
1867 continue prompts.
1848
1868
1849 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1869 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1850 function (basically a big docstring) and a few more things here to
1870 function (basically a big docstring) and a few more things here to
1851 speedup startup. pysh.py is now very lightweight. We want because
1871 speedup startup. pysh.py is now very lightweight. We want because
1852 it gets execfile'd, while InterpreterExec gets imported, so
1872 it gets execfile'd, while InterpreterExec gets imported, so
1853 byte-compilation saves time.
1873 byte-compilation saves time.
1854
1874
1855 2004-06-25 Fernando Perez <fperez@colorado.edu>
1875 2004-06-25 Fernando Perez <fperez@colorado.edu>
1856
1876
1857 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1877 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1858 -NUM', which was recently broken.
1878 -NUM', which was recently broken.
1859
1879
1860 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1880 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1861 in multi-line input (but not !!, which doesn't make sense there).
1881 in multi-line input (but not !!, which doesn't make sense there).
1862
1882
1863 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1883 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1864 It's just too useful, and people can turn it off in the less
1884 It's just too useful, and people can turn it off in the less
1865 common cases where it's a problem.
1885 common cases where it's a problem.
1866
1886
1867 2004-06-24 Fernando Perez <fperez@colorado.edu>
1887 2004-06-24 Fernando Perez <fperez@colorado.edu>
1868
1888
1869 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1889 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1870 special syntaxes (like alias calling) is now allied in multi-line
1890 special syntaxes (like alias calling) is now allied in multi-line
1871 input. This is still _very_ experimental, but it's necessary for
1891 input. This is still _very_ experimental, but it's necessary for
1872 efficient shell usage combining python looping syntax with system
1892 efficient shell usage combining python looping syntax with system
1873 calls. For now it's restricted to aliases, I don't think it
1893 calls. For now it's restricted to aliases, I don't think it
1874 really even makes sense to have this for magics.
1894 really even makes sense to have this for magics.
1875
1895
1876 2004-06-23 Fernando Perez <fperez@colorado.edu>
1896 2004-06-23 Fernando Perez <fperez@colorado.edu>
1877
1897
1878 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1898 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1879 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1899 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1880
1900
1881 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1901 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1882 extensions under Windows (after code sent by Gary Bishop). The
1902 extensions under Windows (after code sent by Gary Bishop). The
1883 extensions considered 'executable' are stored in IPython's rc
1903 extensions considered 'executable' are stored in IPython's rc
1884 structure as win_exec_ext.
1904 structure as win_exec_ext.
1885
1905
1886 * IPython/genutils.py (shell): new function, like system() but
1906 * IPython/genutils.py (shell): new function, like system() but
1887 without return value. Very useful for interactive shell work.
1907 without return value. Very useful for interactive shell work.
1888
1908
1889 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1909 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1890 delete aliases.
1910 delete aliases.
1891
1911
1892 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1912 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1893 sure that the alias table doesn't contain python keywords.
1913 sure that the alias table doesn't contain python keywords.
1894
1914
1895 2004-06-21 Fernando Perez <fperez@colorado.edu>
1915 2004-06-21 Fernando Perez <fperez@colorado.edu>
1896
1916
1897 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1917 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1898 non-existent items are found in $PATH. Reported by Thorsten.
1918 non-existent items are found in $PATH. Reported by Thorsten.
1899
1919
1900 2004-06-20 Fernando Perez <fperez@colorado.edu>
1920 2004-06-20 Fernando Perez <fperez@colorado.edu>
1901
1921
1902 * IPython/iplib.py (complete): modified the completer so that the
1922 * IPython/iplib.py (complete): modified the completer so that the
1903 order of priorities can be easily changed at runtime.
1923 order of priorities can be easily changed at runtime.
1904
1924
1905 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1925 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1906 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1926 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1907
1927
1908 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1928 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1909 expand Python variables prepended with $ in all system calls. The
1929 expand Python variables prepended with $ in all system calls. The
1910 same was done to InteractiveShell.handle_shell_escape. Now all
1930 same was done to InteractiveShell.handle_shell_escape. Now all
1911 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1931 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1912 expansion of python variables and expressions according to the
1932 expansion of python variables and expressions according to the
1913 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1933 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1914
1934
1915 Though PEP-215 has been rejected, a similar (but simpler) one
1935 Though PEP-215 has been rejected, a similar (but simpler) one
1916 seems like it will go into Python 2.4, PEP-292 -
1936 seems like it will go into Python 2.4, PEP-292 -
1917 http://www.python.org/peps/pep-0292.html.
1937 http://www.python.org/peps/pep-0292.html.
1918
1938
1919 I'll keep the full syntax of PEP-215, since IPython has since the
1939 I'll keep the full syntax of PEP-215, since IPython has since the
1920 start used Ka-Ping Yee's reference implementation discussed there
1940 start used Ka-Ping Yee's reference implementation discussed there
1921 (Itpl), and I actually like the powerful semantics it offers.
1941 (Itpl), and I actually like the powerful semantics it offers.
1922
1942
1923 In order to access normal shell variables, the $ has to be escaped
1943 In order to access normal shell variables, the $ has to be escaped
1924 via an extra $. For example:
1944 via an extra $. For example:
1925
1945
1926 In [7]: PATH='a python variable'
1946 In [7]: PATH='a python variable'
1927
1947
1928 In [8]: !echo $PATH
1948 In [8]: !echo $PATH
1929 a python variable
1949 a python variable
1930
1950
1931 In [9]: !echo $$PATH
1951 In [9]: !echo $$PATH
1932 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1952 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1933
1953
1934 (Magic.parse_options): escape $ so the shell doesn't evaluate
1954 (Magic.parse_options): escape $ so the shell doesn't evaluate
1935 things prematurely.
1955 things prematurely.
1936
1956
1937 * IPython/iplib.py (InteractiveShell.call_alias): added the
1957 * IPython/iplib.py (InteractiveShell.call_alias): added the
1938 ability for aliases to expand python variables via $.
1958 ability for aliases to expand python variables via $.
1939
1959
1940 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1960 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1941 system, now there's a @rehash/@rehashx pair of magics. These work
1961 system, now there's a @rehash/@rehashx pair of magics. These work
1942 like the csh rehash command, and can be invoked at any time. They
1962 like the csh rehash command, and can be invoked at any time. They
1943 build a table of aliases to everything in the user's $PATH
1963 build a table of aliases to everything in the user's $PATH
1944 (@rehash uses everything, @rehashx is slower but only adds
1964 (@rehash uses everything, @rehashx is slower but only adds
1945 executable files). With this, the pysh.py-based shell profile can
1965 executable files). With this, the pysh.py-based shell profile can
1946 now simply call rehash upon startup, and full access to all
1966 now simply call rehash upon startup, and full access to all
1947 programs in the user's path is obtained.
1967 programs in the user's path is obtained.
1948
1968
1949 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1969 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1950 functionality is now fully in place. I removed the old dynamic
1970 functionality is now fully in place. I removed the old dynamic
1951 code generation based approach, in favor of a much lighter one
1971 code generation based approach, in favor of a much lighter one
1952 based on a simple dict. The advantage is that this allows me to
1972 based on a simple dict. The advantage is that this allows me to
1953 now have thousands of aliases with negligible cost (unthinkable
1973 now have thousands of aliases with negligible cost (unthinkable
1954 with the old system).
1974 with the old system).
1955
1975
1956 2004-06-19 Fernando Perez <fperez@colorado.edu>
1976 2004-06-19 Fernando Perez <fperez@colorado.edu>
1957
1977
1958 * IPython/iplib.py (__init__): extended MagicCompleter class to
1978 * IPython/iplib.py (__init__): extended MagicCompleter class to
1959 also complete (last in priority) on user aliases.
1979 also complete (last in priority) on user aliases.
1960
1980
1961 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1981 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1962 call to eval.
1982 call to eval.
1963 (ItplNS.__init__): Added a new class which functions like Itpl,
1983 (ItplNS.__init__): Added a new class which functions like Itpl,
1964 but allows configuring the namespace for the evaluation to occur
1984 but allows configuring the namespace for the evaluation to occur
1965 in.
1985 in.
1966
1986
1967 2004-06-18 Fernando Perez <fperez@colorado.edu>
1987 2004-06-18 Fernando Perez <fperez@colorado.edu>
1968
1988
1969 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1989 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1970 better message when 'exit' or 'quit' are typed (a common newbie
1990 better message when 'exit' or 'quit' are typed (a common newbie
1971 confusion).
1991 confusion).
1972
1992
1973 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1993 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1974 check for Windows users.
1994 check for Windows users.
1975
1995
1976 * IPython/iplib.py (InteractiveShell.user_setup): removed
1996 * IPython/iplib.py (InteractiveShell.user_setup): removed
1977 disabling of colors for Windows. I'll test at runtime and issue a
1997 disabling of colors for Windows. I'll test at runtime and issue a
1978 warning if Gary's readline isn't found, as to nudge users to
1998 warning if Gary's readline isn't found, as to nudge users to
1979 download it.
1999 download it.
1980
2000
1981 2004-06-16 Fernando Perez <fperez@colorado.edu>
2001 2004-06-16 Fernando Perez <fperez@colorado.edu>
1982
2002
1983 * IPython/genutils.py (Stream.__init__): changed to print errors
2003 * IPython/genutils.py (Stream.__init__): changed to print errors
1984 to sys.stderr. I had a circular dependency here. Now it's
2004 to sys.stderr. I had a circular dependency here. Now it's
1985 possible to run ipython as IDLE's shell (consider this pre-alpha,
2005 possible to run ipython as IDLE's shell (consider this pre-alpha,
1986 since true stdout things end up in the starting terminal instead
2006 since true stdout things end up in the starting terminal instead
1987 of IDLE's out).
2007 of IDLE's out).
1988
2008
1989 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2009 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1990 users who haven't # updated their prompt_in2 definitions. Remove
2010 users who haven't # updated their prompt_in2 definitions. Remove
1991 eventually.
2011 eventually.
1992 (multiple_replace): added credit to original ASPN recipe.
2012 (multiple_replace): added credit to original ASPN recipe.
1993
2013
1994 2004-06-15 Fernando Perez <fperez@colorado.edu>
2014 2004-06-15 Fernando Perez <fperez@colorado.edu>
1995
2015
1996 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2016 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1997 list of auto-defined aliases.
2017 list of auto-defined aliases.
1998
2018
1999 2004-06-13 Fernando Perez <fperez@colorado.edu>
2019 2004-06-13 Fernando Perez <fperez@colorado.edu>
2000
2020
2001 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2021 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2002 install was really requested (so setup.py can be used for other
2022 install was really requested (so setup.py can be used for other
2003 things under Windows).
2023 things under Windows).
2004
2024
2005 2004-06-10 Fernando Perez <fperez@colorado.edu>
2025 2004-06-10 Fernando Perez <fperez@colorado.edu>
2006
2026
2007 * IPython/Logger.py (Logger.create_log): Manually remove any old
2027 * IPython/Logger.py (Logger.create_log): Manually remove any old
2008 backup, since os.remove may fail under Windows. Fixes bug
2028 backup, since os.remove may fail under Windows. Fixes bug
2009 reported by Thorsten.
2029 reported by Thorsten.
2010
2030
2011 2004-06-09 Fernando Perez <fperez@colorado.edu>
2031 2004-06-09 Fernando Perez <fperez@colorado.edu>
2012
2032
2013 * examples/example-embed.py: fixed all references to %n (replaced
2033 * examples/example-embed.py: fixed all references to %n (replaced
2014 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2034 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2015 for all examples and the manual as well.
2035 for all examples and the manual as well.
2016
2036
2017 2004-06-08 Fernando Perez <fperez@colorado.edu>
2037 2004-06-08 Fernando Perez <fperez@colorado.edu>
2018
2038
2019 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2039 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2020 alignment and color management. All 3 prompt subsystems now
2040 alignment and color management. All 3 prompt subsystems now
2021 inherit from BasePrompt.
2041 inherit from BasePrompt.
2022
2042
2023 * tools/release: updates for windows installer build and tag rpms
2043 * tools/release: updates for windows installer build and tag rpms
2024 with python version (since paths are fixed).
2044 with python version (since paths are fixed).
2025
2045
2026 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2046 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2027 which will become eventually obsolete. Also fixed the default
2047 which will become eventually obsolete. Also fixed the default
2028 prompt_in2 to use \D, so at least new users start with the correct
2048 prompt_in2 to use \D, so at least new users start with the correct
2029 defaults.
2049 defaults.
2030 WARNING: Users with existing ipythonrc files will need to apply
2050 WARNING: Users with existing ipythonrc files will need to apply
2031 this fix manually!
2051 this fix manually!
2032
2052
2033 * setup.py: make windows installer (.exe). This is finally the
2053 * setup.py: make windows installer (.exe). This is finally the
2034 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2054 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2035 which I hadn't included because it required Python 2.3 (or recent
2055 which I hadn't included because it required Python 2.3 (or recent
2036 distutils).
2056 distutils).
2037
2057
2038 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2058 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2039 usage of new '\D' escape.
2059 usage of new '\D' escape.
2040
2060
2041 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2061 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2042 lacks os.getuid())
2062 lacks os.getuid())
2043 (CachedOutput.set_colors): Added the ability to turn coloring
2063 (CachedOutput.set_colors): Added the ability to turn coloring
2044 on/off with @colors even for manually defined prompt colors. It
2064 on/off with @colors even for manually defined prompt colors. It
2045 uses a nasty global, but it works safely and via the generic color
2065 uses a nasty global, but it works safely and via the generic color
2046 handling mechanism.
2066 handling mechanism.
2047 (Prompt2.__init__): Introduced new escape '\D' for continuation
2067 (Prompt2.__init__): Introduced new escape '\D' for continuation
2048 prompts. It represents the counter ('\#') as dots.
2068 prompts. It represents the counter ('\#') as dots.
2049 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2069 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2050 need to update their ipythonrc files and replace '%n' with '\D' in
2070 need to update their ipythonrc files and replace '%n' with '\D' in
2051 their prompt_in2 settings everywhere. Sorry, but there's
2071 their prompt_in2 settings everywhere. Sorry, but there's
2052 otherwise no clean way to get all prompts to properly align. The
2072 otherwise no clean way to get all prompts to properly align. The
2053 ipythonrc shipped with IPython has been updated.
2073 ipythonrc shipped with IPython has been updated.
2054
2074
2055 2004-06-07 Fernando Perez <fperez@colorado.edu>
2075 2004-06-07 Fernando Perez <fperez@colorado.edu>
2056
2076
2057 * setup.py (isfile): Pass local_icons option to latex2html, so the
2077 * setup.py (isfile): Pass local_icons option to latex2html, so the
2058 resulting HTML file is self-contained. Thanks to
2078 resulting HTML file is self-contained. Thanks to
2059 dryice-AT-liu.com.cn for the tip.
2079 dryice-AT-liu.com.cn for the tip.
2060
2080
2061 * pysh.py: I created a new profile 'shell', which implements a
2081 * pysh.py: I created a new profile 'shell', which implements a
2062 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2082 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2063 system shell, nor will it become one anytime soon. It's mainly
2083 system shell, nor will it become one anytime soon. It's mainly
2064 meant to illustrate the use of the new flexible bash-like prompts.
2084 meant to illustrate the use of the new flexible bash-like prompts.
2065 I guess it could be used by hardy souls for true shell management,
2085 I guess it could be used by hardy souls for true shell management,
2066 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2086 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2067 profile. This uses the InterpreterExec extension provided by
2087 profile. This uses the InterpreterExec extension provided by
2068 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2088 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2069
2089
2070 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2090 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2071 auto-align itself with the length of the previous input prompt
2091 auto-align itself with the length of the previous input prompt
2072 (taking into account the invisible color escapes).
2092 (taking into account the invisible color escapes).
2073 (CachedOutput.__init__): Large restructuring of this class. Now
2093 (CachedOutput.__init__): Large restructuring of this class. Now
2074 all three prompts (primary1, primary2, output) are proper objects,
2094 all three prompts (primary1, primary2, output) are proper objects,
2075 managed by the 'parent' CachedOutput class. The code is still a
2095 managed by the 'parent' CachedOutput class. The code is still a
2076 bit hackish (all prompts share state via a pointer to the cache),
2096 bit hackish (all prompts share state via a pointer to the cache),
2077 but it's overall far cleaner than before.
2097 but it's overall far cleaner than before.
2078
2098
2079 * IPython/genutils.py (getoutputerror): modified to add verbose,
2099 * IPython/genutils.py (getoutputerror): modified to add verbose,
2080 debug and header options. This makes the interface of all getout*
2100 debug and header options. This makes the interface of all getout*
2081 functions uniform.
2101 functions uniform.
2082 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2102 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2083
2103
2084 * IPython/Magic.py (Magic.default_option): added a function to
2104 * IPython/Magic.py (Magic.default_option): added a function to
2085 allow registering default options for any magic command. This
2105 allow registering default options for any magic command. This
2086 makes it easy to have profiles which customize the magics globally
2106 makes it easy to have profiles which customize the magics globally
2087 for a certain use. The values set through this function are
2107 for a certain use. The values set through this function are
2088 picked up by the parse_options() method, which all magics should
2108 picked up by the parse_options() method, which all magics should
2089 use to parse their options.
2109 use to parse their options.
2090
2110
2091 * IPython/genutils.py (warn): modified the warnings framework to
2111 * IPython/genutils.py (warn): modified the warnings framework to
2092 use the Term I/O class. I'm trying to slowly unify all of
2112 use the Term I/O class. I'm trying to slowly unify all of
2093 IPython's I/O operations to pass through Term.
2113 IPython's I/O operations to pass through Term.
2094
2114
2095 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2115 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2096 the secondary prompt to correctly match the length of the primary
2116 the secondary prompt to correctly match the length of the primary
2097 one for any prompt. Now multi-line code will properly line up
2117 one for any prompt. Now multi-line code will properly line up
2098 even for path dependent prompts, such as the new ones available
2118 even for path dependent prompts, such as the new ones available
2099 via the prompt_specials.
2119 via the prompt_specials.
2100
2120
2101 2004-06-06 Fernando Perez <fperez@colorado.edu>
2121 2004-06-06 Fernando Perez <fperez@colorado.edu>
2102
2122
2103 * IPython/Prompts.py (prompt_specials): Added the ability to have
2123 * IPython/Prompts.py (prompt_specials): Added the ability to have
2104 bash-like special sequences in the prompts, which get
2124 bash-like special sequences in the prompts, which get
2105 automatically expanded. Things like hostname, current working
2125 automatically expanded. Things like hostname, current working
2106 directory and username are implemented already, but it's easy to
2126 directory and username are implemented already, but it's easy to
2107 add more in the future. Thanks to a patch by W.J. van der Laan
2127 add more in the future. Thanks to a patch by W.J. van der Laan
2108 <gnufnork-AT-hetdigitalegat.nl>
2128 <gnufnork-AT-hetdigitalegat.nl>
2109 (prompt_specials): Added color support for prompt strings, so
2129 (prompt_specials): Added color support for prompt strings, so
2110 users can define arbitrary color setups for their prompts.
2130 users can define arbitrary color setups for their prompts.
2111
2131
2112 2004-06-05 Fernando Perez <fperez@colorado.edu>
2132 2004-06-05 Fernando Perez <fperez@colorado.edu>
2113
2133
2114 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2134 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2115 code to load Gary Bishop's readline and configure it
2135 code to load Gary Bishop's readline and configure it
2116 automatically. Thanks to Gary for help on this.
2136 automatically. Thanks to Gary for help on this.
2117
2137
2118 2004-06-01 Fernando Perez <fperez@colorado.edu>
2138 2004-06-01 Fernando Perez <fperez@colorado.edu>
2119
2139
2120 * IPython/Logger.py (Logger.create_log): fix bug for logging
2140 * IPython/Logger.py (Logger.create_log): fix bug for logging
2121 with no filename (previous fix was incomplete).
2141 with no filename (previous fix was incomplete).
2122
2142
2123 2004-05-25 Fernando Perez <fperez@colorado.edu>
2143 2004-05-25 Fernando Perez <fperez@colorado.edu>
2124
2144
2125 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2145 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2126 parens would get passed to the shell.
2146 parens would get passed to the shell.
2127
2147
2128 2004-05-20 Fernando Perez <fperez@colorado.edu>
2148 2004-05-20 Fernando Perez <fperez@colorado.edu>
2129
2149
2130 * IPython/Magic.py (Magic.magic_prun): changed default profile
2150 * IPython/Magic.py (Magic.magic_prun): changed default profile
2131 sort order to 'time' (the more common profiling need).
2151 sort order to 'time' (the more common profiling need).
2132
2152
2133 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2153 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2134 so that source code shown is guaranteed in sync with the file on
2154 so that source code shown is guaranteed in sync with the file on
2135 disk (also changed in psource). Similar fix to the one for
2155 disk (also changed in psource). Similar fix to the one for
2136 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2156 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2137 <yann.ledu-AT-noos.fr>.
2157 <yann.ledu-AT-noos.fr>.
2138
2158
2139 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2159 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2140 with a single option would not be correctly parsed. Closes
2160 with a single option would not be correctly parsed. Closes
2141 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2161 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2142 introduced in 0.6.0 (on 2004-05-06).
2162 introduced in 0.6.0 (on 2004-05-06).
2143
2163
2144 2004-05-13 *** Released version 0.6.0
2164 2004-05-13 *** Released version 0.6.0
2145
2165
2146 2004-05-13 Fernando Perez <fperez@colorado.edu>
2166 2004-05-13 Fernando Perez <fperez@colorado.edu>
2147
2167
2148 * debian/: Added debian/ directory to CVS, so that debian support
2168 * debian/: Added debian/ directory to CVS, so that debian support
2149 is publicly accessible. The debian package is maintained by Jack
2169 is publicly accessible. The debian package is maintained by Jack
2150 Moffit <jack-AT-xiph.org>.
2170 Moffit <jack-AT-xiph.org>.
2151
2171
2152 * Documentation: included the notes about an ipython-based system
2172 * Documentation: included the notes about an ipython-based system
2153 shell (the hypothetical 'pysh') into the new_design.pdf document,
2173 shell (the hypothetical 'pysh') into the new_design.pdf document,
2154 so that these ideas get distributed to users along with the
2174 so that these ideas get distributed to users along with the
2155 official documentation.
2175 official documentation.
2156
2176
2157 2004-05-10 Fernando Perez <fperez@colorado.edu>
2177 2004-05-10 Fernando Perez <fperez@colorado.edu>
2158
2178
2159 * IPython/Logger.py (Logger.create_log): fix recently introduced
2179 * IPython/Logger.py (Logger.create_log): fix recently introduced
2160 bug (misindented line) where logstart would fail when not given an
2180 bug (misindented line) where logstart would fail when not given an
2161 explicit filename.
2181 explicit filename.
2162
2182
2163 2004-05-09 Fernando Perez <fperez@colorado.edu>
2183 2004-05-09 Fernando Perez <fperez@colorado.edu>
2164
2184
2165 * IPython/Magic.py (Magic.parse_options): skip system call when
2185 * IPython/Magic.py (Magic.parse_options): skip system call when
2166 there are no options to look for. Faster, cleaner for the common
2186 there are no options to look for. Faster, cleaner for the common
2167 case.
2187 case.
2168
2188
2169 * Documentation: many updates to the manual: describing Windows
2189 * Documentation: many updates to the manual: describing Windows
2170 support better, Gnuplot updates, credits, misc small stuff. Also
2190 support better, Gnuplot updates, credits, misc small stuff. Also
2171 updated the new_design doc a bit.
2191 updated the new_design doc a bit.
2172
2192
2173 2004-05-06 *** Released version 0.6.0.rc1
2193 2004-05-06 *** Released version 0.6.0.rc1
2174
2194
2175 2004-05-06 Fernando Perez <fperez@colorado.edu>
2195 2004-05-06 Fernando Perez <fperez@colorado.edu>
2176
2196
2177 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2197 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2178 operations to use the vastly more efficient list/''.join() method.
2198 operations to use the vastly more efficient list/''.join() method.
2179 (FormattedTB.text): Fix
2199 (FormattedTB.text): Fix
2180 http://www.scipy.net/roundup/ipython/issue12 - exception source
2200 http://www.scipy.net/roundup/ipython/issue12 - exception source
2181 extract not updated after reload. Thanks to Mike Salib
2201 extract not updated after reload. Thanks to Mike Salib
2182 <msalib-AT-mit.edu> for pinning the source of the problem.
2202 <msalib-AT-mit.edu> for pinning the source of the problem.
2183 Fortunately, the solution works inside ipython and doesn't require
2203 Fortunately, the solution works inside ipython and doesn't require
2184 any changes to python proper.
2204 any changes to python proper.
2185
2205
2186 * IPython/Magic.py (Magic.parse_options): Improved to process the
2206 * IPython/Magic.py (Magic.parse_options): Improved to process the
2187 argument list as a true shell would (by actually using the
2207 argument list as a true shell would (by actually using the
2188 underlying system shell). This way, all @magics automatically get
2208 underlying system shell). This way, all @magics automatically get
2189 shell expansion for variables. Thanks to a comment by Alex
2209 shell expansion for variables. Thanks to a comment by Alex
2190 Schmolck.
2210 Schmolck.
2191
2211
2192 2004-04-04 Fernando Perez <fperez@colorado.edu>
2212 2004-04-04 Fernando Perez <fperez@colorado.edu>
2193
2213
2194 * IPython/iplib.py (InteractiveShell.interact): Added a special
2214 * IPython/iplib.py (InteractiveShell.interact): Added a special
2195 trap for a debugger quit exception, which is basically impossible
2215 trap for a debugger quit exception, which is basically impossible
2196 to handle by normal mechanisms, given what pdb does to the stack.
2216 to handle by normal mechanisms, given what pdb does to the stack.
2197 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2217 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2198
2218
2199 2004-04-03 Fernando Perez <fperez@colorado.edu>
2219 2004-04-03 Fernando Perez <fperez@colorado.edu>
2200
2220
2201 * IPython/genutils.py (Term): Standardized the names of the Term
2221 * IPython/genutils.py (Term): Standardized the names of the Term
2202 class streams to cin/cout/cerr, following C++ naming conventions
2222 class streams to cin/cout/cerr, following C++ naming conventions
2203 (I can't use in/out/err because 'in' is not a valid attribute
2223 (I can't use in/out/err because 'in' is not a valid attribute
2204 name).
2224 name).
2205
2225
2206 * IPython/iplib.py (InteractiveShell.interact): don't increment
2226 * IPython/iplib.py (InteractiveShell.interact): don't increment
2207 the prompt if there's no user input. By Daniel 'Dang' Griffith
2227 the prompt if there's no user input. By Daniel 'Dang' Griffith
2208 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2228 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2209 Francois Pinard.
2229 Francois Pinard.
2210
2230
2211 2004-04-02 Fernando Perez <fperez@colorado.edu>
2231 2004-04-02 Fernando Perez <fperez@colorado.edu>
2212
2232
2213 * IPython/genutils.py (Stream.__init__): Modified to survive at
2233 * IPython/genutils.py (Stream.__init__): Modified to survive at
2214 least importing in contexts where stdin/out/err aren't true file
2234 least importing in contexts where stdin/out/err aren't true file
2215 objects, such as PyCrust (they lack fileno() and mode). However,
2235 objects, such as PyCrust (they lack fileno() and mode). However,
2216 the recovery facilities which rely on these things existing will
2236 the recovery facilities which rely on these things existing will
2217 not work.
2237 not work.
2218
2238
2219 2004-04-01 Fernando Perez <fperez@colorado.edu>
2239 2004-04-01 Fernando Perez <fperez@colorado.edu>
2220
2240
2221 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2241 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2222 use the new getoutputerror() function, so it properly
2242 use the new getoutputerror() function, so it properly
2223 distinguishes stdout/err.
2243 distinguishes stdout/err.
2224
2244
2225 * IPython/genutils.py (getoutputerror): added a function to
2245 * IPython/genutils.py (getoutputerror): added a function to
2226 capture separately the standard output and error of a command.
2246 capture separately the standard output and error of a command.
2227 After a comment from dang on the mailing lists. This code is
2247 After a comment from dang on the mailing lists. This code is
2228 basically a modified version of commands.getstatusoutput(), from
2248 basically a modified version of commands.getstatusoutput(), from
2229 the standard library.
2249 the standard library.
2230
2250
2231 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2251 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2232 '!!' as a special syntax (shorthand) to access @sx.
2252 '!!' as a special syntax (shorthand) to access @sx.
2233
2253
2234 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2254 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2235 command and return its output as a list split on '\n'.
2255 command and return its output as a list split on '\n'.
2236
2256
2237 2004-03-31 Fernando Perez <fperez@colorado.edu>
2257 2004-03-31 Fernando Perez <fperez@colorado.edu>
2238
2258
2239 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2259 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2240 method to dictionaries used as FakeModule instances if they lack
2260 method to dictionaries used as FakeModule instances if they lack
2241 it. At least pydoc in python2.3 breaks for runtime-defined
2261 it. At least pydoc in python2.3 breaks for runtime-defined
2242 functions without this hack. At some point I need to _really_
2262 functions without this hack. At some point I need to _really_
2243 understand what FakeModule is doing, because it's a gross hack.
2263 understand what FakeModule is doing, because it's a gross hack.
2244 But it solves Arnd's problem for now...
2264 But it solves Arnd's problem for now...
2245
2265
2246 2004-02-27 Fernando Perez <fperez@colorado.edu>
2266 2004-02-27 Fernando Perez <fperez@colorado.edu>
2247
2267
2248 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2268 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2249 mode would behave erratically. Also increased the number of
2269 mode would behave erratically. Also increased the number of
2250 possible logs in rotate mod to 999. Thanks to Rod Holland
2270 possible logs in rotate mod to 999. Thanks to Rod Holland
2251 <rhh@StructureLABS.com> for the report and fixes.
2271 <rhh@StructureLABS.com> for the report and fixes.
2252
2272
2253 2004-02-26 Fernando Perez <fperez@colorado.edu>
2273 2004-02-26 Fernando Perez <fperez@colorado.edu>
2254
2274
2255 * IPython/genutils.py (page): Check that the curses module really
2275 * IPython/genutils.py (page): Check that the curses module really
2256 has the initscr attribute before trying to use it. For some
2276 has the initscr attribute before trying to use it. For some
2257 reason, the Solaris curses module is missing this. I think this
2277 reason, the Solaris curses module is missing this. I think this
2258 should be considered a Solaris python bug, but I'm not sure.
2278 should be considered a Solaris python bug, but I'm not sure.
2259
2279
2260 2004-01-17 Fernando Perez <fperez@colorado.edu>
2280 2004-01-17 Fernando Perez <fperez@colorado.edu>
2261
2281
2262 * IPython/genutils.py (Stream.__init__): Changes to try to make
2282 * IPython/genutils.py (Stream.__init__): Changes to try to make
2263 ipython robust against stdin/out/err being closed by the user.
2283 ipython robust against stdin/out/err being closed by the user.
2264 This is 'user error' (and blocks a normal python session, at least
2284 This is 'user error' (and blocks a normal python session, at least
2265 the stdout case). However, Ipython should be able to survive such
2285 the stdout case). However, Ipython should be able to survive such
2266 instances of abuse as gracefully as possible. To simplify the
2286 instances of abuse as gracefully as possible. To simplify the
2267 coding and maintain compatibility with Gary Bishop's Term
2287 coding and maintain compatibility with Gary Bishop's Term
2268 contributions, I've made use of classmethods for this. I think
2288 contributions, I've made use of classmethods for this. I think
2269 this introduces a dependency on python 2.2.
2289 this introduces a dependency on python 2.2.
2270
2290
2271 2004-01-13 Fernando Perez <fperez@colorado.edu>
2291 2004-01-13 Fernando Perez <fperez@colorado.edu>
2272
2292
2273 * IPython/numutils.py (exp_safe): simplified the code a bit and
2293 * IPython/numutils.py (exp_safe): simplified the code a bit and
2274 removed the need for importing the kinds module altogether.
2294 removed the need for importing the kinds module altogether.
2275
2295
2276 2004-01-06 Fernando Perez <fperez@colorado.edu>
2296 2004-01-06 Fernando Perez <fperez@colorado.edu>
2277
2297
2278 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2298 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2279 a magic function instead, after some community feedback. No
2299 a magic function instead, after some community feedback. No
2280 special syntax will exist for it, but its name is deliberately
2300 special syntax will exist for it, but its name is deliberately
2281 very short.
2301 very short.
2282
2302
2283 2003-12-20 Fernando Perez <fperez@colorado.edu>
2303 2003-12-20 Fernando Perez <fperez@colorado.edu>
2284
2304
2285 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2305 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2286 new functionality, to automagically assign the result of a shell
2306 new functionality, to automagically assign the result of a shell
2287 command to a variable. I'll solicit some community feedback on
2307 command to a variable. I'll solicit some community feedback on
2288 this before making it permanent.
2308 this before making it permanent.
2289
2309
2290 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2310 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2291 requested about callables for which inspect couldn't obtain a
2311 requested about callables for which inspect couldn't obtain a
2292 proper argspec. Thanks to a crash report sent by Etienne
2312 proper argspec. Thanks to a crash report sent by Etienne
2293 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2313 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2294
2314
2295 2003-12-09 Fernando Perez <fperez@colorado.edu>
2315 2003-12-09 Fernando Perez <fperez@colorado.edu>
2296
2316
2297 * IPython/genutils.py (page): patch for the pager to work across
2317 * IPython/genutils.py (page): patch for the pager to work across
2298 various versions of Windows. By Gary Bishop.
2318 various versions of Windows. By Gary Bishop.
2299
2319
2300 2003-12-04 Fernando Perez <fperez@colorado.edu>
2320 2003-12-04 Fernando Perez <fperez@colorado.edu>
2301
2321
2302 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2322 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2303 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2323 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2304 While I tested this and it looks ok, there may still be corner
2324 While I tested this and it looks ok, there may still be corner
2305 cases I've missed.
2325 cases I've missed.
2306
2326
2307 2003-12-01 Fernando Perez <fperez@colorado.edu>
2327 2003-12-01 Fernando Perez <fperez@colorado.edu>
2308
2328
2309 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2329 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2310 where a line like 'p,q=1,2' would fail because the automagic
2330 where a line like 'p,q=1,2' would fail because the automagic
2311 system would be triggered for @p.
2331 system would be triggered for @p.
2312
2332
2313 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2333 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2314 cleanups, code unmodified.
2334 cleanups, code unmodified.
2315
2335
2316 * IPython/genutils.py (Term): added a class for IPython to handle
2336 * IPython/genutils.py (Term): added a class for IPython to handle
2317 output. In most cases it will just be a proxy for stdout/err, but
2337 output. In most cases it will just be a proxy for stdout/err, but
2318 having this allows modifications to be made for some platforms,
2338 having this allows modifications to be made for some platforms,
2319 such as handling color escapes under Windows. All of this code
2339 such as handling color escapes under Windows. All of this code
2320 was contributed by Gary Bishop, with minor modifications by me.
2340 was contributed by Gary Bishop, with minor modifications by me.
2321 The actual changes affect many files.
2341 The actual changes affect many files.
2322
2342
2323 2003-11-30 Fernando Perez <fperez@colorado.edu>
2343 2003-11-30 Fernando Perez <fperez@colorado.edu>
2324
2344
2325 * IPython/iplib.py (file_matches): new completion code, courtesy
2345 * IPython/iplib.py (file_matches): new completion code, courtesy
2326 of Jeff Collins. This enables filename completion again under
2346 of Jeff Collins. This enables filename completion again under
2327 python 2.3, which disabled it at the C level.
2347 python 2.3, which disabled it at the C level.
2328
2348
2329 2003-11-11 Fernando Perez <fperez@colorado.edu>
2349 2003-11-11 Fernando Perez <fperez@colorado.edu>
2330
2350
2331 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2351 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2332 for Numeric.array(map(...)), but often convenient.
2352 for Numeric.array(map(...)), but often convenient.
2333
2353
2334 2003-11-05 Fernando Perez <fperez@colorado.edu>
2354 2003-11-05 Fernando Perez <fperez@colorado.edu>
2335
2355
2336 * IPython/numutils.py (frange): Changed a call from int() to
2356 * IPython/numutils.py (frange): Changed a call from int() to
2337 int(round()) to prevent a problem reported with arange() in the
2357 int(round()) to prevent a problem reported with arange() in the
2338 numpy list.
2358 numpy list.
2339
2359
2340 2003-10-06 Fernando Perez <fperez@colorado.edu>
2360 2003-10-06 Fernando Perez <fperez@colorado.edu>
2341
2361
2342 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2362 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2343 prevent crashes if sys lacks an argv attribute (it happens with
2363 prevent crashes if sys lacks an argv attribute (it happens with
2344 embedded interpreters which build a bare-bones sys module).
2364 embedded interpreters which build a bare-bones sys module).
2345 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2365 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2346
2366
2347 2003-09-24 Fernando Perez <fperez@colorado.edu>
2367 2003-09-24 Fernando Perez <fperez@colorado.edu>
2348
2368
2349 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2369 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2350 to protect against poorly written user objects where __getattr__
2370 to protect against poorly written user objects where __getattr__
2351 raises exceptions other than AttributeError. Thanks to a bug
2371 raises exceptions other than AttributeError. Thanks to a bug
2352 report by Oliver Sander <osander-AT-gmx.de>.
2372 report by Oliver Sander <osander-AT-gmx.de>.
2353
2373
2354 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2374 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2355 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2375 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2356
2376
2357 2003-09-09 Fernando Perez <fperez@colorado.edu>
2377 2003-09-09 Fernando Perez <fperez@colorado.edu>
2358
2378
2359 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2379 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2360 unpacking a list whith a callable as first element would
2380 unpacking a list whith a callable as first element would
2361 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2381 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2362 Collins.
2382 Collins.
2363
2383
2364 2003-08-25 *** Released version 0.5.0
2384 2003-08-25 *** Released version 0.5.0
2365
2385
2366 2003-08-22 Fernando Perez <fperez@colorado.edu>
2386 2003-08-22 Fernando Perez <fperez@colorado.edu>
2367
2387
2368 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2388 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2369 improperly defined user exceptions. Thanks to feedback from Mark
2389 improperly defined user exceptions. Thanks to feedback from Mark
2370 Russell <mrussell-AT-verio.net>.
2390 Russell <mrussell-AT-verio.net>.
2371
2391
2372 2003-08-20 Fernando Perez <fperez@colorado.edu>
2392 2003-08-20 Fernando Perez <fperez@colorado.edu>
2373
2393
2374 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2394 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2375 printing so that it would print multi-line string forms starting
2395 printing so that it would print multi-line string forms starting
2376 with a new line. This way the formatting is better respected for
2396 with a new line. This way the formatting is better respected for
2377 objects which work hard to make nice string forms.
2397 objects which work hard to make nice string forms.
2378
2398
2379 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2399 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2380 autocall would overtake data access for objects with both
2400 autocall would overtake data access for objects with both
2381 __getitem__ and __call__.
2401 __getitem__ and __call__.
2382
2402
2383 2003-08-19 *** Released version 0.5.0-rc1
2403 2003-08-19 *** Released version 0.5.0-rc1
2384
2404
2385 2003-08-19 Fernando Perez <fperez@colorado.edu>
2405 2003-08-19 Fernando Perez <fperez@colorado.edu>
2386
2406
2387 * IPython/deep_reload.py (load_tail): single tiny change here
2407 * IPython/deep_reload.py (load_tail): single tiny change here
2388 seems to fix the long-standing bug of dreload() failing to work
2408 seems to fix the long-standing bug of dreload() failing to work
2389 for dotted names. But this module is pretty tricky, so I may have
2409 for dotted names. But this module is pretty tricky, so I may have
2390 missed some subtlety. Needs more testing!.
2410 missed some subtlety. Needs more testing!.
2391
2411
2392 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2412 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2393 exceptions which have badly implemented __str__ methods.
2413 exceptions which have badly implemented __str__ methods.
2394 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2414 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2395 which I've been getting reports about from Python 2.3 users. I
2415 which I've been getting reports about from Python 2.3 users. I
2396 wish I had a simple test case to reproduce the problem, so I could
2416 wish I had a simple test case to reproduce the problem, so I could
2397 either write a cleaner workaround or file a bug report if
2417 either write a cleaner workaround or file a bug report if
2398 necessary.
2418 necessary.
2399
2419
2400 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2420 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2401 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2421 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2402 a bug report by Tjabo Kloppenburg.
2422 a bug report by Tjabo Kloppenburg.
2403
2423
2404 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2424 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2405 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2425 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2406 seems rather unstable. Thanks to a bug report by Tjabo
2426 seems rather unstable. Thanks to a bug report by Tjabo
2407 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2427 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2408
2428
2409 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2429 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2410 this out soon because of the critical fixes in the inner loop for
2430 this out soon because of the critical fixes in the inner loop for
2411 generators.
2431 generators.
2412
2432
2413 * IPython/Magic.py (Magic.getargspec): removed. This (and
2433 * IPython/Magic.py (Magic.getargspec): removed. This (and
2414 _get_def) have been obsoleted by OInspect for a long time, I
2434 _get_def) have been obsoleted by OInspect for a long time, I
2415 hadn't noticed that they were dead code.
2435 hadn't noticed that they were dead code.
2416 (Magic._ofind): restored _ofind functionality for a few literals
2436 (Magic._ofind): restored _ofind functionality for a few literals
2417 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2437 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2418 for things like "hello".capitalize?, since that would require a
2438 for things like "hello".capitalize?, since that would require a
2419 potentially dangerous eval() again.
2439 potentially dangerous eval() again.
2420
2440
2421 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2441 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2422 logic a bit more to clean up the escapes handling and minimize the
2442 logic a bit more to clean up the escapes handling and minimize the
2423 use of _ofind to only necessary cases. The interactive 'feel' of
2443 use of _ofind to only necessary cases. The interactive 'feel' of
2424 IPython should have improved quite a bit with the changes in
2444 IPython should have improved quite a bit with the changes in
2425 _prefilter and _ofind (besides being far safer than before).
2445 _prefilter and _ofind (besides being far safer than before).
2426
2446
2427 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2447 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2428 obscure, never reported). Edit would fail to find the object to
2448 obscure, never reported). Edit would fail to find the object to
2429 edit under some circumstances.
2449 edit under some circumstances.
2430 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2450 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2431 which were causing double-calling of generators. Those eval calls
2451 which were causing double-calling of generators. Those eval calls
2432 were _very_ dangerous, since code with side effects could be
2452 were _very_ dangerous, since code with side effects could be
2433 triggered. As they say, 'eval is evil'... These were the
2453 triggered. As they say, 'eval is evil'... These were the
2434 nastiest evals in IPython. Besides, _ofind is now far simpler,
2454 nastiest evals in IPython. Besides, _ofind is now far simpler,
2435 and it should also be quite a bit faster. Its use of inspect is
2455 and it should also be quite a bit faster. Its use of inspect is
2436 also safer, so perhaps some of the inspect-related crashes I've
2456 also safer, so perhaps some of the inspect-related crashes I've
2437 seen lately with Python 2.3 might be taken care of. That will
2457 seen lately with Python 2.3 might be taken care of. That will
2438 need more testing.
2458 need more testing.
2439
2459
2440 2003-08-17 Fernando Perez <fperez@colorado.edu>
2460 2003-08-17 Fernando Perez <fperez@colorado.edu>
2441
2461
2442 * IPython/iplib.py (InteractiveShell._prefilter): significant
2462 * IPython/iplib.py (InteractiveShell._prefilter): significant
2443 simplifications to the logic for handling user escapes. Faster
2463 simplifications to the logic for handling user escapes. Faster
2444 and simpler code.
2464 and simpler code.
2445
2465
2446 2003-08-14 Fernando Perez <fperez@colorado.edu>
2466 2003-08-14 Fernando Perez <fperez@colorado.edu>
2447
2467
2448 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2468 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2449 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2469 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2450 but it should be quite a bit faster. And the recursive version
2470 but it should be quite a bit faster. And the recursive version
2451 generated O(log N) intermediate storage for all rank>1 arrays,
2471 generated O(log N) intermediate storage for all rank>1 arrays,
2452 even if they were contiguous.
2472 even if they were contiguous.
2453 (l1norm): Added this function.
2473 (l1norm): Added this function.
2454 (norm): Added this function for arbitrary norms (including
2474 (norm): Added this function for arbitrary norms (including
2455 l-infinity). l1 and l2 are still special cases for convenience
2475 l-infinity). l1 and l2 are still special cases for convenience
2456 and speed.
2476 and speed.
2457
2477
2458 2003-08-03 Fernando Perez <fperez@colorado.edu>
2478 2003-08-03 Fernando Perez <fperez@colorado.edu>
2459
2479
2460 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2480 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2461 exceptions, which now raise PendingDeprecationWarnings in Python
2481 exceptions, which now raise PendingDeprecationWarnings in Python
2462 2.3. There were some in Magic and some in Gnuplot2.
2482 2.3. There were some in Magic and some in Gnuplot2.
2463
2483
2464 2003-06-30 Fernando Perez <fperez@colorado.edu>
2484 2003-06-30 Fernando Perez <fperez@colorado.edu>
2465
2485
2466 * IPython/genutils.py (page): modified to call curses only for
2486 * IPython/genutils.py (page): modified to call curses only for
2467 terminals where TERM=='xterm'. After problems under many other
2487 terminals where TERM=='xterm'. After problems under many other
2468 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2488 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2469
2489
2470 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2490 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2471 would be triggered when readline was absent. This was just an old
2491 would be triggered when readline was absent. This was just an old
2472 debugging statement I'd forgotten to take out.
2492 debugging statement I'd forgotten to take out.
2473
2493
2474 2003-06-20 Fernando Perez <fperez@colorado.edu>
2494 2003-06-20 Fernando Perez <fperez@colorado.edu>
2475
2495
2476 * IPython/genutils.py (clock): modified to return only user time
2496 * IPython/genutils.py (clock): modified to return only user time
2477 (not counting system time), after a discussion on scipy. While
2497 (not counting system time), after a discussion on scipy. While
2478 system time may be a useful quantity occasionally, it may much
2498 system time may be a useful quantity occasionally, it may much
2479 more easily be skewed by occasional swapping or other similar
2499 more easily be skewed by occasional swapping or other similar
2480 activity.
2500 activity.
2481
2501
2482 2003-06-05 Fernando Perez <fperez@colorado.edu>
2502 2003-06-05 Fernando Perez <fperez@colorado.edu>
2483
2503
2484 * IPython/numutils.py (identity): new function, for building
2504 * IPython/numutils.py (identity): new function, for building
2485 arbitrary rank Kronecker deltas (mostly backwards compatible with
2505 arbitrary rank Kronecker deltas (mostly backwards compatible with
2486 Numeric.identity)
2506 Numeric.identity)
2487
2507
2488 2003-06-03 Fernando Perez <fperez@colorado.edu>
2508 2003-06-03 Fernando Perez <fperez@colorado.edu>
2489
2509
2490 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2510 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2491 arguments passed to magics with spaces, to allow trailing '\' to
2511 arguments passed to magics with spaces, to allow trailing '\' to
2492 work normally (mainly for Windows users).
2512 work normally (mainly for Windows users).
2493
2513
2494 2003-05-29 Fernando Perez <fperez@colorado.edu>
2514 2003-05-29 Fernando Perez <fperez@colorado.edu>
2495
2515
2496 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2516 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2497 instead of pydoc.help. This fixes a bizarre behavior where
2517 instead of pydoc.help. This fixes a bizarre behavior where
2498 printing '%s' % locals() would trigger the help system. Now
2518 printing '%s' % locals() would trigger the help system. Now
2499 ipython behaves like normal python does.
2519 ipython behaves like normal python does.
2500
2520
2501 Note that if one does 'from pydoc import help', the bizarre
2521 Note that if one does 'from pydoc import help', the bizarre
2502 behavior returns, but this will also happen in normal python, so
2522 behavior returns, but this will also happen in normal python, so
2503 it's not an ipython bug anymore (it has to do with how pydoc.help
2523 it's not an ipython bug anymore (it has to do with how pydoc.help
2504 is implemented).
2524 is implemented).
2505
2525
2506 2003-05-22 Fernando Perez <fperez@colorado.edu>
2526 2003-05-22 Fernando Perez <fperez@colorado.edu>
2507
2527
2508 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2528 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2509 return [] instead of None when nothing matches, also match to end
2529 return [] instead of None when nothing matches, also match to end
2510 of line. Patch by Gary Bishop.
2530 of line. Patch by Gary Bishop.
2511
2531
2512 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2532 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2513 protection as before, for files passed on the command line. This
2533 protection as before, for files passed on the command line. This
2514 prevents the CrashHandler from kicking in if user files call into
2534 prevents the CrashHandler from kicking in if user files call into
2515 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2535 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2516 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2536 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2517
2537
2518 2003-05-20 *** Released version 0.4.0
2538 2003-05-20 *** Released version 0.4.0
2519
2539
2520 2003-05-20 Fernando Perez <fperez@colorado.edu>
2540 2003-05-20 Fernando Perez <fperez@colorado.edu>
2521
2541
2522 * setup.py: added support for manpages. It's a bit hackish b/c of
2542 * setup.py: added support for manpages. It's a bit hackish b/c of
2523 a bug in the way the bdist_rpm distutils target handles gzipped
2543 a bug in the way the bdist_rpm distutils target handles gzipped
2524 manpages, but it works. After a patch by Jack.
2544 manpages, but it works. After a patch by Jack.
2525
2545
2526 2003-05-19 Fernando Perez <fperez@colorado.edu>
2546 2003-05-19 Fernando Perez <fperez@colorado.edu>
2527
2547
2528 * IPython/numutils.py: added a mockup of the kinds module, since
2548 * IPython/numutils.py: added a mockup of the kinds module, since
2529 it was recently removed from Numeric. This way, numutils will
2549 it was recently removed from Numeric. This way, numutils will
2530 work for all users even if they are missing kinds.
2550 work for all users even if they are missing kinds.
2531
2551
2532 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2552 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2533 failure, which can occur with SWIG-wrapped extensions. After a
2553 failure, which can occur with SWIG-wrapped extensions. After a
2534 crash report from Prabhu.
2554 crash report from Prabhu.
2535
2555
2536 2003-05-16 Fernando Perez <fperez@colorado.edu>
2556 2003-05-16 Fernando Perez <fperez@colorado.edu>
2537
2557
2538 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2558 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2539 protect ipython from user code which may call directly
2559 protect ipython from user code which may call directly
2540 sys.excepthook (this looks like an ipython crash to the user, even
2560 sys.excepthook (this looks like an ipython crash to the user, even
2541 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2561 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2542 This is especially important to help users of WxWindows, but may
2562 This is especially important to help users of WxWindows, but may
2543 also be useful in other cases.
2563 also be useful in other cases.
2544
2564
2545 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2565 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2546 an optional tb_offset to be specified, and to preserve exception
2566 an optional tb_offset to be specified, and to preserve exception
2547 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2567 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2548
2568
2549 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2569 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2550
2570
2551 2003-05-15 Fernando Perez <fperez@colorado.edu>
2571 2003-05-15 Fernando Perez <fperez@colorado.edu>
2552
2572
2553 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2573 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2554 installing for a new user under Windows.
2574 installing for a new user under Windows.
2555
2575
2556 2003-05-12 Fernando Perez <fperez@colorado.edu>
2576 2003-05-12 Fernando Perez <fperez@colorado.edu>
2557
2577
2558 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2578 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2559 handler for Emacs comint-based lines. Currently it doesn't do
2579 handler for Emacs comint-based lines. Currently it doesn't do
2560 much (but importantly, it doesn't update the history cache). In
2580 much (but importantly, it doesn't update the history cache). In
2561 the future it may be expanded if Alex needs more functionality
2581 the future it may be expanded if Alex needs more functionality
2562 there.
2582 there.
2563
2583
2564 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2584 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2565 info to crash reports.
2585 info to crash reports.
2566
2586
2567 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2587 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2568 just like Python's -c. Also fixed crash with invalid -color
2588 just like Python's -c. Also fixed crash with invalid -color
2569 option value at startup. Thanks to Will French
2589 option value at startup. Thanks to Will French
2570 <wfrench-AT-bestweb.net> for the bug report.
2590 <wfrench-AT-bestweb.net> for the bug report.
2571
2591
2572 2003-05-09 Fernando Perez <fperez@colorado.edu>
2592 2003-05-09 Fernando Perez <fperez@colorado.edu>
2573
2593
2574 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2594 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2575 to EvalDict (it's a mapping, after all) and simplified its code
2595 to EvalDict (it's a mapping, after all) and simplified its code
2576 quite a bit, after a nice discussion on c.l.py where Gustavo
2596 quite a bit, after a nice discussion on c.l.py where Gustavo
2577 Córdova <gcordova-AT-sismex.com> suggested the new version.
2597 Córdova <gcordova-AT-sismex.com> suggested the new version.
2578
2598
2579 2003-04-30 Fernando Perez <fperez@colorado.edu>
2599 2003-04-30 Fernando Perez <fperez@colorado.edu>
2580
2600
2581 * IPython/genutils.py (timings_out): modified it to reduce its
2601 * IPython/genutils.py (timings_out): modified it to reduce its
2582 overhead in the common reps==1 case.
2602 overhead in the common reps==1 case.
2583
2603
2584 2003-04-29 Fernando Perez <fperez@colorado.edu>
2604 2003-04-29 Fernando Perez <fperez@colorado.edu>
2585
2605
2586 * IPython/genutils.py (timings_out): Modified to use the resource
2606 * IPython/genutils.py (timings_out): Modified to use the resource
2587 module, which avoids the wraparound problems of time.clock().
2607 module, which avoids the wraparound problems of time.clock().
2588
2608
2589 2003-04-17 *** Released version 0.2.15pre4
2609 2003-04-17 *** Released version 0.2.15pre4
2590
2610
2591 2003-04-17 Fernando Perez <fperez@colorado.edu>
2611 2003-04-17 Fernando Perez <fperez@colorado.edu>
2592
2612
2593 * setup.py (scriptfiles): Split windows-specific stuff over to a
2613 * setup.py (scriptfiles): Split windows-specific stuff over to a
2594 separate file, in an attempt to have a Windows GUI installer.
2614 separate file, in an attempt to have a Windows GUI installer.
2595 That didn't work, but part of the groundwork is done.
2615 That didn't work, but part of the groundwork is done.
2596
2616
2597 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2617 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2598 indent/unindent with 4 spaces. Particularly useful in combination
2618 indent/unindent with 4 spaces. Particularly useful in combination
2599 with the new auto-indent option.
2619 with the new auto-indent option.
2600
2620
2601 2003-04-16 Fernando Perez <fperez@colorado.edu>
2621 2003-04-16 Fernando Perez <fperez@colorado.edu>
2602
2622
2603 * IPython/Magic.py: various replacements of self.rc for
2623 * IPython/Magic.py: various replacements of self.rc for
2604 self.shell.rc. A lot more remains to be done to fully disentangle
2624 self.shell.rc. A lot more remains to be done to fully disentangle
2605 this class from the main Shell class.
2625 this class from the main Shell class.
2606
2626
2607 * IPython/GnuplotRuntime.py: added checks for mouse support so
2627 * IPython/GnuplotRuntime.py: added checks for mouse support so
2608 that we don't try to enable it if the current gnuplot doesn't
2628 that we don't try to enable it if the current gnuplot doesn't
2609 really support it. Also added checks so that we don't try to
2629 really support it. Also added checks so that we don't try to
2610 enable persist under Windows (where Gnuplot doesn't recognize the
2630 enable persist under Windows (where Gnuplot doesn't recognize the
2611 option).
2631 option).
2612
2632
2613 * IPython/iplib.py (InteractiveShell.interact): Added optional
2633 * IPython/iplib.py (InteractiveShell.interact): Added optional
2614 auto-indenting code, after a patch by King C. Shu
2634 auto-indenting code, after a patch by King C. Shu
2615 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2635 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2616 get along well with pasting indented code. If I ever figure out
2636 get along well with pasting indented code. If I ever figure out
2617 how to make that part go well, it will become on by default.
2637 how to make that part go well, it will become on by default.
2618
2638
2619 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2639 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2620 crash ipython if there was an unmatched '%' in the user's prompt
2640 crash ipython if there was an unmatched '%' in the user's prompt
2621 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2641 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2622
2642
2623 * IPython/iplib.py (InteractiveShell.interact): removed the
2643 * IPython/iplib.py (InteractiveShell.interact): removed the
2624 ability to ask the user whether he wants to crash or not at the
2644 ability to ask the user whether he wants to crash or not at the
2625 'last line' exception handler. Calling functions at that point
2645 'last line' exception handler. Calling functions at that point
2626 changes the stack, and the error reports would have incorrect
2646 changes the stack, and the error reports would have incorrect
2627 tracebacks.
2647 tracebacks.
2628
2648
2629 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2649 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2630 pass through a peger a pretty-printed form of any object. After a
2650 pass through a peger a pretty-printed form of any object. After a
2631 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2651 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2632
2652
2633 2003-04-14 Fernando Perez <fperez@colorado.edu>
2653 2003-04-14 Fernando Perez <fperez@colorado.edu>
2634
2654
2635 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2655 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2636 all files in ~ would be modified at first install (instead of
2656 all files in ~ would be modified at first install (instead of
2637 ~/.ipython). This could be potentially disastrous, as the
2657 ~/.ipython). This could be potentially disastrous, as the
2638 modification (make line-endings native) could damage binary files.
2658 modification (make line-endings native) could damage binary files.
2639
2659
2640 2003-04-10 Fernando Perez <fperez@colorado.edu>
2660 2003-04-10 Fernando Perez <fperez@colorado.edu>
2641
2661
2642 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2662 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2643 handle only lines which are invalid python. This now means that
2663 handle only lines which are invalid python. This now means that
2644 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2664 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2645 for the bug report.
2665 for the bug report.
2646
2666
2647 2003-04-01 Fernando Perez <fperez@colorado.edu>
2667 2003-04-01 Fernando Perez <fperez@colorado.edu>
2648
2668
2649 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2669 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2650 where failing to set sys.last_traceback would crash pdb.pm().
2670 where failing to set sys.last_traceback would crash pdb.pm().
2651 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2671 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2652 report.
2672 report.
2653
2673
2654 2003-03-25 Fernando Perez <fperez@colorado.edu>
2674 2003-03-25 Fernando Perez <fperez@colorado.edu>
2655
2675
2656 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2676 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2657 before printing it (it had a lot of spurious blank lines at the
2677 before printing it (it had a lot of spurious blank lines at the
2658 end).
2678 end).
2659
2679
2660 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2680 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2661 output would be sent 21 times! Obviously people don't use this
2681 output would be sent 21 times! Obviously people don't use this
2662 too often, or I would have heard about it.
2682 too often, or I would have heard about it.
2663
2683
2664 2003-03-24 Fernando Perez <fperez@colorado.edu>
2684 2003-03-24 Fernando Perez <fperez@colorado.edu>
2665
2685
2666 * setup.py (scriptfiles): renamed the data_files parameter from
2686 * setup.py (scriptfiles): renamed the data_files parameter from
2667 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2687 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2668 for the patch.
2688 for the patch.
2669
2689
2670 2003-03-20 Fernando Perez <fperez@colorado.edu>
2690 2003-03-20 Fernando Perez <fperez@colorado.edu>
2671
2691
2672 * IPython/genutils.py (error): added error() and fatal()
2692 * IPython/genutils.py (error): added error() and fatal()
2673 functions.
2693 functions.
2674
2694
2675 2003-03-18 *** Released version 0.2.15pre3
2695 2003-03-18 *** Released version 0.2.15pre3
2676
2696
2677 2003-03-18 Fernando Perez <fperez@colorado.edu>
2697 2003-03-18 Fernando Perez <fperez@colorado.edu>
2678
2698
2679 * setupext/install_data_ext.py
2699 * setupext/install_data_ext.py
2680 (install_data_ext.initialize_options): Class contributed by Jack
2700 (install_data_ext.initialize_options): Class contributed by Jack
2681 Moffit for fixing the old distutils hack. He is sending this to
2701 Moffit for fixing the old distutils hack. He is sending this to
2682 the distutils folks so in the future we may not need it as a
2702 the distutils folks so in the future we may not need it as a
2683 private fix.
2703 private fix.
2684
2704
2685 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2705 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2686 changes for Debian packaging. See his patch for full details.
2706 changes for Debian packaging. See his patch for full details.
2687 The old distutils hack of making the ipythonrc* files carry a
2707 The old distutils hack of making the ipythonrc* files carry a
2688 bogus .py extension is gone, at last. Examples were moved to a
2708 bogus .py extension is gone, at last. Examples were moved to a
2689 separate subdir under doc/, and the separate executable scripts
2709 separate subdir under doc/, and the separate executable scripts
2690 now live in their own directory. Overall a great cleanup. The
2710 now live in their own directory. Overall a great cleanup. The
2691 manual was updated to use the new files, and setup.py has been
2711 manual was updated to use the new files, and setup.py has been
2692 fixed for this setup.
2712 fixed for this setup.
2693
2713
2694 * IPython/PyColorize.py (Parser.usage): made non-executable and
2714 * IPython/PyColorize.py (Parser.usage): made non-executable and
2695 created a pycolor wrapper around it to be included as a script.
2715 created a pycolor wrapper around it to be included as a script.
2696
2716
2697 2003-03-12 *** Released version 0.2.15pre2
2717 2003-03-12 *** Released version 0.2.15pre2
2698
2718
2699 2003-03-12 Fernando Perez <fperez@colorado.edu>
2719 2003-03-12 Fernando Perez <fperez@colorado.edu>
2700
2720
2701 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2721 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2702 long-standing problem with garbage characters in some terminals.
2722 long-standing problem with garbage characters in some terminals.
2703 The issue was really that the \001 and \002 escapes must _only_ be
2723 The issue was really that the \001 and \002 escapes must _only_ be
2704 passed to input prompts (which call readline), but _never_ to
2724 passed to input prompts (which call readline), but _never_ to
2705 normal text to be printed on screen. I changed ColorANSI to have
2725 normal text to be printed on screen. I changed ColorANSI to have
2706 two classes: TermColors and InputTermColors, each with the
2726 two classes: TermColors and InputTermColors, each with the
2707 appropriate escapes for input prompts or normal text. The code in
2727 appropriate escapes for input prompts or normal text. The code in
2708 Prompts.py got slightly more complicated, but this very old and
2728 Prompts.py got slightly more complicated, but this very old and
2709 annoying bug is finally fixed.
2729 annoying bug is finally fixed.
2710
2730
2711 All the credit for nailing down the real origin of this problem
2731 All the credit for nailing down the real origin of this problem
2712 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2732 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2713 *Many* thanks to him for spending quite a bit of effort on this.
2733 *Many* thanks to him for spending quite a bit of effort on this.
2714
2734
2715 2003-03-05 *** Released version 0.2.15pre1
2735 2003-03-05 *** Released version 0.2.15pre1
2716
2736
2717 2003-03-03 Fernando Perez <fperez@colorado.edu>
2737 2003-03-03 Fernando Perez <fperez@colorado.edu>
2718
2738
2719 * IPython/FakeModule.py: Moved the former _FakeModule to a
2739 * IPython/FakeModule.py: Moved the former _FakeModule to a
2720 separate file, because it's also needed by Magic (to fix a similar
2740 separate file, because it's also needed by Magic (to fix a similar
2721 pickle-related issue in @run).
2741 pickle-related issue in @run).
2722
2742
2723 2003-03-02 Fernando Perez <fperez@colorado.edu>
2743 2003-03-02 Fernando Perez <fperez@colorado.edu>
2724
2744
2725 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2745 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2726 the autocall option at runtime.
2746 the autocall option at runtime.
2727 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2747 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2728 across Magic.py to start separating Magic from InteractiveShell.
2748 across Magic.py to start separating Magic from InteractiveShell.
2729 (Magic._ofind): Fixed to return proper namespace for dotted
2749 (Magic._ofind): Fixed to return proper namespace for dotted
2730 names. Before, a dotted name would always return 'not currently
2750 names. Before, a dotted name would always return 'not currently
2731 defined', because it would find the 'parent'. s.x would be found,
2751 defined', because it would find the 'parent'. s.x would be found,
2732 but since 'x' isn't defined by itself, it would get confused.
2752 but since 'x' isn't defined by itself, it would get confused.
2733 (Magic.magic_run): Fixed pickling problems reported by Ralf
2753 (Magic.magic_run): Fixed pickling problems reported by Ralf
2734 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2754 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2735 that I'd used when Mike Heeter reported similar issues at the
2755 that I'd used when Mike Heeter reported similar issues at the
2736 top-level, but now for @run. It boils down to injecting the
2756 top-level, but now for @run. It boils down to injecting the
2737 namespace where code is being executed with something that looks
2757 namespace where code is being executed with something that looks
2738 enough like a module to fool pickle.dump(). Since a pickle stores
2758 enough like a module to fool pickle.dump(). Since a pickle stores
2739 a named reference to the importing module, we need this for
2759 a named reference to the importing module, we need this for
2740 pickles to save something sensible.
2760 pickles to save something sensible.
2741
2761
2742 * IPython/ipmaker.py (make_IPython): added an autocall option.
2762 * IPython/ipmaker.py (make_IPython): added an autocall option.
2743
2763
2744 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2764 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2745 the auto-eval code. Now autocalling is an option, and the code is
2765 the auto-eval code. Now autocalling is an option, and the code is
2746 also vastly safer. There is no more eval() involved at all.
2766 also vastly safer. There is no more eval() involved at all.
2747
2767
2748 2003-03-01 Fernando Perez <fperez@colorado.edu>
2768 2003-03-01 Fernando Perez <fperez@colorado.edu>
2749
2769
2750 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2770 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2751 dict with named keys instead of a tuple.
2771 dict with named keys instead of a tuple.
2752
2772
2753 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2773 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2754
2774
2755 * setup.py (make_shortcut): Fixed message about directories
2775 * setup.py (make_shortcut): Fixed message about directories
2756 created during Windows installation (the directories were ok, just
2776 created during Windows installation (the directories were ok, just
2757 the printed message was misleading). Thanks to Chris Liechti
2777 the printed message was misleading). Thanks to Chris Liechti
2758 <cliechti-AT-gmx.net> for the heads up.
2778 <cliechti-AT-gmx.net> for the heads up.
2759
2779
2760 2003-02-21 Fernando Perez <fperez@colorado.edu>
2780 2003-02-21 Fernando Perez <fperez@colorado.edu>
2761
2781
2762 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2782 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2763 of ValueError exception when checking for auto-execution. This
2783 of ValueError exception when checking for auto-execution. This
2764 one is raised by things like Numeric arrays arr.flat when the
2784 one is raised by things like Numeric arrays arr.flat when the
2765 array is non-contiguous.
2785 array is non-contiguous.
2766
2786
2767 2003-01-31 Fernando Perez <fperez@colorado.edu>
2787 2003-01-31 Fernando Perez <fperez@colorado.edu>
2768
2788
2769 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2789 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2770 not return any value at all (even though the command would get
2790 not return any value at all (even though the command would get
2771 executed).
2791 executed).
2772 (xsys): Flush stdout right after printing the command to ensure
2792 (xsys): Flush stdout right after printing the command to ensure
2773 proper ordering of commands and command output in the total
2793 proper ordering of commands and command output in the total
2774 output.
2794 output.
2775 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2795 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2776 system/getoutput as defaults. The old ones are kept for
2796 system/getoutput as defaults. The old ones are kept for
2777 compatibility reasons, so no code which uses this library needs
2797 compatibility reasons, so no code which uses this library needs
2778 changing.
2798 changing.
2779
2799
2780 2003-01-27 *** Released version 0.2.14
2800 2003-01-27 *** Released version 0.2.14
2781
2801
2782 2003-01-25 Fernando Perez <fperez@colorado.edu>
2802 2003-01-25 Fernando Perez <fperez@colorado.edu>
2783
2803
2784 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2804 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2785 functions defined in previous edit sessions could not be re-edited
2805 functions defined in previous edit sessions could not be re-edited
2786 (because the temp files were immediately removed). Now temp files
2806 (because the temp files were immediately removed). Now temp files
2787 are removed only at IPython's exit.
2807 are removed only at IPython's exit.
2788 (Magic.magic_run): Improved @run to perform shell-like expansions
2808 (Magic.magic_run): Improved @run to perform shell-like expansions
2789 on its arguments (~users and $VARS). With this, @run becomes more
2809 on its arguments (~users and $VARS). With this, @run becomes more
2790 like a normal command-line.
2810 like a normal command-line.
2791
2811
2792 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2812 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2793 bugs related to embedding and cleaned up that code. A fairly
2813 bugs related to embedding and cleaned up that code. A fairly
2794 important one was the impossibility to access the global namespace
2814 important one was the impossibility to access the global namespace
2795 through the embedded IPython (only local variables were visible).
2815 through the embedded IPython (only local variables were visible).
2796
2816
2797 2003-01-14 Fernando Perez <fperez@colorado.edu>
2817 2003-01-14 Fernando Perez <fperez@colorado.edu>
2798
2818
2799 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2819 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2800 auto-calling to be a bit more conservative. Now it doesn't get
2820 auto-calling to be a bit more conservative. Now it doesn't get
2801 triggered if any of '!=()<>' are in the rest of the input line, to
2821 triggered if any of '!=()<>' are in the rest of the input line, to
2802 allow comparing callables. Thanks to Alex for the heads up.
2822 allow comparing callables. Thanks to Alex for the heads up.
2803
2823
2804 2003-01-07 Fernando Perez <fperez@colorado.edu>
2824 2003-01-07 Fernando Perez <fperez@colorado.edu>
2805
2825
2806 * IPython/genutils.py (page): fixed estimation of the number of
2826 * IPython/genutils.py (page): fixed estimation of the number of
2807 lines in a string to be paged to simply count newlines. This
2827 lines in a string to be paged to simply count newlines. This
2808 prevents over-guessing due to embedded escape sequences. A better
2828 prevents over-guessing due to embedded escape sequences. A better
2809 long-term solution would involve stripping out the control chars
2829 long-term solution would involve stripping out the control chars
2810 for the count, but it's potentially so expensive I just don't
2830 for the count, but it's potentially so expensive I just don't
2811 think it's worth doing.
2831 think it's worth doing.
2812
2832
2813 2002-12-19 *** Released version 0.2.14pre50
2833 2002-12-19 *** Released version 0.2.14pre50
2814
2834
2815 2002-12-19 Fernando Perez <fperez@colorado.edu>
2835 2002-12-19 Fernando Perez <fperez@colorado.edu>
2816
2836
2817 * tools/release (version): Changed release scripts to inform
2837 * tools/release (version): Changed release scripts to inform
2818 Andrea and build a NEWS file with a list of recent changes.
2838 Andrea and build a NEWS file with a list of recent changes.
2819
2839
2820 * IPython/ColorANSI.py (__all__): changed terminal detection
2840 * IPython/ColorANSI.py (__all__): changed terminal detection
2821 code. Seems to work better for xterms without breaking
2841 code. Seems to work better for xterms without breaking
2822 konsole. Will need more testing to determine if WinXP and Mac OSX
2842 konsole. Will need more testing to determine if WinXP and Mac OSX
2823 also work ok.
2843 also work ok.
2824
2844
2825 2002-12-18 *** Released version 0.2.14pre49
2845 2002-12-18 *** Released version 0.2.14pre49
2826
2846
2827 2002-12-18 Fernando Perez <fperez@colorado.edu>
2847 2002-12-18 Fernando Perez <fperez@colorado.edu>
2828
2848
2829 * Docs: added new info about Mac OSX, from Andrea.
2849 * Docs: added new info about Mac OSX, from Andrea.
2830
2850
2831 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2851 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2832 allow direct plotting of python strings whose format is the same
2852 allow direct plotting of python strings whose format is the same
2833 of gnuplot data files.
2853 of gnuplot data files.
2834
2854
2835 2002-12-16 Fernando Perez <fperez@colorado.edu>
2855 2002-12-16 Fernando Perez <fperez@colorado.edu>
2836
2856
2837 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2857 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2838 value of exit question to be acknowledged.
2858 value of exit question to be acknowledged.
2839
2859
2840 2002-12-03 Fernando Perez <fperez@colorado.edu>
2860 2002-12-03 Fernando Perez <fperez@colorado.edu>
2841
2861
2842 * IPython/ipmaker.py: removed generators, which had been added
2862 * IPython/ipmaker.py: removed generators, which had been added
2843 by mistake in an earlier debugging run. This was causing trouble
2863 by mistake in an earlier debugging run. This was causing trouble
2844 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2864 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2845 for pointing this out.
2865 for pointing this out.
2846
2866
2847 2002-11-17 Fernando Perez <fperez@colorado.edu>
2867 2002-11-17 Fernando Perez <fperez@colorado.edu>
2848
2868
2849 * Manual: updated the Gnuplot section.
2869 * Manual: updated the Gnuplot section.
2850
2870
2851 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2871 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2852 a much better split of what goes in Runtime and what goes in
2872 a much better split of what goes in Runtime and what goes in
2853 Interactive.
2873 Interactive.
2854
2874
2855 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2875 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2856 being imported from iplib.
2876 being imported from iplib.
2857
2877
2858 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2878 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2859 for command-passing. Now the global Gnuplot instance is called
2879 for command-passing. Now the global Gnuplot instance is called
2860 'gp' instead of 'g', which was really a far too fragile and
2880 'gp' instead of 'g', which was really a far too fragile and
2861 common name.
2881 common name.
2862
2882
2863 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2883 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2864 bounding boxes generated by Gnuplot for square plots.
2884 bounding boxes generated by Gnuplot for square plots.
2865
2885
2866 * IPython/genutils.py (popkey): new function added. I should
2886 * IPython/genutils.py (popkey): new function added. I should
2867 suggest this on c.l.py as a dict method, it seems useful.
2887 suggest this on c.l.py as a dict method, it seems useful.
2868
2888
2869 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2889 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2870 to transparently handle PostScript generation. MUCH better than
2890 to transparently handle PostScript generation. MUCH better than
2871 the previous plot_eps/replot_eps (which I removed now). The code
2891 the previous plot_eps/replot_eps (which I removed now). The code
2872 is also fairly clean and well documented now (including
2892 is also fairly clean and well documented now (including
2873 docstrings).
2893 docstrings).
2874
2894
2875 2002-11-13 Fernando Perez <fperez@colorado.edu>
2895 2002-11-13 Fernando Perez <fperez@colorado.edu>
2876
2896
2877 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2897 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2878 (inconsistent with options).
2898 (inconsistent with options).
2879
2899
2880 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2900 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2881 manually disabled, I don't know why. Fixed it.
2901 manually disabled, I don't know why. Fixed it.
2882 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2902 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2883 eps output.
2903 eps output.
2884
2904
2885 2002-11-12 Fernando Perez <fperez@colorado.edu>
2905 2002-11-12 Fernando Perez <fperez@colorado.edu>
2886
2906
2887 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2907 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2888 don't propagate up to caller. Fixes crash reported by François
2908 don't propagate up to caller. Fixes crash reported by François
2889 Pinard.
2909 Pinard.
2890
2910
2891 2002-11-09 Fernando Perez <fperez@colorado.edu>
2911 2002-11-09 Fernando Perez <fperez@colorado.edu>
2892
2912
2893 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2913 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2894 history file for new users.
2914 history file for new users.
2895 (make_IPython): fixed bug where initial install would leave the
2915 (make_IPython): fixed bug where initial install would leave the
2896 user running in the .ipython dir.
2916 user running in the .ipython dir.
2897 (make_IPython): fixed bug where config dir .ipython would be
2917 (make_IPython): fixed bug where config dir .ipython would be
2898 created regardless of the given -ipythondir option. Thanks to Cory
2918 created regardless of the given -ipythondir option. Thanks to Cory
2899 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2919 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2900
2920
2901 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2921 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2902 type confirmations. Will need to use it in all of IPython's code
2922 type confirmations. Will need to use it in all of IPython's code
2903 consistently.
2923 consistently.
2904
2924
2905 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2925 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2906 context to print 31 lines instead of the default 5. This will make
2926 context to print 31 lines instead of the default 5. This will make
2907 the crash reports extremely detailed in case the problem is in
2927 the crash reports extremely detailed in case the problem is in
2908 libraries I don't have access to.
2928 libraries I don't have access to.
2909
2929
2910 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2930 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2911 line of defense' code to still crash, but giving users fair
2931 line of defense' code to still crash, but giving users fair
2912 warning. I don't want internal errors to go unreported: if there's
2932 warning. I don't want internal errors to go unreported: if there's
2913 an internal problem, IPython should crash and generate a full
2933 an internal problem, IPython should crash and generate a full
2914 report.
2934 report.
2915
2935
2916 2002-11-08 Fernando Perez <fperez@colorado.edu>
2936 2002-11-08 Fernando Perez <fperez@colorado.edu>
2917
2937
2918 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2938 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2919 otherwise uncaught exceptions which can appear if people set
2939 otherwise uncaught exceptions which can appear if people set
2920 sys.stdout to something badly broken. Thanks to a crash report
2940 sys.stdout to something badly broken. Thanks to a crash report
2921 from henni-AT-mail.brainbot.com.
2941 from henni-AT-mail.brainbot.com.
2922
2942
2923 2002-11-04 Fernando Perez <fperez@colorado.edu>
2943 2002-11-04 Fernando Perez <fperez@colorado.edu>
2924
2944
2925 * IPython/iplib.py (InteractiveShell.interact): added
2945 * IPython/iplib.py (InteractiveShell.interact): added
2926 __IPYTHON__active to the builtins. It's a flag which goes on when
2946 __IPYTHON__active to the builtins. It's a flag which goes on when
2927 the interaction starts and goes off again when it stops. This
2947 the interaction starts and goes off again when it stops. This
2928 allows embedding code to detect being inside IPython. Before this
2948 allows embedding code to detect being inside IPython. Before this
2929 was done via __IPYTHON__, but that only shows that an IPython
2949 was done via __IPYTHON__, but that only shows that an IPython
2930 instance has been created.
2950 instance has been created.
2931
2951
2932 * IPython/Magic.py (Magic.magic_env): I realized that in a
2952 * IPython/Magic.py (Magic.magic_env): I realized that in a
2933 UserDict, instance.data holds the data as a normal dict. So I
2953 UserDict, instance.data holds the data as a normal dict. So I
2934 modified @env to return os.environ.data instead of rebuilding a
2954 modified @env to return os.environ.data instead of rebuilding a
2935 dict by hand.
2955 dict by hand.
2936
2956
2937 2002-11-02 Fernando Perez <fperez@colorado.edu>
2957 2002-11-02 Fernando Perez <fperez@colorado.edu>
2938
2958
2939 * IPython/genutils.py (warn): changed so that level 1 prints no
2959 * IPython/genutils.py (warn): changed so that level 1 prints no
2940 header. Level 2 is now the default (with 'WARNING' header, as
2960 header. Level 2 is now the default (with 'WARNING' header, as
2941 before). I think I tracked all places where changes were needed in
2961 before). I think I tracked all places where changes were needed in
2942 IPython, but outside code using the old level numbering may have
2962 IPython, but outside code using the old level numbering may have
2943 broken.
2963 broken.
2944
2964
2945 * IPython/iplib.py (InteractiveShell.runcode): added this to
2965 * IPython/iplib.py (InteractiveShell.runcode): added this to
2946 handle the tracebacks in SystemExit traps correctly. The previous
2966 handle the tracebacks in SystemExit traps correctly. The previous
2947 code (through interact) was printing more of the stack than
2967 code (through interact) was printing more of the stack than
2948 necessary, showing IPython internal code to the user.
2968 necessary, showing IPython internal code to the user.
2949
2969
2950 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2970 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2951 default. Now that the default at the confirmation prompt is yes,
2971 default. Now that the default at the confirmation prompt is yes,
2952 it's not so intrusive. François' argument that ipython sessions
2972 it's not so intrusive. François' argument that ipython sessions
2953 tend to be complex enough not to lose them from an accidental C-d,
2973 tend to be complex enough not to lose them from an accidental C-d,
2954 is a valid one.
2974 is a valid one.
2955
2975
2956 * IPython/iplib.py (InteractiveShell.interact): added a
2976 * IPython/iplib.py (InteractiveShell.interact): added a
2957 showtraceback() call to the SystemExit trap, and modified the exit
2977 showtraceback() call to the SystemExit trap, and modified the exit
2958 confirmation to have yes as the default.
2978 confirmation to have yes as the default.
2959
2979
2960 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2980 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2961 this file. It's been gone from the code for a long time, this was
2981 this file. It's been gone from the code for a long time, this was
2962 simply leftover junk.
2982 simply leftover junk.
2963
2983
2964 2002-11-01 Fernando Perez <fperez@colorado.edu>
2984 2002-11-01 Fernando Perez <fperez@colorado.edu>
2965
2985
2966 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2986 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2967 added. If set, IPython now traps EOF and asks for
2987 added. If set, IPython now traps EOF and asks for
2968 confirmation. After a request by François Pinard.
2988 confirmation. After a request by François Pinard.
2969
2989
2970 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2990 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2971 of @abort, and with a new (better) mechanism for handling the
2991 of @abort, and with a new (better) mechanism for handling the
2972 exceptions.
2992 exceptions.
2973
2993
2974 2002-10-27 Fernando Perez <fperez@colorado.edu>
2994 2002-10-27 Fernando Perez <fperez@colorado.edu>
2975
2995
2976 * IPython/usage.py (__doc__): updated the --help information and
2996 * IPython/usage.py (__doc__): updated the --help information and
2977 the ipythonrc file to indicate that -log generates
2997 the ipythonrc file to indicate that -log generates
2978 ./ipython.log. Also fixed the corresponding info in @logstart.
2998 ./ipython.log. Also fixed the corresponding info in @logstart.
2979 This and several other fixes in the manuals thanks to reports by
2999 This and several other fixes in the manuals thanks to reports by
2980 François Pinard <pinard-AT-iro.umontreal.ca>.
3000 François Pinard <pinard-AT-iro.umontreal.ca>.
2981
3001
2982 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3002 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2983 refer to @logstart (instead of @log, which doesn't exist).
3003 refer to @logstart (instead of @log, which doesn't exist).
2984
3004
2985 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3005 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2986 AttributeError crash. Thanks to Christopher Armstrong
3006 AttributeError crash. Thanks to Christopher Armstrong
2987 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3007 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2988 introduced recently (in 0.2.14pre37) with the fix to the eval
3008 introduced recently (in 0.2.14pre37) with the fix to the eval
2989 problem mentioned below.
3009 problem mentioned below.
2990
3010
2991 2002-10-17 Fernando Perez <fperez@colorado.edu>
3011 2002-10-17 Fernando Perez <fperez@colorado.edu>
2992
3012
2993 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3013 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2994 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3014 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2995
3015
2996 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3016 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2997 this function to fix a problem reported by Alex Schmolck. He saw
3017 this function to fix a problem reported by Alex Schmolck. He saw
2998 it with list comprehensions and generators, which were getting
3018 it with list comprehensions and generators, which were getting
2999 called twice. The real problem was an 'eval' call in testing for
3019 called twice. The real problem was an 'eval' call in testing for
3000 automagic which was evaluating the input line silently.
3020 automagic which was evaluating the input line silently.
3001
3021
3002 This is a potentially very nasty bug, if the input has side
3022 This is a potentially very nasty bug, if the input has side
3003 effects which must not be repeated. The code is much cleaner now,
3023 effects which must not be repeated. The code is much cleaner now,
3004 without any blanket 'except' left and with a regexp test for
3024 without any blanket 'except' left and with a regexp test for
3005 actual function names.
3025 actual function names.
3006
3026
3007 But an eval remains, which I'm not fully comfortable with. I just
3027 But an eval remains, which I'm not fully comfortable with. I just
3008 don't know how to find out if an expression could be a callable in
3028 don't know how to find out if an expression could be a callable in
3009 the user's namespace without doing an eval on the string. However
3029 the user's namespace without doing an eval on the string. However
3010 that string is now much more strictly checked so that no code
3030 that string is now much more strictly checked so that no code
3011 slips by, so the eval should only happen for things that can
3031 slips by, so the eval should only happen for things that can
3012 really be only function/method names.
3032 really be only function/method names.
3013
3033
3014 2002-10-15 Fernando Perez <fperez@colorado.edu>
3034 2002-10-15 Fernando Perez <fperez@colorado.edu>
3015
3035
3016 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3036 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3017 OSX information to main manual, removed README_Mac_OSX file from
3037 OSX information to main manual, removed README_Mac_OSX file from
3018 distribution. Also updated credits for recent additions.
3038 distribution. Also updated credits for recent additions.
3019
3039
3020 2002-10-10 Fernando Perez <fperez@colorado.edu>
3040 2002-10-10 Fernando Perez <fperez@colorado.edu>
3021
3041
3022 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3042 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3023 terminal-related issues. Many thanks to Andrea Riciputi
3043 terminal-related issues. Many thanks to Andrea Riciputi
3024 <andrea.riciputi-AT-libero.it> for writing it.
3044 <andrea.riciputi-AT-libero.it> for writing it.
3025
3045
3026 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3046 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3027 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3047 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3028
3048
3029 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3049 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3030 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3050 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3031 <syver-en-AT-online.no> who both submitted patches for this problem.
3051 <syver-en-AT-online.no> who both submitted patches for this problem.
3032
3052
3033 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3053 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3034 global embedding to make sure that things don't overwrite user
3054 global embedding to make sure that things don't overwrite user
3035 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3055 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3036
3056
3037 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3057 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3038 compatibility. Thanks to Hayden Callow
3058 compatibility. Thanks to Hayden Callow
3039 <h.callow-AT-elec.canterbury.ac.nz>
3059 <h.callow-AT-elec.canterbury.ac.nz>
3040
3060
3041 2002-10-04 Fernando Perez <fperez@colorado.edu>
3061 2002-10-04 Fernando Perez <fperez@colorado.edu>
3042
3062
3043 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3063 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3044 Gnuplot.File objects.
3064 Gnuplot.File objects.
3045
3065
3046 2002-07-23 Fernando Perez <fperez@colorado.edu>
3066 2002-07-23 Fernando Perez <fperez@colorado.edu>
3047
3067
3048 * IPython/genutils.py (timing): Added timings() and timing() for
3068 * IPython/genutils.py (timing): Added timings() and timing() for
3049 quick access to the most commonly needed data, the execution
3069 quick access to the most commonly needed data, the execution
3050 times. Old timing() renamed to timings_out().
3070 times. Old timing() renamed to timings_out().
3051
3071
3052 2002-07-18 Fernando Perez <fperez@colorado.edu>
3072 2002-07-18 Fernando Perez <fperez@colorado.edu>
3053
3073
3054 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3074 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3055 bug with nested instances disrupting the parent's tab completion.
3075 bug with nested instances disrupting the parent's tab completion.
3056
3076
3057 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3077 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3058 all_completions code to begin the emacs integration.
3078 all_completions code to begin the emacs integration.
3059
3079
3060 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3080 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3061 argument to allow titling individual arrays when plotting.
3081 argument to allow titling individual arrays when plotting.
3062
3082
3063 2002-07-15 Fernando Perez <fperez@colorado.edu>
3083 2002-07-15 Fernando Perez <fperez@colorado.edu>
3064
3084
3065 * setup.py (make_shortcut): changed to retrieve the value of
3085 * setup.py (make_shortcut): changed to retrieve the value of
3066 'Program Files' directory from the registry (this value changes in
3086 'Program Files' directory from the registry (this value changes in
3067 non-english versions of Windows). Thanks to Thomas Fanslau
3087 non-english versions of Windows). Thanks to Thomas Fanslau
3068 <tfanslau-AT-gmx.de> for the report.
3088 <tfanslau-AT-gmx.de> for the report.
3069
3089
3070 2002-07-10 Fernando Perez <fperez@colorado.edu>
3090 2002-07-10 Fernando Perez <fperez@colorado.edu>
3071
3091
3072 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3092 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3073 a bug in pdb, which crashes if a line with only whitespace is
3093 a bug in pdb, which crashes if a line with only whitespace is
3074 entered. Bug report submitted to sourceforge.
3094 entered. Bug report submitted to sourceforge.
3075
3095
3076 2002-07-09 Fernando Perez <fperez@colorado.edu>
3096 2002-07-09 Fernando Perez <fperez@colorado.edu>
3077
3097
3078 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3098 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3079 reporting exceptions (it's a bug in inspect.py, I just set a
3099 reporting exceptions (it's a bug in inspect.py, I just set a
3080 workaround).
3100 workaround).
3081
3101
3082 2002-07-08 Fernando Perez <fperez@colorado.edu>
3102 2002-07-08 Fernando Perez <fperez@colorado.edu>
3083
3103
3084 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3104 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3085 __IPYTHON__ in __builtins__ to show up in user_ns.
3105 __IPYTHON__ in __builtins__ to show up in user_ns.
3086
3106
3087 2002-07-03 Fernando Perez <fperez@colorado.edu>
3107 2002-07-03 Fernando Perez <fperez@colorado.edu>
3088
3108
3089 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3109 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3090 name from @gp_set_instance to @gp_set_default.
3110 name from @gp_set_instance to @gp_set_default.
3091
3111
3092 * IPython/ipmaker.py (make_IPython): default editor value set to
3112 * IPython/ipmaker.py (make_IPython): default editor value set to
3093 '0' (a string), to match the rc file. Otherwise will crash when
3113 '0' (a string), to match the rc file. Otherwise will crash when
3094 .strip() is called on it.
3114 .strip() is called on it.
3095
3115
3096
3116
3097 2002-06-28 Fernando Perez <fperez@colorado.edu>
3117 2002-06-28 Fernando Perez <fperez@colorado.edu>
3098
3118
3099 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3119 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3100 of files in current directory when a file is executed via
3120 of files in current directory when a file is executed via
3101 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3121 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3102
3122
3103 * setup.py (manfiles): fix for rpm builds, submitted by RA
3123 * setup.py (manfiles): fix for rpm builds, submitted by RA
3104 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3124 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3105
3125
3106 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3126 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3107 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3127 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3108 string!). A. Schmolck caught this one.
3128 string!). A. Schmolck caught this one.
3109
3129
3110 2002-06-27 Fernando Perez <fperez@colorado.edu>
3130 2002-06-27 Fernando Perez <fperez@colorado.edu>
3111
3131
3112 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3132 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3113 defined files at the cmd line. __name__ wasn't being set to
3133 defined files at the cmd line. __name__ wasn't being set to
3114 __main__.
3134 __main__.
3115
3135
3116 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3136 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3117 regular lists and tuples besides Numeric arrays.
3137 regular lists and tuples besides Numeric arrays.
3118
3138
3119 * IPython/Prompts.py (CachedOutput.__call__): Added output
3139 * IPython/Prompts.py (CachedOutput.__call__): Added output
3120 supression for input ending with ';'. Similar to Mathematica and
3140 supression for input ending with ';'. Similar to Mathematica and
3121 Matlab. The _* vars and Out[] list are still updated, just like
3141 Matlab. The _* vars and Out[] list are still updated, just like
3122 Mathematica behaves.
3142 Mathematica behaves.
3123
3143
3124 2002-06-25 Fernando Perez <fperez@colorado.edu>
3144 2002-06-25 Fernando Perez <fperez@colorado.edu>
3125
3145
3126 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3146 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3127 .ini extensions for profiels under Windows.
3147 .ini extensions for profiels under Windows.
3128
3148
3129 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3149 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3130 string form. Fix contributed by Alexander Schmolck
3150 string form. Fix contributed by Alexander Schmolck
3131 <a.schmolck-AT-gmx.net>
3151 <a.schmolck-AT-gmx.net>
3132
3152
3133 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3153 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3134 pre-configured Gnuplot instance.
3154 pre-configured Gnuplot instance.
3135
3155
3136 2002-06-21 Fernando Perez <fperez@colorado.edu>
3156 2002-06-21 Fernando Perez <fperez@colorado.edu>
3137
3157
3138 * IPython/numutils.py (exp_safe): new function, works around the
3158 * IPython/numutils.py (exp_safe): new function, works around the
3139 underflow problems in Numeric.
3159 underflow problems in Numeric.
3140 (log2): New fn. Safe log in base 2: returns exact integer answer
3160 (log2): New fn. Safe log in base 2: returns exact integer answer
3141 for exact integer powers of 2.
3161 for exact integer powers of 2.
3142
3162
3143 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3163 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3144 properly.
3164 properly.
3145
3165
3146 2002-06-20 Fernando Perez <fperez@colorado.edu>
3166 2002-06-20 Fernando Perez <fperez@colorado.edu>
3147
3167
3148 * IPython/genutils.py (timing): new function like
3168 * IPython/genutils.py (timing): new function like
3149 Mathematica's. Similar to time_test, but returns more info.
3169 Mathematica's. Similar to time_test, but returns more info.
3150
3170
3151 2002-06-18 Fernando Perez <fperez@colorado.edu>
3171 2002-06-18 Fernando Perez <fperez@colorado.edu>
3152
3172
3153 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3173 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3154 according to Mike Heeter's suggestions.
3174 according to Mike Heeter's suggestions.
3155
3175
3156 2002-06-16 Fernando Perez <fperez@colorado.edu>
3176 2002-06-16 Fernando Perez <fperez@colorado.edu>
3157
3177
3158 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3178 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3159 system. GnuplotMagic is gone as a user-directory option. New files
3179 system. GnuplotMagic is gone as a user-directory option. New files
3160 make it easier to use all the gnuplot stuff both from external
3180 make it easier to use all the gnuplot stuff both from external
3161 programs as well as from IPython. Had to rewrite part of
3181 programs as well as from IPython. Had to rewrite part of
3162 hardcopy() b/c of a strange bug: often the ps files simply don't
3182 hardcopy() b/c of a strange bug: often the ps files simply don't
3163 get created, and require a repeat of the command (often several
3183 get created, and require a repeat of the command (often several
3164 times).
3184 times).
3165
3185
3166 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3186 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3167 resolve output channel at call time, so that if sys.stderr has
3187 resolve output channel at call time, so that if sys.stderr has
3168 been redirected by user this gets honored.
3188 been redirected by user this gets honored.
3169
3189
3170 2002-06-13 Fernando Perez <fperez@colorado.edu>
3190 2002-06-13 Fernando Perez <fperez@colorado.edu>
3171
3191
3172 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3192 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3173 IPShell. Kept a copy with the old names to avoid breaking people's
3193 IPShell. Kept a copy with the old names to avoid breaking people's
3174 embedded code.
3194 embedded code.
3175
3195
3176 * IPython/ipython: simplified it to the bare minimum after
3196 * IPython/ipython: simplified it to the bare minimum after
3177 Holger's suggestions. Added info about how to use it in
3197 Holger's suggestions. Added info about how to use it in
3178 PYTHONSTARTUP.
3198 PYTHONSTARTUP.
3179
3199
3180 * IPython/Shell.py (IPythonShell): changed the options passing
3200 * IPython/Shell.py (IPythonShell): changed the options passing
3181 from a string with funky %s replacements to a straight list. Maybe
3201 from a string with funky %s replacements to a straight list. Maybe
3182 a bit more typing, but it follows sys.argv conventions, so there's
3202 a bit more typing, but it follows sys.argv conventions, so there's
3183 less special-casing to remember.
3203 less special-casing to remember.
3184
3204
3185 2002-06-12 Fernando Perez <fperez@colorado.edu>
3205 2002-06-12 Fernando Perez <fperez@colorado.edu>
3186
3206
3187 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3207 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3188 command. Thanks to a suggestion by Mike Heeter.
3208 command. Thanks to a suggestion by Mike Heeter.
3189 (Magic.magic_pfile): added behavior to look at filenames if given
3209 (Magic.magic_pfile): added behavior to look at filenames if given
3190 arg is not a defined object.
3210 arg is not a defined object.
3191 (Magic.magic_save): New @save function to save code snippets. Also
3211 (Magic.magic_save): New @save function to save code snippets. Also
3192 a Mike Heeter idea.
3212 a Mike Heeter idea.
3193
3213
3194 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3214 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3195 plot() and replot(). Much more convenient now, especially for
3215 plot() and replot(). Much more convenient now, especially for
3196 interactive use.
3216 interactive use.
3197
3217
3198 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3218 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3199 filenames.
3219 filenames.
3200
3220
3201 2002-06-02 Fernando Perez <fperez@colorado.edu>
3221 2002-06-02 Fernando Perez <fperez@colorado.edu>
3202
3222
3203 * IPython/Struct.py (Struct.__init__): modified to admit
3223 * IPython/Struct.py (Struct.__init__): modified to admit
3204 initialization via another struct.
3224 initialization via another struct.
3205
3225
3206 * IPython/genutils.py (SystemExec.__init__): New stateful
3226 * IPython/genutils.py (SystemExec.__init__): New stateful
3207 interface to xsys and bq. Useful for writing system scripts.
3227 interface to xsys and bq. Useful for writing system scripts.
3208
3228
3209 2002-05-30 Fernando Perez <fperez@colorado.edu>
3229 2002-05-30 Fernando Perez <fperez@colorado.edu>
3210
3230
3211 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3231 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3212 documents. This will make the user download smaller (it's getting
3232 documents. This will make the user download smaller (it's getting
3213 too big).
3233 too big).
3214
3234
3215 2002-05-29 Fernando Perez <fperez@colorado.edu>
3235 2002-05-29 Fernando Perez <fperez@colorado.edu>
3216
3236
3217 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3237 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3218 fix problems with shelve and pickle. Seems to work, but I don't
3238 fix problems with shelve and pickle. Seems to work, but I don't
3219 know if corner cases break it. Thanks to Mike Heeter
3239 know if corner cases break it. Thanks to Mike Heeter
3220 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3240 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3221
3241
3222 2002-05-24 Fernando Perez <fperez@colorado.edu>
3242 2002-05-24 Fernando Perez <fperez@colorado.edu>
3223
3243
3224 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3244 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3225 macros having broken.
3245 macros having broken.
3226
3246
3227 2002-05-21 Fernando Perez <fperez@colorado.edu>
3247 2002-05-21 Fernando Perez <fperez@colorado.edu>
3228
3248
3229 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3249 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3230 introduced logging bug: all history before logging started was
3250 introduced logging bug: all history before logging started was
3231 being written one character per line! This came from the redesign
3251 being written one character per line! This came from the redesign
3232 of the input history as a special list which slices to strings,
3252 of the input history as a special list which slices to strings,
3233 not to lists.
3253 not to lists.
3234
3254
3235 2002-05-20 Fernando Perez <fperez@colorado.edu>
3255 2002-05-20 Fernando Perez <fperez@colorado.edu>
3236
3256
3237 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3257 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3238 be an attribute of all classes in this module. The design of these
3258 be an attribute of all classes in this module. The design of these
3239 classes needs some serious overhauling.
3259 classes needs some serious overhauling.
3240
3260
3241 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3261 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3242 which was ignoring '_' in option names.
3262 which was ignoring '_' in option names.
3243
3263
3244 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3264 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3245 'Verbose_novars' to 'Context' and made it the new default. It's a
3265 'Verbose_novars' to 'Context' and made it the new default. It's a
3246 bit more readable and also safer than verbose.
3266 bit more readable and also safer than verbose.
3247
3267
3248 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3268 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3249 triple-quoted strings.
3269 triple-quoted strings.
3250
3270
3251 * IPython/OInspect.py (__all__): new module exposing the object
3271 * IPython/OInspect.py (__all__): new module exposing the object
3252 introspection facilities. Now the corresponding magics are dummy
3272 introspection facilities. Now the corresponding magics are dummy
3253 wrappers around this. Having this module will make it much easier
3273 wrappers around this. Having this module will make it much easier
3254 to put these functions into our modified pdb.
3274 to put these functions into our modified pdb.
3255 This new object inspector system uses the new colorizing module,
3275 This new object inspector system uses the new colorizing module,
3256 so source code and other things are nicely syntax highlighted.
3276 so source code and other things are nicely syntax highlighted.
3257
3277
3258 2002-05-18 Fernando Perez <fperez@colorado.edu>
3278 2002-05-18 Fernando Perez <fperez@colorado.edu>
3259
3279
3260 * IPython/ColorANSI.py: Split the coloring tools into a separate
3280 * IPython/ColorANSI.py: Split the coloring tools into a separate
3261 module so I can use them in other code easier (they were part of
3281 module so I can use them in other code easier (they were part of
3262 ultraTB).
3282 ultraTB).
3263
3283
3264 2002-05-17 Fernando Perez <fperez@colorado.edu>
3284 2002-05-17 Fernando Perez <fperez@colorado.edu>
3265
3285
3266 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3286 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3267 fixed it to set the global 'g' also to the called instance, as
3287 fixed it to set the global 'g' also to the called instance, as
3268 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3288 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3269 user's 'g' variables).
3289 user's 'g' variables).
3270
3290
3271 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3291 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3272 global variables (aliases to _ih,_oh) so that users which expect
3292 global variables (aliases to _ih,_oh) so that users which expect
3273 In[5] or Out[7] to work aren't unpleasantly surprised.
3293 In[5] or Out[7] to work aren't unpleasantly surprised.
3274 (InputList.__getslice__): new class to allow executing slices of
3294 (InputList.__getslice__): new class to allow executing slices of
3275 input history directly. Very simple class, complements the use of
3295 input history directly. Very simple class, complements the use of
3276 macros.
3296 macros.
3277
3297
3278 2002-05-16 Fernando Perez <fperez@colorado.edu>
3298 2002-05-16 Fernando Perez <fperez@colorado.edu>
3279
3299
3280 * setup.py (docdirbase): make doc directory be just doc/IPython
3300 * setup.py (docdirbase): make doc directory be just doc/IPython
3281 without version numbers, it will reduce clutter for users.
3301 without version numbers, it will reduce clutter for users.
3282
3302
3283 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3303 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3284 execfile call to prevent possible memory leak. See for details:
3304 execfile call to prevent possible memory leak. See for details:
3285 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3305 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3286
3306
3287 2002-05-15 Fernando Perez <fperez@colorado.edu>
3307 2002-05-15 Fernando Perez <fperez@colorado.edu>
3288
3308
3289 * IPython/Magic.py (Magic.magic_psource): made the object
3309 * IPython/Magic.py (Magic.magic_psource): made the object
3290 introspection names be more standard: pdoc, pdef, pfile and
3310 introspection names be more standard: pdoc, pdef, pfile and
3291 psource. They all print/page their output, and it makes
3311 psource. They all print/page their output, and it makes
3292 remembering them easier. Kept old names for compatibility as
3312 remembering them easier. Kept old names for compatibility as
3293 aliases.
3313 aliases.
3294
3314
3295 2002-05-14 Fernando Perez <fperez@colorado.edu>
3315 2002-05-14 Fernando Perez <fperez@colorado.edu>
3296
3316
3297 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3317 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3298 what the mouse problem was. The trick is to use gnuplot with temp
3318 what the mouse problem was. The trick is to use gnuplot with temp
3299 files and NOT with pipes (for data communication), because having
3319 files and NOT with pipes (for data communication), because having
3300 both pipes and the mouse on is bad news.
3320 both pipes and the mouse on is bad news.
3301
3321
3302 2002-05-13 Fernando Perez <fperez@colorado.edu>
3322 2002-05-13 Fernando Perez <fperez@colorado.edu>
3303
3323
3304 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3324 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3305 bug. Information would be reported about builtins even when
3325 bug. Information would be reported about builtins even when
3306 user-defined functions overrode them.
3326 user-defined functions overrode them.
3307
3327
3308 2002-05-11 Fernando Perez <fperez@colorado.edu>
3328 2002-05-11 Fernando Perez <fperez@colorado.edu>
3309
3329
3310 * IPython/__init__.py (__all__): removed FlexCompleter from
3330 * IPython/__init__.py (__all__): removed FlexCompleter from
3311 __all__ so that things don't fail in platforms without readline.
3331 __all__ so that things don't fail in platforms without readline.
3312
3332
3313 2002-05-10 Fernando Perez <fperez@colorado.edu>
3333 2002-05-10 Fernando Perez <fperez@colorado.edu>
3314
3334
3315 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3335 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3316 it requires Numeric, effectively making Numeric a dependency for
3336 it requires Numeric, effectively making Numeric a dependency for
3317 IPython.
3337 IPython.
3318
3338
3319 * Released 0.2.13
3339 * Released 0.2.13
3320
3340
3321 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3341 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3322 profiler interface. Now all the major options from the profiler
3342 profiler interface. Now all the major options from the profiler
3323 module are directly supported in IPython, both for single
3343 module are directly supported in IPython, both for single
3324 expressions (@prun) and for full programs (@run -p).
3344 expressions (@prun) and for full programs (@run -p).
3325
3345
3326 2002-05-09 Fernando Perez <fperez@colorado.edu>
3346 2002-05-09 Fernando Perez <fperez@colorado.edu>
3327
3347
3328 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3348 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3329 magic properly formatted for screen.
3349 magic properly formatted for screen.
3330
3350
3331 * setup.py (make_shortcut): Changed things to put pdf version in
3351 * setup.py (make_shortcut): Changed things to put pdf version in
3332 doc/ instead of doc/manual (had to change lyxport a bit).
3352 doc/ instead of doc/manual (had to change lyxport a bit).
3333
3353
3334 * IPython/Magic.py (Profile.string_stats): made profile runs go
3354 * IPython/Magic.py (Profile.string_stats): made profile runs go
3335 through pager (they are long and a pager allows searching, saving,
3355 through pager (they are long and a pager allows searching, saving,
3336 etc.)
3356 etc.)
3337
3357
3338 2002-05-08 Fernando Perez <fperez@colorado.edu>
3358 2002-05-08 Fernando Perez <fperez@colorado.edu>
3339
3359
3340 * Released 0.2.12
3360 * Released 0.2.12
3341
3361
3342 2002-05-06 Fernando Perez <fperez@colorado.edu>
3362 2002-05-06 Fernando Perez <fperez@colorado.edu>
3343
3363
3344 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3364 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3345 introduced); 'hist n1 n2' was broken.
3365 introduced); 'hist n1 n2' was broken.
3346 (Magic.magic_pdb): added optional on/off arguments to @pdb
3366 (Magic.magic_pdb): added optional on/off arguments to @pdb
3347 (Magic.magic_run): added option -i to @run, which executes code in
3367 (Magic.magic_run): added option -i to @run, which executes code in
3348 the IPython namespace instead of a clean one. Also added @irun as
3368 the IPython namespace instead of a clean one. Also added @irun as
3349 an alias to @run -i.
3369 an alias to @run -i.
3350
3370
3351 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3371 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3352 fixed (it didn't really do anything, the namespaces were wrong).
3372 fixed (it didn't really do anything, the namespaces were wrong).
3353
3373
3354 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3374 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3355
3375
3356 * IPython/__init__.py (__all__): Fixed package namespace, now
3376 * IPython/__init__.py (__all__): Fixed package namespace, now
3357 'import IPython' does give access to IPython.<all> as
3377 'import IPython' does give access to IPython.<all> as
3358 expected. Also renamed __release__ to Release.
3378 expected. Also renamed __release__ to Release.
3359
3379
3360 * IPython/Debugger.py (__license__): created new Pdb class which
3380 * IPython/Debugger.py (__license__): created new Pdb class which
3361 functions like a drop-in for the normal pdb.Pdb but does NOT
3381 functions like a drop-in for the normal pdb.Pdb but does NOT
3362 import readline by default. This way it doesn't muck up IPython's
3382 import readline by default. This way it doesn't muck up IPython's
3363 readline handling, and now tab-completion finally works in the
3383 readline handling, and now tab-completion finally works in the
3364 debugger -- sort of. It completes things globally visible, but the
3384 debugger -- sort of. It completes things globally visible, but the
3365 completer doesn't track the stack as pdb walks it. That's a bit
3385 completer doesn't track the stack as pdb walks it. That's a bit
3366 tricky, and I'll have to implement it later.
3386 tricky, and I'll have to implement it later.
3367
3387
3368 2002-05-05 Fernando Perez <fperez@colorado.edu>
3388 2002-05-05 Fernando Perez <fperez@colorado.edu>
3369
3389
3370 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3390 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3371 magic docstrings when printed via ? (explicit \'s were being
3391 magic docstrings when printed via ? (explicit \'s were being
3372 printed).
3392 printed).
3373
3393
3374 * IPython/ipmaker.py (make_IPython): fixed namespace
3394 * IPython/ipmaker.py (make_IPython): fixed namespace
3375 identification bug. Now variables loaded via logs or command-line
3395 identification bug. Now variables loaded via logs or command-line
3376 files are recognized in the interactive namespace by @who.
3396 files are recognized in the interactive namespace by @who.
3377
3397
3378 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3398 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3379 log replay system stemming from the string form of Structs.
3399 log replay system stemming from the string form of Structs.
3380
3400
3381 * IPython/Magic.py (Macro.__init__): improved macros to properly
3401 * IPython/Magic.py (Macro.__init__): improved macros to properly
3382 handle magic commands in them.
3402 handle magic commands in them.
3383 (Magic.magic_logstart): usernames are now expanded so 'logstart
3403 (Magic.magic_logstart): usernames are now expanded so 'logstart
3384 ~/mylog' now works.
3404 ~/mylog' now works.
3385
3405
3386 * IPython/iplib.py (complete): fixed bug where paths starting with
3406 * IPython/iplib.py (complete): fixed bug where paths starting with
3387 '/' would be completed as magic names.
3407 '/' would be completed as magic names.
3388
3408
3389 2002-05-04 Fernando Perez <fperez@colorado.edu>
3409 2002-05-04 Fernando Perez <fperez@colorado.edu>
3390
3410
3391 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3411 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3392 allow running full programs under the profiler's control.
3412 allow running full programs under the profiler's control.
3393
3413
3394 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3414 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3395 mode to report exceptions verbosely but without formatting
3415 mode to report exceptions verbosely but without formatting
3396 variables. This addresses the issue of ipython 'freezing' (it's
3416 variables. This addresses the issue of ipython 'freezing' (it's
3397 not frozen, but caught in an expensive formatting loop) when huge
3417 not frozen, but caught in an expensive formatting loop) when huge
3398 variables are in the context of an exception.
3418 variables are in the context of an exception.
3399 (VerboseTB.text): Added '--->' markers at line where exception was
3419 (VerboseTB.text): Added '--->' markers at line where exception was
3400 triggered. Much clearer to read, especially in NoColor modes.
3420 triggered. Much clearer to read, especially in NoColor modes.
3401
3421
3402 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3422 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3403 implemented in reverse when changing to the new parse_options().
3423 implemented in reverse when changing to the new parse_options().
3404
3424
3405 2002-05-03 Fernando Perez <fperez@colorado.edu>
3425 2002-05-03 Fernando Perez <fperez@colorado.edu>
3406
3426
3407 * IPython/Magic.py (Magic.parse_options): new function so that
3427 * IPython/Magic.py (Magic.parse_options): new function so that
3408 magics can parse options easier.
3428 magics can parse options easier.
3409 (Magic.magic_prun): new function similar to profile.run(),
3429 (Magic.magic_prun): new function similar to profile.run(),
3410 suggested by Chris Hart.
3430 suggested by Chris Hart.
3411 (Magic.magic_cd): fixed behavior so that it only changes if
3431 (Magic.magic_cd): fixed behavior so that it only changes if
3412 directory actually is in history.
3432 directory actually is in history.
3413
3433
3414 * IPython/usage.py (__doc__): added information about potential
3434 * IPython/usage.py (__doc__): added information about potential
3415 slowness of Verbose exception mode when there are huge data
3435 slowness of Verbose exception mode when there are huge data
3416 structures to be formatted (thanks to Archie Paulson).
3436 structures to be formatted (thanks to Archie Paulson).
3417
3437
3418 * IPython/ipmaker.py (make_IPython): Changed default logging
3438 * IPython/ipmaker.py (make_IPython): Changed default logging
3419 (when simply called with -log) to use curr_dir/ipython.log in
3439 (when simply called with -log) to use curr_dir/ipython.log in
3420 rotate mode. Fixed crash which was occuring with -log before
3440 rotate mode. Fixed crash which was occuring with -log before
3421 (thanks to Jim Boyle).
3441 (thanks to Jim Boyle).
3422
3442
3423 2002-05-01 Fernando Perez <fperez@colorado.edu>
3443 2002-05-01 Fernando Perez <fperez@colorado.edu>
3424
3444
3425 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3445 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3426 was nasty -- though somewhat of a corner case).
3446 was nasty -- though somewhat of a corner case).
3427
3447
3428 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3448 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3429 text (was a bug).
3449 text (was a bug).
3430
3450
3431 2002-04-30 Fernando Perez <fperez@colorado.edu>
3451 2002-04-30 Fernando Perez <fperez@colorado.edu>
3432
3452
3433 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3453 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3434 a print after ^D or ^C from the user so that the In[] prompt
3454 a print after ^D or ^C from the user so that the In[] prompt
3435 doesn't over-run the gnuplot one.
3455 doesn't over-run the gnuplot one.
3436
3456
3437 2002-04-29 Fernando Perez <fperez@colorado.edu>
3457 2002-04-29 Fernando Perez <fperez@colorado.edu>
3438
3458
3439 * Released 0.2.10
3459 * Released 0.2.10
3440
3460
3441 * IPython/__release__.py (version): get date dynamically.
3461 * IPython/__release__.py (version): get date dynamically.
3442
3462
3443 * Misc. documentation updates thanks to Arnd's comments. Also ran
3463 * Misc. documentation updates thanks to Arnd's comments. Also ran
3444 a full spellcheck on the manual (hadn't been done in a while).
3464 a full spellcheck on the manual (hadn't been done in a while).
3445
3465
3446 2002-04-27 Fernando Perez <fperez@colorado.edu>
3466 2002-04-27 Fernando Perez <fperez@colorado.edu>
3447
3467
3448 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3468 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3449 starting a log in mid-session would reset the input history list.
3469 starting a log in mid-session would reset the input history list.
3450
3470
3451 2002-04-26 Fernando Perez <fperez@colorado.edu>
3471 2002-04-26 Fernando Perez <fperez@colorado.edu>
3452
3472
3453 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3473 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3454 all files were being included in an update. Now anything in
3474 all files were being included in an update. Now anything in
3455 UserConfig that matches [A-Za-z]*.py will go (this excludes
3475 UserConfig that matches [A-Za-z]*.py will go (this excludes
3456 __init__.py)
3476 __init__.py)
3457
3477
3458 2002-04-25 Fernando Perez <fperez@colorado.edu>
3478 2002-04-25 Fernando Perez <fperez@colorado.edu>
3459
3479
3460 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3480 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3461 to __builtins__ so that any form of embedded or imported code can
3481 to __builtins__ so that any form of embedded or imported code can
3462 test for being inside IPython.
3482 test for being inside IPython.
3463
3483
3464 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3484 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3465 changed to GnuplotMagic because it's now an importable module,
3485 changed to GnuplotMagic because it's now an importable module,
3466 this makes the name follow that of the standard Gnuplot module.
3486 this makes the name follow that of the standard Gnuplot module.
3467 GnuplotMagic can now be loaded at any time in mid-session.
3487 GnuplotMagic can now be loaded at any time in mid-session.
3468
3488
3469 2002-04-24 Fernando Perez <fperez@colorado.edu>
3489 2002-04-24 Fernando Perez <fperez@colorado.edu>
3470
3490
3471 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3491 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3472 the globals (IPython has its own namespace) and the
3492 the globals (IPython has its own namespace) and the
3473 PhysicalQuantity stuff is much better anyway.
3493 PhysicalQuantity stuff is much better anyway.
3474
3494
3475 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3495 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3476 embedding example to standard user directory for
3496 embedding example to standard user directory for
3477 distribution. Also put it in the manual.
3497 distribution. Also put it in the manual.
3478
3498
3479 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3499 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3480 instance as first argument (so it doesn't rely on some obscure
3500 instance as first argument (so it doesn't rely on some obscure
3481 hidden global).
3501 hidden global).
3482
3502
3483 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3503 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3484 delimiters. While it prevents ().TAB from working, it allows
3504 delimiters. While it prevents ().TAB from working, it allows
3485 completions in open (... expressions. This is by far a more common
3505 completions in open (... expressions. This is by far a more common
3486 case.
3506 case.
3487
3507
3488 2002-04-23 Fernando Perez <fperez@colorado.edu>
3508 2002-04-23 Fernando Perez <fperez@colorado.edu>
3489
3509
3490 * IPython/Extensions/InterpreterPasteInput.py: new
3510 * IPython/Extensions/InterpreterPasteInput.py: new
3491 syntax-processing module for pasting lines with >>> or ... at the
3511 syntax-processing module for pasting lines with >>> or ... at the
3492 start.
3512 start.
3493
3513
3494 * IPython/Extensions/PhysicalQ_Interactive.py
3514 * IPython/Extensions/PhysicalQ_Interactive.py
3495 (PhysicalQuantityInteractive.__int__): fixed to work with either
3515 (PhysicalQuantityInteractive.__int__): fixed to work with either
3496 Numeric or math.
3516 Numeric or math.
3497
3517
3498 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3518 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3499 provided profiles. Now we have:
3519 provided profiles. Now we have:
3500 -math -> math module as * and cmath with its own namespace.
3520 -math -> math module as * and cmath with its own namespace.
3501 -numeric -> Numeric as *, plus gnuplot & grace
3521 -numeric -> Numeric as *, plus gnuplot & grace
3502 -physics -> same as before
3522 -physics -> same as before
3503
3523
3504 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3524 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3505 user-defined magics wouldn't be found by @magic if they were
3525 user-defined magics wouldn't be found by @magic if they were
3506 defined as class methods. Also cleaned up the namespace search
3526 defined as class methods. Also cleaned up the namespace search
3507 logic and the string building (to use %s instead of many repeated
3527 logic and the string building (to use %s instead of many repeated
3508 string adds).
3528 string adds).
3509
3529
3510 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3530 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3511 of user-defined magics to operate with class methods (cleaner, in
3531 of user-defined magics to operate with class methods (cleaner, in
3512 line with the gnuplot code).
3532 line with the gnuplot code).
3513
3533
3514 2002-04-22 Fernando Perez <fperez@colorado.edu>
3534 2002-04-22 Fernando Perez <fperez@colorado.edu>
3515
3535
3516 * setup.py: updated dependency list so that manual is updated when
3536 * setup.py: updated dependency list so that manual is updated when
3517 all included files change.
3537 all included files change.
3518
3538
3519 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3539 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3520 the delimiter removal option (the fix is ugly right now).
3540 the delimiter removal option (the fix is ugly right now).
3521
3541
3522 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3542 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3523 all of the math profile (quicker loading, no conflict between
3543 all of the math profile (quicker loading, no conflict between
3524 g-9.8 and g-gnuplot).
3544 g-9.8 and g-gnuplot).
3525
3545
3526 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3546 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3527 name of post-mortem files to IPython_crash_report.txt.
3547 name of post-mortem files to IPython_crash_report.txt.
3528
3548
3529 * Cleanup/update of the docs. Added all the new readline info and
3549 * Cleanup/update of the docs. Added all the new readline info and
3530 formatted all lists as 'real lists'.
3550 formatted all lists as 'real lists'.
3531
3551
3532 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3552 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3533 tab-completion options, since the full readline parse_and_bind is
3553 tab-completion options, since the full readline parse_and_bind is
3534 now accessible.
3554 now accessible.
3535
3555
3536 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3556 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3537 handling of readline options. Now users can specify any string to
3557 handling of readline options. Now users can specify any string to
3538 be passed to parse_and_bind(), as well as the delimiters to be
3558 be passed to parse_and_bind(), as well as the delimiters to be
3539 removed.
3559 removed.
3540 (InteractiveShell.__init__): Added __name__ to the global
3560 (InteractiveShell.__init__): Added __name__ to the global
3541 namespace so that things like Itpl which rely on its existence
3561 namespace so that things like Itpl which rely on its existence
3542 don't crash.
3562 don't crash.
3543 (InteractiveShell._prefilter): Defined the default with a _ so
3563 (InteractiveShell._prefilter): Defined the default with a _ so
3544 that prefilter() is easier to override, while the default one
3564 that prefilter() is easier to override, while the default one
3545 remains available.
3565 remains available.
3546
3566
3547 2002-04-18 Fernando Perez <fperez@colorado.edu>
3567 2002-04-18 Fernando Perez <fperez@colorado.edu>
3548
3568
3549 * Added information about pdb in the docs.
3569 * Added information about pdb in the docs.
3550
3570
3551 2002-04-17 Fernando Perez <fperez@colorado.edu>
3571 2002-04-17 Fernando Perez <fperez@colorado.edu>
3552
3572
3553 * IPython/ipmaker.py (make_IPython): added rc_override option to
3573 * IPython/ipmaker.py (make_IPython): added rc_override option to
3554 allow passing config options at creation time which may override
3574 allow passing config options at creation time which may override
3555 anything set in the config files or command line. This is
3575 anything set in the config files or command line. This is
3556 particularly useful for configuring embedded instances.
3576 particularly useful for configuring embedded instances.
3557
3577
3558 2002-04-15 Fernando Perez <fperez@colorado.edu>
3578 2002-04-15 Fernando Perez <fperez@colorado.edu>
3559
3579
3560 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3580 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3561 crash embedded instances because of the input cache falling out of
3581 crash embedded instances because of the input cache falling out of
3562 sync with the output counter.
3582 sync with the output counter.
3563
3583
3564 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3584 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3565 mode which calls pdb after an uncaught exception in IPython itself.
3585 mode which calls pdb after an uncaught exception in IPython itself.
3566
3586
3567 2002-04-14 Fernando Perez <fperez@colorado.edu>
3587 2002-04-14 Fernando Perez <fperez@colorado.edu>
3568
3588
3569 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3589 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3570 readline, fix it back after each call.
3590 readline, fix it back after each call.
3571
3591
3572 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3592 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3573 method to force all access via __call__(), which guarantees that
3593 method to force all access via __call__(), which guarantees that
3574 traceback references are properly deleted.
3594 traceback references are properly deleted.
3575
3595
3576 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3596 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3577 improve printing when pprint is in use.
3597 improve printing when pprint is in use.
3578
3598
3579 2002-04-13 Fernando Perez <fperez@colorado.edu>
3599 2002-04-13 Fernando Perez <fperez@colorado.edu>
3580
3600
3581 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3601 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3582 exceptions aren't caught anymore. If the user triggers one, he
3602 exceptions aren't caught anymore. If the user triggers one, he
3583 should know why he's doing it and it should go all the way up,
3603 should know why he's doing it and it should go all the way up,
3584 just like any other exception. So now @abort will fully kill the
3604 just like any other exception. So now @abort will fully kill the
3585 embedded interpreter and the embedding code (unless that happens
3605 embedded interpreter and the embedding code (unless that happens
3586 to catch SystemExit).
3606 to catch SystemExit).
3587
3607
3588 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3608 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3589 and a debugger() method to invoke the interactive pdb debugger
3609 and a debugger() method to invoke the interactive pdb debugger
3590 after printing exception information. Also added the corresponding
3610 after printing exception information. Also added the corresponding
3591 -pdb option and @pdb magic to control this feature, and updated
3611 -pdb option and @pdb magic to control this feature, and updated
3592 the docs. After a suggestion from Christopher Hart
3612 the docs. After a suggestion from Christopher Hart
3593 (hart-AT-caltech.edu).
3613 (hart-AT-caltech.edu).
3594
3614
3595 2002-04-12 Fernando Perez <fperez@colorado.edu>
3615 2002-04-12 Fernando Perez <fperez@colorado.edu>
3596
3616
3597 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3617 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3598 the exception handlers defined by the user (not the CrashHandler)
3618 the exception handlers defined by the user (not the CrashHandler)
3599 so that user exceptions don't trigger an ipython bug report.
3619 so that user exceptions don't trigger an ipython bug report.
3600
3620
3601 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3621 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3602 configurable (it should have always been so).
3622 configurable (it should have always been so).
3603
3623
3604 2002-03-26 Fernando Perez <fperez@colorado.edu>
3624 2002-03-26 Fernando Perez <fperez@colorado.edu>
3605
3625
3606 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3626 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3607 and there to fix embedding namespace issues. This should all be
3627 and there to fix embedding namespace issues. This should all be
3608 done in a more elegant way.
3628 done in a more elegant way.
3609
3629
3610 2002-03-25 Fernando Perez <fperez@colorado.edu>
3630 2002-03-25 Fernando Perez <fperez@colorado.edu>
3611
3631
3612 * IPython/genutils.py (get_home_dir): Try to make it work under
3632 * IPython/genutils.py (get_home_dir): Try to make it work under
3613 win9x also.
3633 win9x also.
3614
3634
3615 2002-03-20 Fernando Perez <fperez@colorado.edu>
3635 2002-03-20 Fernando Perez <fperez@colorado.edu>
3616
3636
3617 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3637 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3618 sys.displayhook untouched upon __init__.
3638 sys.displayhook untouched upon __init__.
3619
3639
3620 2002-03-19 Fernando Perez <fperez@colorado.edu>
3640 2002-03-19 Fernando Perez <fperez@colorado.edu>
3621
3641
3622 * Released 0.2.9 (for embedding bug, basically).
3642 * Released 0.2.9 (for embedding bug, basically).
3623
3643
3624 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3644 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3625 exceptions so that enclosing shell's state can be restored.
3645 exceptions so that enclosing shell's state can be restored.
3626
3646
3627 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3647 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3628 naming conventions in the .ipython/ dir.
3648 naming conventions in the .ipython/ dir.
3629
3649
3630 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3650 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3631 from delimiters list so filenames with - in them get expanded.
3651 from delimiters list so filenames with - in them get expanded.
3632
3652
3633 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3653 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3634 sys.displayhook not being properly restored after an embedded call.
3654 sys.displayhook not being properly restored after an embedded call.
3635
3655
3636 2002-03-18 Fernando Perez <fperez@colorado.edu>
3656 2002-03-18 Fernando Perez <fperez@colorado.edu>
3637
3657
3638 * Released 0.2.8
3658 * Released 0.2.8
3639
3659
3640 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3660 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3641 some files weren't being included in a -upgrade.
3661 some files weren't being included in a -upgrade.
3642 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3662 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3643 on' so that the first tab completes.
3663 on' so that the first tab completes.
3644 (InteractiveShell.handle_magic): fixed bug with spaces around
3664 (InteractiveShell.handle_magic): fixed bug with spaces around
3645 quotes breaking many magic commands.
3665 quotes breaking many magic commands.
3646
3666
3647 * setup.py: added note about ignoring the syntax error messages at
3667 * setup.py: added note about ignoring the syntax error messages at
3648 installation.
3668 installation.
3649
3669
3650 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3670 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3651 streamlining the gnuplot interface, now there's only one magic @gp.
3671 streamlining the gnuplot interface, now there's only one magic @gp.
3652
3672
3653 2002-03-17 Fernando Perez <fperez@colorado.edu>
3673 2002-03-17 Fernando Perez <fperez@colorado.edu>
3654
3674
3655 * IPython/UserConfig/magic_gnuplot.py: new name for the
3675 * IPython/UserConfig/magic_gnuplot.py: new name for the
3656 example-magic_pm.py file. Much enhanced system, now with a shell
3676 example-magic_pm.py file. Much enhanced system, now with a shell
3657 for communicating directly with gnuplot, one command at a time.
3677 for communicating directly with gnuplot, one command at a time.
3658
3678
3659 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3679 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3660 setting __name__=='__main__'.
3680 setting __name__=='__main__'.
3661
3681
3662 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3682 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3663 mini-shell for accessing gnuplot from inside ipython. Should
3683 mini-shell for accessing gnuplot from inside ipython. Should
3664 extend it later for grace access too. Inspired by Arnd's
3684 extend it later for grace access too. Inspired by Arnd's
3665 suggestion.
3685 suggestion.
3666
3686
3667 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3687 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3668 calling magic functions with () in their arguments. Thanks to Arnd
3688 calling magic functions with () in their arguments. Thanks to Arnd
3669 Baecker for pointing this to me.
3689 Baecker for pointing this to me.
3670
3690
3671 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3691 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3672 infinitely for integer or complex arrays (only worked with floats).
3692 infinitely for integer or complex arrays (only worked with floats).
3673
3693
3674 2002-03-16 Fernando Perez <fperez@colorado.edu>
3694 2002-03-16 Fernando Perez <fperez@colorado.edu>
3675
3695
3676 * setup.py: Merged setup and setup_windows into a single script
3696 * setup.py: Merged setup and setup_windows into a single script
3677 which properly handles things for windows users.
3697 which properly handles things for windows users.
3678
3698
3679 2002-03-15 Fernando Perez <fperez@colorado.edu>
3699 2002-03-15 Fernando Perez <fperez@colorado.edu>
3680
3700
3681 * Big change to the manual: now the magics are all automatically
3701 * Big change to the manual: now the magics are all automatically
3682 documented. This information is generated from their docstrings
3702 documented. This information is generated from their docstrings
3683 and put in a latex file included by the manual lyx file. This way
3703 and put in a latex file included by the manual lyx file. This way
3684 we get always up to date information for the magics. The manual
3704 we get always up to date information for the magics. The manual
3685 now also has proper version information, also auto-synced.
3705 now also has proper version information, also auto-synced.
3686
3706
3687 For this to work, an undocumented --magic_docstrings option was added.
3707 For this to work, an undocumented --magic_docstrings option was added.
3688
3708
3689 2002-03-13 Fernando Perez <fperez@colorado.edu>
3709 2002-03-13 Fernando Perez <fperez@colorado.edu>
3690
3710
3691 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3711 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3692 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3712 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3693
3713
3694 2002-03-12 Fernando Perez <fperez@colorado.edu>
3714 2002-03-12 Fernando Perez <fperez@colorado.edu>
3695
3715
3696 * IPython/ultraTB.py (TermColors): changed color escapes again to
3716 * IPython/ultraTB.py (TermColors): changed color escapes again to
3697 fix the (old, reintroduced) line-wrapping bug. Basically, if
3717 fix the (old, reintroduced) line-wrapping bug. Basically, if
3698 \001..\002 aren't given in the color escapes, lines get wrapped
3718 \001..\002 aren't given in the color escapes, lines get wrapped
3699 weirdly. But giving those screws up old xterms and emacs terms. So
3719 weirdly. But giving those screws up old xterms and emacs terms. So
3700 I added some logic for emacs terms to be ok, but I can't identify old
3720 I added some logic for emacs terms to be ok, but I can't identify old
3701 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3721 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3702
3722
3703 2002-03-10 Fernando Perez <fperez@colorado.edu>
3723 2002-03-10 Fernando Perez <fperez@colorado.edu>
3704
3724
3705 * IPython/usage.py (__doc__): Various documentation cleanups and
3725 * IPython/usage.py (__doc__): Various documentation cleanups and
3706 updates, both in usage docstrings and in the manual.
3726 updates, both in usage docstrings and in the manual.
3707
3727
3708 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3728 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3709 handling of caching. Set minimum acceptabe value for having a
3729 handling of caching. Set minimum acceptabe value for having a
3710 cache at 20 values.
3730 cache at 20 values.
3711
3731
3712 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3732 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3713 install_first_time function to a method, renamed it and added an
3733 install_first_time function to a method, renamed it and added an
3714 'upgrade' mode. Now people can update their config directory with
3734 'upgrade' mode. Now people can update their config directory with
3715 a simple command line switch (-upgrade, also new).
3735 a simple command line switch (-upgrade, also new).
3716
3736
3717 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3737 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3718 @file (convenient for automagic users under Python >= 2.2).
3738 @file (convenient for automagic users under Python >= 2.2).
3719 Removed @files (it seemed more like a plural than an abbrev. of
3739 Removed @files (it seemed more like a plural than an abbrev. of
3720 'file show').
3740 'file show').
3721
3741
3722 * IPython/iplib.py (install_first_time): Fixed crash if there were
3742 * IPython/iplib.py (install_first_time): Fixed crash if there were
3723 backup files ('~') in .ipython/ install directory.
3743 backup files ('~') in .ipython/ install directory.
3724
3744
3725 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3745 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3726 system. Things look fine, but these changes are fairly
3746 system. Things look fine, but these changes are fairly
3727 intrusive. Test them for a few days.
3747 intrusive. Test them for a few days.
3728
3748
3729 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3749 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3730 the prompts system. Now all in/out prompt strings are user
3750 the prompts system. Now all in/out prompt strings are user
3731 controllable. This is particularly useful for embedding, as one
3751 controllable. This is particularly useful for embedding, as one
3732 can tag embedded instances with particular prompts.
3752 can tag embedded instances with particular prompts.
3733
3753
3734 Also removed global use of sys.ps1/2, which now allows nested
3754 Also removed global use of sys.ps1/2, which now allows nested
3735 embeddings without any problems. Added command-line options for
3755 embeddings without any problems. Added command-line options for
3736 the prompt strings.
3756 the prompt strings.
3737
3757
3738 2002-03-08 Fernando Perez <fperez@colorado.edu>
3758 2002-03-08 Fernando Perez <fperez@colorado.edu>
3739
3759
3740 * IPython/UserConfig/example-embed-short.py (ipshell): added
3760 * IPython/UserConfig/example-embed-short.py (ipshell): added
3741 example file with the bare minimum code for embedding.
3761 example file with the bare minimum code for embedding.
3742
3762
3743 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3763 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3744 functionality for the embeddable shell to be activated/deactivated
3764 functionality for the embeddable shell to be activated/deactivated
3745 either globally or at each call.
3765 either globally or at each call.
3746
3766
3747 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3767 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3748 rewriting the prompt with '--->' for auto-inputs with proper
3768 rewriting the prompt with '--->' for auto-inputs with proper
3749 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3769 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3750 this is handled by the prompts class itself, as it should.
3770 this is handled by the prompts class itself, as it should.
3751
3771
3752 2002-03-05 Fernando Perez <fperez@colorado.edu>
3772 2002-03-05 Fernando Perez <fperez@colorado.edu>
3753
3773
3754 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3774 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3755 @logstart to avoid name clashes with the math log function.
3775 @logstart to avoid name clashes with the math log function.
3756
3776
3757 * Big updates to X/Emacs section of the manual.
3777 * Big updates to X/Emacs section of the manual.
3758
3778
3759 * Removed ipython_emacs. Milan explained to me how to pass
3779 * Removed ipython_emacs. Milan explained to me how to pass
3760 arguments to ipython through Emacs. Some day I'm going to end up
3780 arguments to ipython through Emacs. Some day I'm going to end up
3761 learning some lisp...
3781 learning some lisp...
3762
3782
3763 2002-03-04 Fernando Perez <fperez@colorado.edu>
3783 2002-03-04 Fernando Perez <fperez@colorado.edu>
3764
3784
3765 * IPython/ipython_emacs: Created script to be used as the
3785 * IPython/ipython_emacs: Created script to be used as the
3766 py-python-command Emacs variable so we can pass IPython
3786 py-python-command Emacs variable so we can pass IPython
3767 parameters. I can't figure out how to tell Emacs directly to pass
3787 parameters. I can't figure out how to tell Emacs directly to pass
3768 parameters to IPython, so a dummy shell script will do it.
3788 parameters to IPython, so a dummy shell script will do it.
3769
3789
3770 Other enhancements made for things to work better under Emacs'
3790 Other enhancements made for things to work better under Emacs'
3771 various types of terminals. Many thanks to Milan Zamazal
3791 various types of terminals. Many thanks to Milan Zamazal
3772 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3792 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3773
3793
3774 2002-03-01 Fernando Perez <fperez@colorado.edu>
3794 2002-03-01 Fernando Perez <fperez@colorado.edu>
3775
3795
3776 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3796 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3777 that loading of readline is now optional. This gives better
3797 that loading of readline is now optional. This gives better
3778 control to emacs users.
3798 control to emacs users.
3779
3799
3780 * IPython/ultraTB.py (__date__): Modified color escape sequences
3800 * IPython/ultraTB.py (__date__): Modified color escape sequences
3781 and now things work fine under xterm and in Emacs' term buffers
3801 and now things work fine under xterm and in Emacs' term buffers
3782 (though not shell ones). Well, in emacs you get colors, but all
3802 (though not shell ones). Well, in emacs you get colors, but all
3783 seem to be 'light' colors (no difference between dark and light
3803 seem to be 'light' colors (no difference between dark and light
3784 ones). But the garbage chars are gone, and also in xterms. It
3804 ones). But the garbage chars are gone, and also in xterms. It
3785 seems that now I'm using 'cleaner' ansi sequences.
3805 seems that now I'm using 'cleaner' ansi sequences.
3786
3806
3787 2002-02-21 Fernando Perez <fperez@colorado.edu>
3807 2002-02-21 Fernando Perez <fperez@colorado.edu>
3788
3808
3789 * Released 0.2.7 (mainly to publish the scoping fix).
3809 * Released 0.2.7 (mainly to publish the scoping fix).
3790
3810
3791 * IPython/Logger.py (Logger.logstate): added. A corresponding
3811 * IPython/Logger.py (Logger.logstate): added. A corresponding
3792 @logstate magic was created.
3812 @logstate magic was created.
3793
3813
3794 * IPython/Magic.py: fixed nested scoping problem under Python
3814 * IPython/Magic.py: fixed nested scoping problem under Python
3795 2.1.x (automagic wasn't working).
3815 2.1.x (automagic wasn't working).
3796
3816
3797 2002-02-20 Fernando Perez <fperez@colorado.edu>
3817 2002-02-20 Fernando Perez <fperez@colorado.edu>
3798
3818
3799 * Released 0.2.6.
3819 * Released 0.2.6.
3800
3820
3801 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3821 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3802 option so that logs can come out without any headers at all.
3822 option so that logs can come out without any headers at all.
3803
3823
3804 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3824 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3805 SciPy.
3825 SciPy.
3806
3826
3807 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3827 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3808 that embedded IPython calls don't require vars() to be explicitly
3828 that embedded IPython calls don't require vars() to be explicitly
3809 passed. Now they are extracted from the caller's frame (code
3829 passed. Now they are extracted from the caller's frame (code
3810 snatched from Eric Jones' weave). Added better documentation to
3830 snatched from Eric Jones' weave). Added better documentation to
3811 the section on embedding and the example file.
3831 the section on embedding and the example file.
3812
3832
3813 * IPython/genutils.py (page): Changed so that under emacs, it just
3833 * IPython/genutils.py (page): Changed so that under emacs, it just
3814 prints the string. You can then page up and down in the emacs
3834 prints the string. You can then page up and down in the emacs
3815 buffer itself. This is how the builtin help() works.
3835 buffer itself. This is how the builtin help() works.
3816
3836
3817 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3837 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3818 macro scoping: macros need to be executed in the user's namespace
3838 macro scoping: macros need to be executed in the user's namespace
3819 to work as if they had been typed by the user.
3839 to work as if they had been typed by the user.
3820
3840
3821 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3841 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3822 execute automatically (no need to type 'exec...'). They then
3842 execute automatically (no need to type 'exec...'). They then
3823 behave like 'true macros'. The printing system was also modified
3843 behave like 'true macros'. The printing system was also modified
3824 for this to work.
3844 for this to work.
3825
3845
3826 2002-02-19 Fernando Perez <fperez@colorado.edu>
3846 2002-02-19 Fernando Perez <fperez@colorado.edu>
3827
3847
3828 * IPython/genutils.py (page_file): new function for paging files
3848 * IPython/genutils.py (page_file): new function for paging files
3829 in an OS-independent way. Also necessary for file viewing to work
3849 in an OS-independent way. Also necessary for file viewing to work
3830 well inside Emacs buffers.
3850 well inside Emacs buffers.
3831 (page): Added checks for being in an emacs buffer.
3851 (page): Added checks for being in an emacs buffer.
3832 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3852 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3833 same bug in iplib.
3853 same bug in iplib.
3834
3854
3835 2002-02-18 Fernando Perez <fperez@colorado.edu>
3855 2002-02-18 Fernando Perez <fperez@colorado.edu>
3836
3856
3837 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3857 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3838 of readline so that IPython can work inside an Emacs buffer.
3858 of readline so that IPython can work inside an Emacs buffer.
3839
3859
3840 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3860 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3841 method signatures (they weren't really bugs, but it looks cleaner
3861 method signatures (they weren't really bugs, but it looks cleaner
3842 and keeps PyChecker happy).
3862 and keeps PyChecker happy).
3843
3863
3844 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3864 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3845 for implementing various user-defined hooks. Currently only
3865 for implementing various user-defined hooks. Currently only
3846 display is done.
3866 display is done.
3847
3867
3848 * IPython/Prompts.py (CachedOutput._display): changed display
3868 * IPython/Prompts.py (CachedOutput._display): changed display
3849 functions so that they can be dynamically changed by users easily.
3869 functions so that they can be dynamically changed by users easily.
3850
3870
3851 * IPython/Extensions/numeric_formats.py (num_display): added an
3871 * IPython/Extensions/numeric_formats.py (num_display): added an
3852 extension for printing NumPy arrays in flexible manners. It
3872 extension for printing NumPy arrays in flexible manners. It
3853 doesn't do anything yet, but all the structure is in
3873 doesn't do anything yet, but all the structure is in
3854 place. Ultimately the plan is to implement output format control
3874 place. Ultimately the plan is to implement output format control
3855 like in Octave.
3875 like in Octave.
3856
3876
3857 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3877 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3858 methods are found at run-time by all the automatic machinery.
3878 methods are found at run-time by all the automatic machinery.
3859
3879
3860 2002-02-17 Fernando Perez <fperez@colorado.edu>
3880 2002-02-17 Fernando Perez <fperez@colorado.edu>
3861
3881
3862 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3882 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3863 whole file a little.
3883 whole file a little.
3864
3884
3865 * ToDo: closed this document. Now there's a new_design.lyx
3885 * ToDo: closed this document. Now there's a new_design.lyx
3866 document for all new ideas. Added making a pdf of it for the
3886 document for all new ideas. Added making a pdf of it for the
3867 end-user distro.
3887 end-user distro.
3868
3888
3869 * IPython/Logger.py (Logger.switch_log): Created this to replace
3889 * IPython/Logger.py (Logger.switch_log): Created this to replace
3870 logon() and logoff(). It also fixes a nasty crash reported by
3890 logon() and logoff(). It also fixes a nasty crash reported by
3871 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3891 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3872
3892
3873 * IPython/iplib.py (complete): got auto-completion to work with
3893 * IPython/iplib.py (complete): got auto-completion to work with
3874 automagic (I had wanted this for a long time).
3894 automagic (I had wanted this for a long time).
3875
3895
3876 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3896 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3877 to @file, since file() is now a builtin and clashes with automagic
3897 to @file, since file() is now a builtin and clashes with automagic
3878 for @file.
3898 for @file.
3879
3899
3880 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3900 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3881 of this was previously in iplib, which had grown to more than 2000
3901 of this was previously in iplib, which had grown to more than 2000
3882 lines, way too long. No new functionality, but it makes managing
3902 lines, way too long. No new functionality, but it makes managing
3883 the code a bit easier.
3903 the code a bit easier.
3884
3904
3885 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3905 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3886 information to crash reports.
3906 information to crash reports.
3887
3907
3888 2002-02-12 Fernando Perez <fperez@colorado.edu>
3908 2002-02-12 Fernando Perez <fperez@colorado.edu>
3889
3909
3890 * Released 0.2.5.
3910 * Released 0.2.5.
3891
3911
3892 2002-02-11 Fernando Perez <fperez@colorado.edu>
3912 2002-02-11 Fernando Perez <fperez@colorado.edu>
3893
3913
3894 * Wrote a relatively complete Windows installer. It puts
3914 * Wrote a relatively complete Windows installer. It puts
3895 everything in place, creates Start Menu entries and fixes the
3915 everything in place, creates Start Menu entries and fixes the
3896 color issues. Nothing fancy, but it works.
3916 color issues. Nothing fancy, but it works.
3897
3917
3898 2002-02-10 Fernando Perez <fperez@colorado.edu>
3918 2002-02-10 Fernando Perez <fperez@colorado.edu>
3899
3919
3900 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3920 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3901 os.path.expanduser() call so that we can type @run ~/myfile.py and
3921 os.path.expanduser() call so that we can type @run ~/myfile.py and
3902 have thigs work as expected.
3922 have thigs work as expected.
3903
3923
3904 * IPython/genutils.py (page): fixed exception handling so things
3924 * IPython/genutils.py (page): fixed exception handling so things
3905 work both in Unix and Windows correctly. Quitting a pager triggers
3925 work both in Unix and Windows correctly. Quitting a pager triggers
3906 an IOError/broken pipe in Unix, and in windows not finding a pager
3926 an IOError/broken pipe in Unix, and in windows not finding a pager
3907 is also an IOError, so I had to actually look at the return value
3927 is also an IOError, so I had to actually look at the return value
3908 of the exception, not just the exception itself. Should be ok now.
3928 of the exception, not just the exception itself. Should be ok now.
3909
3929
3910 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3930 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3911 modified to allow case-insensitive color scheme changes.
3931 modified to allow case-insensitive color scheme changes.
3912
3932
3913 2002-02-09 Fernando Perez <fperez@colorado.edu>
3933 2002-02-09 Fernando Perez <fperez@colorado.edu>
3914
3934
3915 * IPython/genutils.py (native_line_ends): new function to leave
3935 * IPython/genutils.py (native_line_ends): new function to leave
3916 user config files with os-native line-endings.
3936 user config files with os-native line-endings.
3917
3937
3918 * README and manual updates.
3938 * README and manual updates.
3919
3939
3920 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3940 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3921 instead of StringType to catch Unicode strings.
3941 instead of StringType to catch Unicode strings.
3922
3942
3923 * IPython/genutils.py (filefind): fixed bug for paths with
3943 * IPython/genutils.py (filefind): fixed bug for paths with
3924 embedded spaces (very common in Windows).
3944 embedded spaces (very common in Windows).
3925
3945
3926 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3946 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3927 files under Windows, so that they get automatically associated
3947 files under Windows, so that they get automatically associated
3928 with a text editor. Windows makes it a pain to handle
3948 with a text editor. Windows makes it a pain to handle
3929 extension-less files.
3949 extension-less files.
3930
3950
3931 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3951 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3932 warning about readline only occur for Posix. In Windows there's no
3952 warning about readline only occur for Posix. In Windows there's no
3933 way to get readline, so why bother with the warning.
3953 way to get readline, so why bother with the warning.
3934
3954
3935 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3955 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3936 for __str__ instead of dir(self), since dir() changed in 2.2.
3956 for __str__ instead of dir(self), since dir() changed in 2.2.
3937
3957
3938 * Ported to Windows! Tested on XP, I suspect it should work fine
3958 * Ported to Windows! Tested on XP, I suspect it should work fine
3939 on NT/2000, but I don't think it will work on 98 et al. That
3959 on NT/2000, but I don't think it will work on 98 et al. That
3940 series of Windows is such a piece of junk anyway that I won't try
3960 series of Windows is such a piece of junk anyway that I won't try
3941 porting it there. The XP port was straightforward, showed a few
3961 porting it there. The XP port was straightforward, showed a few
3942 bugs here and there (fixed all), in particular some string
3962 bugs here and there (fixed all), in particular some string
3943 handling stuff which required considering Unicode strings (which
3963 handling stuff which required considering Unicode strings (which
3944 Windows uses). This is good, but hasn't been too tested :) No
3964 Windows uses). This is good, but hasn't been too tested :) No
3945 fancy installer yet, I'll put a note in the manual so people at
3965 fancy installer yet, I'll put a note in the manual so people at
3946 least make manually a shortcut.
3966 least make manually a shortcut.
3947
3967
3948 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3968 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3949 into a single one, "colors". This now controls both prompt and
3969 into a single one, "colors". This now controls both prompt and
3950 exception color schemes, and can be changed both at startup
3970 exception color schemes, and can be changed both at startup
3951 (either via command-line switches or via ipythonrc files) and at
3971 (either via command-line switches or via ipythonrc files) and at
3952 runtime, with @colors.
3972 runtime, with @colors.
3953 (Magic.magic_run): renamed @prun to @run and removed the old
3973 (Magic.magic_run): renamed @prun to @run and removed the old
3954 @run. The two were too similar to warrant keeping both.
3974 @run. The two were too similar to warrant keeping both.
3955
3975
3956 2002-02-03 Fernando Perez <fperez@colorado.edu>
3976 2002-02-03 Fernando Perez <fperez@colorado.edu>
3957
3977
3958 * IPython/iplib.py (install_first_time): Added comment on how to
3978 * IPython/iplib.py (install_first_time): Added comment on how to
3959 configure the color options for first-time users. Put a <return>
3979 configure the color options for first-time users. Put a <return>
3960 request at the end so that small-terminal users get a chance to
3980 request at the end so that small-terminal users get a chance to
3961 read the startup info.
3981 read the startup info.
3962
3982
3963 2002-01-23 Fernando Perez <fperez@colorado.edu>
3983 2002-01-23 Fernando Perez <fperez@colorado.edu>
3964
3984
3965 * IPython/iplib.py (CachedOutput.update): Changed output memory
3985 * IPython/iplib.py (CachedOutput.update): Changed output memory
3966 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3986 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3967 input history we still use _i. Did this b/c these variable are
3987 input history we still use _i. Did this b/c these variable are
3968 very commonly used in interactive work, so the less we need to
3988 very commonly used in interactive work, so the less we need to
3969 type the better off we are.
3989 type the better off we are.
3970 (Magic.magic_prun): updated @prun to better handle the namespaces
3990 (Magic.magic_prun): updated @prun to better handle the namespaces
3971 the file will run in, including a fix for __name__ not being set
3991 the file will run in, including a fix for __name__ not being set
3972 before.
3992 before.
3973
3993
3974 2002-01-20 Fernando Perez <fperez@colorado.edu>
3994 2002-01-20 Fernando Perez <fperez@colorado.edu>
3975
3995
3976 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3996 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3977 extra garbage for Python 2.2. Need to look more carefully into
3997 extra garbage for Python 2.2. Need to look more carefully into
3978 this later.
3998 this later.
3979
3999
3980 2002-01-19 Fernando Perez <fperez@colorado.edu>
4000 2002-01-19 Fernando Perez <fperez@colorado.edu>
3981
4001
3982 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4002 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3983 display SyntaxError exceptions properly formatted when they occur
4003 display SyntaxError exceptions properly formatted when they occur
3984 (they can be triggered by imported code).
4004 (they can be triggered by imported code).
3985
4005
3986 2002-01-18 Fernando Perez <fperez@colorado.edu>
4006 2002-01-18 Fernando Perez <fperez@colorado.edu>
3987
4007
3988 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4008 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3989 SyntaxError exceptions are reported nicely formatted, instead of
4009 SyntaxError exceptions are reported nicely formatted, instead of
3990 spitting out only offset information as before.
4010 spitting out only offset information as before.
3991 (Magic.magic_prun): Added the @prun function for executing
4011 (Magic.magic_prun): Added the @prun function for executing
3992 programs with command line args inside IPython.
4012 programs with command line args inside IPython.
3993
4013
3994 2002-01-16 Fernando Perez <fperez@colorado.edu>
4014 2002-01-16 Fernando Perez <fperez@colorado.edu>
3995
4015
3996 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4016 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3997 to *not* include the last item given in a range. This brings their
4017 to *not* include the last item given in a range. This brings their
3998 behavior in line with Python's slicing:
4018 behavior in line with Python's slicing:
3999 a[n1:n2] -> a[n1]...a[n2-1]
4019 a[n1:n2] -> a[n1]...a[n2-1]
4000 It may be a bit less convenient, but I prefer to stick to Python's
4020 It may be a bit less convenient, but I prefer to stick to Python's
4001 conventions *everywhere*, so users never have to wonder.
4021 conventions *everywhere*, so users never have to wonder.
4002 (Magic.magic_macro): Added @macro function to ease the creation of
4022 (Magic.magic_macro): Added @macro function to ease the creation of
4003 macros.
4023 macros.
4004
4024
4005 2002-01-05 Fernando Perez <fperez@colorado.edu>
4025 2002-01-05 Fernando Perez <fperez@colorado.edu>
4006
4026
4007 * Released 0.2.4.
4027 * Released 0.2.4.
4008
4028
4009 * IPython/iplib.py (Magic.magic_pdef):
4029 * IPython/iplib.py (Magic.magic_pdef):
4010 (InteractiveShell.safe_execfile): report magic lines and error
4030 (InteractiveShell.safe_execfile): report magic lines and error
4011 lines without line numbers so one can easily copy/paste them for
4031 lines without line numbers so one can easily copy/paste them for
4012 re-execution.
4032 re-execution.
4013
4033
4014 * Updated manual with recent changes.
4034 * Updated manual with recent changes.
4015
4035
4016 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4036 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4017 docstring printing when class? is called. Very handy for knowing
4037 docstring printing when class? is called. Very handy for knowing
4018 how to create class instances (as long as __init__ is well
4038 how to create class instances (as long as __init__ is well
4019 documented, of course :)
4039 documented, of course :)
4020 (Magic.magic_doc): print both class and constructor docstrings.
4040 (Magic.magic_doc): print both class and constructor docstrings.
4021 (Magic.magic_pdef): give constructor info if passed a class and
4041 (Magic.magic_pdef): give constructor info if passed a class and
4022 __call__ info for callable object instances.
4042 __call__ info for callable object instances.
4023
4043
4024 2002-01-04 Fernando Perez <fperez@colorado.edu>
4044 2002-01-04 Fernando Perez <fperez@colorado.edu>
4025
4045
4026 * Made deep_reload() off by default. It doesn't always work
4046 * Made deep_reload() off by default. It doesn't always work
4027 exactly as intended, so it's probably safer to have it off. It's
4047 exactly as intended, so it's probably safer to have it off. It's
4028 still available as dreload() anyway, so nothing is lost.
4048 still available as dreload() anyway, so nothing is lost.
4029
4049
4030 2002-01-02 Fernando Perez <fperez@colorado.edu>
4050 2002-01-02 Fernando Perez <fperez@colorado.edu>
4031
4051
4032 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4052 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4033 so I wanted an updated release).
4053 so I wanted an updated release).
4034
4054
4035 2001-12-27 Fernando Perez <fperez@colorado.edu>
4055 2001-12-27 Fernando Perez <fperez@colorado.edu>
4036
4056
4037 * IPython/iplib.py (InteractiveShell.interact): Added the original
4057 * IPython/iplib.py (InteractiveShell.interact): Added the original
4038 code from 'code.py' for this module in order to change the
4058 code from 'code.py' for this module in order to change the
4039 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4059 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4040 the history cache would break when the user hit Ctrl-C, and
4060 the history cache would break when the user hit Ctrl-C, and
4041 interact() offers no way to add any hooks to it.
4061 interact() offers no way to add any hooks to it.
4042
4062
4043 2001-12-23 Fernando Perez <fperez@colorado.edu>
4063 2001-12-23 Fernando Perez <fperez@colorado.edu>
4044
4064
4045 * setup.py: added check for 'MANIFEST' before trying to remove
4065 * setup.py: added check for 'MANIFEST' before trying to remove
4046 it. Thanks to Sean Reifschneider.
4066 it. Thanks to Sean Reifschneider.
4047
4067
4048 2001-12-22 Fernando Perez <fperez@colorado.edu>
4068 2001-12-22 Fernando Perez <fperez@colorado.edu>
4049
4069
4050 * Released 0.2.2.
4070 * Released 0.2.2.
4051
4071
4052 * Finished (reasonably) writing the manual. Later will add the
4072 * Finished (reasonably) writing the manual. Later will add the
4053 python-standard navigation stylesheets, but for the time being
4073 python-standard navigation stylesheets, but for the time being
4054 it's fairly complete. Distribution will include html and pdf
4074 it's fairly complete. Distribution will include html and pdf
4055 versions.
4075 versions.
4056
4076
4057 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4077 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4058 (MayaVi author).
4078 (MayaVi author).
4059
4079
4060 2001-12-21 Fernando Perez <fperez@colorado.edu>
4080 2001-12-21 Fernando Perez <fperez@colorado.edu>
4061
4081
4062 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4082 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4063 good public release, I think (with the manual and the distutils
4083 good public release, I think (with the manual and the distutils
4064 installer). The manual can use some work, but that can go
4084 installer). The manual can use some work, but that can go
4065 slowly. Otherwise I think it's quite nice for end users. Next
4085 slowly. Otherwise I think it's quite nice for end users. Next
4066 summer, rewrite the guts of it...
4086 summer, rewrite the guts of it...
4067
4087
4068 * Changed format of ipythonrc files to use whitespace as the
4088 * Changed format of ipythonrc files to use whitespace as the
4069 separator instead of an explicit '='. Cleaner.
4089 separator instead of an explicit '='. Cleaner.
4070
4090
4071 2001-12-20 Fernando Perez <fperez@colorado.edu>
4091 2001-12-20 Fernando Perez <fperez@colorado.edu>
4072
4092
4073 * Started a manual in LyX. For now it's just a quick merge of the
4093 * Started a manual in LyX. For now it's just a quick merge of the
4074 various internal docstrings and READMEs. Later it may grow into a
4094 various internal docstrings and READMEs. Later it may grow into a
4075 nice, full-blown manual.
4095 nice, full-blown manual.
4076
4096
4077 * Set up a distutils based installer. Installation should now be
4097 * Set up a distutils based installer. Installation should now be
4078 trivially simple for end-users.
4098 trivially simple for end-users.
4079
4099
4080 2001-12-11 Fernando Perez <fperez@colorado.edu>
4100 2001-12-11 Fernando Perez <fperez@colorado.edu>
4081
4101
4082 * Released 0.2.0. First public release, announced it at
4102 * Released 0.2.0. First public release, announced it at
4083 comp.lang.python. From now on, just bugfixes...
4103 comp.lang.python. From now on, just bugfixes...
4084
4104
4085 * Went through all the files, set copyright/license notices and
4105 * Went through all the files, set copyright/license notices and
4086 cleaned up things. Ready for release.
4106 cleaned up things. Ready for release.
4087
4107
4088 2001-12-10 Fernando Perez <fperez@colorado.edu>
4108 2001-12-10 Fernando Perez <fperez@colorado.edu>
4089
4109
4090 * Changed the first-time installer not to use tarfiles. It's more
4110 * Changed the first-time installer not to use tarfiles. It's more
4091 robust now and less unix-dependent. Also makes it easier for
4111 robust now and less unix-dependent. Also makes it easier for
4092 people to later upgrade versions.
4112 people to later upgrade versions.
4093
4113
4094 * Changed @exit to @abort to reflect the fact that it's pretty
4114 * Changed @exit to @abort to reflect the fact that it's pretty
4095 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4115 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4096 becomes significant only when IPyhton is embedded: in that case,
4116 becomes significant only when IPyhton is embedded: in that case,
4097 C-D closes IPython only, but @abort kills the enclosing program
4117 C-D closes IPython only, but @abort kills the enclosing program
4098 too (unless it had called IPython inside a try catching
4118 too (unless it had called IPython inside a try catching
4099 SystemExit).
4119 SystemExit).
4100
4120
4101 * Created Shell module which exposes the actuall IPython Shell
4121 * Created Shell module which exposes the actuall IPython Shell
4102 classes, currently the normal and the embeddable one. This at
4122 classes, currently the normal and the embeddable one. This at
4103 least offers a stable interface we won't need to change when
4123 least offers a stable interface we won't need to change when
4104 (later) the internals are rewritten. That rewrite will be confined
4124 (later) the internals are rewritten. That rewrite will be confined
4105 to iplib and ipmaker, but the Shell interface should remain as is.
4125 to iplib and ipmaker, but the Shell interface should remain as is.
4106
4126
4107 * Added embed module which offers an embeddable IPShell object,
4127 * Added embed module which offers an embeddable IPShell object,
4108 useful to fire up IPython *inside* a running program. Great for
4128 useful to fire up IPython *inside* a running program. Great for
4109 debugging or dynamical data analysis.
4129 debugging or dynamical data analysis.
4110
4130
4111 2001-12-08 Fernando Perez <fperez@colorado.edu>
4131 2001-12-08 Fernando Perez <fperez@colorado.edu>
4112
4132
4113 * Fixed small bug preventing seeing info from methods of defined
4133 * Fixed small bug preventing seeing info from methods of defined
4114 objects (incorrect namespace in _ofind()).
4134 objects (incorrect namespace in _ofind()).
4115
4135
4116 * Documentation cleanup. Moved the main usage docstrings to a
4136 * Documentation cleanup. Moved the main usage docstrings to a
4117 separate file, usage.py (cleaner to maintain, and hopefully in the
4137 separate file, usage.py (cleaner to maintain, and hopefully in the
4118 future some perlpod-like way of producing interactive, man and
4138 future some perlpod-like way of producing interactive, man and
4119 html docs out of it will be found).
4139 html docs out of it will be found).
4120
4140
4121 * Added @profile to see your profile at any time.
4141 * Added @profile to see your profile at any time.
4122
4142
4123 * Added @p as an alias for 'print'. It's especially convenient if
4143 * Added @p as an alias for 'print'. It's especially convenient if
4124 using automagic ('p x' prints x).
4144 using automagic ('p x' prints x).
4125
4145
4126 * Small cleanups and fixes after a pychecker run.
4146 * Small cleanups and fixes after a pychecker run.
4127
4147
4128 * Changed the @cd command to handle @cd - and @cd -<n> for
4148 * Changed the @cd command to handle @cd - and @cd -<n> for
4129 visiting any directory in _dh.
4149 visiting any directory in _dh.
4130
4150
4131 * Introduced _dh, a history of visited directories. @dhist prints
4151 * Introduced _dh, a history of visited directories. @dhist prints
4132 it out with numbers.
4152 it out with numbers.
4133
4153
4134 2001-12-07 Fernando Perez <fperez@colorado.edu>
4154 2001-12-07 Fernando Perez <fperez@colorado.edu>
4135
4155
4136 * Released 0.1.22
4156 * Released 0.1.22
4137
4157
4138 * Made initialization a bit more robust against invalid color
4158 * Made initialization a bit more robust against invalid color
4139 options in user input (exit, not traceback-crash).
4159 options in user input (exit, not traceback-crash).
4140
4160
4141 * Changed the bug crash reporter to write the report only in the
4161 * Changed the bug crash reporter to write the report only in the
4142 user's .ipython directory. That way IPython won't litter people's
4162 user's .ipython directory. That way IPython won't litter people's
4143 hard disks with crash files all over the place. Also print on
4163 hard disks with crash files all over the place. Also print on
4144 screen the necessary mail command.
4164 screen the necessary mail command.
4145
4165
4146 * With the new ultraTB, implemented LightBG color scheme for light
4166 * With the new ultraTB, implemented LightBG color scheme for light
4147 background terminals. A lot of people like white backgrounds, so I
4167 background terminals. A lot of people like white backgrounds, so I
4148 guess we should at least give them something readable.
4168 guess we should at least give them something readable.
4149
4169
4150 2001-12-06 Fernando Perez <fperez@colorado.edu>
4170 2001-12-06 Fernando Perez <fperez@colorado.edu>
4151
4171
4152 * Modified the structure of ultraTB. Now there's a proper class
4172 * Modified the structure of ultraTB. Now there's a proper class
4153 for tables of color schemes which allow adding schemes easily and
4173 for tables of color schemes which allow adding schemes easily and
4154 switching the active scheme without creating a new instance every
4174 switching the active scheme without creating a new instance every
4155 time (which was ridiculous). The syntax for creating new schemes
4175 time (which was ridiculous). The syntax for creating new schemes
4156 is also cleaner. I think ultraTB is finally done, with a clean
4176 is also cleaner. I think ultraTB is finally done, with a clean
4157 class structure. Names are also much cleaner (now there's proper
4177 class structure. Names are also much cleaner (now there's proper
4158 color tables, no need for every variable to also have 'color' in
4178 color tables, no need for every variable to also have 'color' in
4159 its name).
4179 its name).
4160
4180
4161 * Broke down genutils into separate files. Now genutils only
4181 * Broke down genutils into separate files. Now genutils only
4162 contains utility functions, and classes have been moved to their
4182 contains utility functions, and classes have been moved to their
4163 own files (they had enough independent functionality to warrant
4183 own files (they had enough independent functionality to warrant
4164 it): ConfigLoader, OutputTrap, Struct.
4184 it): ConfigLoader, OutputTrap, Struct.
4165
4185
4166 2001-12-05 Fernando Perez <fperez@colorado.edu>
4186 2001-12-05 Fernando Perez <fperez@colorado.edu>
4167
4187
4168 * IPython turns 21! Released version 0.1.21, as a candidate for
4188 * IPython turns 21! Released version 0.1.21, as a candidate for
4169 public consumption. If all goes well, release in a few days.
4189 public consumption. If all goes well, release in a few days.
4170
4190
4171 * Fixed path bug (files in Extensions/ directory wouldn't be found
4191 * Fixed path bug (files in Extensions/ directory wouldn't be found
4172 unless IPython/ was explicitly in sys.path).
4192 unless IPython/ was explicitly in sys.path).
4173
4193
4174 * Extended the FlexCompleter class as MagicCompleter to allow
4194 * Extended the FlexCompleter class as MagicCompleter to allow
4175 completion of @-starting lines.
4195 completion of @-starting lines.
4176
4196
4177 * Created __release__.py file as a central repository for release
4197 * Created __release__.py file as a central repository for release
4178 info that other files can read from.
4198 info that other files can read from.
4179
4199
4180 * Fixed small bug in logging: when logging was turned on in
4200 * Fixed small bug in logging: when logging was turned on in
4181 mid-session, old lines with special meanings (!@?) were being
4201 mid-session, old lines with special meanings (!@?) were being
4182 logged without the prepended comment, which is necessary since
4202 logged without the prepended comment, which is necessary since
4183 they are not truly valid python syntax. This should make session
4203 they are not truly valid python syntax. This should make session
4184 restores produce less errors.
4204 restores produce less errors.
4185
4205
4186 * The namespace cleanup forced me to make a FlexCompleter class
4206 * The namespace cleanup forced me to make a FlexCompleter class
4187 which is nothing but a ripoff of rlcompleter, but with selectable
4207 which is nothing but a ripoff of rlcompleter, but with selectable
4188 namespace (rlcompleter only works in __main__.__dict__). I'll try
4208 namespace (rlcompleter only works in __main__.__dict__). I'll try
4189 to submit a note to the authors to see if this change can be
4209 to submit a note to the authors to see if this change can be
4190 incorporated in future rlcompleter releases (Dec.6: done)
4210 incorporated in future rlcompleter releases (Dec.6: done)
4191
4211
4192 * More fixes to namespace handling. It was a mess! Now all
4212 * More fixes to namespace handling. It was a mess! Now all
4193 explicit references to __main__.__dict__ are gone (except when
4213 explicit references to __main__.__dict__ are gone (except when
4194 really needed) and everything is handled through the namespace
4214 really needed) and everything is handled through the namespace
4195 dicts in the IPython instance. We seem to be getting somewhere
4215 dicts in the IPython instance. We seem to be getting somewhere
4196 with this, finally...
4216 with this, finally...
4197
4217
4198 * Small documentation updates.
4218 * Small documentation updates.
4199
4219
4200 * Created the Extensions directory under IPython (with an
4220 * Created the Extensions directory under IPython (with an
4201 __init__.py). Put the PhysicalQ stuff there. This directory should
4221 __init__.py). Put the PhysicalQ stuff there. This directory should
4202 be used for all special-purpose extensions.
4222 be used for all special-purpose extensions.
4203
4223
4204 * File renaming:
4224 * File renaming:
4205 ipythonlib --> ipmaker
4225 ipythonlib --> ipmaker
4206 ipplib --> iplib
4226 ipplib --> iplib
4207 This makes a bit more sense in terms of what these files actually do.
4227 This makes a bit more sense in terms of what these files actually do.
4208
4228
4209 * Moved all the classes and functions in ipythonlib to ipplib, so
4229 * Moved all the classes and functions in ipythonlib to ipplib, so
4210 now ipythonlib only has make_IPython(). This will ease up its
4230 now ipythonlib only has make_IPython(). This will ease up its
4211 splitting in smaller functional chunks later.
4231 splitting in smaller functional chunks later.
4212
4232
4213 * Cleaned up (done, I think) output of @whos. Better column
4233 * Cleaned up (done, I think) output of @whos. Better column
4214 formatting, and now shows str(var) for as much as it can, which is
4234 formatting, and now shows str(var) for as much as it can, which is
4215 typically what one gets with a 'print var'.
4235 typically what one gets with a 'print var'.
4216
4236
4217 2001-12-04 Fernando Perez <fperez@colorado.edu>
4237 2001-12-04 Fernando Perez <fperez@colorado.edu>
4218
4238
4219 * Fixed namespace problems. Now builtin/IPyhton/user names get
4239 * Fixed namespace problems. Now builtin/IPyhton/user names get
4220 properly reported in their namespace. Internal namespace handling
4240 properly reported in their namespace. Internal namespace handling
4221 is finally getting decent (not perfect yet, but much better than
4241 is finally getting decent (not perfect yet, but much better than
4222 the ad-hoc mess we had).
4242 the ad-hoc mess we had).
4223
4243
4224 * Removed -exit option. If people just want to run a python
4244 * Removed -exit option. If people just want to run a python
4225 script, that's what the normal interpreter is for. Less
4245 script, that's what the normal interpreter is for. Less
4226 unnecessary options, less chances for bugs.
4246 unnecessary options, less chances for bugs.
4227
4247
4228 * Added a crash handler which generates a complete post-mortem if
4248 * Added a crash handler which generates a complete post-mortem if
4229 IPython crashes. This will help a lot in tracking bugs down the
4249 IPython crashes. This will help a lot in tracking bugs down the
4230 road.
4250 road.
4231
4251
4232 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4252 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4233 which were boud to functions being reassigned would bypass the
4253 which were boud to functions being reassigned would bypass the
4234 logger, breaking the sync of _il with the prompt counter. This
4254 logger, breaking the sync of _il with the prompt counter. This
4235 would then crash IPython later when a new line was logged.
4255 would then crash IPython later when a new line was logged.
4236
4256
4237 2001-12-02 Fernando Perez <fperez@colorado.edu>
4257 2001-12-02 Fernando Perez <fperez@colorado.edu>
4238
4258
4239 * Made IPython a package. This means people don't have to clutter
4259 * Made IPython a package. This means people don't have to clutter
4240 their sys.path with yet another directory. Changed the INSTALL
4260 their sys.path with yet another directory. Changed the INSTALL
4241 file accordingly.
4261 file accordingly.
4242
4262
4243 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4263 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4244 sorts its output (so @who shows it sorted) and @whos formats the
4264 sorts its output (so @who shows it sorted) and @whos formats the
4245 table according to the width of the first column. Nicer, easier to
4265 table according to the width of the first column. Nicer, easier to
4246 read. Todo: write a generic table_format() which takes a list of
4266 read. Todo: write a generic table_format() which takes a list of
4247 lists and prints it nicely formatted, with optional row/column
4267 lists and prints it nicely formatted, with optional row/column
4248 separators and proper padding and justification.
4268 separators and proper padding and justification.
4249
4269
4250 * Released 0.1.20
4270 * Released 0.1.20
4251
4271
4252 * Fixed bug in @log which would reverse the inputcache list (a
4272 * Fixed bug in @log which would reverse the inputcache list (a
4253 copy operation was missing).
4273 copy operation was missing).
4254
4274
4255 * Code cleanup. @config was changed to use page(). Better, since
4275 * Code cleanup. @config was changed to use page(). Better, since
4256 its output is always quite long.
4276 its output is always quite long.
4257
4277
4258 * Itpl is back as a dependency. I was having too many problems
4278 * Itpl is back as a dependency. I was having too many problems
4259 getting the parametric aliases to work reliably, and it's just
4279 getting the parametric aliases to work reliably, and it's just
4260 easier to code weird string operations with it than playing %()s
4280 easier to code weird string operations with it than playing %()s
4261 games. It's only ~6k, so I don't think it's too big a deal.
4281 games. It's only ~6k, so I don't think it's too big a deal.
4262
4282
4263 * Found (and fixed) a very nasty bug with history. !lines weren't
4283 * Found (and fixed) a very nasty bug with history. !lines weren't
4264 getting cached, and the out of sync caches would crash
4284 getting cached, and the out of sync caches would crash
4265 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4285 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4266 division of labor a bit better. Bug fixed, cleaner structure.
4286 division of labor a bit better. Bug fixed, cleaner structure.
4267
4287
4268 2001-12-01 Fernando Perez <fperez@colorado.edu>
4288 2001-12-01 Fernando Perez <fperez@colorado.edu>
4269
4289
4270 * Released 0.1.19
4290 * Released 0.1.19
4271
4291
4272 * Added option -n to @hist to prevent line number printing. Much
4292 * Added option -n to @hist to prevent line number printing. Much
4273 easier to copy/paste code this way.
4293 easier to copy/paste code this way.
4274
4294
4275 * Created global _il to hold the input list. Allows easy
4295 * Created global _il to hold the input list. Allows easy
4276 re-execution of blocks of code by slicing it (inspired by Janko's
4296 re-execution of blocks of code by slicing it (inspired by Janko's
4277 comment on 'macros').
4297 comment on 'macros').
4278
4298
4279 * Small fixes and doc updates.
4299 * Small fixes and doc updates.
4280
4300
4281 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4301 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4282 much too fragile with automagic. Handles properly multi-line
4302 much too fragile with automagic. Handles properly multi-line
4283 statements and takes parameters.
4303 statements and takes parameters.
4284
4304
4285 2001-11-30 Fernando Perez <fperez@colorado.edu>
4305 2001-11-30 Fernando Perez <fperez@colorado.edu>
4286
4306
4287 * Version 0.1.18 released.
4307 * Version 0.1.18 released.
4288
4308
4289 * Fixed nasty namespace bug in initial module imports.
4309 * Fixed nasty namespace bug in initial module imports.
4290
4310
4291 * Added copyright/license notes to all code files (except
4311 * Added copyright/license notes to all code files (except
4292 DPyGetOpt). For the time being, LGPL. That could change.
4312 DPyGetOpt). For the time being, LGPL. That could change.
4293
4313
4294 * Rewrote a much nicer README, updated INSTALL, cleaned up
4314 * Rewrote a much nicer README, updated INSTALL, cleaned up
4295 ipythonrc-* samples.
4315 ipythonrc-* samples.
4296
4316
4297 * Overall code/documentation cleanup. Basically ready for
4317 * Overall code/documentation cleanup. Basically ready for
4298 release. Only remaining thing: licence decision (LGPL?).
4318 release. Only remaining thing: licence decision (LGPL?).
4299
4319
4300 * Converted load_config to a class, ConfigLoader. Now recursion
4320 * Converted load_config to a class, ConfigLoader. Now recursion
4301 control is better organized. Doesn't include the same file twice.
4321 control is better organized. Doesn't include the same file twice.
4302
4322
4303 2001-11-29 Fernando Perez <fperez@colorado.edu>
4323 2001-11-29 Fernando Perez <fperez@colorado.edu>
4304
4324
4305 * Got input history working. Changed output history variables from
4325 * Got input history working. Changed output history variables from
4306 _p to _o so that _i is for input and _o for output. Just cleaner
4326 _p to _o so that _i is for input and _o for output. Just cleaner
4307 convention.
4327 convention.
4308
4328
4309 * Implemented parametric aliases. This pretty much allows the
4329 * Implemented parametric aliases. This pretty much allows the
4310 alias system to offer full-blown shell convenience, I think.
4330 alias system to offer full-blown shell convenience, I think.
4311
4331
4312 * Version 0.1.17 released, 0.1.18 opened.
4332 * Version 0.1.17 released, 0.1.18 opened.
4313
4333
4314 * dot_ipython/ipythonrc (alias): added documentation.
4334 * dot_ipython/ipythonrc (alias): added documentation.
4315 (xcolor): Fixed small bug (xcolors -> xcolor)
4335 (xcolor): Fixed small bug (xcolors -> xcolor)
4316
4336
4317 * Changed the alias system. Now alias is a magic command to define
4337 * Changed the alias system. Now alias is a magic command to define
4318 aliases just like the shell. Rationale: the builtin magics should
4338 aliases just like the shell. Rationale: the builtin magics should
4319 be there for things deeply connected to IPython's
4339 be there for things deeply connected to IPython's
4320 architecture. And this is a much lighter system for what I think
4340 architecture. And this is a much lighter system for what I think
4321 is the really important feature: allowing users to define quickly
4341 is the really important feature: allowing users to define quickly
4322 magics that will do shell things for them, so they can customize
4342 magics that will do shell things for them, so they can customize
4323 IPython easily to match their work habits. If someone is really
4343 IPython easily to match their work habits. If someone is really
4324 desperate to have another name for a builtin alias, they can
4344 desperate to have another name for a builtin alias, they can
4325 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4345 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4326 works.
4346 works.
4327
4347
4328 2001-11-28 Fernando Perez <fperez@colorado.edu>
4348 2001-11-28 Fernando Perez <fperez@colorado.edu>
4329
4349
4330 * Changed @file so that it opens the source file at the proper
4350 * Changed @file so that it opens the source file at the proper
4331 line. Since it uses less, if your EDITOR environment is
4351 line. Since it uses less, if your EDITOR environment is
4332 configured, typing v will immediately open your editor of choice
4352 configured, typing v will immediately open your editor of choice
4333 right at the line where the object is defined. Not as quick as
4353 right at the line where the object is defined. Not as quick as
4334 having a direct @edit command, but for all intents and purposes it
4354 having a direct @edit command, but for all intents and purposes it
4335 works. And I don't have to worry about writing @edit to deal with
4355 works. And I don't have to worry about writing @edit to deal with
4336 all the editors, less does that.
4356 all the editors, less does that.
4337
4357
4338 * Version 0.1.16 released, 0.1.17 opened.
4358 * Version 0.1.16 released, 0.1.17 opened.
4339
4359
4340 * Fixed some nasty bugs in the page/page_dumb combo that could
4360 * Fixed some nasty bugs in the page/page_dumb combo that could
4341 crash IPython.
4361 crash IPython.
4342
4362
4343 2001-11-27 Fernando Perez <fperez@colorado.edu>
4363 2001-11-27 Fernando Perez <fperez@colorado.edu>
4344
4364
4345 * Version 0.1.15 released, 0.1.16 opened.
4365 * Version 0.1.15 released, 0.1.16 opened.
4346
4366
4347 * Finally got ? and ?? to work for undefined things: now it's
4367 * Finally got ? and ?? to work for undefined things: now it's
4348 possible to type {}.get? and get information about the get method
4368 possible to type {}.get? and get information about the get method
4349 of dicts, or os.path? even if only os is defined (so technically
4369 of dicts, or os.path? even if only os is defined (so technically
4350 os.path isn't). Works at any level. For example, after import os,
4370 os.path isn't). Works at any level. For example, after import os,
4351 os?, os.path?, os.path.abspath? all work. This is great, took some
4371 os?, os.path?, os.path.abspath? all work. This is great, took some
4352 work in _ofind.
4372 work in _ofind.
4353
4373
4354 * Fixed more bugs with logging. The sanest way to do it was to add
4374 * Fixed more bugs with logging. The sanest way to do it was to add
4355 to @log a 'mode' parameter. Killed two in one shot (this mode
4375 to @log a 'mode' parameter. Killed two in one shot (this mode
4356 option was a request of Janko's). I think it's finally clean
4376 option was a request of Janko's). I think it's finally clean
4357 (famous last words).
4377 (famous last words).
4358
4378
4359 * Added a page_dumb() pager which does a decent job of paging on
4379 * Added a page_dumb() pager which does a decent job of paging on
4360 screen, if better things (like less) aren't available. One less
4380 screen, if better things (like less) aren't available. One less
4361 unix dependency (someday maybe somebody will port this to
4381 unix dependency (someday maybe somebody will port this to
4362 windows).
4382 windows).
4363
4383
4364 * Fixed problem in magic_log: would lock of logging out if log
4384 * Fixed problem in magic_log: would lock of logging out if log
4365 creation failed (because it would still think it had succeeded).
4385 creation failed (because it would still think it had succeeded).
4366
4386
4367 * Improved the page() function using curses to auto-detect screen
4387 * Improved the page() function using curses to auto-detect screen
4368 size. Now it can make a much better decision on whether to print
4388 size. Now it can make a much better decision on whether to print
4369 or page a string. Option screen_length was modified: a value 0
4389 or page a string. Option screen_length was modified: a value 0
4370 means auto-detect, and that's the default now.
4390 means auto-detect, and that's the default now.
4371
4391
4372 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4392 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4373 go out. I'll test it for a few days, then talk to Janko about
4393 go out. I'll test it for a few days, then talk to Janko about
4374 licences and announce it.
4394 licences and announce it.
4375
4395
4376 * Fixed the length of the auto-generated ---> prompt which appears
4396 * Fixed the length of the auto-generated ---> prompt which appears
4377 for auto-parens and auto-quotes. Getting this right isn't trivial,
4397 for auto-parens and auto-quotes. Getting this right isn't trivial,
4378 with all the color escapes, different prompt types and optional
4398 with all the color escapes, different prompt types and optional
4379 separators. But it seems to be working in all the combinations.
4399 separators. But it seems to be working in all the combinations.
4380
4400
4381 2001-11-26 Fernando Perez <fperez@colorado.edu>
4401 2001-11-26 Fernando Perez <fperez@colorado.edu>
4382
4402
4383 * Wrote a regexp filter to get option types from the option names
4403 * Wrote a regexp filter to get option types from the option names
4384 string. This eliminates the need to manually keep two duplicate
4404 string. This eliminates the need to manually keep two duplicate
4385 lists.
4405 lists.
4386
4406
4387 * Removed the unneeded check_option_names. Now options are handled
4407 * Removed the unneeded check_option_names. Now options are handled
4388 in a much saner manner and it's easy to visually check that things
4408 in a much saner manner and it's easy to visually check that things
4389 are ok.
4409 are ok.
4390
4410
4391 * Updated version numbers on all files I modified to carry a
4411 * Updated version numbers on all files I modified to carry a
4392 notice so Janko and Nathan have clear version markers.
4412 notice so Janko and Nathan have clear version markers.
4393
4413
4394 * Updated docstring for ultraTB with my changes. I should send
4414 * Updated docstring for ultraTB with my changes. I should send
4395 this to Nathan.
4415 this to Nathan.
4396
4416
4397 * Lots of small fixes. Ran everything through pychecker again.
4417 * Lots of small fixes. Ran everything through pychecker again.
4398
4418
4399 * Made loading of deep_reload an cmd line option. If it's not too
4419 * Made loading of deep_reload an cmd line option. If it's not too
4400 kosher, now people can just disable it. With -nodeep_reload it's
4420 kosher, now people can just disable it. With -nodeep_reload it's
4401 still available as dreload(), it just won't overwrite reload().
4421 still available as dreload(), it just won't overwrite reload().
4402
4422
4403 * Moved many options to the no| form (-opt and -noopt
4423 * Moved many options to the no| form (-opt and -noopt
4404 accepted). Cleaner.
4424 accepted). Cleaner.
4405
4425
4406 * Changed magic_log so that if called with no parameters, it uses
4426 * Changed magic_log so that if called with no parameters, it uses
4407 'rotate' mode. That way auto-generated logs aren't automatically
4427 'rotate' mode. That way auto-generated logs aren't automatically
4408 over-written. For normal logs, now a backup is made if it exists
4428 over-written. For normal logs, now a backup is made if it exists
4409 (only 1 level of backups). A new 'backup' mode was added to the
4429 (only 1 level of backups). A new 'backup' mode was added to the
4410 Logger class to support this. This was a request by Janko.
4430 Logger class to support this. This was a request by Janko.
4411
4431
4412 * Added @logoff/@logon to stop/restart an active log.
4432 * Added @logoff/@logon to stop/restart an active log.
4413
4433
4414 * Fixed a lot of bugs in log saving/replay. It was pretty
4434 * Fixed a lot of bugs in log saving/replay. It was pretty
4415 broken. Now special lines (!@,/) appear properly in the command
4435 broken. Now special lines (!@,/) appear properly in the command
4416 history after a log replay.
4436 history after a log replay.
4417
4437
4418 * Tried and failed to implement full session saving via pickle. My
4438 * Tried and failed to implement full session saving via pickle. My
4419 idea was to pickle __main__.__dict__, but modules can't be
4439 idea was to pickle __main__.__dict__, but modules can't be
4420 pickled. This would be a better alternative to replaying logs, but
4440 pickled. This would be a better alternative to replaying logs, but
4421 seems quite tricky to get to work. Changed -session to be called
4441 seems quite tricky to get to work. Changed -session to be called
4422 -logplay, which more accurately reflects what it does. And if we
4442 -logplay, which more accurately reflects what it does. And if we
4423 ever get real session saving working, -session is now available.
4443 ever get real session saving working, -session is now available.
4424
4444
4425 * Implemented color schemes for prompts also. As for tracebacks,
4445 * Implemented color schemes for prompts also. As for tracebacks,
4426 currently only NoColor and Linux are supported. But now the
4446 currently only NoColor and Linux are supported. But now the
4427 infrastructure is in place, based on a generic ColorScheme
4447 infrastructure is in place, based on a generic ColorScheme
4428 class. So writing and activating new schemes both for the prompts
4448 class. So writing and activating new schemes both for the prompts
4429 and the tracebacks should be straightforward.
4449 and the tracebacks should be straightforward.
4430
4450
4431 * Version 0.1.13 released, 0.1.14 opened.
4451 * Version 0.1.13 released, 0.1.14 opened.
4432
4452
4433 * Changed handling of options for output cache. Now counter is
4453 * Changed handling of options for output cache. Now counter is
4434 hardwired starting at 1 and one specifies the maximum number of
4454 hardwired starting at 1 and one specifies the maximum number of
4435 entries *in the outcache* (not the max prompt counter). This is
4455 entries *in the outcache* (not the max prompt counter). This is
4436 much better, since many statements won't increase the cache
4456 much better, since many statements won't increase the cache
4437 count. It also eliminated some confusing options, now there's only
4457 count. It also eliminated some confusing options, now there's only
4438 one: cache_size.
4458 one: cache_size.
4439
4459
4440 * Added 'alias' magic function and magic_alias option in the
4460 * Added 'alias' magic function and magic_alias option in the
4441 ipythonrc file. Now the user can easily define whatever names he
4461 ipythonrc file. Now the user can easily define whatever names he
4442 wants for the magic functions without having to play weird
4462 wants for the magic functions without having to play weird
4443 namespace games. This gives IPython a real shell-like feel.
4463 namespace games. This gives IPython a real shell-like feel.
4444
4464
4445 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4465 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4446 @ or not).
4466 @ or not).
4447
4467
4448 This was one of the last remaining 'visible' bugs (that I know
4468 This was one of the last remaining 'visible' bugs (that I know
4449 of). I think if I can clean up the session loading so it works
4469 of). I think if I can clean up the session loading so it works
4450 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4470 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4451 about licensing).
4471 about licensing).
4452
4472
4453 2001-11-25 Fernando Perez <fperez@colorado.edu>
4473 2001-11-25 Fernando Perez <fperez@colorado.edu>
4454
4474
4455 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4475 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4456 there's a cleaner distinction between what ? and ?? show.
4476 there's a cleaner distinction between what ? and ?? show.
4457
4477
4458 * Added screen_length option. Now the user can define his own
4478 * Added screen_length option. Now the user can define his own
4459 screen size for page() operations.
4479 screen size for page() operations.
4460
4480
4461 * Implemented magic shell-like functions with automatic code
4481 * Implemented magic shell-like functions with automatic code
4462 generation. Now adding another function is just a matter of adding
4482 generation. Now adding another function is just a matter of adding
4463 an entry to a dict, and the function is dynamically generated at
4483 an entry to a dict, and the function is dynamically generated at
4464 run-time. Python has some really cool features!
4484 run-time. Python has some really cool features!
4465
4485
4466 * Renamed many options to cleanup conventions a little. Now all
4486 * Renamed many options to cleanup conventions a little. Now all
4467 are lowercase, and only underscores where needed. Also in the code
4487 are lowercase, and only underscores where needed. Also in the code
4468 option name tables are clearer.
4488 option name tables are clearer.
4469
4489
4470 * Changed prompts a little. Now input is 'In [n]:' instead of
4490 * Changed prompts a little. Now input is 'In [n]:' instead of
4471 'In[n]:='. This allows it the numbers to be aligned with the
4491 'In[n]:='. This allows it the numbers to be aligned with the
4472 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4492 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4473 Python (it was a Mathematica thing). The '...' continuation prompt
4493 Python (it was a Mathematica thing). The '...' continuation prompt
4474 was also changed a little to align better.
4494 was also changed a little to align better.
4475
4495
4476 * Fixed bug when flushing output cache. Not all _p<n> variables
4496 * Fixed bug when flushing output cache. Not all _p<n> variables
4477 exist, so their deletion needs to be wrapped in a try:
4497 exist, so their deletion needs to be wrapped in a try:
4478
4498
4479 * Figured out how to properly use inspect.formatargspec() (it
4499 * Figured out how to properly use inspect.formatargspec() (it
4480 requires the args preceded by *). So I removed all the code from
4500 requires the args preceded by *). So I removed all the code from
4481 _get_pdef in Magic, which was just replicating that.
4501 _get_pdef in Magic, which was just replicating that.
4482
4502
4483 * Added test to prefilter to allow redefining magic function names
4503 * Added test to prefilter to allow redefining magic function names
4484 as variables. This is ok, since the @ form is always available,
4504 as variables. This is ok, since the @ form is always available,
4485 but whe should allow the user to define a variable called 'ls' if
4505 but whe should allow the user to define a variable called 'ls' if
4486 he needs it.
4506 he needs it.
4487
4507
4488 * Moved the ToDo information from README into a separate ToDo.
4508 * Moved the ToDo information from README into a separate ToDo.
4489
4509
4490 * General code cleanup and small bugfixes. I think it's close to a
4510 * General code cleanup and small bugfixes. I think it's close to a
4491 state where it can be released, obviously with a big 'beta'
4511 state where it can be released, obviously with a big 'beta'
4492 warning on it.
4512 warning on it.
4493
4513
4494 * Got the magic function split to work. Now all magics are defined
4514 * Got the magic function split to work. Now all magics are defined
4495 in a separate class. It just organizes things a bit, and now
4515 in a separate class. It just organizes things a bit, and now
4496 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4516 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4497 was too long).
4517 was too long).
4498
4518
4499 * Changed @clear to @reset to avoid potential confusions with
4519 * Changed @clear to @reset to avoid potential confusions with
4500 the shell command clear. Also renamed @cl to @clear, which does
4520 the shell command clear. Also renamed @cl to @clear, which does
4501 exactly what people expect it to from their shell experience.
4521 exactly what people expect it to from their shell experience.
4502
4522
4503 Added a check to the @reset command (since it's so
4523 Added a check to the @reset command (since it's so
4504 destructive, it's probably a good idea to ask for confirmation).
4524 destructive, it's probably a good idea to ask for confirmation).
4505 But now reset only works for full namespace resetting. Since the
4525 But now reset only works for full namespace resetting. Since the
4506 del keyword is already there for deleting a few specific
4526 del keyword is already there for deleting a few specific
4507 variables, I don't see the point of having a redundant magic
4527 variables, I don't see the point of having a redundant magic
4508 function for the same task.
4528 function for the same task.
4509
4529
4510 2001-11-24 Fernando Perez <fperez@colorado.edu>
4530 2001-11-24 Fernando Perez <fperez@colorado.edu>
4511
4531
4512 * Updated the builtin docs (esp. the ? ones).
4532 * Updated the builtin docs (esp. the ? ones).
4513
4533
4514 * Ran all the code through pychecker. Not terribly impressed with
4534 * Ran all the code through pychecker. Not terribly impressed with
4515 it: lots of spurious warnings and didn't really find anything of
4535 it: lots of spurious warnings and didn't really find anything of
4516 substance (just a few modules being imported and not used).
4536 substance (just a few modules being imported and not used).
4517
4537
4518 * Implemented the new ultraTB functionality into IPython. New
4538 * Implemented the new ultraTB functionality into IPython. New
4519 option: xcolors. This chooses color scheme. xmode now only selects
4539 option: xcolors. This chooses color scheme. xmode now only selects
4520 between Plain and Verbose. Better orthogonality.
4540 between Plain and Verbose. Better orthogonality.
4521
4541
4522 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4542 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4523 mode and color scheme for the exception handlers. Now it's
4543 mode and color scheme for the exception handlers. Now it's
4524 possible to have the verbose traceback with no coloring.
4544 possible to have the verbose traceback with no coloring.
4525
4545
4526 2001-11-23 Fernando Perez <fperez@colorado.edu>
4546 2001-11-23 Fernando Perez <fperez@colorado.edu>
4527
4547
4528 * Version 0.1.12 released, 0.1.13 opened.
4548 * Version 0.1.12 released, 0.1.13 opened.
4529
4549
4530 * Removed option to set auto-quote and auto-paren escapes by
4550 * Removed option to set auto-quote and auto-paren escapes by
4531 user. The chances of breaking valid syntax are just too high. If
4551 user. The chances of breaking valid syntax are just too high. If
4532 someone *really* wants, they can always dig into the code.
4552 someone *really* wants, they can always dig into the code.
4533
4553
4534 * Made prompt separators configurable.
4554 * Made prompt separators configurable.
4535
4555
4536 2001-11-22 Fernando Perez <fperez@colorado.edu>
4556 2001-11-22 Fernando Perez <fperez@colorado.edu>
4537
4557
4538 * Small bugfixes in many places.
4558 * Small bugfixes in many places.
4539
4559
4540 * Removed the MyCompleter class from ipplib. It seemed redundant
4560 * Removed the MyCompleter class from ipplib. It seemed redundant
4541 with the C-p,C-n history search functionality. Less code to
4561 with the C-p,C-n history search functionality. Less code to
4542 maintain.
4562 maintain.
4543
4563
4544 * Moved all the original ipython.py code into ipythonlib.py. Right
4564 * Moved all the original ipython.py code into ipythonlib.py. Right
4545 now it's just one big dump into a function called make_IPython, so
4565 now it's just one big dump into a function called make_IPython, so
4546 no real modularity has been gained. But at least it makes the
4566 no real modularity has been gained. But at least it makes the
4547 wrapper script tiny, and since ipythonlib is a module, it gets
4567 wrapper script tiny, and since ipythonlib is a module, it gets
4548 compiled and startup is much faster.
4568 compiled and startup is much faster.
4549
4569
4550 This is a reasobably 'deep' change, so we should test it for a
4570 This is a reasobably 'deep' change, so we should test it for a
4551 while without messing too much more with the code.
4571 while without messing too much more with the code.
4552
4572
4553 2001-11-21 Fernando Perez <fperez@colorado.edu>
4573 2001-11-21 Fernando Perez <fperez@colorado.edu>
4554
4574
4555 * Version 0.1.11 released, 0.1.12 opened for further work.
4575 * Version 0.1.11 released, 0.1.12 opened for further work.
4556
4576
4557 * Removed dependency on Itpl. It was only needed in one place. It
4577 * Removed dependency on Itpl. It was only needed in one place. It
4558 would be nice if this became part of python, though. It makes life
4578 would be nice if this became part of python, though. It makes life
4559 *a lot* easier in some cases.
4579 *a lot* easier in some cases.
4560
4580
4561 * Simplified the prefilter code a bit. Now all handlers are
4581 * Simplified the prefilter code a bit. Now all handlers are
4562 expected to explicitly return a value (at least a blank string).
4582 expected to explicitly return a value (at least a blank string).
4563
4583
4564 * Heavy edits in ipplib. Removed the help system altogether. Now
4584 * Heavy edits in ipplib. Removed the help system altogether. Now
4565 obj?/?? is used for inspecting objects, a magic @doc prints
4585 obj?/?? is used for inspecting objects, a magic @doc prints
4566 docstrings, and full-blown Python help is accessed via the 'help'
4586 docstrings, and full-blown Python help is accessed via the 'help'
4567 keyword. This cleans up a lot of code (less to maintain) and does
4587 keyword. This cleans up a lot of code (less to maintain) and does
4568 the job. Since 'help' is now a standard Python component, might as
4588 the job. Since 'help' is now a standard Python component, might as
4569 well use it and remove duplicate functionality.
4589 well use it and remove duplicate functionality.
4570
4590
4571 Also removed the option to use ipplib as a standalone program. By
4591 Also removed the option to use ipplib as a standalone program. By
4572 now it's too dependent on other parts of IPython to function alone.
4592 now it's too dependent on other parts of IPython to function alone.
4573
4593
4574 * Fixed bug in genutils.pager. It would crash if the pager was
4594 * Fixed bug in genutils.pager. It would crash if the pager was
4575 exited immediately after opening (broken pipe).
4595 exited immediately after opening (broken pipe).
4576
4596
4577 * Trimmed down the VerboseTB reporting a little. The header is
4597 * Trimmed down the VerboseTB reporting a little. The header is
4578 much shorter now and the repeated exception arguments at the end
4598 much shorter now and the repeated exception arguments at the end
4579 have been removed. For interactive use the old header seemed a bit
4599 have been removed. For interactive use the old header seemed a bit
4580 excessive.
4600 excessive.
4581
4601
4582 * Fixed small bug in output of @whos for variables with multi-word
4602 * Fixed small bug in output of @whos for variables with multi-word
4583 types (only first word was displayed).
4603 types (only first word was displayed).
4584
4604
4585 2001-11-17 Fernando Perez <fperez@colorado.edu>
4605 2001-11-17 Fernando Perez <fperez@colorado.edu>
4586
4606
4587 * Version 0.1.10 released, 0.1.11 opened for further work.
4607 * Version 0.1.10 released, 0.1.11 opened for further work.
4588
4608
4589 * Modified dirs and friends. dirs now *returns* the stack (not
4609 * Modified dirs and friends. dirs now *returns* the stack (not
4590 prints), so one can manipulate it as a variable. Convenient to
4610 prints), so one can manipulate it as a variable. Convenient to
4591 travel along many directories.
4611 travel along many directories.
4592
4612
4593 * Fixed bug in magic_pdef: would only work with functions with
4613 * Fixed bug in magic_pdef: would only work with functions with
4594 arguments with default values.
4614 arguments with default values.
4595
4615
4596 2001-11-14 Fernando Perez <fperez@colorado.edu>
4616 2001-11-14 Fernando Perez <fperez@colorado.edu>
4597
4617
4598 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4618 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4599 example with IPython. Various other minor fixes and cleanups.
4619 example with IPython. Various other minor fixes and cleanups.
4600
4620
4601 * Version 0.1.9 released, 0.1.10 opened for further work.
4621 * Version 0.1.9 released, 0.1.10 opened for further work.
4602
4622
4603 * Added sys.path to the list of directories searched in the
4623 * Added sys.path to the list of directories searched in the
4604 execfile= option. It used to be the current directory and the
4624 execfile= option. It used to be the current directory and the
4605 user's IPYTHONDIR only.
4625 user's IPYTHONDIR only.
4606
4626
4607 2001-11-13 Fernando Perez <fperez@colorado.edu>
4627 2001-11-13 Fernando Perez <fperez@colorado.edu>
4608
4628
4609 * Reinstated the raw_input/prefilter separation that Janko had
4629 * Reinstated the raw_input/prefilter separation that Janko had
4610 initially. This gives a more convenient setup for extending the
4630 initially. This gives a more convenient setup for extending the
4611 pre-processor from the outside: raw_input always gets a string,
4631 pre-processor from the outside: raw_input always gets a string,
4612 and prefilter has to process it. We can then redefine prefilter
4632 and prefilter has to process it. We can then redefine prefilter
4613 from the outside and implement extensions for special
4633 from the outside and implement extensions for special
4614 purposes.
4634 purposes.
4615
4635
4616 Today I got one for inputting PhysicalQuantity objects
4636 Today I got one for inputting PhysicalQuantity objects
4617 (from Scientific) without needing any function calls at
4637 (from Scientific) without needing any function calls at
4618 all. Extremely convenient, and it's all done as a user-level
4638 all. Extremely convenient, and it's all done as a user-level
4619 extension (no IPython code was touched). Now instead of:
4639 extension (no IPython code was touched). Now instead of:
4620 a = PhysicalQuantity(4.2,'m/s**2')
4640 a = PhysicalQuantity(4.2,'m/s**2')
4621 one can simply say
4641 one can simply say
4622 a = 4.2 m/s**2
4642 a = 4.2 m/s**2
4623 or even
4643 or even
4624 a = 4.2 m/s^2
4644 a = 4.2 m/s^2
4625
4645
4626 I use this, but it's also a proof of concept: IPython really is
4646 I use this, but it's also a proof of concept: IPython really is
4627 fully user-extensible, even at the level of the parsing of the
4647 fully user-extensible, even at the level of the parsing of the
4628 command line. It's not trivial, but it's perfectly doable.
4648 command line. It's not trivial, but it's perfectly doable.
4629
4649
4630 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4650 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4631 the problem of modules being loaded in the inverse order in which
4651 the problem of modules being loaded in the inverse order in which
4632 they were defined in
4652 they were defined in
4633
4653
4634 * Version 0.1.8 released, 0.1.9 opened for further work.
4654 * Version 0.1.8 released, 0.1.9 opened for further work.
4635
4655
4636 * Added magics pdef, source and file. They respectively show the
4656 * Added magics pdef, source and file. They respectively show the
4637 definition line ('prototype' in C), source code and full python
4657 definition line ('prototype' in C), source code and full python
4638 file for any callable object. The object inspector oinfo uses
4658 file for any callable object. The object inspector oinfo uses
4639 these to show the same information.
4659 these to show the same information.
4640
4660
4641 * Version 0.1.7 released, 0.1.8 opened for further work.
4661 * Version 0.1.7 released, 0.1.8 opened for further work.
4642
4662
4643 * Separated all the magic functions into a class called Magic. The
4663 * Separated all the magic functions into a class called Magic. The
4644 InteractiveShell class was becoming too big for Xemacs to handle
4664 InteractiveShell class was becoming too big for Xemacs to handle
4645 (de-indenting a line would lock it up for 10 seconds while it
4665 (de-indenting a line would lock it up for 10 seconds while it
4646 backtracked on the whole class!)
4666 backtracked on the whole class!)
4647
4667
4648 FIXME: didn't work. It can be done, but right now namespaces are
4668 FIXME: didn't work. It can be done, but right now namespaces are
4649 all messed up. Do it later (reverted it for now, so at least
4669 all messed up. Do it later (reverted it for now, so at least
4650 everything works as before).
4670 everything works as before).
4651
4671
4652 * Got the object introspection system (magic_oinfo) working! I
4672 * Got the object introspection system (magic_oinfo) working! I
4653 think this is pretty much ready for release to Janko, so he can
4673 think this is pretty much ready for release to Janko, so he can
4654 test it for a while and then announce it. Pretty much 100% of what
4674 test it for a while and then announce it. Pretty much 100% of what
4655 I wanted for the 'phase 1' release is ready. Happy, tired.
4675 I wanted for the 'phase 1' release is ready. Happy, tired.
4656
4676
4657 2001-11-12 Fernando Perez <fperez@colorado.edu>
4677 2001-11-12 Fernando Perez <fperez@colorado.edu>
4658
4678
4659 * Version 0.1.6 released, 0.1.7 opened for further work.
4679 * Version 0.1.6 released, 0.1.7 opened for further work.
4660
4680
4661 * Fixed bug in printing: it used to test for truth before
4681 * Fixed bug in printing: it used to test for truth before
4662 printing, so 0 wouldn't print. Now checks for None.
4682 printing, so 0 wouldn't print. Now checks for None.
4663
4683
4664 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4684 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4665 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4685 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4666 reaches by hand into the outputcache. Think of a better way to do
4686 reaches by hand into the outputcache. Think of a better way to do
4667 this later.
4687 this later.
4668
4688
4669 * Various small fixes thanks to Nathan's comments.
4689 * Various small fixes thanks to Nathan's comments.
4670
4690
4671 * Changed magic_pprint to magic_Pprint. This way it doesn't
4691 * Changed magic_pprint to magic_Pprint. This way it doesn't
4672 collide with pprint() and the name is consistent with the command
4692 collide with pprint() and the name is consistent with the command
4673 line option.
4693 line option.
4674
4694
4675 * Changed prompt counter behavior to be fully like
4695 * Changed prompt counter behavior to be fully like
4676 Mathematica's. That is, even input that doesn't return a result
4696 Mathematica's. That is, even input that doesn't return a result
4677 raises the prompt counter. The old behavior was kind of confusing
4697 raises the prompt counter. The old behavior was kind of confusing
4678 (getting the same prompt number several times if the operation
4698 (getting the same prompt number several times if the operation
4679 didn't return a result).
4699 didn't return a result).
4680
4700
4681 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4701 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4682
4702
4683 * Fixed -Classic mode (wasn't working anymore).
4703 * Fixed -Classic mode (wasn't working anymore).
4684
4704
4685 * Added colored prompts using Nathan's new code. Colors are
4705 * Added colored prompts using Nathan's new code. Colors are
4686 currently hardwired, they can be user-configurable. For
4706 currently hardwired, they can be user-configurable. For
4687 developers, they can be chosen in file ipythonlib.py, at the
4707 developers, they can be chosen in file ipythonlib.py, at the
4688 beginning of the CachedOutput class def.
4708 beginning of the CachedOutput class def.
4689
4709
4690 2001-11-11 Fernando Perez <fperez@colorado.edu>
4710 2001-11-11 Fernando Perez <fperez@colorado.edu>
4691
4711
4692 * Version 0.1.5 released, 0.1.6 opened for further work.
4712 * Version 0.1.5 released, 0.1.6 opened for further work.
4693
4713
4694 * Changed magic_env to *return* the environment as a dict (not to
4714 * Changed magic_env to *return* the environment as a dict (not to
4695 print it). This way it prints, but it can also be processed.
4715 print it). This way it prints, but it can also be processed.
4696
4716
4697 * Added Verbose exception reporting to interactive
4717 * Added Verbose exception reporting to interactive
4698 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4718 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4699 traceback. Had to make some changes to the ultraTB file. This is
4719 traceback. Had to make some changes to the ultraTB file. This is
4700 probably the last 'big' thing in my mental todo list. This ties
4720 probably the last 'big' thing in my mental todo list. This ties
4701 in with the next entry:
4721 in with the next entry:
4702
4722
4703 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4723 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4704 has to specify is Plain, Color or Verbose for all exception
4724 has to specify is Plain, Color or Verbose for all exception
4705 handling.
4725 handling.
4706
4726
4707 * Removed ShellServices option. All this can really be done via
4727 * Removed ShellServices option. All this can really be done via
4708 the magic system. It's easier to extend, cleaner and has automatic
4728 the magic system. It's easier to extend, cleaner and has automatic
4709 namespace protection and documentation.
4729 namespace protection and documentation.
4710
4730
4711 2001-11-09 Fernando Perez <fperez@colorado.edu>
4731 2001-11-09 Fernando Perez <fperez@colorado.edu>
4712
4732
4713 * Fixed bug in output cache flushing (missing parameter to
4733 * Fixed bug in output cache flushing (missing parameter to
4714 __init__). Other small bugs fixed (found using pychecker).
4734 __init__). Other small bugs fixed (found using pychecker).
4715
4735
4716 * Version 0.1.4 opened for bugfixing.
4736 * Version 0.1.4 opened for bugfixing.
4717
4737
4718 2001-11-07 Fernando Perez <fperez@colorado.edu>
4738 2001-11-07 Fernando Perez <fperez@colorado.edu>
4719
4739
4720 * Version 0.1.3 released, mainly because of the raw_input bug.
4740 * Version 0.1.3 released, mainly because of the raw_input bug.
4721
4741
4722 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4742 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4723 and when testing for whether things were callable, a call could
4743 and when testing for whether things were callable, a call could
4724 actually be made to certain functions. They would get called again
4744 actually be made to certain functions. They would get called again
4725 once 'really' executed, with a resulting double call. A disaster
4745 once 'really' executed, with a resulting double call. A disaster
4726 in many cases (list.reverse() would never work!).
4746 in many cases (list.reverse() would never work!).
4727
4747
4728 * Removed prefilter() function, moved its code to raw_input (which
4748 * Removed prefilter() function, moved its code to raw_input (which
4729 after all was just a near-empty caller for prefilter). This saves
4749 after all was just a near-empty caller for prefilter). This saves
4730 a function call on every prompt, and simplifies the class a tiny bit.
4750 a function call on every prompt, and simplifies the class a tiny bit.
4731
4751
4732 * Fix _ip to __ip name in magic example file.
4752 * Fix _ip to __ip name in magic example file.
4733
4753
4734 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4754 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4735 work with non-gnu versions of tar.
4755 work with non-gnu versions of tar.
4736
4756
4737 2001-11-06 Fernando Perez <fperez@colorado.edu>
4757 2001-11-06 Fernando Perez <fperez@colorado.edu>
4738
4758
4739 * Version 0.1.2. Just to keep track of the recent changes.
4759 * Version 0.1.2. Just to keep track of the recent changes.
4740
4760
4741 * Fixed nasty bug in output prompt routine. It used to check 'if
4761 * Fixed nasty bug in output prompt routine. It used to check 'if
4742 arg != None...'. Problem is, this fails if arg implements a
4762 arg != None...'. Problem is, this fails if arg implements a
4743 special comparison (__cmp__) which disallows comparing to
4763 special comparison (__cmp__) which disallows comparing to
4744 None. Found it when trying to use the PhysicalQuantity module from
4764 None. Found it when trying to use the PhysicalQuantity module from
4745 ScientificPython.
4765 ScientificPython.
4746
4766
4747 2001-11-05 Fernando Perez <fperez@colorado.edu>
4767 2001-11-05 Fernando Perez <fperez@colorado.edu>
4748
4768
4749 * Also added dirs. Now the pushd/popd/dirs family functions
4769 * Also added dirs. Now the pushd/popd/dirs family functions
4750 basically like the shell, with the added convenience of going home
4770 basically like the shell, with the added convenience of going home
4751 when called with no args.
4771 when called with no args.
4752
4772
4753 * pushd/popd slightly modified to mimic shell behavior more
4773 * pushd/popd slightly modified to mimic shell behavior more
4754 closely.
4774 closely.
4755
4775
4756 * Added env,pushd,popd from ShellServices as magic functions. I
4776 * Added env,pushd,popd from ShellServices as magic functions. I
4757 think the cleanest will be to port all desired functions from
4777 think the cleanest will be to port all desired functions from
4758 ShellServices as magics and remove ShellServices altogether. This
4778 ShellServices as magics and remove ShellServices altogether. This
4759 will provide a single, clean way of adding functionality
4779 will provide a single, clean way of adding functionality
4760 (shell-type or otherwise) to IP.
4780 (shell-type or otherwise) to IP.
4761
4781
4762 2001-11-04 Fernando Perez <fperez@colorado.edu>
4782 2001-11-04 Fernando Perez <fperez@colorado.edu>
4763
4783
4764 * Added .ipython/ directory to sys.path. This way users can keep
4784 * Added .ipython/ directory to sys.path. This way users can keep
4765 customizations there and access them via import.
4785 customizations there and access them via import.
4766
4786
4767 2001-11-03 Fernando Perez <fperez@colorado.edu>
4787 2001-11-03 Fernando Perez <fperez@colorado.edu>
4768
4788
4769 * Opened version 0.1.1 for new changes.
4789 * Opened version 0.1.1 for new changes.
4770
4790
4771 * Changed version number to 0.1.0: first 'public' release, sent to
4791 * Changed version number to 0.1.0: first 'public' release, sent to
4772 Nathan and Janko.
4792 Nathan and Janko.
4773
4793
4774 * Lots of small fixes and tweaks.
4794 * Lots of small fixes and tweaks.
4775
4795
4776 * Minor changes to whos format. Now strings are shown, snipped if
4796 * Minor changes to whos format. Now strings are shown, snipped if
4777 too long.
4797 too long.
4778
4798
4779 * Changed ShellServices to work on __main__ so they show up in @who
4799 * Changed ShellServices to work on __main__ so they show up in @who
4780
4800
4781 * Help also works with ? at the end of a line:
4801 * Help also works with ? at the end of a line:
4782 ?sin and sin?
4802 ?sin and sin?
4783 both produce the same effect. This is nice, as often I use the
4803 both produce the same effect. This is nice, as often I use the
4784 tab-complete to find the name of a method, but I used to then have
4804 tab-complete to find the name of a method, but I used to then have
4785 to go to the beginning of the line to put a ? if I wanted more
4805 to go to the beginning of the line to put a ? if I wanted more
4786 info. Now I can just add the ? and hit return. Convenient.
4806 info. Now I can just add the ? and hit return. Convenient.
4787
4807
4788 2001-11-02 Fernando Perez <fperez@colorado.edu>
4808 2001-11-02 Fernando Perez <fperez@colorado.edu>
4789
4809
4790 * Python version check (>=2.1) added.
4810 * Python version check (>=2.1) added.
4791
4811
4792 * Added LazyPython documentation. At this point the docs are quite
4812 * Added LazyPython documentation. At this point the docs are quite
4793 a mess. A cleanup is in order.
4813 a mess. A cleanup is in order.
4794
4814
4795 * Auto-installer created. For some bizarre reason, the zipfiles
4815 * Auto-installer created. For some bizarre reason, the zipfiles
4796 module isn't working on my system. So I made a tar version
4816 module isn't working on my system. So I made a tar version
4797 (hopefully the command line options in various systems won't kill
4817 (hopefully the command line options in various systems won't kill
4798 me).
4818 me).
4799
4819
4800 * Fixes to Struct in genutils. Now all dictionary-like methods are
4820 * Fixes to Struct in genutils. Now all dictionary-like methods are
4801 protected (reasonably).
4821 protected (reasonably).
4802
4822
4803 * Added pager function to genutils and changed ? to print usage
4823 * Added pager function to genutils and changed ? to print usage
4804 note through it (it was too long).
4824 note through it (it was too long).
4805
4825
4806 * Added the LazyPython functionality. Works great! I changed the
4826 * Added the LazyPython functionality. Works great! I changed the
4807 auto-quote escape to ';', it's on home row and next to '. But
4827 auto-quote escape to ';', it's on home row and next to '. But
4808 both auto-quote and auto-paren (still /) escapes are command-line
4828 both auto-quote and auto-paren (still /) escapes are command-line
4809 parameters.
4829 parameters.
4810
4830
4811
4831
4812 2001-11-01 Fernando Perez <fperez@colorado.edu>
4832 2001-11-01 Fernando Perez <fperez@colorado.edu>
4813
4833
4814 * Version changed to 0.0.7. Fairly large change: configuration now
4834 * Version changed to 0.0.7. Fairly large change: configuration now
4815 is all stored in a directory, by default .ipython. There, all
4835 is all stored in a directory, by default .ipython. There, all
4816 config files have normal looking names (not .names)
4836 config files have normal looking names (not .names)
4817
4837
4818 * Version 0.0.6 Released first to Lucas and Archie as a test
4838 * Version 0.0.6 Released first to Lucas and Archie as a test
4819 run. Since it's the first 'semi-public' release, change version to
4839 run. Since it's the first 'semi-public' release, change version to
4820 > 0.0.6 for any changes now.
4840 > 0.0.6 for any changes now.
4821
4841
4822 * Stuff I had put in the ipplib.py changelog:
4842 * Stuff I had put in the ipplib.py changelog:
4823
4843
4824 Changes to InteractiveShell:
4844 Changes to InteractiveShell:
4825
4845
4826 - Made the usage message a parameter.
4846 - Made the usage message a parameter.
4827
4847
4828 - Require the name of the shell variable to be given. It's a bit
4848 - Require the name of the shell variable to be given. It's a bit
4829 of a hack, but allows the name 'shell' not to be hardwire in the
4849 of a hack, but allows the name 'shell' not to be hardwire in the
4830 magic (@) handler, which is problematic b/c it requires
4850 magic (@) handler, which is problematic b/c it requires
4831 polluting the global namespace with 'shell'. This in turn is
4851 polluting the global namespace with 'shell'. This in turn is
4832 fragile: if a user redefines a variable called shell, things
4852 fragile: if a user redefines a variable called shell, things
4833 break.
4853 break.
4834
4854
4835 - magic @: all functions available through @ need to be defined
4855 - magic @: all functions available through @ need to be defined
4836 as magic_<name>, even though they can be called simply as
4856 as magic_<name>, even though they can be called simply as
4837 @<name>. This allows the special command @magic to gather
4857 @<name>. This allows the special command @magic to gather
4838 information automatically about all existing magic functions,
4858 information automatically about all existing magic functions,
4839 even if they are run-time user extensions, by parsing the shell
4859 even if they are run-time user extensions, by parsing the shell
4840 instance __dict__ looking for special magic_ names.
4860 instance __dict__ looking for special magic_ names.
4841
4861
4842 - mainloop: added *two* local namespace parameters. This allows
4862 - mainloop: added *two* local namespace parameters. This allows
4843 the class to differentiate between parameters which were there
4863 the class to differentiate between parameters which were there
4844 before and after command line initialization was processed. This
4864 before and after command line initialization was processed. This
4845 way, later @who can show things loaded at startup by the
4865 way, later @who can show things loaded at startup by the
4846 user. This trick was necessary to make session saving/reloading
4866 user. This trick was necessary to make session saving/reloading
4847 really work: ideally after saving/exiting/reloading a session,
4867 really work: ideally after saving/exiting/reloading a session,
4848 *everythin* should look the same, including the output of @who. I
4868 *everythin* should look the same, including the output of @who. I
4849 was only able to make this work with this double namespace
4869 was only able to make this work with this double namespace
4850 trick.
4870 trick.
4851
4871
4852 - added a header to the logfile which allows (almost) full
4872 - added a header to the logfile which allows (almost) full
4853 session restoring.
4873 session restoring.
4854
4874
4855 - prepend lines beginning with @ or !, with a and log
4875 - prepend lines beginning with @ or !, with a and log
4856 them. Why? !lines: may be useful to know what you did @lines:
4876 them. Why? !lines: may be useful to know what you did @lines:
4857 they may affect session state. So when restoring a session, at
4877 they may affect session state. So when restoring a session, at
4858 least inform the user of their presence. I couldn't quite get
4878 least inform the user of their presence. I couldn't quite get
4859 them to properly re-execute, but at least the user is warned.
4879 them to properly re-execute, but at least the user is warned.
4860
4880
4861 * Started ChangeLog.
4881 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now