##// END OF EJS Templates
Prettified and hardened string/backslash quoting with ipsystem(), ipalias() and ...
vivainio -
Show More
@@ -1,1717 +1,1751 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 994 2006-01-08 08:29:44Z fperez $"""
8 $Id: genutils.py 1007 2006-01-12 17:15:41Z vivainio $"""
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
940 # This can be replaced with an isspace() call once we drop 2.2 compatibility
941 _isspace_match = re.compile(r'^\s+$').match
941 _isspace_match = re.compile(r'^\s+$').match
942 def isspace(s):
942 def isspace(s):
943 return bool(_isspace_match(s))
943 return bool(_isspace_match(s))
944
944
945 #----------------------------------------------------------------------------
945 #----------------------------------------------------------------------------
946 def esc_quotes(strng):
946 def esc_quotes(strng):
947 """Return the input string with single and double quotes escaped out"""
947 """Return the input string with single and double quotes escaped out"""
948
948
949 return strng.replace('"','\\"').replace("'","\\'")
949 return strng.replace('"','\\"').replace("'","\\'")
950
950
951 #----------------------------------------------------------------------------
951 #----------------------------------------------------------------------------
952 def make_quoted_expr(s):
953 """Return string s in appropriate quotes, using raw string if possible.
954
955 Effectively this turns string: cd \ao\ao\
956 to: r"cd \ao\ao\_"[:-1]
957
958 Note the use of raw string and padding at the end to allow trailing backslash.
959
960 """
961
962 tail = ''
963 tailpadding = ''
964 raw = ''
965 if "\\" in s:
966 raw = 'r'
967 if s.endswith('\\'):
968 tail = '[:-1]'
969 tailpadding = '_'
970 if '"' not in s:
971 quote = '"'
972 elif "'" not in s:
973 quote = "'"
974 elif '"""' not in s and not s.endswith('"'):
975 quote = '"""'
976 elif "'''" not in s and not s.endswith("'"):
977 quote = "'''"
978 else:
979 # give up, backslash-escaped string will do
980 return '"%s"' % esc_quotes(s)
981 res = itpl("$raw$quote$s$tailpadding$quote$tail")
982 return res
983
984
985 #----------------------------------------------------------------------------
952 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
986 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
953 """Take multiple lines of input.
987 """Take multiple lines of input.
954
988
955 A list with each line of input as a separate element is returned when a
989 A list with each line of input as a separate element is returned when a
956 termination string is entered (defaults to a single '.'). Input can also
990 termination string is entered (defaults to a single '.'). Input can also
957 terminate via EOF (^D in Unix, ^Z-RET in Windows).
991 terminate via EOF (^D in Unix, ^Z-RET in Windows).
958
992
959 Lines of input which end in \\ are joined into single entries (and a
993 Lines of input which end in \\ are joined into single entries (and a
960 secondary continuation prompt is issued as long as the user terminates
994 secondary continuation prompt is issued as long as the user terminates
961 lines with \\). This allows entering very long strings which are still
995 lines with \\). This allows entering very long strings which are still
962 meant to be treated as single entities.
996 meant to be treated as single entities.
963 """
997 """
964
998
965 try:
999 try:
966 if header:
1000 if header:
967 header += '\n'
1001 header += '\n'
968 lines = [raw_input(header + ps1)]
1002 lines = [raw_input(header + ps1)]
969 except EOFError:
1003 except EOFError:
970 return []
1004 return []
971 terminate = [terminate_str]
1005 terminate = [terminate_str]
972 try:
1006 try:
973 while lines[-1:] != terminate:
1007 while lines[-1:] != terminate:
974 new_line = raw_input(ps1)
1008 new_line = raw_input(ps1)
975 while new_line.endswith('\\'):
1009 while new_line.endswith('\\'):
976 new_line = new_line[:-1] + raw_input(ps2)
1010 new_line = new_line[:-1] + raw_input(ps2)
977 lines.append(new_line)
1011 lines.append(new_line)
978
1012
979 return lines[:-1] # don't return the termination command
1013 return lines[:-1] # don't return the termination command
980 except EOFError:
1014 except EOFError:
981 print
1015 print
982 return lines
1016 return lines
983
1017
984 #----------------------------------------------------------------------------
1018 #----------------------------------------------------------------------------
985 def raw_input_ext(prompt='', ps2='... '):
1019 def raw_input_ext(prompt='', ps2='... '):
986 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1020 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
987
1021
988 line = raw_input(prompt)
1022 line = raw_input(prompt)
989 while line.endswith('\\'):
1023 while line.endswith('\\'):
990 line = line[:-1] + raw_input(ps2)
1024 line = line[:-1] + raw_input(ps2)
991 return line
1025 return line
992
1026
993 #----------------------------------------------------------------------------
1027 #----------------------------------------------------------------------------
994 def ask_yes_no(prompt,default=None):
1028 def ask_yes_no(prompt,default=None):
995 """Asks a question and returns an integer 1/0 (y/n) answer.
1029 """Asks a question and returns an integer 1/0 (y/n) answer.
996
1030
997 If default is given (one of 'y','n'), it is used if the user input is
1031 If default is given (one of 'y','n'), it is used if the user input is
998 empty. Otherwise the question is repeated until an answer is given.
1032 empty. Otherwise the question is repeated until an answer is given.
999 If EOF occurs 20 times consecutively, the default answer is assumed,
1033 If EOF occurs 20 times consecutively, the default answer is assumed,
1000 or if there is no default, an exception is raised to prevent infinite
1034 or if there is no default, an exception is raised to prevent infinite
1001 loops.
1035 loops.
1002
1036
1003 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1037 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1004
1038
1005 answers = {'y':True,'n':False,'yes':True,'no':False}
1039 answers = {'y':True,'n':False,'yes':True,'no':False}
1006 ans = None
1040 ans = None
1007 eofs, max_eofs = 0, 20
1041 eofs, max_eofs = 0, 20
1008 while ans not in answers.keys():
1042 while ans not in answers.keys():
1009 try:
1043 try:
1010 ans = raw_input(prompt+' ').lower()
1044 ans = raw_input(prompt+' ').lower()
1011 if not ans: # response was an empty string
1045 if not ans: # response was an empty string
1012 ans = default
1046 ans = default
1013 eofs = 0
1047 eofs = 0
1014 except (EOFError,KeyboardInterrupt):
1048 except (EOFError,KeyboardInterrupt):
1015 eofs = eofs + 1
1049 eofs = eofs + 1
1016 if eofs >= max_eofs:
1050 if eofs >= max_eofs:
1017 if default in answers.keys():
1051 if default in answers.keys():
1018 ans = default
1052 ans = default
1019 else:
1053 else:
1020 raise
1054 raise
1021
1055
1022 return answers[ans]
1056 return answers[ans]
1023
1057
1024 #----------------------------------------------------------------------------
1058 #----------------------------------------------------------------------------
1025 def marquee(txt='',width=78,mark='*'):
1059 def marquee(txt='',width=78,mark='*'):
1026 """Return the input string centered in a 'marquee'."""
1060 """Return the input string centered in a 'marquee'."""
1027 if not txt:
1061 if not txt:
1028 return (mark*width)[:width]
1062 return (mark*width)[:width]
1029 nmark = (width-len(txt)-2)/len(mark)/2
1063 nmark = (width-len(txt)-2)/len(mark)/2
1030 if nmark < 0: nmark =0
1064 if nmark < 0: nmark =0
1031 marks = mark*nmark
1065 marks = mark*nmark
1032 return '%s %s %s' % (marks,txt,marks)
1066 return '%s %s %s' % (marks,txt,marks)
1033
1067
1034 #----------------------------------------------------------------------------
1068 #----------------------------------------------------------------------------
1035 class EvalDict:
1069 class EvalDict:
1036 """
1070 """
1037 Emulate a dict which evaluates its contents in the caller's frame.
1071 Emulate a dict which evaluates its contents in the caller's frame.
1038
1072
1039 Usage:
1073 Usage:
1040 >>>number = 19
1074 >>>number = 19
1041 >>>text = "python"
1075 >>>text = "python"
1042 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1076 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1043 """
1077 """
1044
1078
1045 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1079 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1046 # modified (shorter) version of:
1080 # modified (shorter) version of:
1047 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1081 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1048 # Skip Montanaro (skip@pobox.com).
1082 # Skip Montanaro (skip@pobox.com).
1049
1083
1050 def __getitem__(self, name):
1084 def __getitem__(self, name):
1051 frame = sys._getframe(1)
1085 frame = sys._getframe(1)
1052 return eval(name, frame.f_globals, frame.f_locals)
1086 return eval(name, frame.f_globals, frame.f_locals)
1053
1087
1054 EvalString = EvalDict # for backwards compatibility
1088 EvalString = EvalDict # for backwards compatibility
1055 #----------------------------------------------------------------------------
1089 #----------------------------------------------------------------------------
1056 def qw(words,flat=0,sep=None,maxsplit=-1):
1090 def qw(words,flat=0,sep=None,maxsplit=-1):
1057 """Similar to Perl's qw() operator, but with some more options.
1091 """Similar to Perl's qw() operator, but with some more options.
1058
1092
1059 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1093 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1060
1094
1061 words can also be a list itself, and with flat=1, the output will be
1095 words can also be a list itself, and with flat=1, the output will be
1062 recursively flattened. Examples:
1096 recursively flattened. Examples:
1063
1097
1064 >>> qw('1 2')
1098 >>> qw('1 2')
1065 ['1', '2']
1099 ['1', '2']
1066 >>> qw(['a b','1 2',['m n','p q']])
1100 >>> qw(['a b','1 2',['m n','p q']])
1067 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1101 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1068 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1102 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1069 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1103 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1070
1104
1071 if type(words) in StringTypes:
1105 if type(words) in StringTypes:
1072 return [word.strip() for word in words.split(sep,maxsplit)
1106 return [word.strip() for word in words.split(sep,maxsplit)
1073 if word and not word.isspace() ]
1107 if word and not word.isspace() ]
1074 if flat:
1108 if flat:
1075 return flatten(map(qw,words,[1]*len(words)))
1109 return flatten(map(qw,words,[1]*len(words)))
1076 return map(qw,words)
1110 return map(qw,words)
1077
1111
1078 #----------------------------------------------------------------------------
1112 #----------------------------------------------------------------------------
1079 def qwflat(words,sep=None,maxsplit=-1):
1113 def qwflat(words,sep=None,maxsplit=-1):
1080 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1114 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1081 return qw(words,1,sep,maxsplit)
1115 return qw(words,1,sep,maxsplit)
1082
1116
1083 #----------------------------------------------------------------------------
1117 #----------------------------------------------------------------------------
1084 def qw_lol(indata):
1118 def qw_lol(indata):
1085 """qw_lol('a b') -> [['a','b']],
1119 """qw_lol('a b') -> [['a','b']],
1086 otherwise it's just a call to qw().
1120 otherwise it's just a call to qw().
1087
1121
1088 We need this to make sure the modules_some keys *always* end up as a
1122 We need this to make sure the modules_some keys *always* end up as a
1089 list of lists."""
1123 list of lists."""
1090
1124
1091 if type(indata) in StringTypes:
1125 if type(indata) in StringTypes:
1092 return [qw(indata)]
1126 return [qw(indata)]
1093 else:
1127 else:
1094 return qw(indata)
1128 return qw(indata)
1095
1129
1096 #-----------------------------------------------------------------------------
1130 #-----------------------------------------------------------------------------
1097 def list_strings(arg):
1131 def list_strings(arg):
1098 """Always return a list of strings, given a string or list of strings
1132 """Always return a list of strings, given a string or list of strings
1099 as input."""
1133 as input."""
1100
1134
1101 if type(arg) in StringTypes: return [arg]
1135 if type(arg) in StringTypes: return [arg]
1102 else: return arg
1136 else: return arg
1103
1137
1104 #----------------------------------------------------------------------------
1138 #----------------------------------------------------------------------------
1105 def grep(pat,list,case=1):
1139 def grep(pat,list,case=1):
1106 """Simple minded grep-like function.
1140 """Simple minded grep-like function.
1107 grep(pat,list) returns occurrences of pat in list, None on failure.
1141 grep(pat,list) returns occurrences of pat in list, None on failure.
1108
1142
1109 It only does simple string matching, with no support for regexps. Use the
1143 It only does simple string matching, with no support for regexps. Use the
1110 option case=0 for case-insensitive matching."""
1144 option case=0 for case-insensitive matching."""
1111
1145
1112 # This is pretty crude. At least it should implement copying only references
1146 # This is pretty crude. At least it should implement copying only references
1113 # to the original data in case it's big. Now it copies the data for output.
1147 # to the original data in case it's big. Now it copies the data for output.
1114 out=[]
1148 out=[]
1115 if case:
1149 if case:
1116 for term in list:
1150 for term in list:
1117 if term.find(pat)>-1: out.append(term)
1151 if term.find(pat)>-1: out.append(term)
1118 else:
1152 else:
1119 lpat=pat.lower()
1153 lpat=pat.lower()
1120 for term in list:
1154 for term in list:
1121 if term.lower().find(lpat)>-1: out.append(term)
1155 if term.lower().find(lpat)>-1: out.append(term)
1122
1156
1123 if len(out): return out
1157 if len(out): return out
1124 else: return None
1158 else: return None
1125
1159
1126 #----------------------------------------------------------------------------
1160 #----------------------------------------------------------------------------
1127 def dgrep(pat,*opts):
1161 def dgrep(pat,*opts):
1128 """Return grep() on dir()+dir(__builtins__).
1162 """Return grep() on dir()+dir(__builtins__).
1129
1163
1130 A very common use of grep() when working interactively."""
1164 A very common use of grep() when working interactively."""
1131
1165
1132 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1166 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1133
1167
1134 #----------------------------------------------------------------------------
1168 #----------------------------------------------------------------------------
1135 def idgrep(pat):
1169 def idgrep(pat):
1136 """Case-insensitive dgrep()"""
1170 """Case-insensitive dgrep()"""
1137
1171
1138 return dgrep(pat,0)
1172 return dgrep(pat,0)
1139
1173
1140 #----------------------------------------------------------------------------
1174 #----------------------------------------------------------------------------
1141 def igrep(pat,list):
1175 def igrep(pat,list):
1142 """Synonym for case-insensitive grep."""
1176 """Synonym for case-insensitive grep."""
1143
1177
1144 return grep(pat,list,case=0)
1178 return grep(pat,list,case=0)
1145
1179
1146 #----------------------------------------------------------------------------
1180 #----------------------------------------------------------------------------
1147 def indent(str,nspaces=4,ntabs=0):
1181 def indent(str,nspaces=4,ntabs=0):
1148 """Indent a string a given number of spaces or tabstops.
1182 """Indent a string a given number of spaces or tabstops.
1149
1183
1150 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1184 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1151 """
1185 """
1152 if str is None:
1186 if str is None:
1153 return
1187 return
1154 ind = '\t'*ntabs+' '*nspaces
1188 ind = '\t'*ntabs+' '*nspaces
1155 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1189 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1156 if outstr.endswith(os.linesep+ind):
1190 if outstr.endswith(os.linesep+ind):
1157 return outstr[:-len(ind)]
1191 return outstr[:-len(ind)]
1158 else:
1192 else:
1159 return outstr
1193 return outstr
1160
1194
1161 #-----------------------------------------------------------------------------
1195 #-----------------------------------------------------------------------------
1162 def native_line_ends(filename,backup=1):
1196 def native_line_ends(filename,backup=1):
1163 """Convert (in-place) a file to line-ends native to the current OS.
1197 """Convert (in-place) a file to line-ends native to the current OS.
1164
1198
1165 If the optional backup argument is given as false, no backup of the
1199 If the optional backup argument is given as false, no backup of the
1166 original file is left. """
1200 original file is left. """
1167
1201
1168 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1202 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1169
1203
1170 bak_filename = filename + backup_suffixes[os.name]
1204 bak_filename = filename + backup_suffixes[os.name]
1171
1205
1172 original = open(filename).read()
1206 original = open(filename).read()
1173 shutil.copy2(filename,bak_filename)
1207 shutil.copy2(filename,bak_filename)
1174 try:
1208 try:
1175 new = open(filename,'wb')
1209 new = open(filename,'wb')
1176 new.write(os.linesep.join(original.splitlines()))
1210 new.write(os.linesep.join(original.splitlines()))
1177 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1211 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1178 new.close()
1212 new.close()
1179 except:
1213 except:
1180 os.rename(bak_filename,filename)
1214 os.rename(bak_filename,filename)
1181 if not backup:
1215 if not backup:
1182 try:
1216 try:
1183 os.remove(bak_filename)
1217 os.remove(bak_filename)
1184 except:
1218 except:
1185 pass
1219 pass
1186
1220
1187 #----------------------------------------------------------------------------
1221 #----------------------------------------------------------------------------
1188 def get_pager_cmd(pager_cmd = None):
1222 def get_pager_cmd(pager_cmd = None):
1189 """Return a pager command.
1223 """Return a pager command.
1190
1224
1191 Makes some attempts at finding an OS-correct one."""
1225 Makes some attempts at finding an OS-correct one."""
1192
1226
1193 if os.name == 'posix':
1227 if os.name == 'posix':
1194 default_pager_cmd = 'less -r' # -r for color control sequences
1228 default_pager_cmd = 'less -r' # -r for color control sequences
1195 elif os.name in ['nt','dos']:
1229 elif os.name in ['nt','dos']:
1196 default_pager_cmd = 'type'
1230 default_pager_cmd = 'type'
1197
1231
1198 if pager_cmd is None:
1232 if pager_cmd is None:
1199 try:
1233 try:
1200 pager_cmd = os.environ['PAGER']
1234 pager_cmd = os.environ['PAGER']
1201 except:
1235 except:
1202 pager_cmd = default_pager_cmd
1236 pager_cmd = default_pager_cmd
1203 return pager_cmd
1237 return pager_cmd
1204
1238
1205 #-----------------------------------------------------------------------------
1239 #-----------------------------------------------------------------------------
1206 def get_pager_start(pager,start):
1240 def get_pager_start(pager,start):
1207 """Return the string for paging files with an offset.
1241 """Return the string for paging files with an offset.
1208
1242
1209 This is the '+N' argument which less and more (under Unix) accept.
1243 This is the '+N' argument which less and more (under Unix) accept.
1210 """
1244 """
1211
1245
1212 if pager in ['less','more']:
1246 if pager in ['less','more']:
1213 if start:
1247 if start:
1214 start_string = '+' + str(start)
1248 start_string = '+' + str(start)
1215 else:
1249 else:
1216 start_string = ''
1250 start_string = ''
1217 else:
1251 else:
1218 start_string = ''
1252 start_string = ''
1219 return start_string
1253 return start_string
1220
1254
1221 #----------------------------------------------------------------------------
1255 #----------------------------------------------------------------------------
1222 if os.name == "nt":
1256 if os.name == "nt":
1223 import msvcrt
1257 import msvcrt
1224 def page_more():
1258 def page_more():
1225 """ Smart pausing between pages
1259 """ Smart pausing between pages
1226
1260
1227 @return: True if need print more lines, False if quit
1261 @return: True if need print more lines, False if quit
1228 """
1262 """
1229 Term.cout.write('---Return to continue, q to quit--- ')
1263 Term.cout.write('---Return to continue, q to quit--- ')
1230 ans = msvcrt.getch()
1264 ans = msvcrt.getch()
1231 if ans in ("q", "Q"):
1265 if ans in ("q", "Q"):
1232 result = False
1266 result = False
1233 else:
1267 else:
1234 result = True
1268 result = True
1235 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1269 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1236 return result
1270 return result
1237 else:
1271 else:
1238 def page_more():
1272 def page_more():
1239 ans = raw_input('---Return to continue, q to quit--- ')
1273 ans = raw_input('---Return to continue, q to quit--- ')
1240 if ans.lower().startswith('q'):
1274 if ans.lower().startswith('q'):
1241 return False
1275 return False
1242 else:
1276 else:
1243 return True
1277 return True
1244
1278
1245 esc_re = re.compile(r"(\x1b[^m]+m)")
1279 esc_re = re.compile(r"(\x1b[^m]+m)")
1246
1280
1247 def page_dumb(strng,start=0,screen_lines=25):
1281 def page_dumb(strng,start=0,screen_lines=25):
1248 """Very dumb 'pager' in Python, for when nothing else works.
1282 """Very dumb 'pager' in Python, for when nothing else works.
1249
1283
1250 Only moves forward, same interface as page(), except for pager_cmd and
1284 Only moves forward, same interface as page(), except for pager_cmd and
1251 mode."""
1285 mode."""
1252
1286
1253 out_ln = strng.splitlines()[start:]
1287 out_ln = strng.splitlines()[start:]
1254 screens = chop(out_ln,screen_lines-1)
1288 screens = chop(out_ln,screen_lines-1)
1255 if len(screens) == 1:
1289 if len(screens) == 1:
1256 print >>Term.cout, os.linesep.join(screens[0])
1290 print >>Term.cout, os.linesep.join(screens[0])
1257 else:
1291 else:
1258 last_escape = ""
1292 last_escape = ""
1259 for scr in screens[0:-1]:
1293 for scr in screens[0:-1]:
1260 hunk = os.linesep.join(scr)
1294 hunk = os.linesep.join(scr)
1261 print >>Term.cout, last_escape + hunk
1295 print >>Term.cout, last_escape + hunk
1262 if not page_more():
1296 if not page_more():
1263 return
1297 return
1264 esc_list = esc_re.findall(hunk)
1298 esc_list = esc_re.findall(hunk)
1265 if len(esc_list) > 0:
1299 if len(esc_list) > 0:
1266 last_escape = esc_list[-1]
1300 last_escape = esc_list[-1]
1267 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1301 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1268
1302
1269 #----------------------------------------------------------------------------
1303 #----------------------------------------------------------------------------
1270 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1304 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1271 """Print a string, piping through a pager after a certain length.
1305 """Print a string, piping through a pager after a certain length.
1272
1306
1273 The screen_lines parameter specifies the number of *usable* lines of your
1307 The screen_lines parameter specifies the number of *usable* lines of your
1274 terminal screen (total lines minus lines you need to reserve to show other
1308 terminal screen (total lines minus lines you need to reserve to show other
1275 information).
1309 information).
1276
1310
1277 If you set screen_lines to a number <=0, page() will try to auto-determine
1311 If you set screen_lines to a number <=0, page() will try to auto-determine
1278 your screen size and will only use up to (screen_size+screen_lines) for
1312 your screen size and will only use up to (screen_size+screen_lines) for
1279 printing, paging after that. That is, if you want auto-detection but need
1313 printing, paging after that. That is, if you want auto-detection but need
1280 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1314 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1281 auto-detection without any lines reserved simply use screen_lines = 0.
1315 auto-detection without any lines reserved simply use screen_lines = 0.
1282
1316
1283 If a string won't fit in the allowed lines, it is sent through the
1317 If a string won't fit in the allowed lines, it is sent through the
1284 specified pager command. If none given, look for PAGER in the environment,
1318 specified pager command. If none given, look for PAGER in the environment,
1285 and ultimately default to less.
1319 and ultimately default to less.
1286
1320
1287 If no system pager works, the string is sent through a 'dumb pager'
1321 If no system pager works, the string is sent through a 'dumb pager'
1288 written in python, very simplistic.
1322 written in python, very simplistic.
1289 """
1323 """
1290
1324
1291 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1325 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1292 TERM = os.environ.get('TERM','dumb')
1326 TERM = os.environ.get('TERM','dumb')
1293 if TERM in ['dumb','emacs'] and os.name != 'nt':
1327 if TERM in ['dumb','emacs'] and os.name != 'nt':
1294 print strng
1328 print strng
1295 return
1329 return
1296 # chop off the topmost part of the string we don't want to see
1330 # chop off the topmost part of the string we don't want to see
1297 str_lines = strng.split(os.linesep)[start:]
1331 str_lines = strng.split(os.linesep)[start:]
1298 str_toprint = os.linesep.join(str_lines)
1332 str_toprint = os.linesep.join(str_lines)
1299 num_newlines = len(str_lines)
1333 num_newlines = len(str_lines)
1300 len_str = len(str_toprint)
1334 len_str = len(str_toprint)
1301
1335
1302 # Dumb heuristics to guesstimate number of on-screen lines the string
1336 # Dumb heuristics to guesstimate number of on-screen lines the string
1303 # takes. Very basic, but good enough for docstrings in reasonable
1337 # takes. Very basic, but good enough for docstrings in reasonable
1304 # terminals. If someone later feels like refining it, it's not hard.
1338 # terminals. If someone later feels like refining it, it's not hard.
1305 numlines = max(num_newlines,int(len_str/80)+1)
1339 numlines = max(num_newlines,int(len_str/80)+1)
1306
1340
1307 if os.name == "nt":
1341 if os.name == "nt":
1308 screen_lines_def = get_console_size(defaulty=25)[1]
1342 screen_lines_def = get_console_size(defaulty=25)[1]
1309 else:
1343 else:
1310 screen_lines_def = 25 # default value if we can't auto-determine
1344 screen_lines_def = 25 # default value if we can't auto-determine
1311
1345
1312 # auto-determine screen size
1346 # auto-determine screen size
1313 if screen_lines <= 0:
1347 if screen_lines <= 0:
1314 if TERM=='xterm':
1348 if TERM=='xterm':
1315 try:
1349 try:
1316 import curses
1350 import curses
1317 if hasattr(curses,'initscr'):
1351 if hasattr(curses,'initscr'):
1318 use_curses = 1
1352 use_curses = 1
1319 else:
1353 else:
1320 use_curses = 0
1354 use_curses = 0
1321 except ImportError:
1355 except ImportError:
1322 use_curses = 0
1356 use_curses = 0
1323 else:
1357 else:
1324 # curses causes problems on many terminals other than xterm.
1358 # curses causes problems on many terminals other than xterm.
1325 use_curses = 0
1359 use_curses = 0
1326 if use_curses:
1360 if use_curses:
1327 scr = curses.initscr()
1361 scr = curses.initscr()
1328 screen_lines_real,screen_cols = scr.getmaxyx()
1362 screen_lines_real,screen_cols = scr.getmaxyx()
1329 curses.endwin()
1363 curses.endwin()
1330 screen_lines += screen_lines_real
1364 screen_lines += screen_lines_real
1331 #print '***Screen size:',screen_lines_real,'lines x',\
1365 #print '***Screen size:',screen_lines_real,'lines x',\
1332 #screen_cols,'columns.' # dbg
1366 #screen_cols,'columns.' # dbg
1333 else:
1367 else:
1334 screen_lines += screen_lines_def
1368 screen_lines += screen_lines_def
1335
1369
1336 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1370 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1337 if numlines <= screen_lines :
1371 if numlines <= screen_lines :
1338 #print '*** normal print' # dbg
1372 #print '*** normal print' # dbg
1339 print >>Term.cout, str_toprint
1373 print >>Term.cout, str_toprint
1340 else:
1374 else:
1341 # Try to open pager and default to internal one if that fails.
1375 # Try to open pager and default to internal one if that fails.
1342 # All failure modes are tagged as 'retval=1', to match the return
1376 # All failure modes are tagged as 'retval=1', to match the return
1343 # value of a failed system command. If any intermediate attempt
1377 # value of a failed system command. If any intermediate attempt
1344 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1378 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1345 pager_cmd = get_pager_cmd(pager_cmd)
1379 pager_cmd = get_pager_cmd(pager_cmd)
1346 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1380 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1347 if os.name == 'nt':
1381 if os.name == 'nt':
1348 if pager_cmd.startswith('type'):
1382 if pager_cmd.startswith('type'):
1349 # The default WinXP 'type' command is failing on complex strings.
1383 # The default WinXP 'type' command is failing on complex strings.
1350 retval = 1
1384 retval = 1
1351 else:
1385 else:
1352 tmpname = tempfile.mktemp('.txt')
1386 tmpname = tempfile.mktemp('.txt')
1353 tmpfile = file(tmpname,'wt')
1387 tmpfile = file(tmpname,'wt')
1354 tmpfile.write(strng)
1388 tmpfile.write(strng)
1355 tmpfile.close()
1389 tmpfile.close()
1356 cmd = "%s < %s" % (pager_cmd,tmpname)
1390 cmd = "%s < %s" % (pager_cmd,tmpname)
1357 if os.system(cmd):
1391 if os.system(cmd):
1358 retval = 1
1392 retval = 1
1359 else:
1393 else:
1360 retval = None
1394 retval = None
1361 os.remove(tmpname)
1395 os.remove(tmpname)
1362 else:
1396 else:
1363 try:
1397 try:
1364 retval = None
1398 retval = None
1365 # if I use popen4, things hang. No idea why.
1399 # if I use popen4, things hang. No idea why.
1366 #pager,shell_out = os.popen4(pager_cmd)
1400 #pager,shell_out = os.popen4(pager_cmd)
1367 pager = os.popen(pager_cmd,'w')
1401 pager = os.popen(pager_cmd,'w')
1368 pager.write(strng)
1402 pager.write(strng)
1369 pager.close()
1403 pager.close()
1370 retval = pager.close() # success returns None
1404 retval = pager.close() # success returns None
1371 except IOError,msg: # broken pipe when user quits
1405 except IOError,msg: # broken pipe when user quits
1372 if msg.args == (32,'Broken pipe'):
1406 if msg.args == (32,'Broken pipe'):
1373 retval = None
1407 retval = None
1374 else:
1408 else:
1375 retval = 1
1409 retval = 1
1376 except OSError:
1410 except OSError:
1377 # Other strange problems, sometimes seen in Win2k/cygwin
1411 # Other strange problems, sometimes seen in Win2k/cygwin
1378 retval = 1
1412 retval = 1
1379 if retval is not None:
1413 if retval is not None:
1380 page_dumb(strng,screen_lines=screen_lines)
1414 page_dumb(strng,screen_lines=screen_lines)
1381
1415
1382 #----------------------------------------------------------------------------
1416 #----------------------------------------------------------------------------
1383 def page_file(fname,start = 0, pager_cmd = None):
1417 def page_file(fname,start = 0, pager_cmd = None):
1384 """Page a file, using an optional pager command and starting line.
1418 """Page a file, using an optional pager command and starting line.
1385 """
1419 """
1386
1420
1387 pager_cmd = get_pager_cmd(pager_cmd)
1421 pager_cmd = get_pager_cmd(pager_cmd)
1388 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1422 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1389
1423
1390 try:
1424 try:
1391 if os.environ['TERM'] in ['emacs','dumb']:
1425 if os.environ['TERM'] in ['emacs','dumb']:
1392 raise EnvironmentError
1426 raise EnvironmentError
1393 xsys(pager_cmd + ' ' + fname)
1427 xsys(pager_cmd + ' ' + fname)
1394 except:
1428 except:
1395 try:
1429 try:
1396 if start > 0:
1430 if start > 0:
1397 start -= 1
1431 start -= 1
1398 page(open(fname).read(),start)
1432 page(open(fname).read(),start)
1399 except:
1433 except:
1400 print 'Unable to show file',`fname`
1434 print 'Unable to show file',`fname`
1401
1435
1402 #----------------------------------------------------------------------------
1436 #----------------------------------------------------------------------------
1403 def snip_print(str,width = 75,print_full = 0,header = ''):
1437 def snip_print(str,width = 75,print_full = 0,header = ''):
1404 """Print a string snipping the midsection to fit in width.
1438 """Print a string snipping the midsection to fit in width.
1405
1439
1406 print_full: mode control:
1440 print_full: mode control:
1407 - 0: only snip long strings
1441 - 0: only snip long strings
1408 - 1: send to page() directly.
1442 - 1: send to page() directly.
1409 - 2: snip long strings and ask for full length viewing with page()
1443 - 2: snip long strings and ask for full length viewing with page()
1410 Return 1 if snipping was necessary, 0 otherwise."""
1444 Return 1 if snipping was necessary, 0 otherwise."""
1411
1445
1412 if print_full == 1:
1446 if print_full == 1:
1413 page(header+str)
1447 page(header+str)
1414 return 0
1448 return 0
1415
1449
1416 print header,
1450 print header,
1417 if len(str) < width:
1451 if len(str) < width:
1418 print str
1452 print str
1419 snip = 0
1453 snip = 0
1420 else:
1454 else:
1421 whalf = int((width -5)/2)
1455 whalf = int((width -5)/2)
1422 print str[:whalf] + ' <...> ' + str[-whalf:]
1456 print str[:whalf] + ' <...> ' + str[-whalf:]
1423 snip = 1
1457 snip = 1
1424 if snip and print_full == 2:
1458 if snip and print_full == 2:
1425 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1459 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1426 page(str)
1460 page(str)
1427 return snip
1461 return snip
1428
1462
1429 #****************************************************************************
1463 #****************************************************************************
1430 # lists, dicts and structures
1464 # lists, dicts and structures
1431
1465
1432 def belong(candidates,checklist):
1466 def belong(candidates,checklist):
1433 """Check whether a list of items appear in a given list of options.
1467 """Check whether a list of items appear in a given list of options.
1434
1468
1435 Returns a list of 1 and 0, one for each candidate given."""
1469 Returns a list of 1 and 0, one for each candidate given."""
1436
1470
1437 return [x in checklist for x in candidates]
1471 return [x in checklist for x in candidates]
1438
1472
1439 #----------------------------------------------------------------------------
1473 #----------------------------------------------------------------------------
1440 def uniq_stable(elems):
1474 def uniq_stable(elems):
1441 """uniq_stable(elems) -> list
1475 """uniq_stable(elems) -> list
1442
1476
1443 Return from an iterable, a list of all the unique elements in the input,
1477 Return from an iterable, a list of all the unique elements in the input,
1444 but maintaining the order in which they first appear.
1478 but maintaining the order in which they first appear.
1445
1479
1446 A naive solution to this problem which just makes a dictionary with the
1480 A naive solution to this problem which just makes a dictionary with the
1447 elements as keys fails to respect the stability condition, since
1481 elements as keys fails to respect the stability condition, since
1448 dictionaries are unsorted by nature.
1482 dictionaries are unsorted by nature.
1449
1483
1450 Note: All elements in the input must be valid dictionary keys for this
1484 Note: All elements in the input must be valid dictionary keys for this
1451 routine to work, as it internally uses a dictionary for efficiency
1485 routine to work, as it internally uses a dictionary for efficiency
1452 reasons."""
1486 reasons."""
1453
1487
1454 unique = []
1488 unique = []
1455 unique_dict = {}
1489 unique_dict = {}
1456 for nn in elems:
1490 for nn in elems:
1457 if nn not in unique_dict:
1491 if nn not in unique_dict:
1458 unique.append(nn)
1492 unique.append(nn)
1459 unique_dict[nn] = None
1493 unique_dict[nn] = None
1460 return unique
1494 return unique
1461
1495
1462 #----------------------------------------------------------------------------
1496 #----------------------------------------------------------------------------
1463 class NLprinter:
1497 class NLprinter:
1464 """Print an arbitrarily nested list, indicating index numbers.
1498 """Print an arbitrarily nested list, indicating index numbers.
1465
1499
1466 An instance of this class called nlprint is available and callable as a
1500 An instance of this class called nlprint is available and callable as a
1467 function.
1501 function.
1468
1502
1469 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1503 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1470 and using 'sep' to separate the index from the value. """
1504 and using 'sep' to separate the index from the value. """
1471
1505
1472 def __init__(self):
1506 def __init__(self):
1473 self.depth = 0
1507 self.depth = 0
1474
1508
1475 def __call__(self,lst,pos='',**kw):
1509 def __call__(self,lst,pos='',**kw):
1476 """Prints the nested list numbering levels."""
1510 """Prints the nested list numbering levels."""
1477 kw.setdefault('indent',' ')
1511 kw.setdefault('indent',' ')
1478 kw.setdefault('sep',': ')
1512 kw.setdefault('sep',': ')
1479 kw.setdefault('start',0)
1513 kw.setdefault('start',0)
1480 kw.setdefault('stop',len(lst))
1514 kw.setdefault('stop',len(lst))
1481 # we need to remove start and stop from kw so they don't propagate
1515 # we need to remove start and stop from kw so they don't propagate
1482 # into a recursive call for a nested list.
1516 # into a recursive call for a nested list.
1483 start = kw['start']; del kw['start']
1517 start = kw['start']; del kw['start']
1484 stop = kw['stop']; del kw['stop']
1518 stop = kw['stop']; del kw['stop']
1485 if self.depth == 0 and 'header' in kw.keys():
1519 if self.depth == 0 and 'header' in kw.keys():
1486 print kw['header']
1520 print kw['header']
1487
1521
1488 for idx in range(start,stop):
1522 for idx in range(start,stop):
1489 elem = lst[idx]
1523 elem = lst[idx]
1490 if type(elem)==type([]):
1524 if type(elem)==type([]):
1491 self.depth += 1
1525 self.depth += 1
1492 self.__call__(elem,itpl('$pos$idx,'),**kw)
1526 self.__call__(elem,itpl('$pos$idx,'),**kw)
1493 self.depth -= 1
1527 self.depth -= 1
1494 else:
1528 else:
1495 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1529 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1496
1530
1497 nlprint = NLprinter()
1531 nlprint = NLprinter()
1498 #----------------------------------------------------------------------------
1532 #----------------------------------------------------------------------------
1499 def all_belong(candidates,checklist):
1533 def all_belong(candidates,checklist):
1500 """Check whether a list of items ALL appear in a given list of options.
1534 """Check whether a list of items ALL appear in a given list of options.
1501
1535
1502 Returns a single 1 or 0 value."""
1536 Returns a single 1 or 0 value."""
1503
1537
1504 return 1-(0 in [x in checklist for x in candidates])
1538 return 1-(0 in [x in checklist for x in candidates])
1505
1539
1506 #----------------------------------------------------------------------------
1540 #----------------------------------------------------------------------------
1507 def sort_compare(lst1,lst2,inplace = 1):
1541 def sort_compare(lst1,lst2,inplace = 1):
1508 """Sort and compare two lists.
1542 """Sort and compare two lists.
1509
1543
1510 By default it does it in place, thus modifying the lists. Use inplace = 0
1544 By default it does it in place, thus modifying the lists. Use inplace = 0
1511 to avoid that (at the cost of temporary copy creation)."""
1545 to avoid that (at the cost of temporary copy creation)."""
1512 if not inplace:
1546 if not inplace:
1513 lst1 = lst1[:]
1547 lst1 = lst1[:]
1514 lst2 = lst2[:]
1548 lst2 = lst2[:]
1515 lst1.sort(); lst2.sort()
1549 lst1.sort(); lst2.sort()
1516 return lst1 == lst2
1550 return lst1 == lst2
1517
1551
1518 #----------------------------------------------------------------------------
1552 #----------------------------------------------------------------------------
1519 def mkdict(**kwargs):
1553 def mkdict(**kwargs):
1520 """Return a dict from a keyword list.
1554 """Return a dict from a keyword list.
1521
1555
1522 It's just syntactic sugar for making ditcionary creation more convenient:
1556 It's just syntactic sugar for making ditcionary creation more convenient:
1523 # the standard way
1557 # the standard way
1524 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1558 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1525 # a cleaner way
1559 # a cleaner way
1526 >>>data = dict(red=1, green=2, blue=3)
1560 >>>data = dict(red=1, green=2, blue=3)
1527
1561
1528 If you need more than this, look at the Struct() class."""
1562 If you need more than this, look at the Struct() class."""
1529
1563
1530 return kwargs
1564 return kwargs
1531
1565
1532 #----------------------------------------------------------------------------
1566 #----------------------------------------------------------------------------
1533 def list2dict(lst):
1567 def list2dict(lst):
1534 """Takes a list of (key,value) pairs and turns it into a dict."""
1568 """Takes a list of (key,value) pairs and turns it into a dict."""
1535
1569
1536 dic = {}
1570 dic = {}
1537 for k,v in lst: dic[k] = v
1571 for k,v in lst: dic[k] = v
1538 return dic
1572 return dic
1539
1573
1540 #----------------------------------------------------------------------------
1574 #----------------------------------------------------------------------------
1541 def list2dict2(lst,default=''):
1575 def list2dict2(lst,default=''):
1542 """Takes a list and turns it into a dict.
1576 """Takes a list and turns it into a dict.
1543 Much slower than list2dict, but more versatile. This version can take
1577 Much slower than list2dict, but more versatile. This version can take
1544 lists with sublists of arbitrary length (including sclars)."""
1578 lists with sublists of arbitrary length (including sclars)."""
1545
1579
1546 dic = {}
1580 dic = {}
1547 for elem in lst:
1581 for elem in lst:
1548 if type(elem) in (types.ListType,types.TupleType):
1582 if type(elem) in (types.ListType,types.TupleType):
1549 size = len(elem)
1583 size = len(elem)
1550 if size == 0:
1584 if size == 0:
1551 pass
1585 pass
1552 elif size == 1:
1586 elif size == 1:
1553 dic[elem] = default
1587 dic[elem] = default
1554 else:
1588 else:
1555 k,v = elem[0], elem[1:]
1589 k,v = elem[0], elem[1:]
1556 if len(v) == 1: v = v[0]
1590 if len(v) == 1: v = v[0]
1557 dic[k] = v
1591 dic[k] = v
1558 else:
1592 else:
1559 dic[elem] = default
1593 dic[elem] = default
1560 return dic
1594 return dic
1561
1595
1562 #----------------------------------------------------------------------------
1596 #----------------------------------------------------------------------------
1563 def flatten(seq):
1597 def flatten(seq):
1564 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1598 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1565
1599
1566 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1600 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1567
1601
1568 # if the x=0 isn't made, a *global* variable x is left over after calling
1602 # if the x=0 isn't made, a *global* variable x is left over after calling
1569 # this function, with the value of the last element in the return
1603 # this function, with the value of the last element in the return
1570 # list. This does seem like a bug big time to me.
1604 # list. This does seem like a bug big time to me.
1571
1605
1572 # the problem is fixed with the x=0, which seems to force the creation of
1606 # the problem is fixed with the x=0, which seems to force the creation of
1573 # a local name
1607 # a local name
1574
1608
1575 x = 0
1609 x = 0
1576 return [x for subseq in seq for x in subseq]
1610 return [x for subseq in seq for x in subseq]
1577
1611
1578 #----------------------------------------------------------------------------
1612 #----------------------------------------------------------------------------
1579 def get_slice(seq,start=0,stop=None,step=1):
1613 def get_slice(seq,start=0,stop=None,step=1):
1580 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1614 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1581 if stop == None:
1615 if stop == None:
1582 stop = len(seq)
1616 stop = len(seq)
1583 item = lambda i: seq[i]
1617 item = lambda i: seq[i]
1584 return map(item,xrange(start,stop,step))
1618 return map(item,xrange(start,stop,step))
1585
1619
1586 #----------------------------------------------------------------------------
1620 #----------------------------------------------------------------------------
1587 def chop(seq,size):
1621 def chop(seq,size):
1588 """Chop a sequence into chunks of the given size."""
1622 """Chop a sequence into chunks of the given size."""
1589 chunk = lambda i: seq[i:i+size]
1623 chunk = lambda i: seq[i:i+size]
1590 return map(chunk,xrange(0,len(seq),size))
1624 return map(chunk,xrange(0,len(seq),size))
1591
1625
1592 #----------------------------------------------------------------------------
1626 #----------------------------------------------------------------------------
1593 def with(object, **args):
1627 def with(object, **args):
1594 """Set multiple attributes for an object, similar to Pascal's with.
1628 """Set multiple attributes for an object, similar to Pascal's with.
1595
1629
1596 Example:
1630 Example:
1597 with(jim,
1631 with(jim,
1598 born = 1960,
1632 born = 1960,
1599 haircolour = 'Brown',
1633 haircolour = 'Brown',
1600 eyecolour = 'Green')
1634 eyecolour = 'Green')
1601
1635
1602 Credit: Greg Ewing, in
1636 Credit: Greg Ewing, in
1603 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1637 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1604
1638
1605 object.__dict__.update(args)
1639 object.__dict__.update(args)
1606
1640
1607 #----------------------------------------------------------------------------
1641 #----------------------------------------------------------------------------
1608 def setattr_list(obj,alist,nspace = None):
1642 def setattr_list(obj,alist,nspace = None):
1609 """Set a list of attributes for an object taken from a namespace.
1643 """Set a list of attributes for an object taken from a namespace.
1610
1644
1611 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1645 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1612 alist with their values taken from nspace, which must be a dict (something
1646 alist with their values taken from nspace, which must be a dict (something
1613 like locals() will often do) If nspace isn't given, locals() of the
1647 like locals() will often do) If nspace isn't given, locals() of the
1614 *caller* is used, so in most cases you can omit it.
1648 *caller* is used, so in most cases you can omit it.
1615
1649
1616 Note that alist can be given as a string, which will be automatically
1650 Note that alist can be given as a string, which will be automatically
1617 split into a list on whitespace. If given as a list, it must be a list of
1651 split into a list on whitespace. If given as a list, it must be a list of
1618 *strings* (the variable names themselves), not of variables."""
1652 *strings* (the variable names themselves), not of variables."""
1619
1653
1620 # this grabs the local variables from the *previous* call frame -- that is
1654 # this grabs the local variables from the *previous* call frame -- that is
1621 # the locals from the function that called setattr_list().
1655 # the locals from the function that called setattr_list().
1622 # - snipped from weave.inline()
1656 # - snipped from weave.inline()
1623 if nspace is None:
1657 if nspace is None:
1624 call_frame = sys._getframe().f_back
1658 call_frame = sys._getframe().f_back
1625 nspace = call_frame.f_locals
1659 nspace = call_frame.f_locals
1626
1660
1627 if type(alist) in StringTypes:
1661 if type(alist) in StringTypes:
1628 alist = alist.split()
1662 alist = alist.split()
1629 for attr in alist:
1663 for attr in alist:
1630 val = eval(attr,nspace)
1664 val = eval(attr,nspace)
1631 setattr(obj,attr,val)
1665 setattr(obj,attr,val)
1632
1666
1633 #----------------------------------------------------------------------------
1667 #----------------------------------------------------------------------------
1634 def getattr_list(obj,alist,*args):
1668 def getattr_list(obj,alist,*args):
1635 """getattr_list(obj,alist[, default]) -> attribute list.
1669 """getattr_list(obj,alist[, default]) -> attribute list.
1636
1670
1637 Get a list of named attributes for an object. When a default argument is
1671 Get a list of named attributes for an object. When a default argument is
1638 given, it is returned when the attribute doesn't exist; without it, an
1672 given, it is returned when the attribute doesn't exist; without it, an
1639 exception is raised in that case.
1673 exception is raised in that case.
1640
1674
1641 Note that alist can be given as a string, which will be automatically
1675 Note that alist can be given as a string, which will be automatically
1642 split into a list on whitespace. If given as a list, it must be a list of
1676 split into a list on whitespace. If given as a list, it must be a list of
1643 *strings* (the variable names themselves), not of variables."""
1677 *strings* (the variable names themselves), not of variables."""
1644
1678
1645 if type(alist) in StringTypes:
1679 if type(alist) in StringTypes:
1646 alist = alist.split()
1680 alist = alist.split()
1647 if args:
1681 if args:
1648 if len(args)==1:
1682 if len(args)==1:
1649 default = args[0]
1683 default = args[0]
1650 return map(lambda attr: getattr(obj,attr,default),alist)
1684 return map(lambda attr: getattr(obj,attr,default),alist)
1651 else:
1685 else:
1652 raise ValueError,'getattr_list() takes only one optional argument'
1686 raise ValueError,'getattr_list() takes only one optional argument'
1653 else:
1687 else:
1654 return map(lambda attr: getattr(obj,attr),alist)
1688 return map(lambda attr: getattr(obj,attr),alist)
1655
1689
1656 #----------------------------------------------------------------------------
1690 #----------------------------------------------------------------------------
1657 def map_method(method,object_list,*argseq,**kw):
1691 def map_method(method,object_list,*argseq,**kw):
1658 """map_method(method,object_list,*args,**kw) -> list
1692 """map_method(method,object_list,*args,**kw) -> list
1659
1693
1660 Return a list of the results of applying the methods to the items of the
1694 Return a list of the results of applying the methods to the items of the
1661 argument sequence(s). If more than one sequence is given, the method is
1695 argument sequence(s). If more than one sequence is given, the method is
1662 called with an argument list consisting of the corresponding item of each
1696 called with an argument list consisting of the corresponding item of each
1663 sequence. All sequences must be of the same length.
1697 sequence. All sequences must be of the same length.
1664
1698
1665 Keyword arguments are passed verbatim to all objects called.
1699 Keyword arguments are passed verbatim to all objects called.
1666
1700
1667 This is Python code, so it's not nearly as fast as the builtin map()."""
1701 This is Python code, so it's not nearly as fast as the builtin map()."""
1668
1702
1669 out_list = []
1703 out_list = []
1670 idx = 0
1704 idx = 0
1671 for object in object_list:
1705 for object in object_list:
1672 try:
1706 try:
1673 handler = getattr(object, method)
1707 handler = getattr(object, method)
1674 except AttributeError:
1708 except AttributeError:
1675 out_list.append(None)
1709 out_list.append(None)
1676 else:
1710 else:
1677 if argseq:
1711 if argseq:
1678 args = map(lambda lst:lst[idx],argseq)
1712 args = map(lambda lst:lst[idx],argseq)
1679 #print 'ob',object,'hand',handler,'ar',args # dbg
1713 #print 'ob',object,'hand',handler,'ar',args # dbg
1680 out_list.append(handler(args,**kw))
1714 out_list.append(handler(args,**kw))
1681 else:
1715 else:
1682 out_list.append(handler(**kw))
1716 out_list.append(handler(**kw))
1683 idx += 1
1717 idx += 1
1684 return out_list
1718 return out_list
1685
1719
1686 #----------------------------------------------------------------------------
1720 #----------------------------------------------------------------------------
1687 def import_fail_info(mod_name,fns=None):
1721 def import_fail_info(mod_name,fns=None):
1688 """Inform load failure for a module."""
1722 """Inform load failure for a module."""
1689
1723
1690 if fns == None:
1724 if fns == None:
1691 warn("Loading of %s failed.\n" % (mod_name,))
1725 warn("Loading of %s failed.\n" % (mod_name,))
1692 else:
1726 else:
1693 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1727 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1694
1728
1695 #----------------------------------------------------------------------------
1729 #----------------------------------------------------------------------------
1696 # Proposed popitem() extension, written as a method
1730 # Proposed popitem() extension, written as a method
1697
1731
1698 class NotGiven: pass
1732 class NotGiven: pass
1699
1733
1700 def popkey(dct,key,default=NotGiven):
1734 def popkey(dct,key,default=NotGiven):
1701 """Return dct[key] and delete dct[key].
1735 """Return dct[key] and delete dct[key].
1702
1736
1703 If default is given, return it if dct[key] doesn't exist, otherwise raise
1737 If default is given, return it if dct[key] doesn't exist, otherwise raise
1704 KeyError. """
1738 KeyError. """
1705
1739
1706 try:
1740 try:
1707 val = dct[key]
1741 val = dct[key]
1708 except KeyError:
1742 except KeyError:
1709 if default is NotGiven:
1743 if default is NotGiven:
1710 raise
1744 raise
1711 else:
1745 else:
1712 return default
1746 return default
1713 else:
1747 else:
1714 del dct[key]
1748 del dct[key]
1715 return val
1749 return val
1716 #*************************** end of file <genutils.py> **********************
1750 #*************************** end of file <genutils.py> **********************
1717
1751
@@ -1,2165 +1,2157 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 1005 2006-01-12 08:39:26Z fperez $
9 $Id: iplib.py 1007 2006-01-12 17:15:41Z vivainio $
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+)')
85 ini_spaces_re = re.compile(r'^(\s+)')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
87
87
88
88
89 #****************************************************************************
89 #****************************************************************************
90 # Some utility function definitions
90 # Some utility function definitions
91
91
92 def softspace(file, newvalue):
92 def softspace(file, newvalue):
93 """Copied from code.py, to remove the dependency"""
93 """Copied from code.py, to remove the dependency"""
94 oldvalue = 0
94 oldvalue = 0
95 try:
95 try:
96 oldvalue = file.softspace
96 oldvalue = file.softspace
97 except AttributeError:
97 except AttributeError:
98 pass
98 pass
99 try:
99 try:
100 file.softspace = newvalue
100 file.softspace = newvalue
101 except (AttributeError, TypeError):
101 except (AttributeError, TypeError):
102 # "attribute-less object" or "read-only attributes"
102 # "attribute-less object" or "read-only attributes"
103 pass
103 pass
104 return oldvalue
104 return oldvalue
105
105
106
106
107 #****************************************************************************
107 #****************************************************************************
108 # Local use exceptions
108 # Local use exceptions
109 class SpaceInInput(exceptions.Exception): pass
109 class SpaceInInput(exceptions.Exception): pass
110
110
111
111
112 #****************************************************************************
112 #****************************************************************************
113 # Local use classes
113 # Local use classes
114 class Bunch: pass
114 class Bunch: pass
115
115
116 class Undefined: pass
116 class Undefined: pass
117
117
118 class InputList(list):
118 class InputList(list):
119 """Class to store user input.
119 """Class to store user input.
120
120
121 It's basically a list, but slices return a string instead of a list, thus
121 It's basically a list, but slices return a string instead of a list, thus
122 allowing things like (assuming 'In' is an instance):
122 allowing things like (assuming 'In' is an instance):
123
123
124 exec In[4:7]
124 exec In[4:7]
125
125
126 or
126 or
127
127
128 exec In[5:9] + In[14] + In[21:25]"""
128 exec In[5:9] + In[14] + In[21:25]"""
129
129
130 def __getslice__(self,i,j):
130 def __getslice__(self,i,j):
131 return ''.join(list.__getslice__(self,i,j))
131 return ''.join(list.__getslice__(self,i,j))
132
132
133 class SyntaxTB(ultraTB.ListTB):
133 class SyntaxTB(ultraTB.ListTB):
134 """Extension which holds some state: the last exception value"""
134 """Extension which holds some state: the last exception value"""
135
135
136 def __init__(self,color_scheme = 'NoColor'):
136 def __init__(self,color_scheme = 'NoColor'):
137 ultraTB.ListTB.__init__(self,color_scheme)
137 ultraTB.ListTB.__init__(self,color_scheme)
138 self.last_syntax_error = None
138 self.last_syntax_error = None
139
139
140 def __call__(self, etype, value, elist):
140 def __call__(self, etype, value, elist):
141 self.last_syntax_error = value
141 self.last_syntax_error = value
142 ultraTB.ListTB.__call__(self,etype,value,elist)
142 ultraTB.ListTB.__call__(self,etype,value,elist)
143
143
144 def clear_err_state(self):
144 def clear_err_state(self):
145 """Return the current error state and clear it"""
145 """Return the current error state and clear it"""
146 e = self.last_syntax_error
146 e = self.last_syntax_error
147 self.last_syntax_error = None
147 self.last_syntax_error = None
148 return e
148 return e
149
149
150 #****************************************************************************
150 #****************************************************************************
151 # Main IPython class
151 # Main IPython class
152
152
153 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
153 # 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
154 # 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
155 # 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.
156 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
157 #
157 #
158 # But at least now, all the pieces have been separated and we could, in
158 # 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
159 # principle, stop using the mixin. This will ease the transition to the
160 # chainsaw branch.
160 # chainsaw branch.
161
161
162 # For reference, the following is the list of 'self.foo' uses in the Magic
162 # 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
163 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
164 # class, to prevent clashes.
164 # class, to prevent clashes.
165
165
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
166 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
167 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
168 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
169 # 'self.value']
169 # 'self.value']
170
170
171 class InteractiveShell(object,Magic):
171 class InteractiveShell(object,Magic):
172 """An enhanced console for Python."""
172 """An enhanced console for Python."""
173
173
174 # class attribute to indicate whether the class supports threads or not.
174 # class attribute to indicate whether the class supports threads or not.
175 # Subclasses with thread support should override this as needed.
175 # Subclasses with thread support should override this as needed.
176 isthreaded = False
176 isthreaded = False
177
177
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
178 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
179 user_ns = None,user_global_ns=None,banner2='',
179 user_ns = None,user_global_ns=None,banner2='',
180 custom_exceptions=((),None),embedded=False):
180 custom_exceptions=((),None),embedded=False):
181
181
182 # some minimal strict typechecks. For some core data structures, I
182 # some minimal strict typechecks. For some core data structures, I
183 # want actual basic python types, not just anything that looks like
183 # want actual basic python types, not just anything that looks like
184 # one. This is especially true for namespaces.
184 # one. This is especially true for namespaces.
185 for ns in (user_ns,user_global_ns):
185 for ns in (user_ns,user_global_ns):
186 if ns is not None and type(ns) != types.DictType:
186 if ns is not None and type(ns) != types.DictType:
187 raise TypeError,'namespace must be a dictionary'
187 raise TypeError,'namespace must be a dictionary'
188
188
189 # Job manager (for jobs run as background threads)
189 # Job manager (for jobs run as background threads)
190 self.jobs = BackgroundJobManager()
190 self.jobs = BackgroundJobManager()
191
191
192 # track which builtins we add, so we can clean up later
192 # track which builtins we add, so we can clean up later
193 self.builtins_added = {}
193 self.builtins_added = {}
194 # This method will add the necessary builtins for operation, but
194 # This method will add the necessary builtins for operation, but
195 # tracking what it did via the builtins_added dict.
195 # tracking what it did via the builtins_added dict.
196 self.add_builtins()
196 self.add_builtins()
197
197
198 # Do the intuitively correct thing for quit/exit: we remove the
198 # Do the intuitively correct thing for quit/exit: we remove the
199 # builtins if they exist, and our own magics will deal with this
199 # builtins if they exist, and our own magics will deal with this
200 try:
200 try:
201 del __builtin__.exit, __builtin__.quit
201 del __builtin__.exit, __builtin__.quit
202 except AttributeError:
202 except AttributeError:
203 pass
203 pass
204
204
205 # Store the actual shell's name
205 # Store the actual shell's name
206 self.name = name
206 self.name = name
207
207
208 # We need to know whether the instance is meant for embedding, since
208 # We need to know whether the instance is meant for embedding, since
209 # global/local namespaces need to be handled differently in that case
209 # global/local namespaces need to be handled differently in that case
210 self.embedded = embedded
210 self.embedded = embedded
211
211
212 # command compiler
212 # command compiler
213 self.compile = codeop.CommandCompiler()
213 self.compile = codeop.CommandCompiler()
214
214
215 # User input buffer
215 # User input buffer
216 self.buffer = []
216 self.buffer = []
217
217
218 # Default name given in compilation of code
218 # Default name given in compilation of code
219 self.filename = '<ipython console>'
219 self.filename = '<ipython console>'
220
220
221 # Make an empty namespace, which extension writers can rely on both
221 # Make an empty namespace, which extension writers can rely on both
222 # existing and NEVER being used by ipython itself. This gives them a
222 # existing and NEVER being used by ipython itself. This gives them a
223 # convenient location for storing additional information and state
223 # convenient location for storing additional information and state
224 # their extensions may require, without fear of collisions with other
224 # their extensions may require, without fear of collisions with other
225 # ipython names that may develop later.
225 # ipython names that may develop later.
226 self.meta = Bunch()
226 self.meta = Bunch()
227
227
228 # Create the namespace where the user will operate. user_ns is
228 # 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
229 # 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
230 # the locals argument. But we do carry a user_global_ns namespace
231 # given as the exec 'globals' argument, This is useful in embedding
231 # given as the exec 'globals' argument, This is useful in embedding
232 # situations where the ipython shell opens in a context where the
232 # situations where the ipython shell opens in a context where the
233 # distinction between locals and globals is meaningful.
233 # distinction between locals and globals is meaningful.
234
234
235 # FIXME. For some strange reason, __builtins__ is showing up at user
235 # 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
236 # 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
237 # should really track down where the problem is coming from. Alex
238 # Schmolck reported this problem first.
238 # Schmolck reported this problem first.
239
239
240 # A useful post by Alex Martelli on this topic:
240 # A useful post by Alex Martelli on this topic:
241 # Re: inconsistent value from __builtins__
241 # Re: inconsistent value from __builtins__
242 # Von: Alex Martelli <aleaxit@yahoo.com>
242 # Von: Alex Martelli <aleaxit@yahoo.com>
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
243 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
244 # Gruppen: comp.lang.python
244 # Gruppen: comp.lang.python
245
245
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
246 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
247 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
248 # > <type 'dict'>
248 # > <type 'dict'>
249 # > >>> print type(__builtins__)
249 # > >>> print type(__builtins__)
250 # > <type 'module'>
250 # > <type 'module'>
251 # > Is this difference in return value intentional?
251 # > Is this difference in return value intentional?
252
252
253 # Well, it's documented that '__builtins__' can be either a dictionary
253 # 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
254 # 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
255 # 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
256 # that if you need to access the built-in namespace directly, you
257 # should start with "import __builtin__" (note, no 's') which will
257 # should start with "import __builtin__" (note, no 's') which will
258 # definitely give you a module. Yeah, it's somewhat confusing:-(.
258 # definitely give you a module. Yeah, it's somewhat confusing:-(.
259
259
260 if user_ns is None:
260 if user_ns is None:
261 # Set __name__ to __main__ to better match the behavior of the
261 # Set __name__ to __main__ to better match the behavior of the
262 # normal interpreter.
262 # normal interpreter.
263 user_ns = {'__name__' :'__main__',
263 user_ns = {'__name__' :'__main__',
264 '__builtins__' : __builtin__,
264 '__builtins__' : __builtin__,
265 }
265 }
266
266
267 if user_global_ns is None:
267 if user_global_ns is None:
268 user_global_ns = {}
268 user_global_ns = {}
269
269
270 # Assign namespaces
270 # Assign namespaces
271 # This is the namespace where all normal user variables live
271 # This is the namespace where all normal user variables live
272 self.user_ns = user_ns
272 self.user_ns = user_ns
273 # Embedded instances require a separate namespace for globals.
273 # Embedded instances require a separate namespace for globals.
274 # Normally this one is unused by non-embedded instances.
274 # Normally this one is unused by non-embedded instances.
275 self.user_global_ns = user_global_ns
275 self.user_global_ns = user_global_ns
276 # A namespace to keep track of internal data structures to prevent
276 # A namespace to keep track of internal data structures to prevent
277 # them from cluttering user-visible stuff. Will be updated later
277 # them from cluttering user-visible stuff. Will be updated later
278 self.internal_ns = {}
278 self.internal_ns = {}
279
279
280 # Namespace of system aliases. Each entry in the alias
280 # 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
281 # table must be a 2-tuple of the form (N,name), where N is the number
282 # of positional arguments of the alias.
282 # of positional arguments of the alias.
283 self.alias_table = {}
283 self.alias_table = {}
284
284
285 # A table holding all the namespaces IPython deals with, so that
285 # A table holding all the namespaces IPython deals with, so that
286 # introspection facilities can search easily.
286 # introspection facilities can search easily.
287 self.ns_table = {'user':user_ns,
287 self.ns_table = {'user':user_ns,
288 'user_global':user_global_ns,
288 'user_global':user_global_ns,
289 'alias':self.alias_table,
289 'alias':self.alias_table,
290 'internal':self.internal_ns,
290 'internal':self.internal_ns,
291 'builtin':__builtin__.__dict__
291 'builtin':__builtin__.__dict__
292 }
292 }
293
293
294 # The user namespace MUST have a pointer to the shell itself.
294 # The user namespace MUST have a pointer to the shell itself.
295 self.user_ns[name] = self
295 self.user_ns[name] = self
296
296
297 # We need to insert into sys.modules something that looks like a
297 # We need to insert into sys.modules something that looks like a
298 # module but which accesses the IPython namespace, for shelve and
298 # module but which accesses the IPython namespace, for shelve and
299 # pickle to work interactively. Normally they rely on getting
299 # pickle to work interactively. Normally they rely on getting
300 # everything out of __main__, but for embedding purposes each IPython
300 # everything out of __main__, but for embedding purposes each IPython
301 # instance has its own private namespace, so we can't go shoving
301 # instance has its own private namespace, so we can't go shoving
302 # everything into __main__.
302 # everything into __main__.
303
303
304 # note, however, that we should only do this for non-embedded
304 # note, however, that we should only do this for non-embedded
305 # ipythons, which really mimic the __main__.__dict__ with their own
305 # ipythons, which really mimic the __main__.__dict__ with their own
306 # namespace. Embedded instances, on the other hand, should not do
306 # namespace. Embedded instances, on the other hand, should not do
307 # this because they need to manage the user local/global namespaces
307 # this because they need to manage the user local/global namespaces
308 # only, but they live within a 'normal' __main__ (meaning, they
308 # only, but they live within a 'normal' __main__ (meaning, they
309 # shouldn't overtake the execution environment of the script they're
309 # shouldn't overtake the execution environment of the script they're
310 # embedded in).
310 # embedded in).
311
311
312 if not embedded:
312 if not embedded:
313 try:
313 try:
314 main_name = self.user_ns['__name__']
314 main_name = self.user_ns['__name__']
315 except KeyError:
315 except KeyError:
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
316 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
317 else:
317 else:
318 #print "pickle hack in place" # dbg
318 #print "pickle hack in place" # dbg
319 #print 'main_name:',main_name # dbg
319 #print 'main_name:',main_name # dbg
320 sys.modules[main_name] = FakeModule(self.user_ns)
320 sys.modules[main_name] = FakeModule(self.user_ns)
321
321
322 # List of input with multi-line handling.
322 # List of input with multi-line handling.
323 # Fill its zero entry, user counter starts at 1
323 # Fill its zero entry, user counter starts at 1
324 self.input_hist = InputList(['\n'])
324 self.input_hist = InputList(['\n'])
325
325
326 # list of visited directories
326 # list of visited directories
327 try:
327 try:
328 self.dir_hist = [os.getcwd()]
328 self.dir_hist = [os.getcwd()]
329 except IOError, e:
329 except IOError, e:
330 self.dir_hist = []
330 self.dir_hist = []
331
331
332 # dict of output history
332 # dict of output history
333 self.output_hist = {}
333 self.output_hist = {}
334
334
335 # dict of things NOT to alias (keywords, builtins and some magics)
335 # dict of things NOT to alias (keywords, builtins and some magics)
336 no_alias = {}
336 no_alias = {}
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
337 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
338 for key in keyword.kwlist + no_alias_magics:
338 for key in keyword.kwlist + no_alias_magics:
339 no_alias[key] = 1
339 no_alias[key] = 1
340 no_alias.update(__builtin__.__dict__)
340 no_alias.update(__builtin__.__dict__)
341 self.no_alias = no_alias
341 self.no_alias = no_alias
342
342
343 # make global variables for user access to these
343 # make global variables for user access to these
344 self.user_ns['_ih'] = self.input_hist
344 self.user_ns['_ih'] = self.input_hist
345 self.user_ns['_oh'] = self.output_hist
345 self.user_ns['_oh'] = self.output_hist
346 self.user_ns['_dh'] = self.dir_hist
346 self.user_ns['_dh'] = self.dir_hist
347
347
348 # user aliases to input and output histories
348 # user aliases to input and output histories
349 self.user_ns['In'] = self.input_hist
349 self.user_ns['In'] = self.input_hist
350 self.user_ns['Out'] = self.output_hist
350 self.user_ns['Out'] = self.output_hist
351
351
352 # Object variable to store code object waiting execution. This is
352 # Object variable to store code object waiting execution. This is
353 # used mainly by the multithreaded shells, but it can come in handy in
353 # 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
354 # other situations. No need to use a Queue here, since it's a single
355 # item which gets cleared once run.
355 # item which gets cleared once run.
356 self.code_to_run = None
356 self.code_to_run = None
357
357
358 # escapes for automatic behavior on the command line
358 # escapes for automatic behavior on the command line
359 self.ESC_SHELL = '!'
359 self.ESC_SHELL = '!'
360 self.ESC_HELP = '?'
360 self.ESC_HELP = '?'
361 self.ESC_MAGIC = '%'
361 self.ESC_MAGIC = '%'
362 self.ESC_QUOTE = ','
362 self.ESC_QUOTE = ','
363 self.ESC_QUOTE2 = ';'
363 self.ESC_QUOTE2 = ';'
364 self.ESC_PAREN = '/'
364 self.ESC_PAREN = '/'
365
365
366 # And their associated handlers
366 # And their associated handlers
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
367 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
368 self.ESC_QUOTE : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
369 self.ESC_QUOTE2 : self.handle_auto,
370 self.ESC_MAGIC : self.handle_magic,
370 self.ESC_MAGIC : self.handle_magic,
371 self.ESC_HELP : self.handle_help,
371 self.ESC_HELP : self.handle_help,
372 self.ESC_SHELL : self.handle_shell_escape,
372 self.ESC_SHELL : self.handle_shell_escape,
373 }
373 }
374
374
375 # class initializations
375 # class initializations
376 Magic.__init__(self,self)
376 Magic.__init__(self,self)
377
377
378 # Python source parser/formatter for syntax highlighting
378 # Python source parser/formatter for syntax highlighting
379 pyformat = PyColorize.Parser().format
379 pyformat = PyColorize.Parser().format
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
380 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
381
381
382 # hooks holds pointers used for user-side customizations
382 # hooks holds pointers used for user-side customizations
383 self.hooks = Struct()
383 self.hooks = Struct()
384
384
385 # Set all default hooks, defined in the IPython.hooks module.
385 # Set all default hooks, defined in the IPython.hooks module.
386 hooks = IPython.hooks
386 hooks = IPython.hooks
387 for hook_name in hooks.__all__:
387 for hook_name in hooks.__all__:
388 self.set_hook(hook_name,getattr(hooks,hook_name))
388 self.set_hook(hook_name,getattr(hooks,hook_name))
389
389
390 # Flag to mark unconditional exit
390 # Flag to mark unconditional exit
391 self.exit_now = False
391 self.exit_now = False
392
392
393 self.usage_min = """\
393 self.usage_min = """\
394 An enhanced console for Python.
394 An enhanced console for Python.
395 Some of its features are:
395 Some of its features are:
396 - Readline support if the readline library is present.
396 - Readline support if the readline library is present.
397 - Tab completion in the local namespace.
397 - Tab completion in the local namespace.
398 - Logging of input, see command-line options.
398 - Logging of input, see command-line options.
399 - System shell escape via ! , eg !ls.
399 - System shell escape via ! , eg !ls.
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
400 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
401 - Keeps track of locally defined variables via %who, %whos.
401 - Keeps track of locally defined variables via %who, %whos.
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
402 - Show object information with a ? eg ?x or x? (use ?? for more info).
403 """
403 """
404 if usage: self.usage = usage
404 if usage: self.usage = usage
405 else: self.usage = self.usage_min
405 else: self.usage = self.usage_min
406
406
407 # Storage
407 # Storage
408 self.rc = rc # This will hold all configuration information
408 self.rc = rc # This will hold all configuration information
409 self.pager = 'less'
409 self.pager = 'less'
410 # temporary files used for various purposes. Deleted at exit.
410 # temporary files used for various purposes. Deleted at exit.
411 self.tempfiles = []
411 self.tempfiles = []
412
412
413 # Keep track of readline usage (later set by init_readline)
413 # Keep track of readline usage (later set by init_readline)
414 self.has_readline = False
414 self.has_readline = False
415
415
416 # template for logfile headers. It gets resolved at runtime by the
416 # template for logfile headers. It gets resolved at runtime by the
417 # logstart method.
417 # logstart method.
418 self.loghead_tpl = \
418 self.loghead_tpl = \
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
419 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
420 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
421 #log# opts = %s
421 #log# opts = %s
422 #log# args = %s
422 #log# args = %s
423 #log# It is safe to make manual edits below here.
423 #log# It is safe to make manual edits below here.
424 #log#-----------------------------------------------------------------------
424 #log#-----------------------------------------------------------------------
425 """
425 """
426 # for pushd/popd management
426 # for pushd/popd management
427 try:
427 try:
428 self.home_dir = get_home_dir()
428 self.home_dir = get_home_dir()
429 except HomeDirError,msg:
429 except HomeDirError,msg:
430 fatal(msg)
430 fatal(msg)
431
431
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
432 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
433
433
434 # Functions to call the underlying shell.
434 # Functions to call the underlying shell.
435
435
436 # utility to expand user variables via Itpl
436 # utility to expand user variables via Itpl
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
437 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
438 self.user_ns))
438 self.user_ns))
439 # The first is similar to os.system, but it doesn't return a value,
439 # 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.
440 # and it allows interpolation of variables in the user's namespace.
441 self.system = lambda cmd: shell(self.var_expand(cmd),
441 self.system = lambda cmd: shell(self.var_expand(cmd),
442 header='IPython system call: ',
442 header='IPython system call: ',
443 verbose=self.rc.system_verbose)
443 verbose=self.rc.system_verbose)
444 # These are for getoutput and getoutputerror:
444 # These are for getoutput and getoutputerror:
445 self.getoutput = lambda cmd: \
445 self.getoutput = lambda cmd: \
446 getoutput(self.var_expand(cmd),
446 getoutput(self.var_expand(cmd),
447 header='IPython system call: ',
447 header='IPython system call: ',
448 verbose=self.rc.system_verbose)
448 verbose=self.rc.system_verbose)
449 self.getoutputerror = lambda cmd: \
449 self.getoutputerror = lambda cmd: \
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
450 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
451 self.user_ns)),
451 self.user_ns)),
452 header='IPython system call: ',
452 header='IPython system call: ',
453 verbose=self.rc.system_verbose)
453 verbose=self.rc.system_verbose)
454
454
455 # RegExp for splitting line contents into pre-char//first
455 # RegExp for splitting line contents into pre-char//first
456 # word-method//rest. For clarity, each group in on one line.
456 # word-method//rest. For clarity, each group in on one line.
457
457
458 # WARNING: update the regexp if the above escapes are changed, as they
458 # WARNING: update the regexp if the above escapes are changed, as they
459 # are hardwired in.
459 # are hardwired in.
460
460
461 # Don't get carried away with trying to make the autocalling catch too
461 # 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
462 # much: it's better to be conservative rather than to trigger hidden
463 # evals() somewhere and end up causing side effects.
463 # evals() somewhere and end up causing side effects.
464
464
465 self.line_split = re.compile(r'^([\s*,;/])'
465 self.line_split = re.compile(r'^([\s*,;/])'
466 r'([\?\w\.]+\w*\s*)'
466 r'([\?\w\.]+\w*\s*)'
467 r'(\(?.*$)')
467 r'(\(?.*$)')
468
468
469 # Original re, keep around for a while in case changes break something
469 # Original re, keep around for a while in case changes break something
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
470 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
471 # r'(\s*[\?\w\.]+\w*\s*)'
472 # r'(\(?.*$)')
472 # r'(\(?.*$)')
473
473
474 # RegExp to identify potential function names
474 # RegExp to identify potential function names
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
475 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
476 # RegExp to exclude strings with this start from autocalling
476 # RegExp to exclude strings with this start from autocalling
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
477 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
478
478
479 # try to catch also methods for stuff in lists/tuples/dicts: off
479 # try to catch also methods for stuff in lists/tuples/dicts: off
480 # (experimental). For this to work, the line_split regexp would need
480 # (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
481 # 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_.
482 # 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_.\[\]]*) ?$')
483 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
484
484
485 # keep track of where we started running (mainly for crash post-mortem)
485 # keep track of where we started running (mainly for crash post-mortem)
486 self.starting_dir = os.getcwd()
486 self.starting_dir = os.getcwd()
487
487
488 # Various switches which can be set
488 # Various switches which can be set
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
489 self.CACHELENGTH = 5000 # this is cheap, it's just text
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
490 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
491 self.banner2 = banner2
491 self.banner2 = banner2
492
492
493 # TraceBack handlers:
493 # TraceBack handlers:
494
494
495 # Syntax error handler.
495 # Syntax error handler.
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
496 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
497
497
498 # The interactive one is initialized with an offset, meaning we always
498 # 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
499 # want to remove the topmost item in the traceback, which is our own
500 # internal code. Valid modes: ['Plain','Context','Verbose']
500 # internal code. Valid modes: ['Plain','Context','Verbose']
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
501 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
502 color_scheme='NoColor',
502 color_scheme='NoColor',
503 tb_offset = 1)
503 tb_offset = 1)
504
504
505 # IPython itself shouldn't crash. This will produce a detailed
505 # IPython itself shouldn't crash. This will produce a detailed
506 # post-mortem if it does. But we only install the crash handler for
506 # 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
507 # non-threaded shells, the threaded ones use a normal verbose reporter
508 # and lose the crash handler. This is because exceptions in the main
508 # and lose the crash handler. This is because exceptions in the main
509 # thread (such as in GUI code) propagate directly to sys.excepthook,
509 # 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.
510 # and there's no point in printing crash dumps for every user exception.
511 if self.isthreaded:
511 if self.isthreaded:
512 sys.excepthook = ultraTB.FormattedTB()
512 sys.excepthook = ultraTB.FormattedTB()
513 else:
513 else:
514 from IPython import CrashHandler
514 from IPython import CrashHandler
515 sys.excepthook = CrashHandler.CrashHandler(self)
515 sys.excepthook = CrashHandler.CrashHandler(self)
516
516
517 # The instance will store a pointer to this, so that runtime code
517 # The instance will store a pointer to this, so that runtime code
518 # (such as magics) can access it. This is because during the
518 # (such as magics) can access it. This is because during the
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
519 # read-eval loop, it gets temporarily overwritten (to deal with GUI
520 # frameworks).
520 # frameworks).
521 self.sys_excepthook = sys.excepthook
521 self.sys_excepthook = sys.excepthook
522
522
523 # and add any custom exception handlers the user may have specified
523 # and add any custom exception handlers the user may have specified
524 self.set_custom_exc(*custom_exceptions)
524 self.set_custom_exc(*custom_exceptions)
525
525
526 # Object inspector
526 # Object inspector
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
527 self.inspector = OInspect.Inspector(OInspect.InspectColors,
528 PyColorize.ANSICodeColors,
528 PyColorize.ANSICodeColors,
529 'NoColor')
529 'NoColor')
530 # indentation management
530 # indentation management
531 self.autoindent = False
531 self.autoindent = False
532 self.indent_current_nsp = 0
532 self.indent_current_nsp = 0
533 self.indent_current = '' # actual indent string
533 self.indent_current = '' # actual indent string
534
534
535 # Make some aliases automatically
535 # Make some aliases automatically
536 # Prepare list of shell aliases to auto-define
536 # Prepare list of shell aliases to auto-define
537 if os.name == 'posix':
537 if os.name == 'posix':
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
538 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
539 'mv mv -i','rm rm -i','cp cp -i',
539 'mv mv -i','rm rm -i','cp cp -i',
540 'cat cat','less less','clear clear',
540 'cat cat','less less','clear clear',
541 # a better ls
541 # a better ls
542 'ls ls -F',
542 'ls ls -F',
543 # long ls
543 # long ls
544 'll ls -lF',
544 'll ls -lF',
545 # color ls
545 # color ls
546 'lc ls -F -o --color',
546 'lc ls -F -o --color',
547 # ls normal files only
547 # ls normal files only
548 'lf ls -F -o --color %l | grep ^-',
548 'lf ls -F -o --color %l | grep ^-',
549 # ls symbolic links
549 # ls symbolic links
550 'lk ls -F -o --color %l | grep ^l',
550 'lk ls -F -o --color %l | grep ^l',
551 # directories or links to directories,
551 # directories or links to directories,
552 'ldir ls -F -o --color %l | grep /$',
552 'ldir ls -F -o --color %l | grep /$',
553 # things which are executable
553 # things which are executable
554 'lx ls -F -o --color %l | grep ^-..x',
554 'lx ls -F -o --color %l | grep ^-..x',
555 )
555 )
556 elif os.name in ['nt','dos']:
556 elif os.name in ['nt','dos']:
557 auto_alias = ('dir dir /on', 'ls dir /on',
557 auto_alias = ('dir dir /on', 'ls dir /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
558 'ddir dir /ad /on', 'ldir dir /ad /on',
559 'mkdir mkdir','rmdir rmdir','echo echo',
559 'mkdir mkdir','rmdir rmdir','echo echo',
560 'ren ren','cls cls','copy copy')
560 'ren ren','cls cls','copy copy')
561 else:
561 else:
562 auto_alias = ()
562 auto_alias = ()
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
563 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
564 # Call the actual (public) initializer
564 # Call the actual (public) initializer
565 self.init_auto_alias()
565 self.init_auto_alias()
566 # end __init__
566 # end __init__
567
567
568 def post_config_initialization(self):
568 def post_config_initialization(self):
569 """Post configuration init method
569 """Post configuration init method
570
570
571 This is called after the configuration files have been processed to
571 This is called after the configuration files have been processed to
572 'finalize' the initialization."""
572 'finalize' the initialization."""
573
573
574 rc = self.rc
574 rc = self.rc
575
575
576 # Load readline proper
576 # Load readline proper
577 if rc.readline:
577 if rc.readline:
578 self.init_readline()
578 self.init_readline()
579
579
580 # log system
580 # log system
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
581 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
582 # local shortcut, this is used a LOT
582 # local shortcut, this is used a LOT
583 self.log = self.logger.log
583 self.log = self.logger.log
584
584
585 # Initialize cache, set in/out prompts and printing system
585 # Initialize cache, set in/out prompts and printing system
586 self.outputcache = CachedOutput(self,
586 self.outputcache = CachedOutput(self,
587 rc.cache_size,
587 rc.cache_size,
588 rc.pprint,
588 rc.pprint,
589 input_sep = rc.separate_in,
589 input_sep = rc.separate_in,
590 output_sep = rc.separate_out,
590 output_sep = rc.separate_out,
591 output_sep2 = rc.separate_out2,
591 output_sep2 = rc.separate_out2,
592 ps1 = rc.prompt_in1,
592 ps1 = rc.prompt_in1,
593 ps2 = rc.prompt_in2,
593 ps2 = rc.prompt_in2,
594 ps_out = rc.prompt_out,
594 ps_out = rc.prompt_out,
595 pad_left = rc.prompts_pad_left)
595 pad_left = rc.prompts_pad_left)
596
596
597 # user may have over-ridden the default print hook:
597 # user may have over-ridden the default print hook:
598 try:
598 try:
599 self.outputcache.__class__.display = self.hooks.display
599 self.outputcache.__class__.display = self.hooks.display
600 except AttributeError:
600 except AttributeError:
601 pass
601 pass
602
602
603 # I don't like assigning globally to sys, because it means when embedding
603 # I don't like assigning globally to sys, because it means when embedding
604 # instances, each embedded instance overrides the previous choice. But
604 # 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
605 # sys.displayhook seems to be called internally by exec, so I don't see a
606 # way around it.
606 # way around it.
607 sys.displayhook = self.outputcache
607 sys.displayhook = self.outputcache
608
608
609 # Set user colors (don't do it in the constructor above so that it
609 # Set user colors (don't do it in the constructor above so that it
610 # doesn't crash if colors option is invalid)
610 # doesn't crash if colors option is invalid)
611 self.magic_colors(rc.colors)
611 self.magic_colors(rc.colors)
612
612
613 # Set calling of pdb on exceptions
613 # Set calling of pdb on exceptions
614 self.call_pdb = rc.pdb
614 self.call_pdb = rc.pdb
615
615
616 # Load user aliases
616 # Load user aliases
617 for alias in rc.alias:
617 for alias in rc.alias:
618 self.magic_alias(alias)
618 self.magic_alias(alias)
619
619
620 # dynamic data that survives through sessions
620 # dynamic data that survives through sessions
621 # XXX make the filename a config option?
621 # XXX make the filename a config option?
622 persist_base = 'persist'
622 persist_base = 'persist'
623 if rc.profile:
623 if rc.profile:
624 persist_base += '_%s' % rc.profile
624 persist_base += '_%s' % rc.profile
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
625 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
626
626
627 try:
627 try:
628 self.persist = pickle.load(file(self.persist_fname))
628 self.persist = pickle.load(file(self.persist_fname))
629 except:
629 except:
630 self.persist = {}
630 self.persist = {}
631
631
632
632
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
633 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
634 try:
634 try:
635 obj = pickle.loads(value)
635 obj = pickle.loads(value)
636 except:
636 except:
637
637
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
638 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
639 print "The error was:",sys.exc_info()[0]
639 print "The error was:",sys.exc_info()[0]
640 continue
640 continue
641
641
642
642
643 self.user_ns[key] = obj
643 self.user_ns[key] = obj
644
644
645 def add_builtins(self):
645 def add_builtins(self):
646 """Store ipython references into the builtin namespace.
646 """Store ipython references into the builtin namespace.
647
647
648 Some parts of ipython operate via builtins injected here, which hold a
648 Some parts of ipython operate via builtins injected here, which hold a
649 reference to IPython itself."""
649 reference to IPython itself."""
650
650
651 builtins_new = dict(__IPYTHON__ = self,
651 builtins_new = dict(__IPYTHON__ = self,
652 ip_set_hook = self.set_hook,
652 ip_set_hook = self.set_hook,
653 jobs = self.jobs,
653 jobs = self.jobs,
654 ipmagic = self.ipmagic,
654 ipmagic = self.ipmagic,
655 ipalias = self.ipalias,
655 ipalias = self.ipalias,
656 ipsystem = self.ipsystem,
656 ipsystem = self.ipsystem,
657 )
657 )
658 for biname,bival in builtins_new.items():
658 for biname,bival in builtins_new.items():
659 try:
659 try:
660 # store the orignal value so we can restore it
660 # store the orignal value so we can restore it
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
661 self.builtins_added[biname] = __builtin__.__dict__[biname]
662 except KeyError:
662 except KeyError:
663 # or mark that it wasn't defined, and we'll just delete it at
663 # or mark that it wasn't defined, and we'll just delete it at
664 # cleanup
664 # cleanup
665 self.builtins_added[biname] = Undefined
665 self.builtins_added[biname] = Undefined
666 __builtin__.__dict__[biname] = bival
666 __builtin__.__dict__[biname] = bival
667
667
668 # Keep in the builtins a flag for when IPython is active. We set it
668 # 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
669 # with setdefault so that multiple nested IPythons don't clobber one
670 # another. Each will increase its value by one upon being activated,
670 # another. Each will increase its value by one upon being activated,
671 # which also gives us a way to determine the nesting level.
671 # which also gives us a way to determine the nesting level.
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
672 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
673
673
674 def clean_builtins(self):
674 def clean_builtins(self):
675 """Remove any builtins which might have been added by add_builtins, or
675 """Remove any builtins which might have been added by add_builtins, or
676 restore overwritten ones to their previous values."""
676 restore overwritten ones to their previous values."""
677 for biname,bival in self.builtins_added.items():
677 for biname,bival in self.builtins_added.items():
678 if bival is Undefined:
678 if bival is Undefined:
679 del __builtin__.__dict__[biname]
679 del __builtin__.__dict__[biname]
680 else:
680 else:
681 __builtin__.__dict__[biname] = bival
681 __builtin__.__dict__[biname] = bival
682 self.builtins_added.clear()
682 self.builtins_added.clear()
683
683
684 def set_hook(self,name,hook):
684 def set_hook(self,name,hook):
685 """set_hook(name,hook) -> sets an internal IPython hook.
685 """set_hook(name,hook) -> sets an internal IPython hook.
686
686
687 IPython exposes some of its internal API as user-modifiable hooks. By
687 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
688 resetting one of these hooks, you can modify IPython's behavior to
689 call at runtime your own routines."""
689 call at runtime your own routines."""
690
690
691 # At some point in the future, this should validate the hook before it
691 # 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
692 # accepts it. Probably at least check that the hook takes the number
693 # of args it's supposed to.
693 # of args it's supposed to.
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
694 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
695
695
696 def set_custom_exc(self,exc_tuple,handler):
696 def set_custom_exc(self,exc_tuple,handler):
697 """set_custom_exc(exc_tuple,handler)
697 """set_custom_exc(exc_tuple,handler)
698
698
699 Set a custom exception handler, which will be called if any of the
699 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
700 exceptions in exc_tuple occur in the mainloop (specifically, in the
701 runcode() method.
701 runcode() method.
702
702
703 Inputs:
703 Inputs:
704
704
705 - exc_tuple: a *tuple* of valid exceptions to call the defined
705 - 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
706 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
707 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:
708 you only want to trap a single exception, use a singleton tuple:
709
709
710 exc_tuple == (MyCustomException,)
710 exc_tuple == (MyCustomException,)
711
711
712 - handler: this must be defined as a function with the following
712 - handler: this must be defined as a function with the following
713 basic interface: def my_handler(self,etype,value,tb).
713 basic interface: def my_handler(self,etype,value,tb).
714
714
715 This will be made into an instance method (via new.instancemethod)
715 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
716 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
717 listed in the exc_tuple are caught. If the handler is None, an
718 internal basic one is used, which just prints basic info.
718 internal basic one is used, which just prints basic info.
719
719
720 WARNING: by putting in your own exception handler into IPython's main
720 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
721 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."""
722 facility should only be used if you really know what you are doing."""
723
723
724 assert type(exc_tuple)==type(()) , \
724 assert type(exc_tuple)==type(()) , \
725 "The custom exceptions must be given AS A TUPLE."
725 "The custom exceptions must be given AS A TUPLE."
726
726
727 def dummy_handler(self,etype,value,tb):
727 def dummy_handler(self,etype,value,tb):
728 print '*** Simple custom exception handler ***'
728 print '*** Simple custom exception handler ***'
729 print 'Exception type :',etype
729 print 'Exception type :',etype
730 print 'Exception value:',value
730 print 'Exception value:',value
731 print 'Traceback :',tb
731 print 'Traceback :',tb
732 print 'Source code :','\n'.join(self.buffer)
732 print 'Source code :','\n'.join(self.buffer)
733
733
734 if handler is None: handler = dummy_handler
734 if handler is None: handler = dummy_handler
735
735
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
736 self.CustomTB = new.instancemethod(handler,self,self.__class__)
737 self.custom_exceptions = exc_tuple
737 self.custom_exceptions = exc_tuple
738
738
739 def set_custom_completer(self,completer,pos=0):
739 def set_custom_completer(self,completer,pos=0):
740 """set_custom_completer(completer,pos=0)
740 """set_custom_completer(completer,pos=0)
741
741
742 Adds a new custom completer function.
742 Adds a new custom completer function.
743
743
744 The position argument (defaults to 0) is the index in the completers
744 The position argument (defaults to 0) is the index in the completers
745 list where you want the completer to be inserted."""
745 list where you want the completer to be inserted."""
746
746
747 newcomp = new.instancemethod(completer,self.Completer,
747 newcomp = new.instancemethod(completer,self.Completer,
748 self.Completer.__class__)
748 self.Completer.__class__)
749 self.Completer.matchers.insert(pos,newcomp)
749 self.Completer.matchers.insert(pos,newcomp)
750
750
751 def _get_call_pdb(self):
751 def _get_call_pdb(self):
752 return self._call_pdb
752 return self._call_pdb
753
753
754 def _set_call_pdb(self,val):
754 def _set_call_pdb(self,val):
755
755
756 if val not in (0,1,False,True):
756 if val not in (0,1,False,True):
757 raise ValueError,'new call_pdb value must be boolean'
757 raise ValueError,'new call_pdb value must be boolean'
758
758
759 # store value in instance
759 # store value in instance
760 self._call_pdb = val
760 self._call_pdb = val
761
761
762 # notify the actual exception handlers
762 # notify the actual exception handlers
763 self.InteractiveTB.call_pdb = val
763 self.InteractiveTB.call_pdb = val
764 if self.isthreaded:
764 if self.isthreaded:
765 try:
765 try:
766 self.sys_excepthook.call_pdb = val
766 self.sys_excepthook.call_pdb = val
767 except:
767 except:
768 warn('Failed to activate pdb for threaded exception handler')
768 warn('Failed to activate pdb for threaded exception handler')
769
769
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
770 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
771 'Control auto-activation of pdb at exceptions')
771 'Control auto-activation of pdb at exceptions')
772
772
773
773
774 # These special functions get installed in the builtin namespace, to
774 # These special functions get installed in the builtin namespace, to
775 # provide programmatic (pure python) access to magics, aliases and system
775 # provide programmatic (pure python) access to magics, aliases and system
776 # calls. This is important for logging, user scripting, and more.
776 # calls. This is important for logging, user scripting, and more.
777
777
778 # We are basically exposing, via normal python functions, the three
778 # We are basically exposing, via normal python functions, the three
779 # mechanisms in which ipython offers special call modes (magics for
779 # mechanisms in which ipython offers special call modes (magics for
780 # internal control, aliases for direct system access via pre-selected
780 # internal control, aliases for direct system access via pre-selected
781 # names, and !cmd for calling arbitrary system commands).
781 # names, and !cmd for calling arbitrary system commands).
782
782
783 def ipmagic(self,arg_s):
783 def ipmagic(self,arg_s):
784 """Call a magic function by name.
784 """Call a magic function by name.
785
785
786 Input: a string containing the name of the magic function to call and any
786 Input: a string containing the name of the magic function to call and any
787 additional arguments to be passed to the magic.
787 additional arguments to be passed to the magic.
788
788
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
789 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
790 prompt:
790 prompt:
791
791
792 In[1]: %name -opt foo bar
792 In[1]: %name -opt foo bar
793
793
794 To call a magic without arguments, simply use ipmagic('name').
794 To call a magic without arguments, simply use ipmagic('name').
795
795
796 This provides a proper Python function to call IPython's magics in any
796 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
797 valid Python code you can type at the interpreter, including loops and
798 compound statements. It is added by IPython to the Python builtin
798 compound statements. It is added by IPython to the Python builtin
799 namespace upon initialization."""
799 namespace upon initialization."""
800
800
801 args = arg_s.split(' ',1)
801 args = arg_s.split(' ',1)
802 magic_name = args[0]
802 magic_name = args[0]
803 if magic_name.startswith(self.ESC_MAGIC):
803 if magic_name.startswith(self.ESC_MAGIC):
804 magic_name = magic_name[1:]
804 magic_name = magic_name[1:]
805 try:
805 try:
806 magic_args = args[1]
806 magic_args = args[1]
807 except IndexError:
807 except IndexError:
808 magic_args = ''
808 magic_args = ''
809 fn = getattr(self,'magic_'+magic_name,None)
809 fn = getattr(self,'magic_'+magic_name,None)
810 if fn is None:
810 if fn is None:
811 error("Magic function `%s` not found." % magic_name)
811 error("Magic function `%s` not found." % magic_name)
812 else:
812 else:
813 magic_args = self.var_expand(magic_args)
813 magic_args = self.var_expand(magic_args)
814 return fn(magic_args)
814 return fn(magic_args)
815
815
816 def ipalias(self,arg_s):
816 def ipalias(self,arg_s):
817 """Call an alias by name.
817 """Call an alias by name.
818
818
819 Input: a string containing the name of the alias to call and any
819 Input: a string containing the name of the alias to call and any
820 additional arguments to be passed to the magic.
820 additional arguments to be passed to the magic.
821
821
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
822 ipalias('name -opt foo bar') is equivalent to typing at the ipython
823 prompt:
823 prompt:
824
824
825 In[1]: name -opt foo bar
825 In[1]: name -opt foo bar
826
826
827 To call an alias without arguments, simply use ipalias('name').
827 To call an alias without arguments, simply use ipalias('name').
828
828
829 This provides a proper Python function to call IPython's aliases in any
829 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
830 valid Python code you can type at the interpreter, including loops and
831 compound statements. It is added by IPython to the Python builtin
831 compound statements. It is added by IPython to the Python builtin
832 namespace upon initialization."""
832 namespace upon initialization."""
833
833
834 args = arg_s.split(' ',1)
834 args = arg_s.split(' ',1)
835 alias_name = args[0]
835 alias_name = args[0]
836 try:
836 try:
837 alias_args = args[1]
837 alias_args = args[1]
838 except IndexError:
838 except IndexError:
839 alias_args = ''
839 alias_args = ''
840 if alias_name in self.alias_table:
840 if alias_name in self.alias_table:
841 self.call_alias(alias_name,alias_args)
841 self.call_alias(alias_name,alias_args)
842 else:
842 else:
843 error("Alias `%s` not found." % alias_name)
843 error("Alias `%s` not found." % alias_name)
844
844
845 def ipsystem(self,arg_s):
845 def ipsystem(self,arg_s):
846 """Make a system call, using IPython."""
846 """Make a system call, using IPython."""
847
847
848 self.system(arg_s)
848 self.system(arg_s)
849
849
850 def complete(self,text):
850 def complete(self,text):
851 """Return a sorted list of all possible completions on text.
851 """Return a sorted list of all possible completions on text.
852
852
853 Inputs:
853 Inputs:
854
854
855 - text: a string of text to be completed on.
855 - text: a string of text to be completed on.
856
856
857 This is a wrapper around the completion mechanism, similar to what
857 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
858 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
859 exposing it as a method, it can be used by other non-readline
860 environments (such as GUIs) for text completion.
860 environments (such as GUIs) for text completion.
861
861
862 Simple usage example:
862 Simple usage example:
863
863
864 In [1]: x = 'hello'
864 In [1]: x = 'hello'
865
865
866 In [2]: __IP.complete('x.l')
866 In [2]: __IP.complete('x.l')
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
867 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
868
868
869 complete = self.Completer.complete
869 complete = self.Completer.complete
870 state = 0
870 state = 0
871 # use a dict so we get unique keys, since ipyhton's multiple
871 # use a dict so we get unique keys, since ipyhton's multiple
872 # completers can return duplicates.
872 # completers can return duplicates.
873 comps = {}
873 comps = {}
874 while True:
874 while True:
875 newcomp = complete(text,state)
875 newcomp = complete(text,state)
876 if newcomp is None:
876 if newcomp is None:
877 break
877 break
878 comps[newcomp] = 1
878 comps[newcomp] = 1
879 state += 1
879 state += 1
880 outcomps = comps.keys()
880 outcomps = comps.keys()
881 outcomps.sort()
881 outcomps.sort()
882 return outcomps
882 return outcomps
883
883
884 def set_completer_frame(self, frame=None):
884 def set_completer_frame(self, frame=None):
885 if frame:
885 if frame:
886 self.Completer.namespace = frame.f_locals
886 self.Completer.namespace = frame.f_locals
887 self.Completer.global_namespace = frame.f_globals
887 self.Completer.global_namespace = frame.f_globals
888 else:
888 else:
889 self.Completer.namespace = self.user_ns
889 self.Completer.namespace = self.user_ns
890 self.Completer.global_namespace = self.user_global_ns
890 self.Completer.global_namespace = self.user_global_ns
891
891
892 def init_auto_alias(self):
892 def init_auto_alias(self):
893 """Define some aliases automatically.
893 """Define some aliases automatically.
894
894
895 These are ALL parameter-less aliases"""
895 These are ALL parameter-less aliases"""
896
896
897 for alias,cmd in self.auto_alias:
897 for alias,cmd in self.auto_alias:
898 self.alias_table[alias] = (0,cmd)
898 self.alias_table[alias] = (0,cmd)
899
899
900 def alias_table_validate(self,verbose=0):
900 def alias_table_validate(self,verbose=0):
901 """Update information about the alias table.
901 """Update information about the alias table.
902
902
903 In particular, make sure no Python keywords/builtins are in it."""
903 In particular, make sure no Python keywords/builtins are in it."""
904
904
905 no_alias = self.no_alias
905 no_alias = self.no_alias
906 for k in self.alias_table.keys():
906 for k in self.alias_table.keys():
907 if k in no_alias:
907 if k in no_alias:
908 del self.alias_table[k]
908 del self.alias_table[k]
909 if verbose:
909 if verbose:
910 print ("Deleting alias <%s>, it's a Python "
910 print ("Deleting alias <%s>, it's a Python "
911 "keyword or builtin." % k)
911 "keyword or builtin." % k)
912
912
913 def set_autoindent(self,value=None):
913 def set_autoindent(self,value=None):
914 """Set the autoindent flag, checking for readline support.
914 """Set the autoindent flag, checking for readline support.
915
915
916 If called with no arguments, it acts as a toggle."""
916 If called with no arguments, it acts as a toggle."""
917
917
918 if not self.has_readline:
918 if not self.has_readline:
919 if os.name == 'posix':
919 if os.name == 'posix':
920 warn("The auto-indent feature requires the readline library")
920 warn("The auto-indent feature requires the readline library")
921 self.autoindent = 0
921 self.autoindent = 0
922 return
922 return
923 if value is None:
923 if value is None:
924 self.autoindent = not self.autoindent
924 self.autoindent = not self.autoindent
925 else:
925 else:
926 self.autoindent = value
926 self.autoindent = value
927
927
928 def rc_set_toggle(self,rc_field,value=None):
928 def rc_set_toggle(self,rc_field,value=None):
929 """Set or toggle a field in IPython's rc config. structure.
929 """Set or toggle a field in IPython's rc config. structure.
930
930
931 If called with no arguments, it acts as a toggle.
931 If called with no arguments, it acts as a toggle.
932
932
933 If called with a non-existent field, the resulting AttributeError
933 If called with a non-existent field, the resulting AttributeError
934 exception will propagate out."""
934 exception will propagate out."""
935
935
936 rc_val = getattr(self.rc,rc_field)
936 rc_val = getattr(self.rc,rc_field)
937 if value is None:
937 if value is None:
938 value = not rc_val
938 value = not rc_val
939 setattr(self.rc,rc_field,value)
939 setattr(self.rc,rc_field,value)
940
940
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
941 def user_setup(self,ipythondir,rc_suffix,mode='install'):
942 """Install the user configuration directory.
942 """Install the user configuration directory.
943
943
944 Can be called when running for the first time or to upgrade the user's
944 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'
945 .ipython/ directory with the mode parameter. Valid modes are 'install'
946 and 'upgrade'."""
946 and 'upgrade'."""
947
947
948 def wait():
948 def wait():
949 try:
949 try:
950 raw_input("Please press <RETURN> to start IPython.")
950 raw_input("Please press <RETURN> to start IPython.")
951 except EOFError:
951 except EOFError:
952 print >> Term.cout
952 print >> Term.cout
953 print '*'*70
953 print '*'*70
954
954
955 cwd = os.getcwd() # remember where we started
955 cwd = os.getcwd() # remember where we started
956 glb = glob.glob
956 glb = glob.glob
957 print '*'*70
957 print '*'*70
958 if mode == 'install':
958 if mode == 'install':
959 print \
959 print \
960 """Welcome to IPython. I will try to create a personal configuration directory
960 """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"""
961 where you can customize many aspects of IPython's functionality in:\n"""
962 else:
962 else:
963 print 'I am going to upgrade your configuration in:'
963 print 'I am going to upgrade your configuration in:'
964
964
965 print ipythondir
965 print ipythondir
966
966
967 rcdirend = os.path.join('IPython','UserConfig')
967 rcdirend = os.path.join('IPython','UserConfig')
968 cfg = lambda d: os.path.join(d,rcdirend)
968 cfg = lambda d: os.path.join(d,rcdirend)
969 try:
969 try:
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
970 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
971 except IOError:
971 except IOError:
972 warning = """
972 warning = """
973 Installation error. IPython's directory was not found.
973 Installation error. IPython's directory was not found.
974
974
975 Check the following:
975 Check the following:
976
976
977 The ipython/IPython directory should be in a directory belonging to your
977 The ipython/IPython directory should be in a directory belonging to your
978 PYTHONPATH environment variable (that is, it should be in a directory
978 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.
979 belonging to sys.path). You can copy it explicitly there or just link to it.
980
980
981 IPython will proceed with builtin defaults.
981 IPython will proceed with builtin defaults.
982 """
982 """
983 warn(warning)
983 warn(warning)
984 wait()
984 wait()
985 return
985 return
986
986
987 if mode == 'install':
987 if mode == 'install':
988 try:
988 try:
989 shutil.copytree(rcdir,ipythondir)
989 shutil.copytree(rcdir,ipythondir)
990 os.chdir(ipythondir)
990 os.chdir(ipythondir)
991 rc_files = glb("ipythonrc*")
991 rc_files = glb("ipythonrc*")
992 for rc_file in rc_files:
992 for rc_file in rc_files:
993 os.rename(rc_file,rc_file+rc_suffix)
993 os.rename(rc_file,rc_file+rc_suffix)
994 except:
994 except:
995 warning = """
995 warning = """
996
996
997 There was a problem with the installation:
997 There was a problem with the installation:
998 %s
998 %s
999 Try to correct it or contact the developers if you think it's a bug.
999 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]
1000 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1001 warn(warning)
1001 warn(warning)
1002 wait()
1002 wait()
1003 return
1003 return
1004
1004
1005 elif mode == 'upgrade':
1005 elif mode == 'upgrade':
1006 try:
1006 try:
1007 os.chdir(ipythondir)
1007 os.chdir(ipythondir)
1008 except:
1008 except:
1009 print """
1009 print """
1010 Can not upgrade: changing to directory %s failed. Details:
1010 Can not upgrade: changing to directory %s failed. Details:
1011 %s
1011 %s
1012 """ % (ipythondir,sys.exc_info()[1])
1012 """ % (ipythondir,sys.exc_info()[1])
1013 wait()
1013 wait()
1014 return
1014 return
1015 else:
1015 else:
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1016 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1017 for new_full_path in sources:
1017 for new_full_path in sources:
1018 new_filename = os.path.basename(new_full_path)
1018 new_filename = os.path.basename(new_full_path)
1019 if new_filename.startswith('ipythonrc'):
1019 if new_filename.startswith('ipythonrc'):
1020 new_filename = new_filename + rc_suffix
1020 new_filename = new_filename + rc_suffix
1021 # The config directory should only contain files, skip any
1021 # The config directory should only contain files, skip any
1022 # directories which may be there (like CVS)
1022 # directories which may be there (like CVS)
1023 if os.path.isdir(new_full_path):
1023 if os.path.isdir(new_full_path):
1024 continue
1024 continue
1025 if os.path.exists(new_filename):
1025 if os.path.exists(new_filename):
1026 old_file = new_filename+'.old'
1026 old_file = new_filename+'.old'
1027 if os.path.exists(old_file):
1027 if os.path.exists(old_file):
1028 os.remove(old_file)
1028 os.remove(old_file)
1029 os.rename(new_filename,old_file)
1029 os.rename(new_filename,old_file)
1030 shutil.copy(new_full_path,new_filename)
1030 shutil.copy(new_full_path,new_filename)
1031 else:
1031 else:
1032 raise ValueError,'unrecognized mode for install:',`mode`
1032 raise ValueError,'unrecognized mode for install:',`mode`
1033
1033
1034 # Fix line-endings to those native to each platform in the config
1034 # Fix line-endings to those native to each platform in the config
1035 # directory.
1035 # directory.
1036 try:
1036 try:
1037 os.chdir(ipythondir)
1037 os.chdir(ipythondir)
1038 except:
1038 except:
1039 print """
1039 print """
1040 Problem: changing to directory %s failed.
1040 Problem: changing to directory %s failed.
1041 Details:
1041 Details:
1042 %s
1042 %s
1043
1043
1044 Some configuration files may have incorrect line endings. This should not
1044 Some configuration files may have incorrect line endings. This should not
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1045 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1046 wait()
1046 wait()
1047 else:
1047 else:
1048 for fname in glb('ipythonrc*'):
1048 for fname in glb('ipythonrc*'):
1049 try:
1049 try:
1050 native_line_ends(fname,backup=0)
1050 native_line_ends(fname,backup=0)
1051 except IOError:
1051 except IOError:
1052 pass
1052 pass
1053
1053
1054 if mode == 'install':
1054 if mode == 'install':
1055 print """
1055 print """
1056 Successful installation!
1056 Successful installation!
1057
1057
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1058 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1059 IPython manual (there are both HTML and PDF versions supplied with the
1060 distribution) to make sure that your system environment is properly configured
1060 distribution) to make sure that your system environment is properly configured
1061 to take advantage of IPython's features."""
1061 to take advantage of IPython's features."""
1062 else:
1062 else:
1063 print """
1063 print """
1064 Successful upgrade!
1064 Successful upgrade!
1065
1065
1066 All files in your directory:
1066 All files in your directory:
1067 %(ipythondir)s
1067 %(ipythondir)s
1068 which would have been overwritten by the upgrade were backed up with a .old
1068 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
1069 extension. If you had made particular customizations in those files you may
1070 want to merge them back into the new files.""" % locals()
1070 want to merge them back into the new files.""" % locals()
1071 wait()
1071 wait()
1072 os.chdir(cwd)
1072 os.chdir(cwd)
1073 # end user_setup()
1073 # end user_setup()
1074
1074
1075 def atexit_operations(self):
1075 def atexit_operations(self):
1076 """This will be executed at the time of exit.
1076 """This will be executed at the time of exit.
1077
1077
1078 Saving of persistent data should be performed here. """
1078 Saving of persistent data should be performed here. """
1079
1079
1080 # input history
1080 # input history
1081 self.savehist()
1081 self.savehist()
1082
1082
1083 # Cleanup all tempfiles left around
1083 # Cleanup all tempfiles left around
1084 for tfile in self.tempfiles:
1084 for tfile in self.tempfiles:
1085 try:
1085 try:
1086 os.unlink(tfile)
1086 os.unlink(tfile)
1087 except OSError:
1087 except OSError:
1088 pass
1088 pass
1089
1089
1090 # save the "persistent data" catch-all dictionary
1090 # save the "persistent data" catch-all dictionary
1091 try:
1091 try:
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1092 pickle.dump(self.persist, open(self.persist_fname,"w"))
1093 except:
1093 except:
1094 print "*** ERROR *** persistent data saving failed."
1094 print "*** ERROR *** persistent data saving failed."
1095
1095
1096 def savehist(self):
1096 def savehist(self):
1097 """Save input history to a file (via readline library)."""
1097 """Save input history to a file (via readline library)."""
1098 try:
1098 try:
1099 self.readline.write_history_file(self.histfile)
1099 self.readline.write_history_file(self.histfile)
1100 except:
1100 except:
1101 print 'Unable to save IPython command history to file: ' + \
1101 print 'Unable to save IPython command history to file: ' + \
1102 `self.histfile`
1102 `self.histfile`
1103
1103
1104 def pre_readline(self):
1104 def pre_readline(self):
1105 """readline hook to be used at the start of each line.
1105 """readline hook to be used at the start of each line.
1106
1106
1107 Currently it handles auto-indent only."""
1107 Currently it handles auto-indent only."""
1108
1108
1109 self.readline.insert_text(self.indent_current)
1109 self.readline.insert_text(self.indent_current)
1110
1110
1111 def init_readline(self):
1111 def init_readline(self):
1112 """Command history completion/saving/reloading."""
1112 """Command history completion/saving/reloading."""
1113 try:
1113 try:
1114 import readline
1114 import readline
1115 except ImportError:
1115 except ImportError:
1116 self.has_readline = 0
1116 self.has_readline = 0
1117 self.readline = None
1117 self.readline = None
1118 # no point in bugging windows users with this every time:
1118 # no point in bugging windows users with this every time:
1119 if os.name == 'posix':
1119 if os.name == 'posix':
1120 warn('Readline services not available on this platform.')
1120 warn('Readline services not available on this platform.')
1121 else:
1121 else:
1122 import atexit
1122 import atexit
1123 from IPython.completer import IPCompleter
1123 from IPython.completer import IPCompleter
1124 self.Completer = IPCompleter(self,
1124 self.Completer = IPCompleter(self,
1125 self.user_ns,
1125 self.user_ns,
1126 self.user_global_ns,
1126 self.user_global_ns,
1127 self.rc.readline_omit__names,
1127 self.rc.readline_omit__names,
1128 self.alias_table)
1128 self.alias_table)
1129
1129
1130 # Platform-specific configuration
1130 # Platform-specific configuration
1131 if os.name == 'nt':
1131 if os.name == 'nt':
1132 self.readline_startup_hook = readline.set_pre_input_hook
1132 self.readline_startup_hook = readline.set_pre_input_hook
1133 else:
1133 else:
1134 self.readline_startup_hook = readline.set_startup_hook
1134 self.readline_startup_hook = readline.set_startup_hook
1135
1135
1136 # Load user's initrc file (readline config)
1136 # Load user's initrc file (readline config)
1137 inputrc_name = os.environ.get('INPUTRC')
1137 inputrc_name = os.environ.get('INPUTRC')
1138 if inputrc_name is None:
1138 if inputrc_name is None:
1139 home_dir = get_home_dir()
1139 home_dir = get_home_dir()
1140 if home_dir is not None:
1140 if home_dir is not None:
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1141 inputrc_name = os.path.join(home_dir,'.inputrc')
1142 if os.path.isfile(inputrc_name):
1142 if os.path.isfile(inputrc_name):
1143 try:
1143 try:
1144 readline.read_init_file(inputrc_name)
1144 readline.read_init_file(inputrc_name)
1145 except:
1145 except:
1146 warn('Problems reading readline initialization file <%s>'
1146 warn('Problems reading readline initialization file <%s>'
1147 % inputrc_name)
1147 % inputrc_name)
1148
1148
1149 self.has_readline = 1
1149 self.has_readline = 1
1150 self.readline = readline
1150 self.readline = readline
1151 # save this in sys so embedded copies can restore it properly
1151 # save this in sys so embedded copies can restore it properly
1152 sys.ipcompleter = self.Completer.complete
1152 sys.ipcompleter = self.Completer.complete
1153 readline.set_completer(self.Completer.complete)
1153 readline.set_completer(self.Completer.complete)
1154
1154
1155 # Configure readline according to user's prefs
1155 # Configure readline according to user's prefs
1156 for rlcommand in self.rc.readline_parse_and_bind:
1156 for rlcommand in self.rc.readline_parse_and_bind:
1157 readline.parse_and_bind(rlcommand)
1157 readline.parse_and_bind(rlcommand)
1158
1158
1159 # remove some chars from the delimiters list
1159 # remove some chars from the delimiters list
1160 delims = readline.get_completer_delims()
1160 delims = readline.get_completer_delims()
1161 delims = delims.translate(string._idmap,
1161 delims = delims.translate(string._idmap,
1162 self.rc.readline_remove_delims)
1162 self.rc.readline_remove_delims)
1163 readline.set_completer_delims(delims)
1163 readline.set_completer_delims(delims)
1164 # otherwise we end up with a monster history after a while:
1164 # otherwise we end up with a monster history after a while:
1165 readline.set_history_length(1000)
1165 readline.set_history_length(1000)
1166 try:
1166 try:
1167 #print '*** Reading readline history' # dbg
1167 #print '*** Reading readline history' # dbg
1168 readline.read_history_file(self.histfile)
1168 readline.read_history_file(self.histfile)
1169 except IOError:
1169 except IOError:
1170 pass # It doesn't exist yet.
1170 pass # It doesn't exist yet.
1171
1171
1172 atexit.register(self.atexit_operations)
1172 atexit.register(self.atexit_operations)
1173 del atexit
1173 del atexit
1174
1174
1175 # Configure auto-indent for all platforms
1175 # Configure auto-indent for all platforms
1176 self.set_autoindent(self.rc.autoindent)
1176 self.set_autoindent(self.rc.autoindent)
1177
1177
1178 def _should_recompile(self,e):
1178 def _should_recompile(self,e):
1179 """Utility routine for edit_syntax_error"""
1179 """Utility routine for edit_syntax_error"""
1180
1180
1181 if e.filename in ('<ipython console>','<input>','<string>',
1181 if e.filename in ('<ipython console>','<input>','<string>',
1182 '<console>',None):
1182 '<console>',None):
1183
1183 return False
1184 return False
1184 try:
1185 try:
1185 if not ask_yes_no('Return to editor to correct syntax error? '
1186 if not ask_yes_no('Return to editor to correct syntax error? '
1186 '[Y/n] ','y'):
1187 '[Y/n] ','y'):
1187 return False
1188 return False
1188 except EOFError:
1189 except EOFError:
1189 return False
1190 return False
1190
1191
1191 def int0(x):
1192 def int0(x):
1192 try:
1193 try:
1193 return int(x)
1194 return int(x)
1194 except TypeError:
1195 except TypeError:
1195 return 0
1196 return 0
1196 # always pass integer line and offset values to editor hook
1197 # always pass integer line and offset values to editor hook
1197 self.hooks.fix_error_editor(e.filename,
1198 self.hooks.fix_error_editor(e.filename,
1198 int0(e.lineno),int0(e.offset),e.msg)
1199 int0(e.lineno),int0(e.offset),e.msg)
1199 return True
1200 return True
1200
1201
1201 def edit_syntax_error(self):
1202 def edit_syntax_error(self):
1202 """The bottom half of the syntax error handler called in the main loop.
1203 """The bottom half of the syntax error handler called in the main loop.
1203
1204
1204 Loop until syntax error is fixed or user cancels.
1205 Loop until syntax error is fixed or user cancels.
1205 """
1206 """
1206
1207
1207 while self.SyntaxTB.last_syntax_error:
1208 while self.SyntaxTB.last_syntax_error:
1208 # copy and clear last_syntax_error
1209 # copy and clear last_syntax_error
1209 err = self.SyntaxTB.clear_err_state()
1210 err = self.SyntaxTB.clear_err_state()
1210 if not self._should_recompile(err):
1211 if not self._should_recompile(err):
1211 return
1212 return
1212 try:
1213 try:
1213 # may set last_syntax_error again if a SyntaxError is raised
1214 # may set last_syntax_error again if a SyntaxError is raised
1214 self.safe_execfile(err.filename,self.shell.user_ns)
1215 self.safe_execfile(err.filename,self.shell.user_ns)
1215 except:
1216 except:
1216 self.showtraceback()
1217 self.showtraceback()
1217 else:
1218 else:
1218 f = file(err.filename)
1219 f = file(err.filename)
1219 try:
1220 try:
1220 sys.displayhook(f.read())
1221 sys.displayhook(f.read())
1221 finally:
1222 finally:
1222 f.close()
1223 f.close()
1223
1224
1224 def showsyntaxerror(self, filename=None):
1225 def showsyntaxerror(self, filename=None):
1225 """Display the syntax error that just occurred.
1226 """Display the syntax error that just occurred.
1226
1227
1227 This doesn't display a stack trace because there isn't one.
1228 This doesn't display a stack trace because there isn't one.
1228
1229
1229 If a filename is given, it is stuffed in the exception instead
1230 If a filename is given, it is stuffed in the exception instead
1230 of what was there before (because Python's parser always uses
1231 of what was there before (because Python's parser always uses
1231 "<string>" when reading from a string).
1232 "<string>" when reading from a string).
1232 """
1233 """
1233 etype, value, last_traceback = sys.exc_info()
1234 etype, value, last_traceback = sys.exc_info()
1234 if filename and etype is SyntaxError:
1235 if filename and etype is SyntaxError:
1235 # Work hard to stuff the correct filename in the exception
1236 # Work hard to stuff the correct filename in the exception
1236 try:
1237 try:
1237 msg, (dummy_filename, lineno, offset, line) = value
1238 msg, (dummy_filename, lineno, offset, line) = value
1238 except:
1239 except:
1239 # Not the format we expect; leave it alone
1240 # Not the format we expect; leave it alone
1240 pass
1241 pass
1241 else:
1242 else:
1242 # Stuff in the right filename
1243 # Stuff in the right filename
1243 try:
1244 try:
1244 # Assume SyntaxError is a class exception
1245 # Assume SyntaxError is a class exception
1245 value = SyntaxError(msg, (filename, lineno, offset, line))
1246 value = SyntaxError(msg, (filename, lineno, offset, line))
1246 except:
1247 except:
1247 # If that failed, assume SyntaxError is a string
1248 # If that failed, assume SyntaxError is a string
1248 value = msg, (filename, lineno, offset, line)
1249 value = msg, (filename, lineno, offset, line)
1249 self.SyntaxTB(etype,value,[])
1250 self.SyntaxTB(etype,value,[])
1250
1251
1251 def debugger(self):
1252 def debugger(self):
1252 """Call the pdb debugger."""
1253 """Call the pdb debugger."""
1253
1254
1254 if not self.rc.pdb:
1255 if not self.rc.pdb:
1255 return
1256 return
1256 pdb.pm()
1257 pdb.pm()
1257
1258
1258 def showtraceback(self,exc_tuple = None,filename=None):
1259 def showtraceback(self,exc_tuple = None,filename=None):
1259 """Display the exception that just occurred."""
1260 """Display the exception that just occurred."""
1260
1261
1261 # Though this won't be called by syntax errors in the input line,
1262 # Though this won't be called by syntax errors in the input line,
1262 # there may be SyntaxError cases whith imported code.
1263 # there may be SyntaxError cases whith imported code.
1263 if exc_tuple is None:
1264 if exc_tuple is None:
1264 type, value, tb = sys.exc_info()
1265 type, value, tb = sys.exc_info()
1265 else:
1266 else:
1266 type, value, tb = exc_tuple
1267 type, value, tb = exc_tuple
1267 if type is SyntaxError:
1268 if type is SyntaxError:
1268 self.showsyntaxerror(filename)
1269 self.showsyntaxerror(filename)
1269 else:
1270 else:
1270 self.InteractiveTB()
1271 self.InteractiveTB()
1271 if self.InteractiveTB.call_pdb and self.has_readline:
1272 if self.InteractiveTB.call_pdb and self.has_readline:
1272 # pdb mucks up readline, fix it back
1273 # pdb mucks up readline, fix it back
1273 self.readline.set_completer(self.Completer.complete)
1274 self.readline.set_completer(self.Completer.complete)
1274
1275
1275 def mainloop(self,banner=None):
1276 def mainloop(self,banner=None):
1276 """Creates the local namespace and starts the mainloop.
1277 """Creates the local namespace and starts the mainloop.
1277
1278
1278 If an optional banner argument is given, it will override the
1279 If an optional banner argument is given, it will override the
1279 internally created default banner."""
1280 internally created default banner."""
1280
1281
1281 if self.rc.c: # Emulate Python's -c option
1282 if self.rc.c: # Emulate Python's -c option
1282 self.exec_init_cmd()
1283 self.exec_init_cmd()
1283 if banner is None:
1284 if banner is None:
1284 if self.rc.banner:
1285 if self.rc.banner:
1285 banner = self.BANNER+self.banner2
1286 banner = self.BANNER+self.banner2
1286 else:
1287 else:
1287 banner = ''
1288 banner = ''
1288 self.interact(banner)
1289 self.interact(banner)
1289
1290
1290 def exec_init_cmd(self):
1291 def exec_init_cmd(self):
1291 """Execute a command given at the command line.
1292 """Execute a command given at the command line.
1292
1293
1293 This emulates Python's -c option."""
1294 This emulates Python's -c option."""
1294
1295
1295 sys.argv = ['-c']
1296 sys.argv = ['-c']
1296 self.push(self.rc.c)
1297 self.push(self.rc.c)
1297
1298
1298 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1299 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1299 """Embeds IPython into a running python program.
1300 """Embeds IPython into a running python program.
1300
1301
1301 Input:
1302 Input:
1302
1303
1303 - header: An optional header message can be specified.
1304 - header: An optional header message can be specified.
1304
1305
1305 - local_ns, global_ns: working namespaces. If given as None, the
1306 - local_ns, global_ns: working namespaces. If given as None, the
1306 IPython-initialized one is updated with __main__.__dict__, so that
1307 IPython-initialized one is updated with __main__.__dict__, so that
1307 program variables become visible but user-specific configuration
1308 program variables become visible but user-specific configuration
1308 remains possible.
1309 remains possible.
1309
1310
1310 - stack_depth: specifies how many levels in the stack to go to
1311 - stack_depth: specifies how many levels in the stack to go to
1311 looking for namespaces (when local_ns and global_ns are None). This
1312 looking for namespaces (when local_ns and global_ns are None). This
1312 allows an intermediate caller to make sure that this function gets
1313 allows an intermediate caller to make sure that this function gets
1313 the namespace from the intended level in the stack. By default (0)
1314 the namespace from the intended level in the stack. By default (0)
1314 it will get its locals and globals from the immediate caller.
1315 it will get its locals and globals from the immediate caller.
1315
1316
1316 Warning: it's possible to use this in a program which is being run by
1317 Warning: it's possible to use this in a program which is being run by
1317 IPython itself (via %run), but some funny things will happen (a few
1318 IPython itself (via %run), but some funny things will happen (a few
1318 globals get overwritten). In the future this will be cleaned up, as
1319 globals get overwritten). In the future this will be cleaned up, as
1319 there is no fundamental reason why it can't work perfectly."""
1320 there is no fundamental reason why it can't work perfectly."""
1320
1321
1321 # Get locals and globals from caller
1322 # Get locals and globals from caller
1322 if local_ns is None or global_ns is None:
1323 if local_ns is None or global_ns is None:
1323 call_frame = sys._getframe(stack_depth).f_back
1324 call_frame = sys._getframe(stack_depth).f_back
1324
1325
1325 if local_ns is None:
1326 if local_ns is None:
1326 local_ns = call_frame.f_locals
1327 local_ns = call_frame.f_locals
1327 if global_ns is None:
1328 if global_ns is None:
1328 global_ns = call_frame.f_globals
1329 global_ns = call_frame.f_globals
1329
1330
1330 # Update namespaces and fire up interpreter
1331 # Update namespaces and fire up interpreter
1331
1332
1332 # The global one is easy, we can just throw it in
1333 # The global one is easy, we can just throw it in
1333 self.user_global_ns = global_ns
1334 self.user_global_ns = global_ns
1334
1335
1335 # but the user/local one is tricky: ipython needs it to store internal
1336 # but the user/local one is tricky: ipython needs it to store internal
1336 # data, but we also need the locals. We'll copy locals in the user
1337 # data, but we also need the locals. We'll copy locals in the user
1337 # one, but will track what got copied so we can delete them at exit.
1338 # one, but will track what got copied so we can delete them at exit.
1338 # This is so that a later embedded call doesn't see locals from a
1339 # This is so that a later embedded call doesn't see locals from a
1339 # previous call (which most likely existed in a separate scope).
1340 # previous call (which most likely existed in a separate scope).
1340 local_varnames = local_ns.keys()
1341 local_varnames = local_ns.keys()
1341 self.user_ns.update(local_ns)
1342 self.user_ns.update(local_ns)
1342
1343
1343 # Patch for global embedding to make sure that things don't overwrite
1344 # Patch for global embedding to make sure that things don't overwrite
1344 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1345 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1345 # FIXME. Test this a bit more carefully (the if.. is new)
1346 # FIXME. Test this a bit more carefully (the if.. is new)
1346 if local_ns is None and global_ns is None:
1347 if local_ns is None and global_ns is None:
1347 self.user_global_ns.update(__main__.__dict__)
1348 self.user_global_ns.update(__main__.__dict__)
1348
1349
1349 # make sure the tab-completer has the correct frame information, so it
1350 # make sure the tab-completer has the correct frame information, so it
1350 # actually completes using the frame's locals/globals
1351 # actually completes using the frame's locals/globals
1351 self.set_completer_frame()
1352 self.set_completer_frame()
1352
1353
1353 # before activating the interactive mode, we need to make sure that
1354 # before activating the interactive mode, we need to make sure that
1354 # all names in the builtin namespace needed by ipython point to
1355 # all names in the builtin namespace needed by ipython point to
1355 # ourselves, and not to other instances.
1356 # ourselves, and not to other instances.
1356 self.add_builtins()
1357 self.add_builtins()
1357
1358
1358 self.interact(header)
1359 self.interact(header)
1359
1360
1360 # now, purge out the user namespace from anything we might have added
1361 # now, purge out the user namespace from anything we might have added
1361 # from the caller's local namespace
1362 # from the caller's local namespace
1362 delvar = self.user_ns.pop
1363 delvar = self.user_ns.pop
1363 for var in local_varnames:
1364 for var in local_varnames:
1364 delvar(var,None)
1365 delvar(var,None)
1365 # and clean builtins we may have overridden
1366 # and clean builtins we may have overridden
1366 self.clean_builtins()
1367 self.clean_builtins()
1367
1368
1368 def interact(self, banner=None):
1369 def interact(self, banner=None):
1369 """Closely emulate the interactive Python console.
1370 """Closely emulate the interactive Python console.
1370
1371
1371 The optional banner argument specify the banner to print
1372 The optional banner argument specify the banner to print
1372 before the first interaction; by default it prints a banner
1373 before the first interaction; by default it prints a banner
1373 similar to the one printed by the real Python interpreter,
1374 similar to the one printed by the real Python interpreter,
1374 followed by the current class name in parentheses (so as not
1375 followed by the current class name in parentheses (so as not
1375 to confuse this with the real interpreter -- since it's so
1376 to confuse this with the real interpreter -- since it's so
1376 close!).
1377 close!).
1377
1378
1378 """
1379 """
1379 cprt = 'Type "copyright", "credits" or "license" for more information.'
1380 cprt = 'Type "copyright", "credits" or "license" for more information.'
1380 if banner is None:
1381 if banner is None:
1381 self.write("Python %s on %s\n%s\n(%s)\n" %
1382 self.write("Python %s on %s\n%s\n(%s)\n" %
1382 (sys.version, sys.platform, cprt,
1383 (sys.version, sys.platform, cprt,
1383 self.__class__.__name__))
1384 self.__class__.__name__))
1384 else:
1385 else:
1385 self.write(banner)
1386 self.write(banner)
1386
1387
1387 more = 0
1388 more = 0
1388
1389
1389 # Mark activity in the builtins
1390 # Mark activity in the builtins
1390 __builtin__.__dict__['__IPYTHON__active'] += 1
1391 __builtin__.__dict__['__IPYTHON__active'] += 1
1391
1392
1392 # exit_now is set by a call to %Exit or %Quit
1393 # exit_now is set by a call to %Exit or %Quit
1393 self.exit_now = False
1394 self.exit_now = False
1394 while not self.exit_now:
1395 while not self.exit_now:
1395
1396
1396 try:
1397 try:
1397 if more:
1398 if more:
1398 prompt = self.outputcache.prompt2
1399 prompt = self.outputcache.prompt2
1399 if self.autoindent:
1400 if self.autoindent:
1400 self.readline_startup_hook(self.pre_readline)
1401 self.readline_startup_hook(self.pre_readline)
1401 else:
1402 else:
1402 prompt = self.outputcache.prompt1
1403 prompt = self.outputcache.prompt1
1403 try:
1404 try:
1404 line = self.raw_input(prompt,more)
1405 line = self.raw_input(prompt,more)
1405 if self.autoindent:
1406 if self.autoindent:
1406 self.readline_startup_hook(None)
1407 self.readline_startup_hook(None)
1407 except EOFError:
1408 except EOFError:
1408 if self.autoindent:
1409 if self.autoindent:
1409 self.readline_startup_hook(None)
1410 self.readline_startup_hook(None)
1410 self.write("\n")
1411 self.write("\n")
1411 self.exit()
1412 self.exit()
1412 else:
1413 else:
1413 more = self.push(line)
1414 more = self.push(line)
1414
1415
1415 if (self.SyntaxTB.last_syntax_error and
1416 if (self.SyntaxTB.last_syntax_error and
1416 self.rc.autoedit_syntax):
1417 self.rc.autoedit_syntax):
1417 self.edit_syntax_error()
1418 self.edit_syntax_error()
1418
1419
1419 except KeyboardInterrupt:
1420 except KeyboardInterrupt:
1420 self.write("\nKeyboardInterrupt\n")
1421 self.write("\nKeyboardInterrupt\n")
1421 self.resetbuffer()
1422 self.resetbuffer()
1422 more = 0
1423 more = 0
1423 # keep cache in sync with the prompt counter:
1424 # keep cache in sync with the prompt counter:
1424 self.outputcache.prompt_count -= 1
1425 self.outputcache.prompt_count -= 1
1425
1426
1426 if self.autoindent:
1427 if self.autoindent:
1427 self.indent_current_nsp = 0
1428 self.indent_current_nsp = 0
1428 self.indent_current = ' '* self.indent_current_nsp
1429 self.indent_current = ' '* self.indent_current_nsp
1429
1430
1430 except bdb.BdbQuit:
1431 except bdb.BdbQuit:
1431 warn("The Python debugger has exited with a BdbQuit exception.\n"
1432 warn("The Python debugger has exited with a BdbQuit exception.\n"
1432 "Because of how pdb handles the stack, it is impossible\n"
1433 "Because of how pdb handles the stack, it is impossible\n"
1433 "for IPython to properly format this particular exception.\n"
1434 "for IPython to properly format this particular exception.\n"
1434 "IPython will resume normal operation.")
1435 "IPython will resume normal operation.")
1435
1436
1436 # We are off again...
1437 # We are off again...
1437 __builtin__.__dict__['__IPYTHON__active'] -= 1
1438 __builtin__.__dict__['__IPYTHON__active'] -= 1
1438
1439
1439 def excepthook(self, type, value, tb):
1440 def excepthook(self, type, value, tb):
1440 """One more defense for GUI apps that call sys.excepthook.
1441 """One more defense for GUI apps that call sys.excepthook.
1441
1442
1442 GUI frameworks like wxPython trap exceptions and call
1443 GUI frameworks like wxPython trap exceptions and call
1443 sys.excepthook themselves. I guess this is a feature that
1444 sys.excepthook themselves. I guess this is a feature that
1444 enables them to keep running after exceptions that would
1445 enables them to keep running after exceptions that would
1445 otherwise kill their mainloop. This is a bother for IPython
1446 otherwise kill their mainloop. This is a bother for IPython
1446 which excepts to catch all of the program exceptions with a try:
1447 which excepts to catch all of the program exceptions with a try:
1447 except: statement.
1448 except: statement.
1448
1449
1449 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1450 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1450 any app directly invokes sys.excepthook, it will look to the user like
1451 any app directly invokes sys.excepthook, it will look to the user like
1451 IPython crashed. In order to work around this, we can disable the
1452 IPython crashed. In order to work around this, we can disable the
1452 CrashHandler and replace it with this excepthook instead, which prints a
1453 CrashHandler and replace it with this excepthook instead, which prints a
1453 regular traceback using our InteractiveTB. In this fashion, apps which
1454 regular traceback using our InteractiveTB. In this fashion, apps which
1454 call sys.excepthook will generate a regular-looking exception from
1455 call sys.excepthook will generate a regular-looking exception from
1455 IPython, and the CrashHandler will only be triggered by real IPython
1456 IPython, and the CrashHandler will only be triggered by real IPython
1456 crashes.
1457 crashes.
1457
1458
1458 This hook should be used sparingly, only in places which are not likely
1459 This hook should be used sparingly, only in places which are not likely
1459 to be true IPython errors.
1460 to be true IPython errors.
1460 """
1461 """
1461
1462
1462 self.InteractiveTB(type, value, tb, tb_offset=0)
1463 self.InteractiveTB(type, value, tb, tb_offset=0)
1463 if self.InteractiveTB.call_pdb and self.has_readline:
1464 if self.InteractiveTB.call_pdb and self.has_readline:
1464 self.readline.set_completer(self.Completer.complete)
1465 self.readline.set_completer(self.Completer.complete)
1465
1466
1466 def call_alias(self,alias,rest=''):
1467 def call_alias(self,alias,rest=''):
1467 """Call an alias given its name and the rest of the line.
1468 """Call an alias given its name and the rest of the line.
1468
1469
1469 This function MUST be given a proper alias, because it doesn't make
1470 This function MUST be given a proper alias, because it doesn't make
1470 any checks when looking up into the alias table. The caller is
1471 any checks when looking up into the alias table. The caller is
1471 responsible for invoking it only with a valid alias."""
1472 responsible for invoking it only with a valid alias."""
1472
1473
1473 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1474 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1474 nargs,cmd = self.alias_table[alias]
1475 nargs,cmd = self.alias_table[alias]
1475 # Expand the %l special to be the user's input line
1476 # Expand the %l special to be the user's input line
1476 if cmd.find('%l') >= 0:
1477 if cmd.find('%l') >= 0:
1477 cmd = cmd.replace('%l',rest)
1478 cmd = cmd.replace('%l',rest)
1478 rest = ''
1479 rest = ''
1479 if nargs==0:
1480 if nargs==0:
1480 # Simple, argument-less aliases
1481 # Simple, argument-less aliases
1481 cmd = '%s %s' % (cmd,rest)
1482 cmd = '%s %s' % (cmd,rest)
1482 else:
1483 else:
1483 # Handle aliases with positional arguments
1484 # Handle aliases with positional arguments
1484 args = rest.split(None,nargs)
1485 args = rest.split(None,nargs)
1485 if len(args)< nargs:
1486 if len(args)< nargs:
1486 error('Alias <%s> requires %s arguments, %s given.' %
1487 error('Alias <%s> requires %s arguments, %s given.' %
1487 (alias,nargs,len(args)))
1488 (alias,nargs,len(args)))
1488 return
1489 return
1489 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1490 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1490 # Now call the macro, evaluating in the user's namespace
1491 # Now call the macro, evaluating in the user's namespace
1491 try:
1492 try:
1492 self.system(cmd)
1493 self.system(cmd)
1493 except:
1494 except:
1494 self.showtraceback()
1495 self.showtraceback()
1495
1496
1496 def autoindent_update(self,line):
1497 def autoindent_update(self,line):
1497 """Keep track of the indent level."""
1498 """Keep track of the indent level."""
1498 if self.autoindent:
1499 if self.autoindent:
1499 if line:
1500 if line:
1500 ini_spaces = ini_spaces_re.match(line)
1501 ini_spaces = ini_spaces_re.match(line)
1501 if ini_spaces:
1502 if ini_spaces:
1502 nspaces = ini_spaces.end()
1503 nspaces = ini_spaces.end()
1503 else:
1504 else:
1504 nspaces = 0
1505 nspaces = 0
1505 self.indent_current_nsp = nspaces
1506 self.indent_current_nsp = nspaces
1506
1507
1507 if line[-1] == ':':
1508 if line[-1] == ':':
1508 self.indent_current_nsp += 4
1509 self.indent_current_nsp += 4
1509 elif dedent_re.match(line):
1510 elif dedent_re.match(line):
1510 self.indent_current_nsp -= 4
1511 self.indent_current_nsp -= 4
1511 else:
1512 else:
1512 self.indent_current_nsp = 0
1513 self.indent_current_nsp = 0
1513
1514
1514 # indent_current is the actual string to be inserted
1515 # indent_current is the actual string to be inserted
1515 # by the readline hooks for indentation
1516 # by the readline hooks for indentation
1516 self.indent_current = ' '* self.indent_current_nsp
1517 self.indent_current = ' '* self.indent_current_nsp
1517
1518
1518 def runlines(self,lines):
1519 def runlines(self,lines):
1519 """Run a string of one or more lines of source.
1520 """Run a string of one or more lines of source.
1520
1521
1521 This method is capable of running a string containing multiple source
1522 This method is capable of running a string containing multiple source
1522 lines, as if they had been entered at the IPython prompt. Since it
1523 lines, as if they had been entered at the IPython prompt. Since it
1523 exposes IPython's processing machinery, the given strings can contain
1524 exposes IPython's processing machinery, the given strings can contain
1524 magic calls (%magic), special shell access (!cmd), etc."""
1525 magic calls (%magic), special shell access (!cmd), etc."""
1525
1526
1526 # We must start with a clean buffer, in case this is run from an
1527 # We must start with a clean buffer, in case this is run from an
1527 # interactive IPython session (via a magic, for example).
1528 # interactive IPython session (via a magic, for example).
1528 self.resetbuffer()
1529 self.resetbuffer()
1529 lines = lines.split('\n')
1530 lines = lines.split('\n')
1530 more = 0
1531 more = 0
1531 for line in lines:
1532 for line in lines:
1532 # skip blank lines so we don't mess up the prompt counter, but do
1533 # skip blank lines so we don't mess up the prompt counter, but do
1533 # NOT skip even a blank line if we are in a code block (more is
1534 # NOT skip even a blank line if we are in a code block (more is
1534 # true)
1535 # true)
1535 if line or more:
1536 if line or more:
1536 more = self.push(self.prefilter(line,more))
1537 more = self.push(self.prefilter(line,more))
1537 # IPython's runsource returns None if there was an error
1538 # IPython's runsource returns None if there was an error
1538 # compiling the code. This allows us to stop processing right
1539 # compiling the code. This allows us to stop processing right
1539 # away, so the user gets the error message at the right place.
1540 # away, so the user gets the error message at the right place.
1540 if more is None:
1541 if more is None:
1541 break
1542 break
1542 # final newline in case the input didn't have it, so that the code
1543 # final newline in case the input didn't have it, so that the code
1543 # actually does get executed
1544 # actually does get executed
1544 if more:
1545 if more:
1545 self.push('\n')
1546 self.push('\n')
1546
1547
1547 def runsource(self, source, filename='<input>', symbol='single'):
1548 def runsource(self, source, filename='<input>', symbol='single'):
1548 """Compile and run some source in the interpreter.
1549 """Compile and run some source in the interpreter.
1549
1550
1550 Arguments are as for compile_command().
1551 Arguments are as for compile_command().
1551
1552
1552 One several things can happen:
1553 One several things can happen:
1553
1554
1554 1) The input is incorrect; compile_command() raised an
1555 1) The input is incorrect; compile_command() raised an
1555 exception (SyntaxError or OverflowError). A syntax traceback
1556 exception (SyntaxError or OverflowError). A syntax traceback
1556 will be printed by calling the showsyntaxerror() method.
1557 will be printed by calling the showsyntaxerror() method.
1557
1558
1558 2) The input is incomplete, and more input is required;
1559 2) The input is incomplete, and more input is required;
1559 compile_command() returned None. Nothing happens.
1560 compile_command() returned None. Nothing happens.
1560
1561
1561 3) The input is complete; compile_command() returned a code
1562 3) The input is complete; compile_command() returned a code
1562 object. The code is executed by calling self.runcode() (which
1563 object. The code is executed by calling self.runcode() (which
1563 also handles run-time exceptions, except for SystemExit).
1564 also handles run-time exceptions, except for SystemExit).
1564
1565
1565 The return value is:
1566 The return value is:
1566
1567
1567 - True in case 2
1568 - True in case 2
1568
1569
1569 - False in the other cases, unless an exception is raised, where
1570 - False in the other cases, unless an exception is raised, where
1570 None is returned instead. This can be used by external callers to
1571 None is returned instead. This can be used by external callers to
1571 know whether to continue feeding input or not.
1572 know whether to continue feeding input or not.
1572
1573
1573 The return value can be used to decide whether to use sys.ps1 or
1574 The return value can be used to decide whether to use sys.ps1 or
1574 sys.ps2 to prompt the next line."""
1575 sys.ps2 to prompt the next line."""
1575
1576
1576 try:
1577 try:
1577 code = self.compile(source,filename,symbol)
1578 code = self.compile(source,filename,symbol)
1578 except (OverflowError, SyntaxError, ValueError):
1579 except (OverflowError, SyntaxError, ValueError):
1579 # Case 1
1580 # Case 1
1580 self.showsyntaxerror(filename)
1581 self.showsyntaxerror(filename)
1581 return None
1582 return None
1582
1583
1583 if code is None:
1584 if code is None:
1584 # Case 2
1585 # Case 2
1585 return True
1586 return True
1586
1587
1587 # Case 3
1588 # Case 3
1588 # We store the code object so that threaded shells and
1589 # We store the code object so that threaded shells and
1589 # custom exception handlers can access all this info if needed.
1590 # custom exception handlers can access all this info if needed.
1590 # The source corresponding to this can be obtained from the
1591 # The source corresponding to this can be obtained from the
1591 # buffer attribute as '\n'.join(self.buffer).
1592 # buffer attribute as '\n'.join(self.buffer).
1592 self.code_to_run = code
1593 self.code_to_run = code
1593 # now actually execute the code object
1594 # now actually execute the code object
1594 if self.runcode(code) == 0:
1595 if self.runcode(code) == 0:
1595 return False
1596 return False
1596 else:
1597 else:
1597 return None
1598 return None
1598
1599
1599 def runcode(self,code_obj):
1600 def runcode(self,code_obj):
1600 """Execute a code object.
1601 """Execute a code object.
1601
1602
1602 When an exception occurs, self.showtraceback() is called to display a
1603 When an exception occurs, self.showtraceback() is called to display a
1603 traceback.
1604 traceback.
1604
1605
1605 Return value: a flag indicating whether the code to be run completed
1606 Return value: a flag indicating whether the code to be run completed
1606 successfully:
1607 successfully:
1607
1608
1608 - 0: successful execution.
1609 - 0: successful execution.
1609 - 1: an error occurred.
1610 - 1: an error occurred.
1610 """
1611 """
1611
1612
1612 # Set our own excepthook in case the user code tries to call it
1613 # Set our own excepthook in case the user code tries to call it
1613 # directly, so that the IPython crash handler doesn't get triggered
1614 # directly, so that the IPython crash handler doesn't get triggered
1614 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1615 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1615
1616
1616 # we save the original sys.excepthook in the instance, in case config
1617 # we save the original sys.excepthook in the instance, in case config
1617 # code (such as magics) needs access to it.
1618 # code (such as magics) needs access to it.
1618 self.sys_excepthook = old_excepthook
1619 self.sys_excepthook = old_excepthook
1619 outflag = 1 # happens in more places, so it's easier as default
1620 outflag = 1 # happens in more places, so it's easier as default
1620 try:
1621 try:
1621 try:
1622 try:
1622 # Embedded instances require separate global/local namespaces
1623 # Embedded instances require separate global/local namespaces
1623 # so they can see both the surrounding (local) namespace and
1624 # so they can see both the surrounding (local) namespace and
1624 # the module-level globals when called inside another function.
1625 # the module-level globals when called inside another function.
1625 if self.embedded:
1626 if self.embedded:
1626 exec code_obj in self.user_global_ns, self.user_ns
1627 exec code_obj in self.user_global_ns, self.user_ns
1627 # Normal (non-embedded) instances should only have a single
1628 # Normal (non-embedded) instances should only have a single
1628 # namespace for user code execution, otherwise functions won't
1629 # namespace for user code execution, otherwise functions won't
1629 # see interactive top-level globals.
1630 # see interactive top-level globals.
1630 else:
1631 else:
1631 exec code_obj in self.user_ns
1632 exec code_obj in self.user_ns
1632 finally:
1633 finally:
1633 # Reset our crash handler in place
1634 # Reset our crash handler in place
1634 sys.excepthook = old_excepthook
1635 sys.excepthook = old_excepthook
1635 except SystemExit:
1636 except SystemExit:
1636 self.resetbuffer()
1637 self.resetbuffer()
1637 self.showtraceback()
1638 self.showtraceback()
1638 warn("Type exit or quit to exit IPython "
1639 warn("Type exit or quit to exit IPython "
1639 "(%Exit or %Quit do so unconditionally).",level=1)
1640 "(%Exit or %Quit do so unconditionally).",level=1)
1640 except self.custom_exceptions:
1641 except self.custom_exceptions:
1641 etype,value,tb = sys.exc_info()
1642 etype,value,tb = sys.exc_info()
1642 self.CustomTB(etype,value,tb)
1643 self.CustomTB(etype,value,tb)
1643 except:
1644 except:
1644 self.showtraceback()
1645 self.showtraceback()
1645 else:
1646 else:
1646 outflag = 0
1647 outflag = 0
1647 if softspace(sys.stdout, 0):
1648 if softspace(sys.stdout, 0):
1648 print
1649 print
1649 # Flush out code object which has been run (and source)
1650 # Flush out code object which has been run (and source)
1650 self.code_to_run = None
1651 self.code_to_run = None
1651 return outflag
1652 return outflag
1652
1653
1653 def push(self, line):
1654 def push(self, line):
1654 """Push a line to the interpreter.
1655 """Push a line to the interpreter.
1655
1656
1656 The line should not have a trailing newline; it may have
1657 The line should not have a trailing newline; it may have
1657 internal newlines. The line is appended to a buffer and the
1658 internal newlines. The line is appended to a buffer and the
1658 interpreter's runsource() method is called with the
1659 interpreter's runsource() method is called with the
1659 concatenated contents of the buffer as source. If this
1660 concatenated contents of the buffer as source. If this
1660 indicates that the command was executed or invalid, the buffer
1661 indicates that the command was executed or invalid, the buffer
1661 is reset; otherwise, the command is incomplete, and the buffer
1662 is reset; otherwise, the command is incomplete, and the buffer
1662 is left as it was after the line was appended. The return
1663 is left as it was after the line was appended. The return
1663 value is 1 if more input is required, 0 if the line was dealt
1664 value is 1 if more input is required, 0 if the line was dealt
1664 with in some way (this is the same as runsource()).
1665 with in some way (this is the same as runsource()).
1665 """
1666 """
1666
1667
1667 # autoindent management should be done here, and not in the
1668 # autoindent management should be done here, and not in the
1668 # interactive loop, since that one is only seen by keyboard input. We
1669 # interactive loop, since that one is only seen by keyboard input. We
1669 # need this done correctly even for code run via runlines (which uses
1670 # need this done correctly even for code run via runlines (which uses
1670 # push).
1671 # push).
1671
1672
1672 #print 'push line: <%s>' % line # dbg
1673 #print 'push line: <%s>' % line # dbg
1673 self.autoindent_update(line)
1674 self.autoindent_update(line)
1674
1675
1675 self.buffer.append(line)
1676 self.buffer.append(line)
1676 more = self.runsource('\n'.join(self.buffer), self.filename)
1677 more = self.runsource('\n'.join(self.buffer), self.filename)
1677 if not more:
1678 if not more:
1678 self.resetbuffer()
1679 self.resetbuffer()
1679 return more
1680 return more
1680
1681
1681 def resetbuffer(self):
1682 def resetbuffer(self):
1682 """Reset the input buffer."""
1683 """Reset the input buffer."""
1683 self.buffer[:] = []
1684 self.buffer[:] = []
1684
1685
1685 def raw_input(self,prompt='',continue_prompt=False):
1686 def raw_input(self,prompt='',continue_prompt=False):
1686 """Write a prompt and read a line.
1687 """Write a prompt and read a line.
1687
1688
1688 The returned line does not include the trailing newline.
1689 The returned line does not include the trailing newline.
1689 When the user enters the EOF key sequence, EOFError is raised.
1690 When the user enters the EOF key sequence, EOFError is raised.
1690
1691
1691 Optional inputs:
1692 Optional inputs:
1692
1693
1693 - prompt(''): a string to be printed to prompt the user.
1694 - prompt(''): a string to be printed to prompt the user.
1694
1695
1695 - continue_prompt(False): whether this line is the first one or a
1696 - continue_prompt(False): whether this line is the first one or a
1696 continuation in a sequence of inputs.
1697 continuation in a sequence of inputs.
1697 """
1698 """
1698
1699
1699 line = raw_input_original(prompt)
1700 line = raw_input_original(prompt)
1700 # Try to be reasonably smart about not re-indenting pasted input more
1701 # Try to be reasonably smart about not re-indenting pasted input more
1701 # than necessary. We do this by trimming out the auto-indent initial
1702 # than necessary. We do this by trimming out the auto-indent initial
1702 # spaces, if the user's actual input started itself with whitespace.
1703 # spaces, if the user's actual input started itself with whitespace.
1703 if self.autoindent:
1704 if self.autoindent:
1704 line2 = line[self.indent_current_nsp:]
1705 line2 = line[self.indent_current_nsp:]
1705 if line2[0:1] in (' ','\t'):
1706 if line2[0:1] in (' ','\t'):
1706 line = line2
1707 line = line2
1707 return self.prefilter(line,continue_prompt)
1708 return self.prefilter(line,continue_prompt)
1708
1709
1709 def split_user_input(self,line):
1710 def split_user_input(self,line):
1710 """Split user input into pre-char, function part and rest."""
1711 """Split user input into pre-char, function part and rest."""
1711
1712
1712 lsplit = self.line_split.match(line)
1713 lsplit = self.line_split.match(line)
1713 if lsplit is None: # no regexp match returns None
1714 if lsplit is None: # no regexp match returns None
1714 try:
1715 try:
1715 iFun,theRest = line.split(None,1)
1716 iFun,theRest = line.split(None,1)
1716 except ValueError:
1717 except ValueError:
1717 iFun,theRest = line,''
1718 iFun,theRest = line,''
1718 pre = re.match('^(\s*)(.*)',line).groups()[0]
1719 pre = re.match('^(\s*)(.*)',line).groups()[0]
1719 else:
1720 else:
1720 pre,iFun,theRest = lsplit.groups()
1721 pre,iFun,theRest = lsplit.groups()
1721
1722
1722 #print 'line:<%s>' % line # dbg
1723 #print 'line:<%s>' % line # dbg
1723 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1724 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1724 return pre,iFun.strip(),theRest
1725 return pre,iFun.strip(),theRest
1725
1726
1726 def _prefilter(self, line, continue_prompt):
1727 def _prefilter(self, line, continue_prompt):
1727 """Calls different preprocessors, depending on the form of line."""
1728 """Calls different preprocessors, depending on the form of line."""
1728
1729
1729 # All handlers *must* return a value, even if it's blank ('').
1730 # All handlers *must* return a value, even if it's blank ('').
1730
1731
1731 # Lines are NOT logged here. Handlers should process the line as
1732 # Lines are NOT logged here. Handlers should process the line as
1732 # needed, update the cache AND log it (so that the input cache array
1733 # needed, update the cache AND log it (so that the input cache array
1733 # stays synced).
1734 # stays synced).
1734
1735
1735 # This function is _very_ delicate, and since it's also the one which
1736 # This function is _very_ delicate, and since it's also the one which
1736 # determines IPython's response to user input, it must be as efficient
1737 # determines IPython's response to user input, it must be as efficient
1737 # as possible. For this reason it has _many_ returns in it, trying
1738 # as possible. For this reason it has _many_ returns in it, trying
1738 # always to exit as quickly as it can figure out what it needs to do.
1739 # always to exit as quickly as it can figure out what it needs to do.
1739
1740
1740 # This function is the main responsible for maintaining IPython's
1741 # This function is the main responsible for maintaining IPython's
1741 # behavior respectful of Python's semantics. So be _very_ careful if
1742 # behavior respectful of Python's semantics. So be _very_ careful if
1742 # making changes to anything here.
1743 # making changes to anything here.
1743
1744
1744 #.....................................................................
1745 #.....................................................................
1745 # Code begins
1746 # Code begins
1746
1747
1747 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1748 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1748
1749
1749 # save the line away in case we crash, so the post-mortem handler can
1750 # save the line away in case we crash, so the post-mortem handler can
1750 # record it
1751 # record it
1751 self._last_input_line = line
1752 self._last_input_line = line
1752
1753
1753 #print '***line: <%s>' % line # dbg
1754 #print '***line: <%s>' % line # dbg
1754
1755
1755 # the input history needs to track even empty lines
1756 # the input history needs to track even empty lines
1756 if not line.strip():
1757 if not line.strip():
1757 if not continue_prompt:
1758 if not continue_prompt:
1758 self.outputcache.prompt_count -= 1
1759 self.outputcache.prompt_count -= 1
1759 return self.handle_normal(line,continue_prompt)
1760 return self.handle_normal(line,continue_prompt)
1760 #return self.handle_normal('',continue_prompt)
1761 #return self.handle_normal('',continue_prompt)
1761
1762
1762 # print '***cont',continue_prompt # dbg
1763 # print '***cont',continue_prompt # dbg
1763 # special handlers are only allowed for single line statements
1764 # special handlers are only allowed for single line statements
1764 if continue_prompt and not self.rc.multi_line_specials:
1765 if continue_prompt and not self.rc.multi_line_specials:
1765 return self.handle_normal(line,continue_prompt)
1766 return self.handle_normal(line,continue_prompt)
1766
1767
1767 # For the rest, we need the structure of the input
1768 # For the rest, we need the structure of the input
1768 pre,iFun,theRest = self.split_user_input(line)
1769 pre,iFun,theRest = self.split_user_input(line)
1769 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1770 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1770
1771
1771 # First check for explicit escapes in the last/first character
1772 # First check for explicit escapes in the last/first character
1772 handler = None
1773 handler = None
1773 if line[-1] == self.ESC_HELP:
1774 if line[-1] == self.ESC_HELP:
1774 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1775 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1775 if handler is None:
1776 if handler is None:
1776 # look at the first character of iFun, NOT of line, so we skip
1777 # look at the first character of iFun, NOT of line, so we skip
1777 # leading whitespace in multiline input
1778 # leading whitespace in multiline input
1778 handler = self.esc_handlers.get(iFun[0:1])
1779 handler = self.esc_handlers.get(iFun[0:1])
1779 if handler is not None:
1780 if handler is not None:
1780 return handler(line,continue_prompt,pre,iFun,theRest)
1781 return handler(line,continue_prompt,pre,iFun,theRest)
1781 # Emacs ipython-mode tags certain input lines
1782 # Emacs ipython-mode tags certain input lines
1782 if line.endswith('# PYTHON-MODE'):
1783 if line.endswith('# PYTHON-MODE'):
1783 return self.handle_emacs(line,continue_prompt)
1784 return self.handle_emacs(line,continue_prompt)
1784
1785
1785 # Next, check if we can automatically execute this thing
1786 # Next, check if we can automatically execute this thing
1786
1787
1787 # Allow ! in multi-line statements if multi_line_specials is on:
1788 # Allow ! in multi-line statements if multi_line_specials is on:
1788 if continue_prompt and self.rc.multi_line_specials and \
1789 if continue_prompt and self.rc.multi_line_specials and \
1789 iFun.startswith(self.ESC_SHELL):
1790 iFun.startswith(self.ESC_SHELL):
1790 return self.handle_shell_escape(line,continue_prompt,
1791 return self.handle_shell_escape(line,continue_prompt,
1791 pre=pre,iFun=iFun,
1792 pre=pre,iFun=iFun,
1792 theRest=theRest)
1793 theRest=theRest)
1793
1794
1794 # Let's try to find if the input line is a magic fn
1795 # Let's try to find if the input line is a magic fn
1795 oinfo = None
1796 oinfo = None
1796 if hasattr(self,'magic_'+iFun):
1797 if hasattr(self,'magic_'+iFun):
1797 # WARNING: _ofind uses getattr(), so it can consume generators and
1798 # WARNING: _ofind uses getattr(), so it can consume generators and
1798 # cause other side effects.
1799 # cause other side effects.
1799 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1800 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1800 if oinfo['ismagic']:
1801 if oinfo['ismagic']:
1801 # Be careful not to call magics when a variable assignment is
1802 # Be careful not to call magics when a variable assignment is
1802 # being made (ls='hi', for example)
1803 # being made (ls='hi', for example)
1803 if self.rc.automagic and \
1804 if self.rc.automagic and \
1804 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1805 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1805 (self.rc.multi_line_specials or not continue_prompt):
1806 (self.rc.multi_line_specials or not continue_prompt):
1806 return self.handle_magic(line,continue_prompt,
1807 return self.handle_magic(line,continue_prompt,
1807 pre,iFun,theRest)
1808 pre,iFun,theRest)
1808 else:
1809 else:
1809 return self.handle_normal(line,continue_prompt)
1810 return self.handle_normal(line,continue_prompt)
1810
1811
1811 # If the rest of the line begins with an (in)equality, assginment or
1812 # If the rest of the line begins with an (in)equality, assginment or
1812 # function call, we should not call _ofind but simply execute it.
1813 # function call, we should not call _ofind but simply execute it.
1813 # This avoids spurious geattr() accesses on objects upon assignment.
1814 # This avoids spurious geattr() accesses on objects upon assignment.
1814 #
1815 #
1815 # It also allows users to assign to either alias or magic names true
1816 # It also allows users to assign to either alias or magic names true
1816 # python variables (the magic/alias systems always take second seat to
1817 # python variables (the magic/alias systems always take second seat to
1817 # true python code).
1818 # true python code).
1818 if theRest and theRest[0] in '!=()':
1819 if theRest and theRest[0] in '!=()':
1819 return self.handle_normal(line,continue_prompt)
1820 return self.handle_normal(line,continue_prompt)
1820
1821
1821 if oinfo is None:
1822 if oinfo is None:
1822 # let's try to ensure that _oinfo is ONLY called when autocall is
1823 # let's try to ensure that _oinfo is ONLY called when autocall is
1823 # on. Since it has inevitable potential side effects, at least
1824 # on. Since it has inevitable potential side effects, at least
1824 # having autocall off should be a guarantee to the user that no
1825 # having autocall off should be a guarantee to the user that no
1825 # weird things will happen.
1826 # weird things will happen.
1826
1827
1827 if self.rc.autocall:
1828 if self.rc.autocall:
1828 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1829 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1829 else:
1830 else:
1830 # in this case, all that's left is either an alias or
1831 # in this case, all that's left is either an alias or
1831 # processing the line normally.
1832 # processing the line normally.
1832 if iFun in self.alias_table:
1833 if iFun in self.alias_table:
1833 return self.handle_alias(line,continue_prompt,
1834 return self.handle_alias(line,continue_prompt,
1834 pre,iFun,theRest)
1835 pre,iFun,theRest)
1835 else:
1836 else:
1836 return self.handle_normal(line,continue_prompt)
1837 return self.handle_normal(line,continue_prompt)
1837
1838
1838 if not oinfo['found']:
1839 if not oinfo['found']:
1839 return self.handle_normal(line,continue_prompt)
1840 return self.handle_normal(line,continue_prompt)
1840 else:
1841 else:
1841 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1842 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1842 if oinfo['isalias']:
1843 if oinfo['isalias']:
1843 return self.handle_alias(line,continue_prompt,
1844 return self.handle_alias(line,continue_prompt,
1844 pre,iFun,theRest)
1845 pre,iFun,theRest)
1845
1846
1846 if self.rc.autocall and \
1847 if self.rc.autocall and \
1847 not self.re_exclude_auto.match(theRest) and \
1848 not self.re_exclude_auto.match(theRest) and \
1848 self.re_fun_name.match(iFun) and \
1849 self.re_fun_name.match(iFun) and \
1849 callable(oinfo['obj']) :
1850 callable(oinfo['obj']) :
1850 #print 'going auto' # dbg
1851 #print 'going auto' # dbg
1851 return self.handle_auto(line,continue_prompt,
1852 return self.handle_auto(line,continue_prompt,
1852 pre,iFun,theRest,oinfo['obj'])
1853 pre,iFun,theRest,oinfo['obj'])
1853 else:
1854 else:
1854 #print 'was callable?', callable(oinfo['obj']) # dbg
1855 #print 'was callable?', callable(oinfo['obj']) # dbg
1855 return self.handle_normal(line,continue_prompt)
1856 return self.handle_normal(line,continue_prompt)
1856
1857
1857 # If we get here, we have a normal Python line. Log and return.
1858 # If we get here, we have a normal Python line. Log and return.
1858 return self.handle_normal(line,continue_prompt)
1859 return self.handle_normal(line,continue_prompt)
1859
1860
1860 def _prefilter_dumb(self, line, continue_prompt):
1861 def _prefilter_dumb(self, line, continue_prompt):
1861 """simple prefilter function, for debugging"""
1862 """simple prefilter function, for debugging"""
1862 return self.handle_normal(line,continue_prompt)
1863 return self.handle_normal(line,continue_prompt)
1863
1864
1864 # Set the default prefilter() function (this can be user-overridden)
1865 # Set the default prefilter() function (this can be user-overridden)
1865 prefilter = _prefilter
1866 prefilter = _prefilter
1866
1867
1867 def handle_normal(self,line,continue_prompt=None,
1868 def handle_normal(self,line,continue_prompt=None,
1868 pre=None,iFun=None,theRest=None):
1869 pre=None,iFun=None,theRest=None):
1869 """Handle normal input lines. Use as a template for handlers."""
1870 """Handle normal input lines. Use as a template for handlers."""
1870
1871
1871 # With autoindent on, we need some way to exit the input loop, and I
1872 # With autoindent on, we need some way to exit the input loop, and I
1872 # don't want to force the user to have to backspace all the way to
1873 # don't want to force the user to have to backspace all the way to
1873 # clear the line. The rule will be in this case, that either two
1874 # clear the line. The rule will be in this case, that either two
1874 # lines of pure whitespace in a row, or a line of pure whitespace but
1875 # lines of pure whitespace in a row, or a line of pure whitespace but
1875 # of a size different to the indent level, will exit the input loop.
1876 # of a size different to the indent level, will exit the input loop.
1876
1877
1877 if (continue_prompt and self.autoindent and isspace(line) and
1878 if (continue_prompt and self.autoindent and isspace(line) and
1878 (line != self.indent_current or isspace(self.buffer[-1]))):
1879 (line != self.indent_current or isspace(self.buffer[-1]))):
1879 line = ''
1880 line = ''
1880
1881
1881 self.log(line,continue_prompt)
1882 self.log(line,continue_prompt)
1882 return line
1883 return line
1883
1884
1884 def handle_alias(self,line,continue_prompt=None,
1885 def handle_alias(self,line,continue_prompt=None,
1885 pre=None,iFun=None,theRest=None):
1886 pre=None,iFun=None,theRest=None):
1886 """Handle alias input lines. """
1887 """Handle alias input lines. """
1887
1888
1888 # pre is needed, because it carries the leading whitespace. Otherwise
1889 # pre is needed, because it carries the leading whitespace. Otherwise
1889 # aliases won't work in indented sections.
1890 # aliases won't work in indented sections.
1890 line_out = '%sipalias("%s %s")' % (pre,iFun,esc_quotes(theRest))
1891 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1891 self.log(line_out,continue_prompt)
1892 self.log(line_out,continue_prompt)
1892 return line_out
1893 return line_out
1893
1894
1894 def handle_shell_escape(self, line, continue_prompt=None,
1895 def handle_shell_escape(self, line, continue_prompt=None,
1895 pre=None,iFun=None,theRest=None):
1896 pre=None,iFun=None,theRest=None):
1896 """Execute the line in a shell, empty return value"""
1897 """Execute the line in a shell, empty return value"""
1897
1898
1898 #print 'line in :', `line` # dbg
1899 #print 'line in :', `line` # dbg
1899 # Example of a special handler. Others follow a similar pattern.
1900 # Example of a special handler. Others follow a similar pattern.
1900 if continue_prompt: # multi-line statements
1901 if iFun.startswith('!!'):
1902 print 'SyntaxError: !! is not allowed in multiline statements'
1903 return pre
1904 else:
1905 cmd = ("%s %s" % (iFun[1:],theRest))
1906 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd + "_")
1907 else: # single-line input
1908 if line.startswith('!!'):
1901 if line.startswith('!!'):
1909 # rewrite iFun/theRest to properly hold the call to %sx and
1902 # rewrite iFun/theRest to properly hold the call to %sx and
1910 # the actual command to be executed, so handle_magic can work
1903 # the actual command to be executed, so handle_magic can work
1911 # correctly
1904 # correctly
1912 theRest = '%s %s' % (iFun[2:],theRest)
1905 theRest = '%s %s' % (iFun[2:],theRest)
1913 iFun = 'sx'
1906 iFun = 'sx'
1914 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1907 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1915 continue_prompt,pre,iFun,theRest)
1908 continue_prompt,pre,iFun,theRest)
1916 else:
1909 else:
1917 cmd=line[1:]
1910 cmd=line[1:]
1918 line_out = '%sipsystem(r"""%s"""[:-1])' % (pre,cmd +"_")
1911 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1919 # update cache/log and return
1912 # update cache/log and return
1920 self.log(line_out,continue_prompt)
1913 self.log(line_out,continue_prompt)
1921 return line_out
1914 return line_out
1922
1915
1923 def handle_magic(self, line, continue_prompt=None,
1916 def handle_magic(self, line, continue_prompt=None,
1924 pre=None,iFun=None,theRest=None):
1917 pre=None,iFun=None,theRest=None):
1925 """Execute magic functions.
1918 """Execute magic functions."""
1926
1919
1927 Also log them with a prepended # so the log is clean Python."""
1928
1920
1929 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1921 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1930 self.log(cmd,continue_prompt)
1922 self.log(cmd,continue_prompt)
1931 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1923 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1932 return cmd
1924 return cmd
1933
1925
1934 def handle_auto(self, line, continue_prompt=None,
1926 def handle_auto(self, line, continue_prompt=None,
1935 pre=None,iFun=None,theRest=None,obj=None):
1927 pre=None,iFun=None,theRest=None,obj=None):
1936 """Hande lines which can be auto-executed, quoting if requested."""
1928 """Hande lines which can be auto-executed, quoting if requested."""
1937
1929
1938 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1930 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1939
1931
1940 # This should only be active for single-line input!
1932 # This should only be active for single-line input!
1941 if continue_prompt:
1933 if continue_prompt:
1942 self.log(line,continue_prompt)
1934 self.log(line,continue_prompt)
1943 return line
1935 return line
1944
1936
1945 auto_rewrite = True
1937 auto_rewrite = True
1946 if pre == self.ESC_QUOTE:
1938 if pre == self.ESC_QUOTE:
1947 # Auto-quote splitting on whitespace
1939 # Auto-quote splitting on whitespace
1948 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1940 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1949 elif pre == self.ESC_QUOTE2:
1941 elif pre == self.ESC_QUOTE2:
1950 # Auto-quote whole string
1942 # Auto-quote whole string
1951 newcmd = '%s("%s")' % (iFun,theRest)
1943 newcmd = '%s("%s")' % (iFun,theRest)
1952 else:
1944 else:
1953 # Auto-paren.
1945 # Auto-paren.
1954 # We only apply it to argument-less calls if the autocall
1946 # We only apply it to argument-less calls if the autocall
1955 # parameter is set to 2. We only need to check that autocall is <
1947 # parameter is set to 2. We only need to check that autocall is <
1956 # 2, since this function isn't called unless it's at least 1.
1948 # 2, since this function isn't called unless it's at least 1.
1957 if not theRest and (self.rc.autocall < 2):
1949 if not theRest and (self.rc.autocall < 2):
1958 newcmd = '%s %s' % (iFun,theRest)
1950 newcmd = '%s %s' % (iFun,theRest)
1959 auto_rewrite = False
1951 auto_rewrite = False
1960 else:
1952 else:
1961 if theRest.startswith('['):
1953 if theRest.startswith('['):
1962 if hasattr(obj,'__getitem__'):
1954 if hasattr(obj,'__getitem__'):
1963 # Don't autocall in this case: item access for an object
1955 # Don't autocall in this case: item access for an object
1964 # which is BOTH callable and implements __getitem__.
1956 # which is BOTH callable and implements __getitem__.
1965 newcmd = '%s %s' % (iFun,theRest)
1957 newcmd = '%s %s' % (iFun,theRest)
1966 auto_rewrite = False
1958 auto_rewrite = False
1967 else:
1959 else:
1968 # if the object doesn't support [] access, go ahead and
1960 # if the object doesn't support [] access, go ahead and
1969 # autocall
1961 # autocall
1970 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1962 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1971 elif theRest.endswith(';'):
1963 elif theRest.endswith(';'):
1972 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1964 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1973 else:
1965 else:
1974 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1966 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1975
1967
1976 if auto_rewrite:
1968 if auto_rewrite:
1977 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1969 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1978 # log what is now valid Python, not the actual user input (without the
1970 # log what is now valid Python, not the actual user input (without the
1979 # final newline)
1971 # final newline)
1980 self.log(newcmd,continue_prompt)
1972 self.log(newcmd,continue_prompt)
1981 return newcmd
1973 return newcmd
1982
1974
1983 def handle_help(self, line, continue_prompt=None,
1975 def handle_help(self, line, continue_prompt=None,
1984 pre=None,iFun=None,theRest=None):
1976 pre=None,iFun=None,theRest=None):
1985 """Try to get some help for the object.
1977 """Try to get some help for the object.
1986
1978
1987 obj? or ?obj -> basic information.
1979 obj? or ?obj -> basic information.
1988 obj?? or ??obj -> more details.
1980 obj?? or ??obj -> more details.
1989 """
1981 """
1990
1982
1991 # We need to make sure that we don't process lines which would be
1983 # We need to make sure that we don't process lines which would be
1992 # otherwise valid python, such as "x=1 # what?"
1984 # otherwise valid python, such as "x=1 # what?"
1993 try:
1985 try:
1994 codeop.compile_command(line)
1986 codeop.compile_command(line)
1995 except SyntaxError:
1987 except SyntaxError:
1996 # We should only handle as help stuff which is NOT valid syntax
1988 # We should only handle as help stuff which is NOT valid syntax
1997 if line[0]==self.ESC_HELP:
1989 if line[0]==self.ESC_HELP:
1998 line = line[1:]
1990 line = line[1:]
1999 elif line[-1]==self.ESC_HELP:
1991 elif line[-1]==self.ESC_HELP:
2000 line = line[:-1]
1992 line = line[:-1]
2001 self.log('#?'+line)
1993 self.log('#?'+line)
2002 if line:
1994 if line:
2003 self.magic_pinfo(line)
1995 self.magic_pinfo(line)
2004 else:
1996 else:
2005 page(self.usage,screen_lines=self.rc.screen_length)
1997 page(self.usage,screen_lines=self.rc.screen_length)
2006 return '' # Empty string is needed here!
1998 return '' # Empty string is needed here!
2007 except:
1999 except:
2008 # Pass any other exceptions through to the normal handler
2000 # Pass any other exceptions through to the normal handler
2009 return self.handle_normal(line,continue_prompt)
2001 return self.handle_normal(line,continue_prompt)
2010 else:
2002 else:
2011 # If the code compiles ok, we should handle it normally
2003 # If the code compiles ok, we should handle it normally
2012 return self.handle_normal(line,continue_prompt)
2004 return self.handle_normal(line,continue_prompt)
2013
2005
2014 def handle_emacs(self,line,continue_prompt=None,
2006 def handle_emacs(self,line,continue_prompt=None,
2015 pre=None,iFun=None,theRest=None):
2007 pre=None,iFun=None,theRest=None):
2016 """Handle input lines marked by python-mode."""
2008 """Handle input lines marked by python-mode."""
2017
2009
2018 # Currently, nothing is done. Later more functionality can be added
2010 # Currently, nothing is done. Later more functionality can be added
2019 # here if needed.
2011 # here if needed.
2020
2012
2021 # The input cache shouldn't be updated
2013 # The input cache shouldn't be updated
2022
2014
2023 return line
2015 return line
2024
2016
2025 def mktempfile(self,data=None):
2017 def mktempfile(self,data=None):
2026 """Make a new tempfile and return its filename.
2018 """Make a new tempfile and return its filename.
2027
2019
2028 This makes a call to tempfile.mktemp, but it registers the created
2020 This makes a call to tempfile.mktemp, but it registers the created
2029 filename internally so ipython cleans it up at exit time.
2021 filename internally so ipython cleans it up at exit time.
2030
2022
2031 Optional inputs:
2023 Optional inputs:
2032
2024
2033 - data(None): if data is given, it gets written out to the temp file
2025 - data(None): if data is given, it gets written out to the temp file
2034 immediately, and the file is closed again."""
2026 immediately, and the file is closed again."""
2035
2027
2036 filename = tempfile.mktemp('.py','ipython_edit_')
2028 filename = tempfile.mktemp('.py','ipython_edit_')
2037 self.tempfiles.append(filename)
2029 self.tempfiles.append(filename)
2038
2030
2039 if data:
2031 if data:
2040 tmp_file = open(filename,'w')
2032 tmp_file = open(filename,'w')
2041 tmp_file.write(data)
2033 tmp_file.write(data)
2042 tmp_file.close()
2034 tmp_file.close()
2043 return filename
2035 return filename
2044
2036
2045 def write(self,data):
2037 def write(self,data):
2046 """Write a string to the default output"""
2038 """Write a string to the default output"""
2047 Term.cout.write(data)
2039 Term.cout.write(data)
2048
2040
2049 def write_err(self,data):
2041 def write_err(self,data):
2050 """Write a string to the default error output"""
2042 """Write a string to the default error output"""
2051 Term.cerr.write(data)
2043 Term.cerr.write(data)
2052
2044
2053 def exit(self):
2045 def exit(self):
2054 """Handle interactive exit.
2046 """Handle interactive exit.
2055
2047
2056 This method sets the exit_now attribute."""
2048 This method sets the exit_now attribute."""
2057
2049
2058 if self.rc.confirm_exit:
2050 if self.rc.confirm_exit:
2059 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2051 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2060 self.exit_now = True
2052 self.exit_now = True
2061 else:
2053 else:
2062 self.exit_now = True
2054 self.exit_now = True
2063 return self.exit_now
2055 return self.exit_now
2064
2056
2065 def safe_execfile(self,fname,*where,**kw):
2057 def safe_execfile(self,fname,*where,**kw):
2066 fname = os.path.expanduser(fname)
2058 fname = os.path.expanduser(fname)
2067
2059
2068 # find things also in current directory
2060 # find things also in current directory
2069 dname = os.path.dirname(fname)
2061 dname = os.path.dirname(fname)
2070 if not sys.path.count(dname):
2062 if not sys.path.count(dname):
2071 sys.path.append(dname)
2063 sys.path.append(dname)
2072
2064
2073 try:
2065 try:
2074 xfile = open(fname)
2066 xfile = open(fname)
2075 except:
2067 except:
2076 print >> Term.cerr, \
2068 print >> Term.cerr, \
2077 'Could not open file <%s> for safe execution.' % fname
2069 'Could not open file <%s> for safe execution.' % fname
2078 return None
2070 return None
2079
2071
2080 kw.setdefault('islog',0)
2072 kw.setdefault('islog',0)
2081 kw.setdefault('quiet',1)
2073 kw.setdefault('quiet',1)
2082 kw.setdefault('exit_ignore',0)
2074 kw.setdefault('exit_ignore',0)
2083 first = xfile.readline()
2075 first = xfile.readline()
2084 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2076 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2085 xfile.close()
2077 xfile.close()
2086 # line by line execution
2078 # line by line execution
2087 if first.startswith(loghead) or kw['islog']:
2079 if first.startswith(loghead) or kw['islog']:
2088 print 'Loading log file <%s> one line at a time...' % fname
2080 print 'Loading log file <%s> one line at a time...' % fname
2089 if kw['quiet']:
2081 if kw['quiet']:
2090 stdout_save = sys.stdout
2082 stdout_save = sys.stdout
2091 sys.stdout = StringIO.StringIO()
2083 sys.stdout = StringIO.StringIO()
2092 try:
2084 try:
2093 globs,locs = where[0:2]
2085 globs,locs = where[0:2]
2094 except:
2086 except:
2095 try:
2087 try:
2096 globs = locs = where[0]
2088 globs = locs = where[0]
2097 except:
2089 except:
2098 globs = locs = globals()
2090 globs = locs = globals()
2099 badblocks = []
2091 badblocks = []
2100
2092
2101 # we also need to identify indented blocks of code when replaying
2093 # we also need to identify indented blocks of code when replaying
2102 # logs and put them together before passing them to an exec
2094 # logs and put them together before passing them to an exec
2103 # statement. This takes a bit of regexp and look-ahead work in the
2095 # statement. This takes a bit of regexp and look-ahead work in the
2104 # file. It's easiest if we swallow the whole thing in memory
2096 # file. It's easiest if we swallow the whole thing in memory
2105 # first, and manually walk through the lines list moving the
2097 # first, and manually walk through the lines list moving the
2106 # counter ourselves.
2098 # counter ourselves.
2107 indent_re = re.compile('\s+\S')
2099 indent_re = re.compile('\s+\S')
2108 xfile = open(fname)
2100 xfile = open(fname)
2109 filelines = xfile.readlines()
2101 filelines = xfile.readlines()
2110 xfile.close()
2102 xfile.close()
2111 nlines = len(filelines)
2103 nlines = len(filelines)
2112 lnum = 0
2104 lnum = 0
2113 while lnum < nlines:
2105 while lnum < nlines:
2114 line = filelines[lnum]
2106 line = filelines[lnum]
2115 lnum += 1
2107 lnum += 1
2116 # don't re-insert logger status info into cache
2108 # don't re-insert logger status info into cache
2117 if line.startswith('#log#'):
2109 if line.startswith('#log#'):
2118 continue
2110 continue
2119 else:
2111 else:
2120 # build a block of code (maybe a single line) for execution
2112 # build a block of code (maybe a single line) for execution
2121 block = line
2113 block = line
2122 try:
2114 try:
2123 next = filelines[lnum] # lnum has already incremented
2115 next = filelines[lnum] # lnum has already incremented
2124 except:
2116 except:
2125 next = None
2117 next = None
2126 while next and indent_re.match(next):
2118 while next and indent_re.match(next):
2127 block += next
2119 block += next
2128 lnum += 1
2120 lnum += 1
2129 try:
2121 try:
2130 next = filelines[lnum]
2122 next = filelines[lnum]
2131 except:
2123 except:
2132 next = None
2124 next = None
2133 # now execute the block of one or more lines
2125 # now execute the block of one or more lines
2134 try:
2126 try:
2135 exec block in globs,locs
2127 exec block in globs,locs
2136 except SystemExit:
2128 except SystemExit:
2137 pass
2129 pass
2138 except:
2130 except:
2139 badblocks.append(block.rstrip())
2131 badblocks.append(block.rstrip())
2140 if kw['quiet']: # restore stdout
2132 if kw['quiet']: # restore stdout
2141 sys.stdout.close()
2133 sys.stdout.close()
2142 sys.stdout = stdout_save
2134 sys.stdout = stdout_save
2143 print 'Finished replaying log file <%s>' % fname
2135 print 'Finished replaying log file <%s>' % fname
2144 if badblocks:
2136 if badblocks:
2145 print >> sys.stderr, ('\nThe following lines/blocks in file '
2137 print >> sys.stderr, ('\nThe following lines/blocks in file '
2146 '<%s> reported errors:' % fname)
2138 '<%s> reported errors:' % fname)
2147
2139
2148 for badline in badblocks:
2140 for badline in badblocks:
2149 print >> sys.stderr, badline
2141 print >> sys.stderr, badline
2150 else: # regular file execution
2142 else: # regular file execution
2151 try:
2143 try:
2152 execfile(fname,*where)
2144 execfile(fname,*where)
2153 except SyntaxError:
2145 except SyntaxError:
2154 etype,evalue = sys.exc_info()[:2]
2146 etype,evalue = sys.exc_info()[:2]
2155 self.SyntaxTB(etype,evalue,[])
2147 self.SyntaxTB(etype,evalue,[])
2156 warn('Failure executing file: <%s>' % fname)
2148 warn('Failure executing file: <%s>' % fname)
2157 except SystemExit,status:
2149 except SystemExit,status:
2158 if not kw['exit_ignore']:
2150 if not kw['exit_ignore']:
2159 self.InteractiveTB()
2151 self.InteractiveTB()
2160 warn('Failure executing file: <%s>' % fname)
2152 warn('Failure executing file: <%s>' % fname)
2161 except:
2153 except:
2162 self.InteractiveTB()
2154 self.InteractiveTB()
2163 warn('Failure executing file: <%s>' % fname)
2155 warn('Failure executing file: <%s>' % fname)
2164
2156
2165 #************************* end of file <iplib.py> *****************************
2157 #************************* end of file <iplib.py> *****************************
@@ -1,4833 +1,4844 b''
1 2006-01-12 Ville Vainio <vivainio@gmail.com>
2
3 * IPython/iplib.py.py (make_quoted_expr,handle_shell_escape):
4 Prettified and hardened string/backslash quoting with ipsystem(),
5 ipalias() and ipmagic(). Now even \ characters are passed to
6 %magics, !shell escapes and aliases exactly as they are in the
7 ipython command line. Should improve backslash experience,
8 particularly in Windows. %cd magic still doesn't support backslash
9 path delimiters, though. Also deleted all pretense of supporting
10 multiline command strings in !system or %magic commands.
11
1 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
12 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2
13
3 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
14 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
4 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
15 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
5 module in case-insensitive installation. Was causing crashes
16 module in case-insensitive installation. Was causing crashes
6 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
17 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
7
18
8 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
19 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
9 <marienz-AT-gentoo.org>, closes
20 <marienz-AT-gentoo.org>, closes
10 http://www.scipy.net/roundup/ipython/issue51.
21 http://www.scipy.net/roundup/ipython/issue51.
11
22
12 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
23 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
13
24
14 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
25 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
15 problem of excessive CPU usage under *nix and keyboard lag under
26 problem of excessive CPU usage under *nix and keyboard lag under
16 win32.
27 win32.
17
28
18 2006-01-10 *** Released version 0.7.0
29 2006-01-10 *** Released version 0.7.0
19
30
20 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
31 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
21
32
22 * IPython/Release.py (revision): tag version number to 0.7.0,
33 * IPython/Release.py (revision): tag version number to 0.7.0,
23 ready for release.
34 ready for release.
24
35
25 * IPython/Magic.py (magic_edit): Add print statement to %edit so
36 * IPython/Magic.py (magic_edit): Add print statement to %edit so
26 it informs the user of the name of the temp. file used. This can
37 it informs the user of the name of the temp. file used. This can
27 help if you decide later to reuse that same file, so you know
38 help if you decide later to reuse that same file, so you know
28 where to copy the info from.
39 where to copy the info from.
29
40
30 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
41 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
31
42
32 * setup_bdist_egg.py: little script to build an egg. Added
43 * setup_bdist_egg.py: little script to build an egg. Added
33 support in the release tools as well.
44 support in the release tools as well.
34
45
35 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
46 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
36
47
37 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
48 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
38 version selection (new -wxversion command line and ipythonrc
49 version selection (new -wxversion command line and ipythonrc
39 parameter). Patch contributed by Arnd Baecker
50 parameter). Patch contributed by Arnd Baecker
40 <arnd.baecker-AT-web.de>.
51 <arnd.baecker-AT-web.de>.
41
52
42 * IPython/iplib.py (embed_mainloop): fix tab-completion in
53 * IPython/iplib.py (embed_mainloop): fix tab-completion in
43 embedded instances, for variables defined at the interactive
54 embedded instances, for variables defined at the interactive
44 prompt of the embedded ipython. Reported by Arnd.
55 prompt of the embedded ipython. Reported by Arnd.
45
56
46 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
57 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
47 it can be used as a (stateful) toggle, or with a direct parameter.
58 it can be used as a (stateful) toggle, or with a direct parameter.
48
59
49 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
60 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
50 could be triggered in certain cases and cause the traceback
61 could be triggered in certain cases and cause the traceback
51 printer not to work.
62 printer not to work.
52
63
53 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
64 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
54
65
55 * IPython/iplib.py (_should_recompile): Small fix, closes
66 * IPython/iplib.py (_should_recompile): Small fix, closes
56 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
67 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
57
68
58 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
69 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
59
70
60 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
71 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
61 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
72 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
62 Moad for help with tracking it down.
73 Moad for help with tracking it down.
63
74
64 * IPython/iplib.py (handle_auto): fix autocall handling for
75 * IPython/iplib.py (handle_auto): fix autocall handling for
65 objects which support BOTH __getitem__ and __call__ (so that f [x]
76 objects which support BOTH __getitem__ and __call__ (so that f [x]
66 is left alone, instead of becoming f([x]) automatically).
77 is left alone, instead of becoming f([x]) automatically).
67
78
68 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
79 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
69 Ville's patch.
80 Ville's patch.
70
81
71 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
82 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
72
83
73 * IPython/iplib.py (handle_auto): changed autocall semantics to
84 * IPython/iplib.py (handle_auto): changed autocall semantics to
74 include 'smart' mode, where the autocall transformation is NOT
85 include 'smart' mode, where the autocall transformation is NOT
75 applied if there are no arguments on the line. This allows you to
86 applied if there are no arguments on the line. This allows you to
76 just type 'foo' if foo is a callable to see its internal form,
87 just type 'foo' if foo is a callable to see its internal form,
77 instead of having it called with no arguments (typically a
88 instead of having it called with no arguments (typically a
78 mistake). The old 'full' autocall still exists: for that, you
89 mistake). The old 'full' autocall still exists: for that, you
79 need to set the 'autocall' parameter to 2 in your ipythonrc file.
90 need to set the 'autocall' parameter to 2 in your ipythonrc file.
80
91
81 * IPython/completer.py (Completer.attr_matches): add
92 * IPython/completer.py (Completer.attr_matches): add
82 tab-completion support for Enthoughts' traits. After a report by
93 tab-completion support for Enthoughts' traits. After a report by
83 Arnd and a patch by Prabhu.
94 Arnd and a patch by Prabhu.
84
95
85 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
96 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
86
97
87 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
98 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
88 Schmolck's patch to fix inspect.getinnerframes().
99 Schmolck's patch to fix inspect.getinnerframes().
89
100
90 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
101 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
91 for embedded instances, regarding handling of namespaces and items
102 for embedded instances, regarding handling of namespaces and items
92 added to the __builtin__ one. Multiple embedded instances and
103 added to the __builtin__ one. Multiple embedded instances and
93 recursive embeddings should work better now (though I'm not sure
104 recursive embeddings should work better now (though I'm not sure
94 I've got all the corner cases fixed, that code is a bit of a brain
105 I've got all the corner cases fixed, that code is a bit of a brain
95 twister).
106 twister).
96
107
97 * IPython/Magic.py (magic_edit): added support to edit in-memory
108 * IPython/Magic.py (magic_edit): added support to edit in-memory
98 macros (automatically creates the necessary temp files). %edit
109 macros (automatically creates the necessary temp files). %edit
99 also doesn't return the file contents anymore, it's just noise.
110 also doesn't return the file contents anymore, it's just noise.
100
111
101 * IPython/completer.py (Completer.attr_matches): revert change to
112 * IPython/completer.py (Completer.attr_matches): revert change to
102 complete only on attributes listed in __all__. I realized it
113 complete only on attributes listed in __all__. I realized it
103 cripples the tab-completion system as a tool for exploring the
114 cripples the tab-completion system as a tool for exploring the
104 internals of unknown libraries (it renders any non-__all__
115 internals of unknown libraries (it renders any non-__all__
105 attribute off-limits). I got bit by this when trying to see
116 attribute off-limits). I got bit by this when trying to see
106 something inside the dis module.
117 something inside the dis module.
107
118
108 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
119 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
109
120
110 * IPython/iplib.py (InteractiveShell.__init__): add .meta
121 * IPython/iplib.py (InteractiveShell.__init__): add .meta
111 namespace for users and extension writers to hold data in. This
122 namespace for users and extension writers to hold data in. This
112 follows the discussion in
123 follows the discussion in
113 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
124 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
114
125
115 * IPython/completer.py (IPCompleter.complete): small patch to help
126 * IPython/completer.py (IPCompleter.complete): small patch to help
116 tab-completion under Emacs, after a suggestion by John Barnard
127 tab-completion under Emacs, after a suggestion by John Barnard
117 <barnarj-AT-ccf.org>.
128 <barnarj-AT-ccf.org>.
118
129
119 * IPython/Magic.py (Magic.extract_input_slices): added support for
130 * IPython/Magic.py (Magic.extract_input_slices): added support for
120 the slice notation in magics to use N-M to represent numbers N...M
131 the slice notation in magics to use N-M to represent numbers N...M
121 (closed endpoints). This is used by %macro and %save.
132 (closed endpoints). This is used by %macro and %save.
122
133
123 * IPython/completer.py (Completer.attr_matches): for modules which
134 * IPython/completer.py (Completer.attr_matches): for modules which
124 define __all__, complete only on those. After a patch by Jeffrey
135 define __all__, complete only on those. After a patch by Jeffrey
125 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
136 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
126 speed up this routine.
137 speed up this routine.
127
138
128 * IPython/Logger.py (Logger.log): fix a history handling bug. I
139 * IPython/Logger.py (Logger.log): fix a history handling bug. I
129 don't know if this is the end of it, but the behavior now is
140 don't know if this is the end of it, but the behavior now is
130 certainly much more correct. Note that coupled with macros,
141 certainly much more correct. Note that coupled with macros,
131 slightly surprising (at first) behavior may occur: a macro will in
142 slightly surprising (at first) behavior may occur: a macro will in
132 general expand to multiple lines of input, so upon exiting, the
143 general expand to multiple lines of input, so upon exiting, the
133 in/out counters will both be bumped by the corresponding amount
144 in/out counters will both be bumped by the corresponding amount
134 (as if the macro's contents had been typed interactively). Typing
145 (as if the macro's contents had been typed interactively). Typing
135 %hist will reveal the intermediate (silently processed) lines.
146 %hist will reveal the intermediate (silently processed) lines.
136
147
137 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
148 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
138 pickle to fail (%run was overwriting __main__ and not restoring
149 pickle to fail (%run was overwriting __main__ and not restoring
139 it, but pickle relies on __main__ to operate).
150 it, but pickle relies on __main__ to operate).
140
151
141 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
152 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
142 using properties, but forgot to make the main InteractiveShell
153 using properties, but forgot to make the main InteractiveShell
143 class a new-style class. Properties fail silently, and
154 class a new-style class. Properties fail silently, and
144 misteriously, with old-style class (getters work, but
155 misteriously, with old-style class (getters work, but
145 setters don't do anything).
156 setters don't do anything).
146
157
147 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
158 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
148
159
149 * IPython/Magic.py (magic_history): fix history reporting bug (I
160 * IPython/Magic.py (magic_history): fix history reporting bug (I
150 know some nasties are still there, I just can't seem to find a
161 know some nasties are still there, I just can't seem to find a
151 reproducible test case to track them down; the input history is
162 reproducible test case to track them down; the input history is
152 falling out of sync...)
163 falling out of sync...)
153
164
154 * IPython/iplib.py (handle_shell_escape): fix bug where both
165 * IPython/iplib.py (handle_shell_escape): fix bug where both
155 aliases and system accesses where broken for indented code (such
166 aliases and system accesses where broken for indented code (such
156 as loops).
167 as loops).
157
168
158 * IPython/genutils.py (shell): fix small but critical bug for
169 * IPython/genutils.py (shell): fix small but critical bug for
159 win32 system access.
170 win32 system access.
160
171
161 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
172 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
162
173
163 * IPython/iplib.py (showtraceback): remove use of the
174 * IPython/iplib.py (showtraceback): remove use of the
164 sys.last_{type/value/traceback} structures, which are non
175 sys.last_{type/value/traceback} structures, which are non
165 thread-safe.
176 thread-safe.
166 (_prefilter): change control flow to ensure that we NEVER
177 (_prefilter): change control flow to ensure that we NEVER
167 introspect objects when autocall is off. This will guarantee that
178 introspect objects when autocall is off. This will guarantee that
168 having an input line of the form 'x.y', where access to attribute
179 having an input line of the form 'x.y', where access to attribute
169 'y' has side effects, doesn't trigger the side effect TWICE. It
180 'y' has side effects, doesn't trigger the side effect TWICE. It
170 is important to note that, with autocall on, these side effects
181 is important to note that, with autocall on, these side effects
171 can still happen.
182 can still happen.
172 (ipsystem): new builtin, to complete the ip{magic/alias/system}
183 (ipsystem): new builtin, to complete the ip{magic/alias/system}
173 trio. IPython offers these three kinds of special calls which are
184 trio. IPython offers these three kinds of special calls which are
174 not python code, and it's a good thing to have their call method
185 not python code, and it's a good thing to have their call method
175 be accessible as pure python functions (not just special syntax at
186 be accessible as pure python functions (not just special syntax at
176 the command line). It gives us a better internal implementation
187 the command line). It gives us a better internal implementation
177 structure, as well as exposing these for user scripting more
188 structure, as well as exposing these for user scripting more
178 cleanly.
189 cleanly.
179
190
180 * IPython/macro.py (Macro.__init__): moved macros to a standalone
191 * IPython/macro.py (Macro.__init__): moved macros to a standalone
181 file. Now that they'll be more likely to be used with the
192 file. Now that they'll be more likely to be used with the
182 persistance system (%store), I want to make sure their module path
193 persistance system (%store), I want to make sure their module path
183 doesn't change in the future, so that we don't break things for
194 doesn't change in the future, so that we don't break things for
184 users' persisted data.
195 users' persisted data.
185
196
186 * IPython/iplib.py (autoindent_update): move indentation
197 * IPython/iplib.py (autoindent_update): move indentation
187 management into the _text_ processing loop, not the keyboard
198 management into the _text_ processing loop, not the keyboard
188 interactive one. This is necessary to correctly process non-typed
199 interactive one. This is necessary to correctly process non-typed
189 multiline input (such as macros).
200 multiline input (such as macros).
190
201
191 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
202 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
192 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
203 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
193 which was producing problems in the resulting manual.
204 which was producing problems in the resulting manual.
194 (magic_whos): improve reporting of instances (show their class,
205 (magic_whos): improve reporting of instances (show their class,
195 instead of simply printing 'instance' which isn't terribly
206 instead of simply printing 'instance' which isn't terribly
196 informative).
207 informative).
197
208
198 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
209 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
199 (minor mods) to support network shares under win32.
210 (minor mods) to support network shares under win32.
200
211
201 * IPython/winconsole.py (get_console_size): add new winconsole
212 * IPython/winconsole.py (get_console_size): add new winconsole
202 module and fixes to page_dumb() to improve its behavior under
213 module and fixes to page_dumb() to improve its behavior under
203 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
214 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
204
215
205 * IPython/Magic.py (Macro): simplified Macro class to just
216 * IPython/Magic.py (Macro): simplified Macro class to just
206 subclass list. We've had only 2.2 compatibility for a very long
217 subclass list. We've had only 2.2 compatibility for a very long
207 time, yet I was still avoiding subclassing the builtin types. No
218 time, yet I was still avoiding subclassing the builtin types. No
208 more (I'm also starting to use properties, though I won't shift to
219 more (I'm also starting to use properties, though I won't shift to
209 2.3-specific features quite yet).
220 2.3-specific features quite yet).
210 (magic_store): added Ville's patch for lightweight variable
221 (magic_store): added Ville's patch for lightweight variable
211 persistence, after a request on the user list by Matt Wilkie
222 persistence, after a request on the user list by Matt Wilkie
212 <maphew-AT-gmail.com>. The new %store magic's docstring has full
223 <maphew-AT-gmail.com>. The new %store magic's docstring has full
213 details.
224 details.
214
225
215 * IPython/iplib.py (InteractiveShell.post_config_initialization):
226 * IPython/iplib.py (InteractiveShell.post_config_initialization):
216 changed the default logfile name from 'ipython.log' to
227 changed the default logfile name from 'ipython.log' to
217 'ipython_log.py'. These logs are real python files, and now that
228 'ipython_log.py'. These logs are real python files, and now that
218 we have much better multiline support, people are more likely to
229 we have much better multiline support, people are more likely to
219 want to use them as such. Might as well name them correctly.
230 want to use them as such. Might as well name them correctly.
220
231
221 * IPython/Magic.py: substantial cleanup. While we can't stop
232 * IPython/Magic.py: substantial cleanup. While we can't stop
222 using magics as mixins, due to the existing customizations 'out
233 using magics as mixins, due to the existing customizations 'out
223 there' which rely on the mixin naming conventions, at least I
234 there' which rely on the mixin naming conventions, at least I
224 cleaned out all cross-class name usage. So once we are OK with
235 cleaned out all cross-class name usage. So once we are OK with
225 breaking compatibility, the two systems can be separated.
236 breaking compatibility, the two systems can be separated.
226
237
227 * IPython/Logger.py: major cleanup. This one is NOT a mixin
238 * IPython/Logger.py: major cleanup. This one is NOT a mixin
228 anymore, and the class is a fair bit less hideous as well. New
239 anymore, and the class is a fair bit less hideous as well. New
229 features were also introduced: timestamping of input, and logging
240 features were also introduced: timestamping of input, and logging
230 of output results. These are user-visible with the -t and -o
241 of output results. These are user-visible with the -t and -o
231 options to %logstart. Closes
242 options to %logstart. Closes
232 http://www.scipy.net/roundup/ipython/issue11 and a request by
243 http://www.scipy.net/roundup/ipython/issue11 and a request by
233 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
244 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
234
245
235 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
246 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
236
247
237 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
248 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
238 better hadnle backslashes in paths. See the thread 'More Windows
249 better hadnle backslashes in paths. See the thread 'More Windows
239 questions part 2 - \/ characters revisited' on the iypthon user
250 questions part 2 - \/ characters revisited' on the iypthon user
240 list:
251 list:
241 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
252 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
242
253
243 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
254 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
244
255
245 (InteractiveShell.__init__): change threaded shells to not use the
256 (InteractiveShell.__init__): change threaded shells to not use the
246 ipython crash handler. This was causing more problems than not,
257 ipython crash handler. This was causing more problems than not,
247 as exceptions in the main thread (GUI code, typically) would
258 as exceptions in the main thread (GUI code, typically) would
248 always show up as a 'crash', when they really weren't.
259 always show up as a 'crash', when they really weren't.
249
260
250 The colors and exception mode commands (%colors/%xmode) have been
261 The colors and exception mode commands (%colors/%xmode) have been
251 synchronized to also take this into account, so users can get
262 synchronized to also take this into account, so users can get
252 verbose exceptions for their threaded code as well. I also added
263 verbose exceptions for their threaded code as well. I also added
253 support for activating pdb inside this exception handler as well,
264 support for activating pdb inside this exception handler as well,
254 so now GUI authors can use IPython's enhanced pdb at runtime.
265 so now GUI authors can use IPython's enhanced pdb at runtime.
255
266
256 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
267 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
257 true by default, and add it to the shipped ipythonrc file. Since
268 true by default, and add it to the shipped ipythonrc file. Since
258 this asks the user before proceeding, I think it's OK to make it
269 this asks the user before proceeding, I think it's OK to make it
259 true by default.
270 true by default.
260
271
261 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
272 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
262 of the previous special-casing of input in the eval loop. I think
273 of the previous special-casing of input in the eval loop. I think
263 this is cleaner, as they really are commands and shouldn't have
274 this is cleaner, as they really are commands and shouldn't have
264 a special role in the middle of the core code.
275 a special role in the middle of the core code.
265
276
266 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
277 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
267
278
268 * IPython/iplib.py (edit_syntax_error): added support for
279 * IPython/iplib.py (edit_syntax_error): added support for
269 automatically reopening the editor if the file had a syntax error
280 automatically reopening the editor if the file had a syntax error
270 in it. Thanks to scottt who provided the patch at:
281 in it. Thanks to scottt who provided the patch at:
271 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
282 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
272 version committed).
283 version committed).
273
284
274 * IPython/iplib.py (handle_normal): add suport for multi-line
285 * IPython/iplib.py (handle_normal): add suport for multi-line
275 input with emtpy lines. This fixes
286 input with emtpy lines. This fixes
276 http://www.scipy.net/roundup/ipython/issue43 and a similar
287 http://www.scipy.net/roundup/ipython/issue43 and a similar
277 discussion on the user list.
288 discussion on the user list.
278
289
279 WARNING: a behavior change is necessarily introduced to support
290 WARNING: a behavior change is necessarily introduced to support
280 blank lines: now a single blank line with whitespace does NOT
291 blank lines: now a single blank line with whitespace does NOT
281 break the input loop, which means that when autoindent is on, by
292 break the input loop, which means that when autoindent is on, by
282 default hitting return on the next (indented) line does NOT exit.
293 default hitting return on the next (indented) line does NOT exit.
283
294
284 Instead, to exit a multiline input you can either have:
295 Instead, to exit a multiline input you can either have:
285
296
286 - TWO whitespace lines (just hit return again), or
297 - TWO whitespace lines (just hit return again), or
287 - a single whitespace line of a different length than provided
298 - a single whitespace line of a different length than provided
288 by the autoindent (add or remove a space).
299 by the autoindent (add or remove a space).
289
300
290 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
301 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
291 module to better organize all readline-related functionality.
302 module to better organize all readline-related functionality.
292 I've deleted FlexCompleter and put all completion clases here.
303 I've deleted FlexCompleter and put all completion clases here.
293
304
294 * IPython/iplib.py (raw_input): improve indentation management.
305 * IPython/iplib.py (raw_input): improve indentation management.
295 It is now possible to paste indented code with autoindent on, and
306 It is now possible to paste indented code with autoindent on, and
296 the code is interpreted correctly (though it still looks bad on
307 the code is interpreted correctly (though it still looks bad on
297 screen, due to the line-oriented nature of ipython).
308 screen, due to the line-oriented nature of ipython).
298 (MagicCompleter.complete): change behavior so that a TAB key on an
309 (MagicCompleter.complete): change behavior so that a TAB key on an
299 otherwise empty line actually inserts a tab, instead of completing
310 otherwise empty line actually inserts a tab, instead of completing
300 on the entire global namespace. This makes it easier to use the
311 on the entire global namespace. This makes it easier to use the
301 TAB key for indentation. After a request by Hans Meine
312 TAB key for indentation. After a request by Hans Meine
302 <hans_meine-AT-gmx.net>
313 <hans_meine-AT-gmx.net>
303 (_prefilter): add support so that typing plain 'exit' or 'quit'
314 (_prefilter): add support so that typing plain 'exit' or 'quit'
304 does a sensible thing. Originally I tried to deviate as little as
315 does a sensible thing. Originally I tried to deviate as little as
305 possible from the default python behavior, but even that one may
316 possible from the default python behavior, but even that one may
306 change in this direction (thread on python-dev to that effect).
317 change in this direction (thread on python-dev to that effect).
307 Regardless, ipython should do the right thing even if CPython's
318 Regardless, ipython should do the right thing even if CPython's
308 '>>>' prompt doesn't.
319 '>>>' prompt doesn't.
309 (InteractiveShell): removed subclassing code.InteractiveConsole
320 (InteractiveShell): removed subclassing code.InteractiveConsole
310 class. By now we'd overridden just about all of its methods: I've
321 class. By now we'd overridden just about all of its methods: I've
311 copied the remaining two over, and now ipython is a standalone
322 copied the remaining two over, and now ipython is a standalone
312 class. This will provide a clearer picture for the chainsaw
323 class. This will provide a clearer picture for the chainsaw
313 branch refactoring.
324 branch refactoring.
314
325
315 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
326 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
316
327
317 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
328 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
318 failures for objects which break when dir() is called on them.
329 failures for objects which break when dir() is called on them.
319
330
320 * IPython/FlexCompleter.py (Completer.__init__): Added support for
331 * IPython/FlexCompleter.py (Completer.__init__): Added support for
321 distinct local and global namespaces in the completer API. This
332 distinct local and global namespaces in the completer API. This
322 change allows us top properly handle completion with distinct
333 change allows us top properly handle completion with distinct
323 scopes, including in embedded instances (this had never really
334 scopes, including in embedded instances (this had never really
324 worked correctly).
335 worked correctly).
325
336
326 Note: this introduces a change in the constructor for
337 Note: this introduces a change in the constructor for
327 MagicCompleter, as a new global_namespace parameter is now the
338 MagicCompleter, as a new global_namespace parameter is now the
328 second argument (the others were bumped one position).
339 second argument (the others were bumped one position).
329
340
330 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
341 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
331
342
332 * IPython/iplib.py (embed_mainloop): fix tab-completion in
343 * IPython/iplib.py (embed_mainloop): fix tab-completion in
333 embedded instances (which can be done now thanks to Vivian's
344 embedded instances (which can be done now thanks to Vivian's
334 frame-handling fixes for pdb).
345 frame-handling fixes for pdb).
335 (InteractiveShell.__init__): Fix namespace handling problem in
346 (InteractiveShell.__init__): Fix namespace handling problem in
336 embedded instances. We were overwriting __main__ unconditionally,
347 embedded instances. We were overwriting __main__ unconditionally,
337 and this should only be done for 'full' (non-embedded) IPython;
348 and this should only be done for 'full' (non-embedded) IPython;
338 embedded instances must respect the caller's __main__. Thanks to
349 embedded instances must respect the caller's __main__. Thanks to
339 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
350 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
340
351
341 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
352 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
342
353
343 * setup.py: added download_url to setup(). This registers the
354 * setup.py: added download_url to setup(). This registers the
344 download address at PyPI, which is not only useful to humans
355 download address at PyPI, which is not only useful to humans
345 browsing the site, but is also picked up by setuptools (the Eggs
356 browsing the site, but is also picked up by setuptools (the Eggs
346 machinery). Thanks to Ville and R. Kern for the info/discussion
357 machinery). Thanks to Ville and R. Kern for the info/discussion
347 on this.
358 on this.
348
359
349 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
360 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
350
361
351 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
362 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
352 This brings a lot of nice functionality to the pdb mode, which now
363 This brings a lot of nice functionality to the pdb mode, which now
353 has tab-completion, syntax highlighting, and better stack handling
364 has tab-completion, syntax highlighting, and better stack handling
354 than before. Many thanks to Vivian De Smedt
365 than before. Many thanks to Vivian De Smedt
355 <vivian-AT-vdesmedt.com> for the original patches.
366 <vivian-AT-vdesmedt.com> for the original patches.
356
367
357 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
368 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
358
369
359 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
370 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
360 sequence to consistently accept the banner argument. The
371 sequence to consistently accept the banner argument. The
361 inconsistency was tripping SAGE, thanks to Gary Zablackis
372 inconsistency was tripping SAGE, thanks to Gary Zablackis
362 <gzabl-AT-yahoo.com> for the report.
373 <gzabl-AT-yahoo.com> for the report.
363
374
364 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
375 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
365
376
366 * IPython/iplib.py (InteractiveShell.post_config_initialization):
377 * IPython/iplib.py (InteractiveShell.post_config_initialization):
367 Fix bug where a naked 'alias' call in the ipythonrc file would
378 Fix bug where a naked 'alias' call in the ipythonrc file would
368 cause a crash. Bug reported by Jorgen Stenarson.
379 cause a crash. Bug reported by Jorgen Stenarson.
369
380
370 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
381 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
371
382
372 * IPython/ipmaker.py (make_IPython): cleanups which should improve
383 * IPython/ipmaker.py (make_IPython): cleanups which should improve
373 startup time.
384 startup time.
374
385
375 * IPython/iplib.py (runcode): my globals 'fix' for embedded
386 * IPython/iplib.py (runcode): my globals 'fix' for embedded
376 instances had introduced a bug with globals in normal code. Now
387 instances had introduced a bug with globals in normal code. Now
377 it's working in all cases.
388 it's working in all cases.
378
389
379 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
390 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
380 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
391 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
381 has been introduced to set the default case sensitivity of the
392 has been introduced to set the default case sensitivity of the
382 searches. Users can still select either mode at runtime on a
393 searches. Users can still select either mode at runtime on a
383 per-search basis.
394 per-search basis.
384
395
385 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
396 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
386
397
387 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
398 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
388 attributes in wildcard searches for subclasses. Modified version
399 attributes in wildcard searches for subclasses. Modified version
389 of a patch by Jorgen.
400 of a patch by Jorgen.
390
401
391 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
402 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
392
403
393 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
404 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
394 embedded instances. I added a user_global_ns attribute to the
405 embedded instances. I added a user_global_ns attribute to the
395 InteractiveShell class to handle this.
406 InteractiveShell class to handle this.
396
407
397 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
408 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
398
409
399 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
410 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
400 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
411 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
401 (reported under win32, but may happen also in other platforms).
412 (reported under win32, but may happen also in other platforms).
402 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
413 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
403
414
404 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
415 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
405
416
406 * IPython/Magic.py (magic_psearch): new support for wildcard
417 * IPython/Magic.py (magic_psearch): new support for wildcard
407 patterns. Now, typing ?a*b will list all names which begin with a
418 patterns. Now, typing ?a*b will list all names which begin with a
408 and end in b, for example. The %psearch magic has full
419 and end in b, for example. The %psearch magic has full
409 docstrings. Many thanks to Jörgen Stenarson
420 docstrings. Many thanks to Jörgen Stenarson
410 <jorgen.stenarson-AT-bostream.nu>, author of the patches
421 <jorgen.stenarson-AT-bostream.nu>, author of the patches
411 implementing this functionality.
422 implementing this functionality.
412
423
413 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
424 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
414
425
415 * Manual: fixed long-standing annoyance of double-dashes (as in
426 * Manual: fixed long-standing annoyance of double-dashes (as in
416 --prefix=~, for example) being stripped in the HTML version. This
427 --prefix=~, for example) being stripped in the HTML version. This
417 is a latex2html bug, but a workaround was provided. Many thanks
428 is a latex2html bug, but a workaround was provided. Many thanks
418 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
429 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
419 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
430 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
420 rolling. This seemingly small issue had tripped a number of users
431 rolling. This seemingly small issue had tripped a number of users
421 when first installing, so I'm glad to see it gone.
432 when first installing, so I'm glad to see it gone.
422
433
423 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
434 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
424
435
425 * IPython/Extensions/numeric_formats.py: fix missing import,
436 * IPython/Extensions/numeric_formats.py: fix missing import,
426 reported by Stephen Walton.
437 reported by Stephen Walton.
427
438
428 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
439 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
429
440
430 * IPython/demo.py: finish demo module, fully documented now.
441 * IPython/demo.py: finish demo module, fully documented now.
431
442
432 * IPython/genutils.py (file_read): simple little utility to read a
443 * IPython/genutils.py (file_read): simple little utility to read a
433 file and ensure it's closed afterwards.
444 file and ensure it's closed afterwards.
434
445
435 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
446 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
436
447
437 * IPython/demo.py (Demo.__init__): added support for individually
448 * IPython/demo.py (Demo.__init__): added support for individually
438 tagging blocks for automatic execution.
449 tagging blocks for automatic execution.
439
450
440 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
451 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
441 syntax-highlighted python sources, requested by John.
452 syntax-highlighted python sources, requested by John.
442
453
443 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
454 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
444
455
445 * IPython/demo.py (Demo.again): fix bug where again() blocks after
456 * IPython/demo.py (Demo.again): fix bug where again() blocks after
446 finishing.
457 finishing.
447
458
448 * IPython/genutils.py (shlex_split): moved from Magic to here,
459 * IPython/genutils.py (shlex_split): moved from Magic to here,
449 where all 2.2 compatibility stuff lives. I needed it for demo.py.
460 where all 2.2 compatibility stuff lives. I needed it for demo.py.
450
461
451 * IPython/demo.py (Demo.__init__): added support for silent
462 * IPython/demo.py (Demo.__init__): added support for silent
452 blocks, improved marks as regexps, docstrings written.
463 blocks, improved marks as regexps, docstrings written.
453 (Demo.__init__): better docstring, added support for sys.argv.
464 (Demo.__init__): better docstring, added support for sys.argv.
454
465
455 * IPython/genutils.py (marquee): little utility used by the demo
466 * IPython/genutils.py (marquee): little utility used by the demo
456 code, handy in general.
467 code, handy in general.
457
468
458 * IPython/demo.py (Demo.__init__): new class for interactive
469 * IPython/demo.py (Demo.__init__): new class for interactive
459 demos. Not documented yet, I just wrote it in a hurry for
470 demos. Not documented yet, I just wrote it in a hurry for
460 scipy'05. Will docstring later.
471 scipy'05. Will docstring later.
461
472
462 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
473 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
463
474
464 * IPython/Shell.py (sigint_handler): Drastic simplification which
475 * IPython/Shell.py (sigint_handler): Drastic simplification which
465 also seems to make Ctrl-C work correctly across threads! This is
476 also seems to make Ctrl-C work correctly across threads! This is
466 so simple, that I can't beleive I'd missed it before. Needs more
477 so simple, that I can't beleive I'd missed it before. Needs more
467 testing, though.
478 testing, though.
468 (KBINT): Never mind, revert changes. I'm sure I'd tried something
479 (KBINT): Never mind, revert changes. I'm sure I'd tried something
469 like this before...
480 like this before...
470
481
471 * IPython/genutils.py (get_home_dir): add protection against
482 * IPython/genutils.py (get_home_dir): add protection against
472 non-dirs in win32 registry.
483 non-dirs in win32 registry.
473
484
474 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
485 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
475 bug where dict was mutated while iterating (pysh crash).
486 bug where dict was mutated while iterating (pysh crash).
476
487
477 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
488 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
478
489
479 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
490 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
480 spurious newlines added by this routine. After a report by
491 spurious newlines added by this routine. After a report by
481 F. Mantegazza.
492 F. Mantegazza.
482
493
483 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
494 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
484
495
485 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
496 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
486 calls. These were a leftover from the GTK 1.x days, and can cause
497 calls. These were a leftover from the GTK 1.x days, and can cause
487 problems in certain cases (after a report by John Hunter).
498 problems in certain cases (after a report by John Hunter).
488
499
489 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
500 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
490 os.getcwd() fails at init time. Thanks to patch from David Remahl
501 os.getcwd() fails at init time. Thanks to patch from David Remahl
491 <chmod007-AT-mac.com>.
502 <chmod007-AT-mac.com>.
492 (InteractiveShell.__init__): prevent certain special magics from
503 (InteractiveShell.__init__): prevent certain special magics from
493 being shadowed by aliases. Closes
504 being shadowed by aliases. Closes
494 http://www.scipy.net/roundup/ipython/issue41.
505 http://www.scipy.net/roundup/ipython/issue41.
495
506
496 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
507 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
497
508
498 * IPython/iplib.py (InteractiveShell.complete): Added new
509 * IPython/iplib.py (InteractiveShell.complete): Added new
499 top-level completion method to expose the completion mechanism
510 top-level completion method to expose the completion mechanism
500 beyond readline-based environments.
511 beyond readline-based environments.
501
512
502 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
513 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
503
514
504 * tools/ipsvnc (svnversion): fix svnversion capture.
515 * tools/ipsvnc (svnversion): fix svnversion capture.
505
516
506 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
517 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
507 attribute to self, which was missing. Before, it was set by a
518 attribute to self, which was missing. Before, it was set by a
508 routine which in certain cases wasn't being called, so the
519 routine which in certain cases wasn't being called, so the
509 instance could end up missing the attribute. This caused a crash.
520 instance could end up missing the attribute. This caused a crash.
510 Closes http://www.scipy.net/roundup/ipython/issue40.
521 Closes http://www.scipy.net/roundup/ipython/issue40.
511
522
512 2005-08-16 Fernando Perez <fperez@colorado.edu>
523 2005-08-16 Fernando Perez <fperez@colorado.edu>
513
524
514 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
525 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
515 contains non-string attribute. Closes
526 contains non-string attribute. Closes
516 http://www.scipy.net/roundup/ipython/issue38.
527 http://www.scipy.net/roundup/ipython/issue38.
517
528
518 2005-08-14 Fernando Perez <fperez@colorado.edu>
529 2005-08-14 Fernando Perez <fperez@colorado.edu>
519
530
520 * tools/ipsvnc: Minor improvements, to add changeset info.
531 * tools/ipsvnc: Minor improvements, to add changeset info.
521
532
522 2005-08-12 Fernando Perez <fperez@colorado.edu>
533 2005-08-12 Fernando Perez <fperez@colorado.edu>
523
534
524 * IPython/iplib.py (runsource): remove self.code_to_run_src
535 * IPython/iplib.py (runsource): remove self.code_to_run_src
525 attribute. I realized this is nothing more than
536 attribute. I realized this is nothing more than
526 '\n'.join(self.buffer), and having the same data in two different
537 '\n'.join(self.buffer), and having the same data in two different
527 places is just asking for synchronization bugs. This may impact
538 places is just asking for synchronization bugs. This may impact
528 people who have custom exception handlers, so I need to warn
539 people who have custom exception handlers, so I need to warn
529 ipython-dev about it (F. Mantegazza may use them).
540 ipython-dev about it (F. Mantegazza may use them).
530
541
531 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
542 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
532
543
533 * IPython/genutils.py: fix 2.2 compatibility (generators)
544 * IPython/genutils.py: fix 2.2 compatibility (generators)
534
545
535 2005-07-18 Fernando Perez <fperez@colorado.edu>
546 2005-07-18 Fernando Perez <fperez@colorado.edu>
536
547
537 * IPython/genutils.py (get_home_dir): fix to help users with
548 * IPython/genutils.py (get_home_dir): fix to help users with
538 invalid $HOME under win32.
549 invalid $HOME under win32.
539
550
540 2005-07-17 Fernando Perez <fperez@colorado.edu>
551 2005-07-17 Fernando Perez <fperez@colorado.edu>
541
552
542 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
553 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
543 some old hacks and clean up a bit other routines; code should be
554 some old hacks and clean up a bit other routines; code should be
544 simpler and a bit faster.
555 simpler and a bit faster.
545
556
546 * IPython/iplib.py (interact): removed some last-resort attempts
557 * IPython/iplib.py (interact): removed some last-resort attempts
547 to survive broken stdout/stderr. That code was only making it
558 to survive broken stdout/stderr. That code was only making it
548 harder to abstract out the i/o (necessary for gui integration),
559 harder to abstract out the i/o (necessary for gui integration),
549 and the crashes it could prevent were extremely rare in practice
560 and the crashes it could prevent were extremely rare in practice
550 (besides being fully user-induced in a pretty violent manner).
561 (besides being fully user-induced in a pretty violent manner).
551
562
552 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
563 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
553 Nothing major yet, but the code is simpler to read; this should
564 Nothing major yet, but the code is simpler to read; this should
554 make it easier to do more serious modifications in the future.
565 make it easier to do more serious modifications in the future.
555
566
556 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
567 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
557 which broke in .15 (thanks to a report by Ville).
568 which broke in .15 (thanks to a report by Ville).
558
569
559 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
570 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
560 be quite correct, I know next to nothing about unicode). This
571 be quite correct, I know next to nothing about unicode). This
561 will allow unicode strings to be used in prompts, amongst other
572 will allow unicode strings to be used in prompts, amongst other
562 cases. It also will prevent ipython from crashing when unicode
573 cases. It also will prevent ipython from crashing when unicode
563 shows up unexpectedly in many places. If ascii encoding fails, we
574 shows up unexpectedly in many places. If ascii encoding fails, we
564 assume utf_8. Currently the encoding is not a user-visible
575 assume utf_8. Currently the encoding is not a user-visible
565 setting, though it could be made so if there is demand for it.
576 setting, though it could be made so if there is demand for it.
566
577
567 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
578 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
568
579
569 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
580 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
570
581
571 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
582 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
572
583
573 * IPython/genutils.py: Add 2.2 compatibility here, so all other
584 * IPython/genutils.py: Add 2.2 compatibility here, so all other
574 code can work transparently for 2.2/2.3.
585 code can work transparently for 2.2/2.3.
575
586
576 2005-07-16 Fernando Perez <fperez@colorado.edu>
587 2005-07-16 Fernando Perez <fperez@colorado.edu>
577
588
578 * IPython/ultraTB.py (ExceptionColors): Make a global variable
589 * IPython/ultraTB.py (ExceptionColors): Make a global variable
579 out of the color scheme table used for coloring exception
590 out of the color scheme table used for coloring exception
580 tracebacks. This allows user code to add new schemes at runtime.
591 tracebacks. This allows user code to add new schemes at runtime.
581 This is a minimally modified version of the patch at
592 This is a minimally modified version of the patch at
582 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
593 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
583 for the contribution.
594 for the contribution.
584
595
585 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
596 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
586 slightly modified version of the patch in
597 slightly modified version of the patch in
587 http://www.scipy.net/roundup/ipython/issue34, which also allows me
598 http://www.scipy.net/roundup/ipython/issue34, which also allows me
588 to remove the previous try/except solution (which was costlier).
599 to remove the previous try/except solution (which was costlier).
589 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
600 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
590
601
591 2005-06-08 Fernando Perez <fperez@colorado.edu>
602 2005-06-08 Fernando Perez <fperez@colorado.edu>
592
603
593 * IPython/iplib.py (write/write_err): Add methods to abstract all
604 * IPython/iplib.py (write/write_err): Add methods to abstract all
594 I/O a bit more.
605 I/O a bit more.
595
606
596 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
607 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
597 warning, reported by Aric Hagberg, fix by JD Hunter.
608 warning, reported by Aric Hagberg, fix by JD Hunter.
598
609
599 2005-06-02 *** Released version 0.6.15
610 2005-06-02 *** Released version 0.6.15
600
611
601 2005-06-01 Fernando Perez <fperez@colorado.edu>
612 2005-06-01 Fernando Perez <fperez@colorado.edu>
602
613
603 * IPython/iplib.py (MagicCompleter.file_matches): Fix
614 * IPython/iplib.py (MagicCompleter.file_matches): Fix
604 tab-completion of filenames within open-quoted strings. Note that
615 tab-completion of filenames within open-quoted strings. Note that
605 this requires that in ~/.ipython/ipythonrc, users change the
616 this requires that in ~/.ipython/ipythonrc, users change the
606 readline delimiters configuration to read:
617 readline delimiters configuration to read:
607
618
608 readline_remove_delims -/~
619 readline_remove_delims -/~
609
620
610
621
611 2005-05-31 *** Released version 0.6.14
622 2005-05-31 *** Released version 0.6.14
612
623
613 2005-05-29 Fernando Perez <fperez@colorado.edu>
624 2005-05-29 Fernando Perez <fperez@colorado.edu>
614
625
615 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
626 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
616 with files not on the filesystem. Reported by Eliyahu Sandler
627 with files not on the filesystem. Reported by Eliyahu Sandler
617 <eli@gondolin.net>
628 <eli@gondolin.net>
618
629
619 2005-05-22 Fernando Perez <fperez@colorado.edu>
630 2005-05-22 Fernando Perez <fperez@colorado.edu>
620
631
621 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
632 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
622 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
633 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
623
634
624 2005-05-19 Fernando Perez <fperez@colorado.edu>
635 2005-05-19 Fernando Perez <fperez@colorado.edu>
625
636
626 * IPython/iplib.py (safe_execfile): close a file which could be
637 * IPython/iplib.py (safe_execfile): close a file which could be
627 left open (causing problems in win32, which locks open files).
638 left open (causing problems in win32, which locks open files).
628 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
639 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
629
640
630 2005-05-18 Fernando Perez <fperez@colorado.edu>
641 2005-05-18 Fernando Perez <fperez@colorado.edu>
631
642
632 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
643 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
633 keyword arguments correctly to safe_execfile().
644 keyword arguments correctly to safe_execfile().
634
645
635 2005-05-13 Fernando Perez <fperez@colorado.edu>
646 2005-05-13 Fernando Perez <fperez@colorado.edu>
636
647
637 * ipython.1: Added info about Qt to manpage, and threads warning
648 * ipython.1: Added info about Qt to manpage, and threads warning
638 to usage page (invoked with --help).
649 to usage page (invoked with --help).
639
650
640 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
651 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
641 new matcher (it goes at the end of the priority list) to do
652 new matcher (it goes at the end of the priority list) to do
642 tab-completion on named function arguments. Submitted by George
653 tab-completion on named function arguments. Submitted by George
643 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
654 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
644 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
655 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
645 for more details.
656 for more details.
646
657
647 * IPython/Magic.py (magic_run): Added new -e flag to ignore
658 * IPython/Magic.py (magic_run): Added new -e flag to ignore
648 SystemExit exceptions in the script being run. Thanks to a report
659 SystemExit exceptions in the script being run. Thanks to a report
649 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
660 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
650 producing very annoying behavior when running unit tests.
661 producing very annoying behavior when running unit tests.
651
662
652 2005-05-12 Fernando Perez <fperez@colorado.edu>
663 2005-05-12 Fernando Perez <fperez@colorado.edu>
653
664
654 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
665 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
655 which I'd broken (again) due to a changed regexp. In the process,
666 which I'd broken (again) due to a changed regexp. In the process,
656 added ';' as an escape to auto-quote the whole line without
667 added ';' as an escape to auto-quote the whole line without
657 splitting its arguments. Thanks to a report by Jerry McRae
668 splitting its arguments. Thanks to a report by Jerry McRae
658 <qrs0xyc02-AT-sneakemail.com>.
669 <qrs0xyc02-AT-sneakemail.com>.
659
670
660 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
671 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
661 possible crashes caused by a TokenError. Reported by Ed Schofield
672 possible crashes caused by a TokenError. Reported by Ed Schofield
662 <schofield-AT-ftw.at>.
673 <schofield-AT-ftw.at>.
663
674
664 2005-05-06 Fernando Perez <fperez@colorado.edu>
675 2005-05-06 Fernando Perez <fperez@colorado.edu>
665
676
666 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
677 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
667
678
668 2005-04-29 Fernando Perez <fperez@colorado.edu>
679 2005-04-29 Fernando Perez <fperez@colorado.edu>
669
680
670 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
681 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
671 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
682 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
672 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
683 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
673 which provides support for Qt interactive usage (similar to the
684 which provides support for Qt interactive usage (similar to the
674 existing one for WX and GTK). This had been often requested.
685 existing one for WX and GTK). This had been often requested.
675
686
676 2005-04-14 *** Released version 0.6.13
687 2005-04-14 *** Released version 0.6.13
677
688
678 2005-04-08 Fernando Perez <fperez@colorado.edu>
689 2005-04-08 Fernando Perez <fperez@colorado.edu>
679
690
680 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
691 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
681 from _ofind, which gets called on almost every input line. Now,
692 from _ofind, which gets called on almost every input line. Now,
682 we only try to get docstrings if they are actually going to be
693 we only try to get docstrings if they are actually going to be
683 used (the overhead of fetching unnecessary docstrings can be
694 used (the overhead of fetching unnecessary docstrings can be
684 noticeable for certain objects, such as Pyro proxies).
695 noticeable for certain objects, such as Pyro proxies).
685
696
686 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
697 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
687 for completers. For some reason I had been passing them the state
698 for completers. For some reason I had been passing them the state
688 variable, which completers never actually need, and was in
699 variable, which completers never actually need, and was in
689 conflict with the rlcompleter API. Custom completers ONLY need to
700 conflict with the rlcompleter API. Custom completers ONLY need to
690 take the text parameter.
701 take the text parameter.
691
702
692 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
703 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
693 work correctly in pysh. I've also moved all the logic which used
704 work correctly in pysh. I've also moved all the logic which used
694 to be in pysh.py here, which will prevent problems with future
705 to be in pysh.py here, which will prevent problems with future
695 upgrades. However, this time I must warn users to update their
706 upgrades. However, this time I must warn users to update their
696 pysh profile to include the line
707 pysh profile to include the line
697
708
698 import_all IPython.Extensions.InterpreterExec
709 import_all IPython.Extensions.InterpreterExec
699
710
700 because otherwise things won't work for them. They MUST also
711 because otherwise things won't work for them. They MUST also
701 delete pysh.py and the line
712 delete pysh.py and the line
702
713
703 execfile pysh.py
714 execfile pysh.py
704
715
705 from their ipythonrc-pysh.
716 from their ipythonrc-pysh.
706
717
707 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
718 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
708 robust in the face of objects whose dir() returns non-strings
719 robust in the face of objects whose dir() returns non-strings
709 (which it shouldn't, but some broken libs like ITK do). Thanks to
720 (which it shouldn't, but some broken libs like ITK do). Thanks to
710 a patch by John Hunter (implemented differently, though). Also
721 a patch by John Hunter (implemented differently, though). Also
711 minor improvements by using .extend instead of + on lists.
722 minor improvements by using .extend instead of + on lists.
712
723
713 * pysh.py:
724 * pysh.py:
714
725
715 2005-04-06 Fernando Perez <fperez@colorado.edu>
726 2005-04-06 Fernando Perez <fperez@colorado.edu>
716
727
717 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
728 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
718 by default, so that all users benefit from it. Those who don't
729 by default, so that all users benefit from it. Those who don't
719 want it can still turn it off.
730 want it can still turn it off.
720
731
721 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
732 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
722 config file, I'd forgotten about this, so users were getting it
733 config file, I'd forgotten about this, so users were getting it
723 off by default.
734 off by default.
724
735
725 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
736 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
726 consistency. Now magics can be called in multiline statements,
737 consistency. Now magics can be called in multiline statements,
727 and python variables can be expanded in magic calls via $var.
738 and python variables can be expanded in magic calls via $var.
728 This makes the magic system behave just like aliases or !system
739 This makes the magic system behave just like aliases or !system
729 calls.
740 calls.
730
741
731 2005-03-28 Fernando Perez <fperez@colorado.edu>
742 2005-03-28 Fernando Perez <fperez@colorado.edu>
732
743
733 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
744 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
734 expensive string additions for building command. Add support for
745 expensive string additions for building command. Add support for
735 trailing ';' when autocall is used.
746 trailing ';' when autocall is used.
736
747
737 2005-03-26 Fernando Perez <fperez@colorado.edu>
748 2005-03-26 Fernando Perez <fperez@colorado.edu>
738
749
739 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
750 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
740 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
751 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
741 ipython.el robust against prompts with any number of spaces
752 ipython.el robust against prompts with any number of spaces
742 (including 0) after the ':' character.
753 (including 0) after the ':' character.
743
754
744 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
755 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
745 continuation prompt, which misled users to think the line was
756 continuation prompt, which misled users to think the line was
746 already indented. Closes debian Bug#300847, reported to me by
757 already indented. Closes debian Bug#300847, reported to me by
747 Norbert Tretkowski <tretkowski-AT-inittab.de>.
758 Norbert Tretkowski <tretkowski-AT-inittab.de>.
748
759
749 2005-03-23 Fernando Perez <fperez@colorado.edu>
760 2005-03-23 Fernando Perez <fperez@colorado.edu>
750
761
751 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
762 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
752 properly aligned if they have embedded newlines.
763 properly aligned if they have embedded newlines.
753
764
754 * IPython/iplib.py (runlines): Add a public method to expose
765 * IPython/iplib.py (runlines): Add a public method to expose
755 IPython's code execution machinery, so that users can run strings
766 IPython's code execution machinery, so that users can run strings
756 as if they had been typed at the prompt interactively.
767 as if they had been typed at the prompt interactively.
757 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
768 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
758 methods which can call the system shell, but with python variable
769 methods which can call the system shell, but with python variable
759 expansion. The three such methods are: __IPYTHON__.system,
770 expansion. The three such methods are: __IPYTHON__.system,
760 .getoutput and .getoutputerror. These need to be documented in a
771 .getoutput and .getoutputerror. These need to be documented in a
761 'public API' section (to be written) of the manual.
772 'public API' section (to be written) of the manual.
762
773
763 2005-03-20 Fernando Perez <fperez@colorado.edu>
774 2005-03-20 Fernando Perez <fperez@colorado.edu>
764
775
765 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
776 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
766 for custom exception handling. This is quite powerful, and it
777 for custom exception handling. This is quite powerful, and it
767 allows for user-installable exception handlers which can trap
778 allows for user-installable exception handlers which can trap
768 custom exceptions at runtime and treat them separately from
779 custom exceptions at runtime and treat them separately from
769 IPython's default mechanisms. At the request of Frédéric
780 IPython's default mechanisms. At the request of Frédéric
770 Mantegazza <mantegazza-AT-ill.fr>.
781 Mantegazza <mantegazza-AT-ill.fr>.
771 (InteractiveShell.set_custom_completer): public API function to
782 (InteractiveShell.set_custom_completer): public API function to
772 add new completers at runtime.
783 add new completers at runtime.
773
784
774 2005-03-19 Fernando Perez <fperez@colorado.edu>
785 2005-03-19 Fernando Perez <fperez@colorado.edu>
775
786
776 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
787 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
777 allow objects which provide their docstrings via non-standard
788 allow objects which provide their docstrings via non-standard
778 mechanisms (like Pyro proxies) to still be inspected by ipython's
789 mechanisms (like Pyro proxies) to still be inspected by ipython's
779 ? system.
790 ? system.
780
791
781 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
792 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
782 automatic capture system. I tried quite hard to make it work
793 automatic capture system. I tried quite hard to make it work
783 reliably, and simply failed. I tried many combinations with the
794 reliably, and simply failed. I tried many combinations with the
784 subprocess module, but eventually nothing worked in all needed
795 subprocess module, but eventually nothing worked in all needed
785 cases (not blocking stdin for the child, duplicating stdout
796 cases (not blocking stdin for the child, duplicating stdout
786 without blocking, etc). The new %sc/%sx still do capture to these
797 without blocking, etc). The new %sc/%sx still do capture to these
787 magical list/string objects which make shell use much more
798 magical list/string objects which make shell use much more
788 conveninent, so not all is lost.
799 conveninent, so not all is lost.
789
800
790 XXX - FIX MANUAL for the change above!
801 XXX - FIX MANUAL for the change above!
791
802
792 (runsource): I copied code.py's runsource() into ipython to modify
803 (runsource): I copied code.py's runsource() into ipython to modify
793 it a bit. Now the code object and source to be executed are
804 it a bit. Now the code object and source to be executed are
794 stored in ipython. This makes this info accessible to third-party
805 stored in ipython. This makes this info accessible to third-party
795 tools, like custom exception handlers. After a request by Frédéric
806 tools, like custom exception handlers. After a request by Frédéric
796 Mantegazza <mantegazza-AT-ill.fr>.
807 Mantegazza <mantegazza-AT-ill.fr>.
797
808
798 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
809 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
799 history-search via readline (like C-p/C-n). I'd wanted this for a
810 history-search via readline (like C-p/C-n). I'd wanted this for a
800 long time, but only recently found out how to do it. For users
811 long time, but only recently found out how to do it. For users
801 who already have their ipythonrc files made and want this, just
812 who already have their ipythonrc files made and want this, just
802 add:
813 add:
803
814
804 readline_parse_and_bind "\e[A": history-search-backward
815 readline_parse_and_bind "\e[A": history-search-backward
805 readline_parse_and_bind "\e[B": history-search-forward
816 readline_parse_and_bind "\e[B": history-search-forward
806
817
807 2005-03-18 Fernando Perez <fperez@colorado.edu>
818 2005-03-18 Fernando Perez <fperez@colorado.edu>
808
819
809 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
820 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
810 LSString and SList classes which allow transparent conversions
821 LSString and SList classes which allow transparent conversions
811 between list mode and whitespace-separated string.
822 between list mode and whitespace-separated string.
812 (magic_r): Fix recursion problem in %r.
823 (magic_r): Fix recursion problem in %r.
813
824
814 * IPython/genutils.py (LSString): New class to be used for
825 * IPython/genutils.py (LSString): New class to be used for
815 automatic storage of the results of all alias/system calls in _o
826 automatic storage of the results of all alias/system calls in _o
816 and _e (stdout/err). These provide a .l/.list attribute which
827 and _e (stdout/err). These provide a .l/.list attribute which
817 does automatic splitting on newlines. This means that for most
828 does automatic splitting on newlines. This means that for most
818 uses, you'll never need to do capturing of output with %sc/%sx
829 uses, you'll never need to do capturing of output with %sc/%sx
819 anymore, since ipython keeps this always done for you. Note that
830 anymore, since ipython keeps this always done for you. Note that
820 only the LAST results are stored, the _o/e variables are
831 only the LAST results are stored, the _o/e variables are
821 overwritten on each call. If you need to save their contents
832 overwritten on each call. If you need to save their contents
822 further, simply bind them to any other name.
833 further, simply bind them to any other name.
823
834
824 2005-03-17 Fernando Perez <fperez@colorado.edu>
835 2005-03-17 Fernando Perez <fperez@colorado.edu>
825
836
826 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
837 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
827 prompt namespace handling.
838 prompt namespace handling.
828
839
829 2005-03-16 Fernando Perez <fperez@colorado.edu>
840 2005-03-16 Fernando Perez <fperez@colorado.edu>
830
841
831 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
842 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
832 classic prompts to be '>>> ' (final space was missing, and it
843 classic prompts to be '>>> ' (final space was missing, and it
833 trips the emacs python mode).
844 trips the emacs python mode).
834 (BasePrompt.__str__): Added safe support for dynamic prompt
845 (BasePrompt.__str__): Added safe support for dynamic prompt
835 strings. Now you can set your prompt string to be '$x', and the
846 strings. Now you can set your prompt string to be '$x', and the
836 value of x will be printed from your interactive namespace. The
847 value of x will be printed from your interactive namespace. The
837 interpolation syntax includes the full Itpl support, so
848 interpolation syntax includes the full Itpl support, so
838 ${foo()+x+bar()} is a valid prompt string now, and the function
849 ${foo()+x+bar()} is a valid prompt string now, and the function
839 calls will be made at runtime.
850 calls will be made at runtime.
840
851
841 2005-03-15 Fernando Perez <fperez@colorado.edu>
852 2005-03-15 Fernando Perez <fperez@colorado.edu>
842
853
843 * IPython/Magic.py (magic_history): renamed %hist to %history, to
854 * IPython/Magic.py (magic_history): renamed %hist to %history, to
844 avoid name clashes in pylab. %hist still works, it just forwards
855 avoid name clashes in pylab. %hist still works, it just forwards
845 the call to %history.
856 the call to %history.
846
857
847 2005-03-02 *** Released version 0.6.12
858 2005-03-02 *** Released version 0.6.12
848
859
849 2005-03-02 Fernando Perez <fperez@colorado.edu>
860 2005-03-02 Fernando Perez <fperez@colorado.edu>
850
861
851 * IPython/iplib.py (handle_magic): log magic calls properly as
862 * IPython/iplib.py (handle_magic): log magic calls properly as
852 ipmagic() function calls.
863 ipmagic() function calls.
853
864
854 * IPython/Magic.py (magic_time): Improved %time to support
865 * IPython/Magic.py (magic_time): Improved %time to support
855 statements and provide wall-clock as well as CPU time.
866 statements and provide wall-clock as well as CPU time.
856
867
857 2005-02-27 Fernando Perez <fperez@colorado.edu>
868 2005-02-27 Fernando Perez <fperez@colorado.edu>
858
869
859 * IPython/hooks.py: New hooks module, to expose user-modifiable
870 * IPython/hooks.py: New hooks module, to expose user-modifiable
860 IPython functionality in a clean manner. For now only the editor
871 IPython functionality in a clean manner. For now only the editor
861 hook is actually written, and other thigns which I intend to turn
872 hook is actually written, and other thigns which I intend to turn
862 into proper hooks aren't yet there. The display and prefilter
873 into proper hooks aren't yet there. The display and prefilter
863 stuff, for example, should be hooks. But at least now the
874 stuff, for example, should be hooks. But at least now the
864 framework is in place, and the rest can be moved here with more
875 framework is in place, and the rest can be moved here with more
865 time later. IPython had had a .hooks variable for a long time for
876 time later. IPython had had a .hooks variable for a long time for
866 this purpose, but I'd never actually used it for anything.
877 this purpose, but I'd never actually used it for anything.
867
878
868 2005-02-26 Fernando Perez <fperez@colorado.edu>
879 2005-02-26 Fernando Perez <fperez@colorado.edu>
869
880
870 * IPython/ipmaker.py (make_IPython): make the default ipython
881 * IPython/ipmaker.py (make_IPython): make the default ipython
871 directory be called _ipython under win32, to follow more the
882 directory be called _ipython under win32, to follow more the
872 naming peculiarities of that platform (where buggy software like
883 naming peculiarities of that platform (where buggy software like
873 Visual Sourcesafe breaks with .named directories). Reported by
884 Visual Sourcesafe breaks with .named directories). Reported by
874 Ville Vainio.
885 Ville Vainio.
875
886
876 2005-02-23 Fernando Perez <fperez@colorado.edu>
887 2005-02-23 Fernando Perez <fperez@colorado.edu>
877
888
878 * IPython/iplib.py (InteractiveShell.__init__): removed a few
889 * IPython/iplib.py (InteractiveShell.__init__): removed a few
879 auto_aliases for win32 which were causing problems. Users can
890 auto_aliases for win32 which were causing problems. Users can
880 define the ones they personally like.
891 define the ones they personally like.
881
892
882 2005-02-21 Fernando Perez <fperez@colorado.edu>
893 2005-02-21 Fernando Perez <fperez@colorado.edu>
883
894
884 * IPython/Magic.py (magic_time): new magic to time execution of
895 * IPython/Magic.py (magic_time): new magic to time execution of
885 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
896 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
886
897
887 2005-02-19 Fernando Perez <fperez@colorado.edu>
898 2005-02-19 Fernando Perez <fperez@colorado.edu>
888
899
889 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
900 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
890 into keys (for prompts, for example).
901 into keys (for prompts, for example).
891
902
892 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
903 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
893 prompts in case users want them. This introduces a small behavior
904 prompts in case users want them. This introduces a small behavior
894 change: ipython does not automatically add a space to all prompts
905 change: ipython does not automatically add a space to all prompts
895 anymore. To get the old prompts with a space, users should add it
906 anymore. To get the old prompts with a space, users should add it
896 manually to their ipythonrc file, so for example prompt_in1 should
907 manually to their ipythonrc file, so for example prompt_in1 should
897 now read 'In [\#]: ' instead of 'In [\#]:'.
908 now read 'In [\#]: ' instead of 'In [\#]:'.
898 (BasePrompt.__init__): New option prompts_pad_left (only in rc
909 (BasePrompt.__init__): New option prompts_pad_left (only in rc
899 file) to control left-padding of secondary prompts.
910 file) to control left-padding of secondary prompts.
900
911
901 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
912 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
902 the profiler can't be imported. Fix for Debian, which removed
913 the profiler can't be imported. Fix for Debian, which removed
903 profile.py because of License issues. I applied a slightly
914 profile.py because of License issues. I applied a slightly
904 modified version of the original Debian patch at
915 modified version of the original Debian patch at
905 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
916 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
906
917
907 2005-02-17 Fernando Perez <fperez@colorado.edu>
918 2005-02-17 Fernando Perez <fperez@colorado.edu>
908
919
909 * IPython/genutils.py (native_line_ends): Fix bug which would
920 * IPython/genutils.py (native_line_ends): Fix bug which would
910 cause improper line-ends under win32 b/c I was not opening files
921 cause improper line-ends under win32 b/c I was not opening files
911 in binary mode. Bug report and fix thanks to Ville.
922 in binary mode. Bug report and fix thanks to Ville.
912
923
913 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
924 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
914 trying to catch spurious foo[1] autocalls. My fix actually broke
925 trying to catch spurious foo[1] autocalls. My fix actually broke
915 ',/' autoquote/call with explicit escape (bad regexp).
926 ',/' autoquote/call with explicit escape (bad regexp).
916
927
917 2005-02-15 *** Released version 0.6.11
928 2005-02-15 *** Released version 0.6.11
918
929
919 2005-02-14 Fernando Perez <fperez@colorado.edu>
930 2005-02-14 Fernando Perez <fperez@colorado.edu>
920
931
921 * IPython/background_jobs.py: New background job management
932 * IPython/background_jobs.py: New background job management
922 subsystem. This is implemented via a new set of classes, and
933 subsystem. This is implemented via a new set of classes, and
923 IPython now provides a builtin 'jobs' object for background job
934 IPython now provides a builtin 'jobs' object for background job
924 execution. A convenience %bg magic serves as a lightweight
935 execution. A convenience %bg magic serves as a lightweight
925 frontend for starting the more common type of calls. This was
936 frontend for starting the more common type of calls. This was
926 inspired by discussions with B. Granger and the BackgroundCommand
937 inspired by discussions with B. Granger and the BackgroundCommand
927 class described in the book Python Scripting for Computational
938 class described in the book Python Scripting for Computational
928 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
939 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
929 (although ultimately no code from this text was used, as IPython's
940 (although ultimately no code from this text was used, as IPython's
930 system is a separate implementation).
941 system is a separate implementation).
931
942
932 * IPython/iplib.py (MagicCompleter.python_matches): add new option
943 * IPython/iplib.py (MagicCompleter.python_matches): add new option
933 to control the completion of single/double underscore names
944 to control the completion of single/double underscore names
934 separately. As documented in the example ipytonrc file, the
945 separately. As documented in the example ipytonrc file, the
935 readline_omit__names variable can now be set to 2, to omit even
946 readline_omit__names variable can now be set to 2, to omit even
936 single underscore names. Thanks to a patch by Brian Wong
947 single underscore names. Thanks to a patch by Brian Wong
937 <BrianWong-AT-AirgoNetworks.Com>.
948 <BrianWong-AT-AirgoNetworks.Com>.
938 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
949 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
939 be autocalled as foo([1]) if foo were callable. A problem for
950 be autocalled as foo([1]) if foo were callable. A problem for
940 things which are both callable and implement __getitem__.
951 things which are both callable and implement __getitem__.
941 (init_readline): Fix autoindentation for win32. Thanks to a patch
952 (init_readline): Fix autoindentation for win32. Thanks to a patch
942 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
953 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
943
954
944 2005-02-12 Fernando Perez <fperez@colorado.edu>
955 2005-02-12 Fernando Perez <fperez@colorado.edu>
945
956
946 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
957 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
947 which I had written long ago to sort out user error messages which
958 which I had written long ago to sort out user error messages which
948 may occur during startup. This seemed like a good idea initially,
959 may occur during startup. This seemed like a good idea initially,
949 but it has proven a disaster in retrospect. I don't want to
960 but it has proven a disaster in retrospect. I don't want to
950 change much code for now, so my fix is to set the internal 'debug'
961 change much code for now, so my fix is to set the internal 'debug'
951 flag to true everywhere, whose only job was precisely to control
962 flag to true everywhere, whose only job was precisely to control
952 this subsystem. This closes issue 28 (as well as avoiding all
963 this subsystem. This closes issue 28 (as well as avoiding all
953 sorts of strange hangups which occur from time to time).
964 sorts of strange hangups which occur from time to time).
954
965
955 2005-02-07 Fernando Perez <fperez@colorado.edu>
966 2005-02-07 Fernando Perez <fperez@colorado.edu>
956
967
957 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
968 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
958 previous call produced a syntax error.
969 previous call produced a syntax error.
959
970
960 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
971 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
961 classes without constructor.
972 classes without constructor.
962
973
963 2005-02-06 Fernando Perez <fperez@colorado.edu>
974 2005-02-06 Fernando Perez <fperez@colorado.edu>
964
975
965 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
976 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
966 completions with the results of each matcher, so we return results
977 completions with the results of each matcher, so we return results
967 to the user from all namespaces. This breaks with ipython
978 to the user from all namespaces. This breaks with ipython
968 tradition, but I think it's a nicer behavior. Now you get all
979 tradition, but I think it's a nicer behavior. Now you get all
969 possible completions listed, from all possible namespaces (python,
980 possible completions listed, from all possible namespaces (python,
970 filesystem, magics...) After a request by John Hunter
981 filesystem, magics...) After a request by John Hunter
971 <jdhunter-AT-nitace.bsd.uchicago.edu>.
982 <jdhunter-AT-nitace.bsd.uchicago.edu>.
972
983
973 2005-02-05 Fernando Perez <fperez@colorado.edu>
984 2005-02-05 Fernando Perez <fperez@colorado.edu>
974
985
975 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
986 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
976 the call had quote characters in it (the quotes were stripped).
987 the call had quote characters in it (the quotes were stripped).
977
988
978 2005-01-31 Fernando Perez <fperez@colorado.edu>
989 2005-01-31 Fernando Perez <fperez@colorado.edu>
979
990
980 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
991 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
981 Itpl.itpl() to make the code more robust against psyco
992 Itpl.itpl() to make the code more robust against psyco
982 optimizations.
993 optimizations.
983
994
984 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
995 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
985 of causing an exception. Quicker, cleaner.
996 of causing an exception. Quicker, cleaner.
986
997
987 2005-01-28 Fernando Perez <fperez@colorado.edu>
998 2005-01-28 Fernando Perez <fperez@colorado.edu>
988
999
989 * scripts/ipython_win_post_install.py (install): hardcode
1000 * scripts/ipython_win_post_install.py (install): hardcode
990 sys.prefix+'python.exe' as the executable path. It turns out that
1001 sys.prefix+'python.exe' as the executable path. It turns out that
991 during the post-installation run, sys.executable resolves to the
1002 during the post-installation run, sys.executable resolves to the
992 name of the binary installer! I should report this as a distutils
1003 name of the binary installer! I should report this as a distutils
993 bug, I think. I updated the .10 release with this tiny fix, to
1004 bug, I think. I updated the .10 release with this tiny fix, to
994 avoid annoying the lists further.
1005 avoid annoying the lists further.
995
1006
996 2005-01-27 *** Released version 0.6.10
1007 2005-01-27 *** Released version 0.6.10
997
1008
998 2005-01-27 Fernando Perez <fperez@colorado.edu>
1009 2005-01-27 Fernando Perez <fperez@colorado.edu>
999
1010
1000 * IPython/numutils.py (norm): Added 'inf' as optional name for
1011 * IPython/numutils.py (norm): Added 'inf' as optional name for
1001 L-infinity norm, included references to mathworld.com for vector
1012 L-infinity norm, included references to mathworld.com for vector
1002 norm definitions.
1013 norm definitions.
1003 (amin/amax): added amin/amax for array min/max. Similar to what
1014 (amin/amax): added amin/amax for array min/max. Similar to what
1004 pylab ships with after the recent reorganization of names.
1015 pylab ships with after the recent reorganization of names.
1005 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1016 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1006
1017
1007 * ipython.el: committed Alex's recent fixes and improvements.
1018 * ipython.el: committed Alex's recent fixes and improvements.
1008 Tested with python-mode from CVS, and it looks excellent. Since
1019 Tested with python-mode from CVS, and it looks excellent. Since
1009 python-mode hasn't released anything in a while, I'm temporarily
1020 python-mode hasn't released anything in a while, I'm temporarily
1010 putting a copy of today's CVS (v 4.70) of python-mode in:
1021 putting a copy of today's CVS (v 4.70) of python-mode in:
1011 http://ipython.scipy.org/tmp/python-mode.el
1022 http://ipython.scipy.org/tmp/python-mode.el
1012
1023
1013 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1024 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1014 sys.executable for the executable name, instead of assuming it's
1025 sys.executable for the executable name, instead of assuming it's
1015 called 'python.exe' (the post-installer would have produced broken
1026 called 'python.exe' (the post-installer would have produced broken
1016 setups on systems with a differently named python binary).
1027 setups on systems with a differently named python binary).
1017
1028
1018 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1029 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1019 references to os.linesep, to make the code more
1030 references to os.linesep, to make the code more
1020 platform-independent. This is also part of the win32 coloring
1031 platform-independent. This is also part of the win32 coloring
1021 fixes.
1032 fixes.
1022
1033
1023 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1034 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1024 lines, which actually cause coloring bugs because the length of
1035 lines, which actually cause coloring bugs because the length of
1025 the line is very difficult to correctly compute with embedded
1036 the line is very difficult to correctly compute with embedded
1026 escapes. This was the source of all the coloring problems under
1037 escapes. This was the source of all the coloring problems under
1027 Win32. I think that _finally_, Win32 users have a properly
1038 Win32. I think that _finally_, Win32 users have a properly
1028 working ipython in all respects. This would never have happened
1039 working ipython in all respects. This would never have happened
1029 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1040 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1030
1041
1031 2005-01-26 *** Released version 0.6.9
1042 2005-01-26 *** Released version 0.6.9
1032
1043
1033 2005-01-25 Fernando Perez <fperez@colorado.edu>
1044 2005-01-25 Fernando Perez <fperez@colorado.edu>
1034
1045
1035 * setup.py: finally, we have a true Windows installer, thanks to
1046 * setup.py: finally, we have a true Windows installer, thanks to
1036 the excellent work of Viktor Ransmayr
1047 the excellent work of Viktor Ransmayr
1037 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1048 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1038 Windows users. The setup routine is quite a bit cleaner thanks to
1049 Windows users. The setup routine is quite a bit cleaner thanks to
1039 this, and the post-install script uses the proper functions to
1050 this, and the post-install script uses the proper functions to
1040 allow a clean de-installation using the standard Windows Control
1051 allow a clean de-installation using the standard Windows Control
1041 Panel.
1052 Panel.
1042
1053
1043 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1054 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1044 environment variable under all OSes (including win32) if
1055 environment variable under all OSes (including win32) if
1045 available. This will give consistency to win32 users who have set
1056 available. This will give consistency to win32 users who have set
1046 this variable for any reason. If os.environ['HOME'] fails, the
1057 this variable for any reason. If os.environ['HOME'] fails, the
1047 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1058 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1048
1059
1049 2005-01-24 Fernando Perez <fperez@colorado.edu>
1060 2005-01-24 Fernando Perez <fperez@colorado.edu>
1050
1061
1051 * IPython/numutils.py (empty_like): add empty_like(), similar to
1062 * IPython/numutils.py (empty_like): add empty_like(), similar to
1052 zeros_like() but taking advantage of the new empty() Numeric routine.
1063 zeros_like() but taking advantage of the new empty() Numeric routine.
1053
1064
1054 2005-01-23 *** Released version 0.6.8
1065 2005-01-23 *** Released version 0.6.8
1055
1066
1056 2005-01-22 Fernando Perez <fperez@colorado.edu>
1067 2005-01-22 Fernando Perez <fperez@colorado.edu>
1057
1068
1058 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1069 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1059 automatic show() calls. After discussing things with JDH, it
1070 automatic show() calls. After discussing things with JDH, it
1060 turns out there are too many corner cases where this can go wrong.
1071 turns out there are too many corner cases where this can go wrong.
1061 It's best not to try to be 'too smart', and simply have ipython
1072 It's best not to try to be 'too smart', and simply have ipython
1062 reproduce as much as possible the default behavior of a normal
1073 reproduce as much as possible the default behavior of a normal
1063 python shell.
1074 python shell.
1064
1075
1065 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1076 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1066 line-splitting regexp and _prefilter() to avoid calling getattr()
1077 line-splitting regexp and _prefilter() to avoid calling getattr()
1067 on assignments. This closes
1078 on assignments. This closes
1068 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1079 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1069 readline uses getattr(), so a simple <TAB> keypress is still
1080 readline uses getattr(), so a simple <TAB> keypress is still
1070 enough to trigger getattr() calls on an object.
1081 enough to trigger getattr() calls on an object.
1071
1082
1072 2005-01-21 Fernando Perez <fperez@colorado.edu>
1083 2005-01-21 Fernando Perez <fperez@colorado.edu>
1073
1084
1074 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1085 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1075 docstring under pylab so it doesn't mask the original.
1086 docstring under pylab so it doesn't mask the original.
1076
1087
1077 2005-01-21 *** Released version 0.6.7
1088 2005-01-21 *** Released version 0.6.7
1078
1089
1079 2005-01-21 Fernando Perez <fperez@colorado.edu>
1090 2005-01-21 Fernando Perez <fperez@colorado.edu>
1080
1091
1081 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1092 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1082 signal handling for win32 users in multithreaded mode.
1093 signal handling for win32 users in multithreaded mode.
1083
1094
1084 2005-01-17 Fernando Perez <fperez@colorado.edu>
1095 2005-01-17 Fernando Perez <fperez@colorado.edu>
1085
1096
1086 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1097 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1087 instances with no __init__. After a crash report by Norbert Nemec
1098 instances with no __init__. After a crash report by Norbert Nemec
1088 <Norbert-AT-nemec-online.de>.
1099 <Norbert-AT-nemec-online.de>.
1089
1100
1090 2005-01-14 Fernando Perez <fperez@colorado.edu>
1101 2005-01-14 Fernando Perez <fperez@colorado.edu>
1091
1102
1092 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1103 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1093 names for verbose exceptions, when multiple dotted names and the
1104 names for verbose exceptions, when multiple dotted names and the
1094 'parent' object were present on the same line.
1105 'parent' object were present on the same line.
1095
1106
1096 2005-01-11 Fernando Perez <fperez@colorado.edu>
1107 2005-01-11 Fernando Perez <fperez@colorado.edu>
1097
1108
1098 * IPython/genutils.py (flag_calls): new utility to trap and flag
1109 * IPython/genutils.py (flag_calls): new utility to trap and flag
1099 calls in functions. I need it to clean up matplotlib support.
1110 calls in functions. I need it to clean up matplotlib support.
1100 Also removed some deprecated code in genutils.
1111 Also removed some deprecated code in genutils.
1101
1112
1102 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1113 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1103 that matplotlib scripts called with %run, which don't call show()
1114 that matplotlib scripts called with %run, which don't call show()
1104 themselves, still have their plotting windows open.
1115 themselves, still have their plotting windows open.
1105
1116
1106 2005-01-05 Fernando Perez <fperez@colorado.edu>
1117 2005-01-05 Fernando Perez <fperez@colorado.edu>
1107
1118
1108 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1119 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1109 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1120 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1110
1121
1111 2004-12-19 Fernando Perez <fperez@colorado.edu>
1122 2004-12-19 Fernando Perez <fperez@colorado.edu>
1112
1123
1113 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1124 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1114 parent_runcode, which was an eyesore. The same result can be
1125 parent_runcode, which was an eyesore. The same result can be
1115 obtained with Python's regular superclass mechanisms.
1126 obtained with Python's regular superclass mechanisms.
1116
1127
1117 2004-12-17 Fernando Perez <fperez@colorado.edu>
1128 2004-12-17 Fernando Perez <fperez@colorado.edu>
1118
1129
1119 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1130 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1120 reported by Prabhu.
1131 reported by Prabhu.
1121 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1132 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1122 sys.stderr) instead of explicitly calling sys.stderr. This helps
1133 sys.stderr) instead of explicitly calling sys.stderr. This helps
1123 maintain our I/O abstractions clean, for future GUI embeddings.
1134 maintain our I/O abstractions clean, for future GUI embeddings.
1124
1135
1125 * IPython/genutils.py (info): added new utility for sys.stderr
1136 * IPython/genutils.py (info): added new utility for sys.stderr
1126 unified info message handling (thin wrapper around warn()).
1137 unified info message handling (thin wrapper around warn()).
1127
1138
1128 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1139 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1129 composite (dotted) names on verbose exceptions.
1140 composite (dotted) names on verbose exceptions.
1130 (VerboseTB.nullrepr): harden against another kind of errors which
1141 (VerboseTB.nullrepr): harden against another kind of errors which
1131 Python's inspect module can trigger, and which were crashing
1142 Python's inspect module can trigger, and which were crashing
1132 IPython. Thanks to a report by Marco Lombardi
1143 IPython. Thanks to a report by Marco Lombardi
1133 <mlombard-AT-ma010192.hq.eso.org>.
1144 <mlombard-AT-ma010192.hq.eso.org>.
1134
1145
1135 2004-12-13 *** Released version 0.6.6
1146 2004-12-13 *** Released version 0.6.6
1136
1147
1137 2004-12-12 Fernando Perez <fperez@colorado.edu>
1148 2004-12-12 Fernando Perez <fperez@colorado.edu>
1138
1149
1139 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1150 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1140 generated by pygtk upon initialization if it was built without
1151 generated by pygtk upon initialization if it was built without
1141 threads (for matplotlib users). After a crash reported by
1152 threads (for matplotlib users). After a crash reported by
1142 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1153 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1143
1154
1144 * IPython/ipmaker.py (make_IPython): fix small bug in the
1155 * IPython/ipmaker.py (make_IPython): fix small bug in the
1145 import_some parameter for multiple imports.
1156 import_some parameter for multiple imports.
1146
1157
1147 * IPython/iplib.py (ipmagic): simplified the interface of
1158 * IPython/iplib.py (ipmagic): simplified the interface of
1148 ipmagic() to take a single string argument, just as it would be
1159 ipmagic() to take a single string argument, just as it would be
1149 typed at the IPython cmd line.
1160 typed at the IPython cmd line.
1150 (ipalias): Added new ipalias() with an interface identical to
1161 (ipalias): Added new ipalias() with an interface identical to
1151 ipmagic(). This completes exposing a pure python interface to the
1162 ipmagic(). This completes exposing a pure python interface to the
1152 alias and magic system, which can be used in loops or more complex
1163 alias and magic system, which can be used in loops or more complex
1153 code where IPython's automatic line mangling is not active.
1164 code where IPython's automatic line mangling is not active.
1154
1165
1155 * IPython/genutils.py (timing): changed interface of timing to
1166 * IPython/genutils.py (timing): changed interface of timing to
1156 simply run code once, which is the most common case. timings()
1167 simply run code once, which is the most common case. timings()
1157 remains unchanged, for the cases where you want multiple runs.
1168 remains unchanged, for the cases where you want multiple runs.
1158
1169
1159 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1170 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1160 bug where Python2.2 crashes with exec'ing code which does not end
1171 bug where Python2.2 crashes with exec'ing code which does not end
1161 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1172 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1162 before.
1173 before.
1163
1174
1164 2004-12-10 Fernando Perez <fperez@colorado.edu>
1175 2004-12-10 Fernando Perez <fperez@colorado.edu>
1165
1176
1166 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1177 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1167 -t to -T, to accomodate the new -t flag in %run (the %run and
1178 -t to -T, to accomodate the new -t flag in %run (the %run and
1168 %prun options are kind of intermixed, and it's not easy to change
1179 %prun options are kind of intermixed, and it's not easy to change
1169 this with the limitations of python's getopt).
1180 this with the limitations of python's getopt).
1170
1181
1171 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1182 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1172 the execution of scripts. It's not as fine-tuned as timeit.py,
1183 the execution of scripts. It's not as fine-tuned as timeit.py,
1173 but it works from inside ipython (and under 2.2, which lacks
1184 but it works from inside ipython (and under 2.2, which lacks
1174 timeit.py). Optionally a number of runs > 1 can be given for
1185 timeit.py). Optionally a number of runs > 1 can be given for
1175 timing very short-running code.
1186 timing very short-running code.
1176
1187
1177 * IPython/genutils.py (uniq_stable): new routine which returns a
1188 * IPython/genutils.py (uniq_stable): new routine which returns a
1178 list of unique elements in any iterable, but in stable order of
1189 list of unique elements in any iterable, but in stable order of
1179 appearance. I needed this for the ultraTB fixes, and it's a handy
1190 appearance. I needed this for the ultraTB fixes, and it's a handy
1180 utility.
1191 utility.
1181
1192
1182 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1193 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1183 dotted names in Verbose exceptions. This had been broken since
1194 dotted names in Verbose exceptions. This had been broken since
1184 the very start, now x.y will properly be printed in a Verbose
1195 the very start, now x.y will properly be printed in a Verbose
1185 traceback, instead of x being shown and y appearing always as an
1196 traceback, instead of x being shown and y appearing always as an
1186 'undefined global'. Getting this to work was a bit tricky,
1197 'undefined global'. Getting this to work was a bit tricky,
1187 because by default python tokenizers are stateless. Saved by
1198 because by default python tokenizers are stateless. Saved by
1188 python's ability to easily add a bit of state to an arbitrary
1199 python's ability to easily add a bit of state to an arbitrary
1189 function (without needing to build a full-blown callable object).
1200 function (without needing to build a full-blown callable object).
1190
1201
1191 Also big cleanup of this code, which had horrendous runtime
1202 Also big cleanup of this code, which had horrendous runtime
1192 lookups of zillions of attributes for colorization. Moved all
1203 lookups of zillions of attributes for colorization. Moved all
1193 this code into a few templates, which make it cleaner and quicker.
1204 this code into a few templates, which make it cleaner and quicker.
1194
1205
1195 Printout quality was also improved for Verbose exceptions: one
1206 Printout quality was also improved for Verbose exceptions: one
1196 variable per line, and memory addresses are printed (this can be
1207 variable per line, and memory addresses are printed (this can be
1197 quite handy in nasty debugging situations, which is what Verbose
1208 quite handy in nasty debugging situations, which is what Verbose
1198 is for).
1209 is for).
1199
1210
1200 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1211 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1201 the command line as scripts to be loaded by embedded instances.
1212 the command line as scripts to be loaded by embedded instances.
1202 Doing so has the potential for an infinite recursion if there are
1213 Doing so has the potential for an infinite recursion if there are
1203 exceptions thrown in the process. This fixes a strange crash
1214 exceptions thrown in the process. This fixes a strange crash
1204 reported by Philippe MULLER <muller-AT-irit.fr>.
1215 reported by Philippe MULLER <muller-AT-irit.fr>.
1205
1216
1206 2004-12-09 Fernando Perez <fperez@colorado.edu>
1217 2004-12-09 Fernando Perez <fperez@colorado.edu>
1207
1218
1208 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1219 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1209 to reflect new names in matplotlib, which now expose the
1220 to reflect new names in matplotlib, which now expose the
1210 matlab-compatible interface via a pylab module instead of the
1221 matlab-compatible interface via a pylab module instead of the
1211 'matlab' name. The new code is backwards compatible, so users of
1222 'matlab' name. The new code is backwards compatible, so users of
1212 all matplotlib versions are OK. Patch by J. Hunter.
1223 all matplotlib versions are OK. Patch by J. Hunter.
1213
1224
1214 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1225 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1215 of __init__ docstrings for instances (class docstrings are already
1226 of __init__ docstrings for instances (class docstrings are already
1216 automatically printed). Instances with customized docstrings
1227 automatically printed). Instances with customized docstrings
1217 (indep. of the class) are also recognized and all 3 separate
1228 (indep. of the class) are also recognized and all 3 separate
1218 docstrings are printed (instance, class, constructor). After some
1229 docstrings are printed (instance, class, constructor). After some
1219 comments/suggestions by J. Hunter.
1230 comments/suggestions by J. Hunter.
1220
1231
1221 2004-12-05 Fernando Perez <fperez@colorado.edu>
1232 2004-12-05 Fernando Perez <fperez@colorado.edu>
1222
1233
1223 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1234 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1224 warnings when tab-completion fails and triggers an exception.
1235 warnings when tab-completion fails and triggers an exception.
1225
1236
1226 2004-12-03 Fernando Perez <fperez@colorado.edu>
1237 2004-12-03 Fernando Perez <fperez@colorado.edu>
1227
1238
1228 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1239 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1229 be triggered when using 'run -p'. An incorrect option flag was
1240 be triggered when using 'run -p'. An incorrect option flag was
1230 being set ('d' instead of 'D').
1241 being set ('d' instead of 'D').
1231 (manpage): fix missing escaped \- sign.
1242 (manpage): fix missing escaped \- sign.
1232
1243
1233 2004-11-30 *** Released version 0.6.5
1244 2004-11-30 *** Released version 0.6.5
1234
1245
1235 2004-11-30 Fernando Perez <fperez@colorado.edu>
1246 2004-11-30 Fernando Perez <fperez@colorado.edu>
1236
1247
1237 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1248 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1238 setting with -d option.
1249 setting with -d option.
1239
1250
1240 * setup.py (docfiles): Fix problem where the doc glob I was using
1251 * setup.py (docfiles): Fix problem where the doc glob I was using
1241 was COMPLETELY BROKEN. It was giving the right files by pure
1252 was COMPLETELY BROKEN. It was giving the right files by pure
1242 accident, but failed once I tried to include ipython.el. Note:
1253 accident, but failed once I tried to include ipython.el. Note:
1243 glob() does NOT allow you to do exclusion on multiple endings!
1254 glob() does NOT allow you to do exclusion on multiple endings!
1244
1255
1245 2004-11-29 Fernando Perez <fperez@colorado.edu>
1256 2004-11-29 Fernando Perez <fperez@colorado.edu>
1246
1257
1247 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1258 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1248 the manpage as the source. Better formatting & consistency.
1259 the manpage as the source. Better formatting & consistency.
1249
1260
1250 * IPython/Magic.py (magic_run): Added new -d option, to run
1261 * IPython/Magic.py (magic_run): Added new -d option, to run
1251 scripts under the control of the python pdb debugger. Note that
1262 scripts under the control of the python pdb debugger. Note that
1252 this required changing the %prun option -d to -D, to avoid a clash
1263 this required changing the %prun option -d to -D, to avoid a clash
1253 (since %run must pass options to %prun, and getopt is too dumb to
1264 (since %run must pass options to %prun, and getopt is too dumb to
1254 handle options with string values with embedded spaces). Thanks
1265 handle options with string values with embedded spaces). Thanks
1255 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1266 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1256 (magic_who_ls): added type matching to %who and %whos, so that one
1267 (magic_who_ls): added type matching to %who and %whos, so that one
1257 can filter their output to only include variables of certain
1268 can filter their output to only include variables of certain
1258 types. Another suggestion by Matthew.
1269 types. Another suggestion by Matthew.
1259 (magic_whos): Added memory summaries in kb and Mb for arrays.
1270 (magic_whos): Added memory summaries in kb and Mb for arrays.
1260 (magic_who): Improve formatting (break lines every 9 vars).
1271 (magic_who): Improve formatting (break lines every 9 vars).
1261
1272
1262 2004-11-28 Fernando Perez <fperez@colorado.edu>
1273 2004-11-28 Fernando Perez <fperez@colorado.edu>
1263
1274
1264 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1275 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1265 cache when empty lines were present.
1276 cache when empty lines were present.
1266
1277
1267 2004-11-24 Fernando Perez <fperez@colorado.edu>
1278 2004-11-24 Fernando Perez <fperez@colorado.edu>
1268
1279
1269 * IPython/usage.py (__doc__): document the re-activated threading
1280 * IPython/usage.py (__doc__): document the re-activated threading
1270 options for WX and GTK.
1281 options for WX and GTK.
1271
1282
1272 2004-11-23 Fernando Perez <fperez@colorado.edu>
1283 2004-11-23 Fernando Perez <fperez@colorado.edu>
1273
1284
1274 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1285 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1275 the -wthread and -gthread options, along with a new -tk one to try
1286 the -wthread and -gthread options, along with a new -tk one to try
1276 and coordinate Tk threading with wx/gtk. The tk support is very
1287 and coordinate Tk threading with wx/gtk. The tk support is very
1277 platform dependent, since it seems to require Tcl and Tk to be
1288 platform dependent, since it seems to require Tcl and Tk to be
1278 built with threads (Fedora1/2 appears NOT to have it, but in
1289 built with threads (Fedora1/2 appears NOT to have it, but in
1279 Prabhu's Debian boxes it works OK). But even with some Tk
1290 Prabhu's Debian boxes it works OK). But even with some Tk
1280 limitations, this is a great improvement.
1291 limitations, this is a great improvement.
1281
1292
1282 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1293 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1283 info in user prompts. Patch by Prabhu.
1294 info in user prompts. Patch by Prabhu.
1284
1295
1285 2004-11-18 Fernando Perez <fperez@colorado.edu>
1296 2004-11-18 Fernando Perez <fperez@colorado.edu>
1286
1297
1287 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1298 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1288 EOFErrors and bail, to avoid infinite loops if a non-terminating
1299 EOFErrors and bail, to avoid infinite loops if a non-terminating
1289 file is fed into ipython. Patch submitted in issue 19 by user,
1300 file is fed into ipython. Patch submitted in issue 19 by user,
1290 many thanks.
1301 many thanks.
1291
1302
1292 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1303 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1293 autoquote/parens in continuation prompts, which can cause lots of
1304 autoquote/parens in continuation prompts, which can cause lots of
1294 problems. Closes roundup issue 20.
1305 problems. Closes roundup issue 20.
1295
1306
1296 2004-11-17 Fernando Perez <fperez@colorado.edu>
1307 2004-11-17 Fernando Perez <fperez@colorado.edu>
1297
1308
1298 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1309 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1299 reported as debian bug #280505. I'm not sure my local changelog
1310 reported as debian bug #280505. I'm not sure my local changelog
1300 entry has the proper debian format (Jack?).
1311 entry has the proper debian format (Jack?).
1301
1312
1302 2004-11-08 *** Released version 0.6.4
1313 2004-11-08 *** Released version 0.6.4
1303
1314
1304 2004-11-08 Fernando Perez <fperez@colorado.edu>
1315 2004-11-08 Fernando Perez <fperez@colorado.edu>
1305
1316
1306 * IPython/iplib.py (init_readline): Fix exit message for Windows
1317 * IPython/iplib.py (init_readline): Fix exit message for Windows
1307 when readline is active. Thanks to a report by Eric Jones
1318 when readline is active. Thanks to a report by Eric Jones
1308 <eric-AT-enthought.com>.
1319 <eric-AT-enthought.com>.
1309
1320
1310 2004-11-07 Fernando Perez <fperez@colorado.edu>
1321 2004-11-07 Fernando Perez <fperez@colorado.edu>
1311
1322
1312 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1323 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1313 sometimes seen by win2k/cygwin users.
1324 sometimes seen by win2k/cygwin users.
1314
1325
1315 2004-11-06 Fernando Perez <fperez@colorado.edu>
1326 2004-11-06 Fernando Perez <fperez@colorado.edu>
1316
1327
1317 * IPython/iplib.py (interact): Change the handling of %Exit from
1328 * IPython/iplib.py (interact): Change the handling of %Exit from
1318 trying to propagate a SystemExit to an internal ipython flag.
1329 trying to propagate a SystemExit to an internal ipython flag.
1319 This is less elegant than using Python's exception mechanism, but
1330 This is less elegant than using Python's exception mechanism, but
1320 I can't get that to work reliably with threads, so under -pylab
1331 I can't get that to work reliably with threads, so under -pylab
1321 %Exit was hanging IPython. Cross-thread exception handling is
1332 %Exit was hanging IPython. Cross-thread exception handling is
1322 really a bitch. Thaks to a bug report by Stephen Walton
1333 really a bitch. Thaks to a bug report by Stephen Walton
1323 <stephen.walton-AT-csun.edu>.
1334 <stephen.walton-AT-csun.edu>.
1324
1335
1325 2004-11-04 Fernando Perez <fperez@colorado.edu>
1336 2004-11-04 Fernando Perez <fperez@colorado.edu>
1326
1337
1327 * IPython/iplib.py (raw_input_original): store a pointer to the
1338 * IPython/iplib.py (raw_input_original): store a pointer to the
1328 true raw_input to harden against code which can modify it
1339 true raw_input to harden against code which can modify it
1329 (wx.py.PyShell does this and would otherwise crash ipython).
1340 (wx.py.PyShell does this and would otherwise crash ipython).
1330 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1341 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1331
1342
1332 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1343 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1333 Ctrl-C problem, which does not mess up the input line.
1344 Ctrl-C problem, which does not mess up the input line.
1334
1345
1335 2004-11-03 Fernando Perez <fperez@colorado.edu>
1346 2004-11-03 Fernando Perez <fperez@colorado.edu>
1336
1347
1337 * IPython/Release.py: Changed licensing to BSD, in all files.
1348 * IPython/Release.py: Changed licensing to BSD, in all files.
1338 (name): lowercase name for tarball/RPM release.
1349 (name): lowercase name for tarball/RPM release.
1339
1350
1340 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1351 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1341 use throughout ipython.
1352 use throughout ipython.
1342
1353
1343 * IPython/Magic.py (Magic._ofind): Switch to using the new
1354 * IPython/Magic.py (Magic._ofind): Switch to using the new
1344 OInspect.getdoc() function.
1355 OInspect.getdoc() function.
1345
1356
1346 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1357 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1347 of the line currently being canceled via Ctrl-C. It's extremely
1358 of the line currently being canceled via Ctrl-C. It's extremely
1348 ugly, but I don't know how to do it better (the problem is one of
1359 ugly, but I don't know how to do it better (the problem is one of
1349 handling cross-thread exceptions).
1360 handling cross-thread exceptions).
1350
1361
1351 2004-10-28 Fernando Perez <fperez@colorado.edu>
1362 2004-10-28 Fernando Perez <fperez@colorado.edu>
1352
1363
1353 * IPython/Shell.py (signal_handler): add signal handlers to trap
1364 * IPython/Shell.py (signal_handler): add signal handlers to trap
1354 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1365 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1355 report by Francesc Alted.
1366 report by Francesc Alted.
1356
1367
1357 2004-10-21 Fernando Perez <fperez@colorado.edu>
1368 2004-10-21 Fernando Perez <fperez@colorado.edu>
1358
1369
1359 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1370 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1360 to % for pysh syntax extensions.
1371 to % for pysh syntax extensions.
1361
1372
1362 2004-10-09 Fernando Perez <fperez@colorado.edu>
1373 2004-10-09 Fernando Perez <fperez@colorado.edu>
1363
1374
1364 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1375 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1365 arrays to print a more useful summary, without calling str(arr).
1376 arrays to print a more useful summary, without calling str(arr).
1366 This avoids the problem of extremely lengthy computations which
1377 This avoids the problem of extremely lengthy computations which
1367 occur if arr is large, and appear to the user as a system lockup
1378 occur if arr is large, and appear to the user as a system lockup
1368 with 100% cpu activity. After a suggestion by Kristian Sandberg
1379 with 100% cpu activity. After a suggestion by Kristian Sandberg
1369 <Kristian.Sandberg@colorado.edu>.
1380 <Kristian.Sandberg@colorado.edu>.
1370 (Magic.__init__): fix bug in global magic escapes not being
1381 (Magic.__init__): fix bug in global magic escapes not being
1371 correctly set.
1382 correctly set.
1372
1383
1373 2004-10-08 Fernando Perez <fperez@colorado.edu>
1384 2004-10-08 Fernando Perez <fperez@colorado.edu>
1374
1385
1375 * IPython/Magic.py (__license__): change to absolute imports of
1386 * IPython/Magic.py (__license__): change to absolute imports of
1376 ipython's own internal packages, to start adapting to the absolute
1387 ipython's own internal packages, to start adapting to the absolute
1377 import requirement of PEP-328.
1388 import requirement of PEP-328.
1378
1389
1379 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1390 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1380 files, and standardize author/license marks through the Release
1391 files, and standardize author/license marks through the Release
1381 module instead of having per/file stuff (except for files with
1392 module instead of having per/file stuff (except for files with
1382 particular licenses, like the MIT/PSF-licensed codes).
1393 particular licenses, like the MIT/PSF-licensed codes).
1383
1394
1384 * IPython/Debugger.py: remove dead code for python 2.1
1395 * IPython/Debugger.py: remove dead code for python 2.1
1385
1396
1386 2004-10-04 Fernando Perez <fperez@colorado.edu>
1397 2004-10-04 Fernando Perez <fperez@colorado.edu>
1387
1398
1388 * IPython/iplib.py (ipmagic): New function for accessing magics
1399 * IPython/iplib.py (ipmagic): New function for accessing magics
1389 via a normal python function call.
1400 via a normal python function call.
1390
1401
1391 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1402 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1392 from '@' to '%', to accomodate the new @decorator syntax of python
1403 from '@' to '%', to accomodate the new @decorator syntax of python
1393 2.4.
1404 2.4.
1394
1405
1395 2004-09-29 Fernando Perez <fperez@colorado.edu>
1406 2004-09-29 Fernando Perez <fperez@colorado.edu>
1396
1407
1397 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1408 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1398 matplotlib.use to prevent running scripts which try to switch
1409 matplotlib.use to prevent running scripts which try to switch
1399 interactive backends from within ipython. This will just crash
1410 interactive backends from within ipython. This will just crash
1400 the python interpreter, so we can't allow it (but a detailed error
1411 the python interpreter, so we can't allow it (but a detailed error
1401 is given to the user).
1412 is given to the user).
1402
1413
1403 2004-09-28 Fernando Perez <fperez@colorado.edu>
1414 2004-09-28 Fernando Perez <fperez@colorado.edu>
1404
1415
1405 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1416 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1406 matplotlib-related fixes so that using @run with non-matplotlib
1417 matplotlib-related fixes so that using @run with non-matplotlib
1407 scripts doesn't pop up spurious plot windows. This requires
1418 scripts doesn't pop up spurious plot windows. This requires
1408 matplotlib >= 0.63, where I had to make some changes as well.
1419 matplotlib >= 0.63, where I had to make some changes as well.
1409
1420
1410 * IPython/ipmaker.py (make_IPython): update version requirement to
1421 * IPython/ipmaker.py (make_IPython): update version requirement to
1411 python 2.2.
1422 python 2.2.
1412
1423
1413 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1424 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1414 banner arg for embedded customization.
1425 banner arg for embedded customization.
1415
1426
1416 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1427 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1417 explicit uses of __IP as the IPython's instance name. Now things
1428 explicit uses of __IP as the IPython's instance name. Now things
1418 are properly handled via the shell.name value. The actual code
1429 are properly handled via the shell.name value. The actual code
1419 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1430 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1420 is much better than before. I'll clean things completely when the
1431 is much better than before. I'll clean things completely when the
1421 magic stuff gets a real overhaul.
1432 magic stuff gets a real overhaul.
1422
1433
1423 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1434 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1424 minor changes to debian dir.
1435 minor changes to debian dir.
1425
1436
1426 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1437 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1427 pointer to the shell itself in the interactive namespace even when
1438 pointer to the shell itself in the interactive namespace even when
1428 a user-supplied dict is provided. This is needed for embedding
1439 a user-supplied dict is provided. This is needed for embedding
1429 purposes (found by tests with Michel Sanner).
1440 purposes (found by tests with Michel Sanner).
1430
1441
1431 2004-09-27 Fernando Perez <fperez@colorado.edu>
1442 2004-09-27 Fernando Perez <fperez@colorado.edu>
1432
1443
1433 * IPython/UserConfig/ipythonrc: remove []{} from
1444 * IPython/UserConfig/ipythonrc: remove []{} from
1434 readline_remove_delims, so that things like [modname.<TAB> do
1445 readline_remove_delims, so that things like [modname.<TAB> do
1435 proper completion. This disables [].TAB, but that's a less common
1446 proper completion. This disables [].TAB, but that's a less common
1436 case than module names in list comprehensions, for example.
1447 case than module names in list comprehensions, for example.
1437 Thanks to a report by Andrea Riciputi.
1448 Thanks to a report by Andrea Riciputi.
1438
1449
1439 2004-09-09 Fernando Perez <fperez@colorado.edu>
1450 2004-09-09 Fernando Perez <fperez@colorado.edu>
1440
1451
1441 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1452 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1442 blocking problems in win32 and osx. Fix by John.
1453 blocking problems in win32 and osx. Fix by John.
1443
1454
1444 2004-09-08 Fernando Perez <fperez@colorado.edu>
1455 2004-09-08 Fernando Perez <fperez@colorado.edu>
1445
1456
1446 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1457 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1447 for Win32 and OSX. Fix by John Hunter.
1458 for Win32 and OSX. Fix by John Hunter.
1448
1459
1449 2004-08-30 *** Released version 0.6.3
1460 2004-08-30 *** Released version 0.6.3
1450
1461
1451 2004-08-30 Fernando Perez <fperez@colorado.edu>
1462 2004-08-30 Fernando Perez <fperez@colorado.edu>
1452
1463
1453 * setup.py (isfile): Add manpages to list of dependent files to be
1464 * setup.py (isfile): Add manpages to list of dependent files to be
1454 updated.
1465 updated.
1455
1466
1456 2004-08-27 Fernando Perez <fperez@colorado.edu>
1467 2004-08-27 Fernando Perez <fperez@colorado.edu>
1457
1468
1458 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1469 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1459 for now. They don't really work with standalone WX/GTK code
1470 for now. They don't really work with standalone WX/GTK code
1460 (though matplotlib IS working fine with both of those backends).
1471 (though matplotlib IS working fine with both of those backends).
1461 This will neeed much more testing. I disabled most things with
1472 This will neeed much more testing. I disabled most things with
1462 comments, so turning it back on later should be pretty easy.
1473 comments, so turning it back on later should be pretty easy.
1463
1474
1464 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1475 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1465 autocalling of expressions like r'foo', by modifying the line
1476 autocalling of expressions like r'foo', by modifying the line
1466 split regexp. Closes
1477 split regexp. Closes
1467 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1478 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1468 Riley <ipythonbugs-AT-sabi.net>.
1479 Riley <ipythonbugs-AT-sabi.net>.
1469 (InteractiveShell.mainloop): honor --nobanner with banner
1480 (InteractiveShell.mainloop): honor --nobanner with banner
1470 extensions.
1481 extensions.
1471
1482
1472 * IPython/Shell.py: Significant refactoring of all classes, so
1483 * IPython/Shell.py: Significant refactoring of all classes, so
1473 that we can really support ALL matplotlib backends and threading
1484 that we can really support ALL matplotlib backends and threading
1474 models (John spotted a bug with Tk which required this). Now we
1485 models (John spotted a bug with Tk which required this). Now we
1475 should support single-threaded, WX-threads and GTK-threads, both
1486 should support single-threaded, WX-threads and GTK-threads, both
1476 for generic code and for matplotlib.
1487 for generic code and for matplotlib.
1477
1488
1478 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1489 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1479 -pylab, to simplify things for users. Will also remove the pylab
1490 -pylab, to simplify things for users. Will also remove the pylab
1480 profile, since now all of matplotlib configuration is directly
1491 profile, since now all of matplotlib configuration is directly
1481 handled here. This also reduces startup time.
1492 handled here. This also reduces startup time.
1482
1493
1483 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1494 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1484 shell wasn't being correctly called. Also in IPShellWX.
1495 shell wasn't being correctly called. Also in IPShellWX.
1485
1496
1486 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1497 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1487 fine-tune banner.
1498 fine-tune banner.
1488
1499
1489 * IPython/numutils.py (spike): Deprecate these spike functions,
1500 * IPython/numutils.py (spike): Deprecate these spike functions,
1490 delete (long deprecated) gnuplot_exec handler.
1501 delete (long deprecated) gnuplot_exec handler.
1491
1502
1492 2004-08-26 Fernando Perez <fperez@colorado.edu>
1503 2004-08-26 Fernando Perez <fperez@colorado.edu>
1493
1504
1494 * ipython.1: Update for threading options, plus some others which
1505 * ipython.1: Update for threading options, plus some others which
1495 were missing.
1506 were missing.
1496
1507
1497 * IPython/ipmaker.py (__call__): Added -wthread option for
1508 * IPython/ipmaker.py (__call__): Added -wthread option for
1498 wxpython thread handling. Make sure threading options are only
1509 wxpython thread handling. Make sure threading options are only
1499 valid at the command line.
1510 valid at the command line.
1500
1511
1501 * scripts/ipython: moved shell selection into a factory function
1512 * scripts/ipython: moved shell selection into a factory function
1502 in Shell.py, to keep the starter script to a minimum.
1513 in Shell.py, to keep the starter script to a minimum.
1503
1514
1504 2004-08-25 Fernando Perez <fperez@colorado.edu>
1515 2004-08-25 Fernando Perez <fperez@colorado.edu>
1505
1516
1506 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1517 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1507 John. Along with some recent changes he made to matplotlib, the
1518 John. Along with some recent changes he made to matplotlib, the
1508 next versions of both systems should work very well together.
1519 next versions of both systems should work very well together.
1509
1520
1510 2004-08-24 Fernando Perez <fperez@colorado.edu>
1521 2004-08-24 Fernando Perez <fperez@colorado.edu>
1511
1522
1512 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1523 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1513 tried to switch the profiling to using hotshot, but I'm getting
1524 tried to switch the profiling to using hotshot, but I'm getting
1514 strange errors from prof.runctx() there. I may be misreading the
1525 strange errors from prof.runctx() there. I may be misreading the
1515 docs, but it looks weird. For now the profiling code will
1526 docs, but it looks weird. For now the profiling code will
1516 continue to use the standard profiler.
1527 continue to use the standard profiler.
1517
1528
1518 2004-08-23 Fernando Perez <fperez@colorado.edu>
1529 2004-08-23 Fernando Perez <fperez@colorado.edu>
1519
1530
1520 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1531 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1521 threaded shell, by John Hunter. It's not quite ready yet, but
1532 threaded shell, by John Hunter. It's not quite ready yet, but
1522 close.
1533 close.
1523
1534
1524 2004-08-22 Fernando Perez <fperez@colorado.edu>
1535 2004-08-22 Fernando Perez <fperez@colorado.edu>
1525
1536
1526 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1537 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1527 in Magic and ultraTB.
1538 in Magic and ultraTB.
1528
1539
1529 * ipython.1: document threading options in manpage.
1540 * ipython.1: document threading options in manpage.
1530
1541
1531 * scripts/ipython: Changed name of -thread option to -gthread,
1542 * scripts/ipython: Changed name of -thread option to -gthread,
1532 since this is GTK specific. I want to leave the door open for a
1543 since this is GTK specific. I want to leave the door open for a
1533 -wthread option for WX, which will most likely be necessary. This
1544 -wthread option for WX, which will most likely be necessary. This
1534 change affects usage and ipmaker as well.
1545 change affects usage and ipmaker as well.
1535
1546
1536 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1547 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1537 handle the matplotlib shell issues. Code by John Hunter
1548 handle the matplotlib shell issues. Code by John Hunter
1538 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1549 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1539 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1550 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1540 broken (and disabled for end users) for now, but it puts the
1551 broken (and disabled for end users) for now, but it puts the
1541 infrastructure in place.
1552 infrastructure in place.
1542
1553
1543 2004-08-21 Fernando Perez <fperez@colorado.edu>
1554 2004-08-21 Fernando Perez <fperez@colorado.edu>
1544
1555
1545 * ipythonrc-pylab: Add matplotlib support.
1556 * ipythonrc-pylab: Add matplotlib support.
1546
1557
1547 * matplotlib_config.py: new files for matplotlib support, part of
1558 * matplotlib_config.py: new files for matplotlib support, part of
1548 the pylab profile.
1559 the pylab profile.
1549
1560
1550 * IPython/usage.py (__doc__): documented the threading options.
1561 * IPython/usage.py (__doc__): documented the threading options.
1551
1562
1552 2004-08-20 Fernando Perez <fperez@colorado.edu>
1563 2004-08-20 Fernando Perez <fperez@colorado.edu>
1553
1564
1554 * ipython: Modified the main calling routine to handle the -thread
1565 * ipython: Modified the main calling routine to handle the -thread
1555 and -mpthread options. This needs to be done as a top-level hack,
1566 and -mpthread options. This needs to be done as a top-level hack,
1556 because it determines which class to instantiate for IPython
1567 because it determines which class to instantiate for IPython
1557 itself.
1568 itself.
1558
1569
1559 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1570 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1560 classes to support multithreaded GTK operation without blocking,
1571 classes to support multithreaded GTK operation without blocking,
1561 and matplotlib with all backends. This is a lot of still very
1572 and matplotlib with all backends. This is a lot of still very
1562 experimental code, and threads are tricky. So it may still have a
1573 experimental code, and threads are tricky. So it may still have a
1563 few rough edges... This code owes a lot to
1574 few rough edges... This code owes a lot to
1564 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1575 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1565 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1576 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1566 to John Hunter for all the matplotlib work.
1577 to John Hunter for all the matplotlib work.
1567
1578
1568 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1579 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1569 options for gtk thread and matplotlib support.
1580 options for gtk thread and matplotlib support.
1570
1581
1571 2004-08-16 Fernando Perez <fperez@colorado.edu>
1582 2004-08-16 Fernando Perez <fperez@colorado.edu>
1572
1583
1573 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1584 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1574 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1585 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1575 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1586 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1576
1587
1577 2004-08-11 Fernando Perez <fperez@colorado.edu>
1588 2004-08-11 Fernando Perez <fperez@colorado.edu>
1578
1589
1579 * setup.py (isfile): Fix build so documentation gets updated for
1590 * setup.py (isfile): Fix build so documentation gets updated for
1580 rpms (it was only done for .tgz builds).
1591 rpms (it was only done for .tgz builds).
1581
1592
1582 2004-08-10 Fernando Perez <fperez@colorado.edu>
1593 2004-08-10 Fernando Perez <fperez@colorado.edu>
1583
1594
1584 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1595 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1585
1596
1586 * iplib.py : Silence syntax error exceptions in tab-completion.
1597 * iplib.py : Silence syntax error exceptions in tab-completion.
1587
1598
1588 2004-08-05 Fernando Perez <fperez@colorado.edu>
1599 2004-08-05 Fernando Perez <fperez@colorado.edu>
1589
1600
1590 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1601 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1591 'color off' mark for continuation prompts. This was causing long
1602 'color off' mark for continuation prompts. This was causing long
1592 continuation lines to mis-wrap.
1603 continuation lines to mis-wrap.
1593
1604
1594 2004-08-01 Fernando Perez <fperez@colorado.edu>
1605 2004-08-01 Fernando Perez <fperez@colorado.edu>
1595
1606
1596 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1607 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1597 for building ipython to be a parameter. All this is necessary
1608 for building ipython to be a parameter. All this is necessary
1598 right now to have a multithreaded version, but this insane
1609 right now to have a multithreaded version, but this insane
1599 non-design will be cleaned up soon. For now, it's a hack that
1610 non-design will be cleaned up soon. For now, it's a hack that
1600 works.
1611 works.
1601
1612
1602 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1613 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1603 args in various places. No bugs so far, but it's a dangerous
1614 args in various places. No bugs so far, but it's a dangerous
1604 practice.
1615 practice.
1605
1616
1606 2004-07-31 Fernando Perez <fperez@colorado.edu>
1617 2004-07-31 Fernando Perez <fperez@colorado.edu>
1607
1618
1608 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1619 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1609 fix completion of files with dots in their names under most
1620 fix completion of files with dots in their names under most
1610 profiles (pysh was OK because the completion order is different).
1621 profiles (pysh was OK because the completion order is different).
1611
1622
1612 2004-07-27 Fernando Perez <fperez@colorado.edu>
1623 2004-07-27 Fernando Perez <fperez@colorado.edu>
1613
1624
1614 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1625 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1615 keywords manually, b/c the one in keyword.py was removed in python
1626 keywords manually, b/c the one in keyword.py was removed in python
1616 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1627 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1617 This is NOT a bug under python 2.3 and earlier.
1628 This is NOT a bug under python 2.3 and earlier.
1618
1629
1619 2004-07-26 Fernando Perez <fperez@colorado.edu>
1630 2004-07-26 Fernando Perez <fperez@colorado.edu>
1620
1631
1621 * IPython/ultraTB.py (VerboseTB.text): Add another
1632 * IPython/ultraTB.py (VerboseTB.text): Add another
1622 linecache.checkcache() call to try to prevent inspect.py from
1633 linecache.checkcache() call to try to prevent inspect.py from
1623 crashing under python 2.3. I think this fixes
1634 crashing under python 2.3. I think this fixes
1624 http://www.scipy.net/roundup/ipython/issue17.
1635 http://www.scipy.net/roundup/ipython/issue17.
1625
1636
1626 2004-07-26 *** Released version 0.6.2
1637 2004-07-26 *** Released version 0.6.2
1627
1638
1628 2004-07-26 Fernando Perez <fperez@colorado.edu>
1639 2004-07-26 Fernando Perez <fperez@colorado.edu>
1629
1640
1630 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1641 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1631 fail for any number.
1642 fail for any number.
1632 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1643 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1633 empty bookmarks.
1644 empty bookmarks.
1634
1645
1635 2004-07-26 *** Released version 0.6.1
1646 2004-07-26 *** Released version 0.6.1
1636
1647
1637 2004-07-26 Fernando Perez <fperez@colorado.edu>
1648 2004-07-26 Fernando Perez <fperez@colorado.edu>
1638
1649
1639 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1650 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1640
1651
1641 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1652 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1642 escaping '()[]{}' in filenames.
1653 escaping '()[]{}' in filenames.
1643
1654
1644 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1655 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1645 Python 2.2 users who lack a proper shlex.split.
1656 Python 2.2 users who lack a proper shlex.split.
1646
1657
1647 2004-07-19 Fernando Perez <fperez@colorado.edu>
1658 2004-07-19 Fernando Perez <fperez@colorado.edu>
1648
1659
1649 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1660 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1650 for reading readline's init file. I follow the normal chain:
1661 for reading readline's init file. I follow the normal chain:
1651 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1662 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1652 report by Mike Heeter. This closes
1663 report by Mike Heeter. This closes
1653 http://www.scipy.net/roundup/ipython/issue16.
1664 http://www.scipy.net/roundup/ipython/issue16.
1654
1665
1655 2004-07-18 Fernando Perez <fperez@colorado.edu>
1666 2004-07-18 Fernando Perez <fperez@colorado.edu>
1656
1667
1657 * IPython/iplib.py (__init__): Add better handling of '\' under
1668 * IPython/iplib.py (__init__): Add better handling of '\' under
1658 Win32 for filenames. After a patch by Ville.
1669 Win32 for filenames. After a patch by Ville.
1659
1670
1660 2004-07-17 Fernando Perez <fperez@colorado.edu>
1671 2004-07-17 Fernando Perez <fperez@colorado.edu>
1661
1672
1662 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1673 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1663 autocalling would be triggered for 'foo is bar' if foo is
1674 autocalling would be triggered for 'foo is bar' if foo is
1664 callable. I also cleaned up the autocall detection code to use a
1675 callable. I also cleaned up the autocall detection code to use a
1665 regexp, which is faster. Bug reported by Alexander Schmolck.
1676 regexp, which is faster. Bug reported by Alexander Schmolck.
1666
1677
1667 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1678 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1668 '?' in them would confuse the help system. Reported by Alex
1679 '?' in them would confuse the help system. Reported by Alex
1669 Schmolck.
1680 Schmolck.
1670
1681
1671 2004-07-16 Fernando Perez <fperez@colorado.edu>
1682 2004-07-16 Fernando Perez <fperez@colorado.edu>
1672
1683
1673 * IPython/GnuplotInteractive.py (__all__): added plot2.
1684 * IPython/GnuplotInteractive.py (__all__): added plot2.
1674
1685
1675 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1686 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1676 plotting dictionaries, lists or tuples of 1d arrays.
1687 plotting dictionaries, lists or tuples of 1d arrays.
1677
1688
1678 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1689 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1679 optimizations.
1690 optimizations.
1680
1691
1681 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1692 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1682 the information which was there from Janko's original IPP code:
1693 the information which was there from Janko's original IPP code:
1683
1694
1684 03.05.99 20:53 porto.ifm.uni-kiel.de
1695 03.05.99 20:53 porto.ifm.uni-kiel.de
1685 --Started changelog.
1696 --Started changelog.
1686 --make clear do what it say it does
1697 --make clear do what it say it does
1687 --added pretty output of lines from inputcache
1698 --added pretty output of lines from inputcache
1688 --Made Logger a mixin class, simplifies handling of switches
1699 --Made Logger a mixin class, simplifies handling of switches
1689 --Added own completer class. .string<TAB> expands to last history
1700 --Added own completer class. .string<TAB> expands to last history
1690 line which starts with string. The new expansion is also present
1701 line which starts with string. The new expansion is also present
1691 with Ctrl-r from the readline library. But this shows, who this
1702 with Ctrl-r from the readline library. But this shows, who this
1692 can be done for other cases.
1703 can be done for other cases.
1693 --Added convention that all shell functions should accept a
1704 --Added convention that all shell functions should accept a
1694 parameter_string This opens the door for different behaviour for
1705 parameter_string This opens the door for different behaviour for
1695 each function. @cd is a good example of this.
1706 each function. @cd is a good example of this.
1696
1707
1697 04.05.99 12:12 porto.ifm.uni-kiel.de
1708 04.05.99 12:12 porto.ifm.uni-kiel.de
1698 --added logfile rotation
1709 --added logfile rotation
1699 --added new mainloop method which freezes first the namespace
1710 --added new mainloop method which freezes first the namespace
1700
1711
1701 07.05.99 21:24 porto.ifm.uni-kiel.de
1712 07.05.99 21:24 porto.ifm.uni-kiel.de
1702 --added the docreader classes. Now there is a help system.
1713 --added the docreader classes. Now there is a help system.
1703 -This is only a first try. Currently it's not easy to put new
1714 -This is only a first try. Currently it's not easy to put new
1704 stuff in the indices. But this is the way to go. Info would be
1715 stuff in the indices. But this is the way to go. Info would be
1705 better, but HTML is every where and not everybody has an info
1716 better, but HTML is every where and not everybody has an info
1706 system installed and it's not so easy to change html-docs to info.
1717 system installed and it's not so easy to change html-docs to info.
1707 --added global logfile option
1718 --added global logfile option
1708 --there is now a hook for object inspection method pinfo needs to
1719 --there is now a hook for object inspection method pinfo needs to
1709 be provided for this. Can be reached by two '??'.
1720 be provided for this. Can be reached by two '??'.
1710
1721
1711 08.05.99 20:51 porto.ifm.uni-kiel.de
1722 08.05.99 20:51 porto.ifm.uni-kiel.de
1712 --added a README
1723 --added a README
1713 --bug in rc file. Something has changed so functions in the rc
1724 --bug in rc file. Something has changed so functions in the rc
1714 file need to reference the shell and not self. Not clear if it's a
1725 file need to reference the shell and not self. Not clear if it's a
1715 bug or feature.
1726 bug or feature.
1716 --changed rc file for new behavior
1727 --changed rc file for new behavior
1717
1728
1718 2004-07-15 Fernando Perez <fperez@colorado.edu>
1729 2004-07-15 Fernando Perez <fperez@colorado.edu>
1719
1730
1720 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1731 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1721 cache was falling out of sync in bizarre manners when multi-line
1732 cache was falling out of sync in bizarre manners when multi-line
1722 input was present. Minor optimizations and cleanup.
1733 input was present. Minor optimizations and cleanup.
1723
1734
1724 (Logger): Remove old Changelog info for cleanup. This is the
1735 (Logger): Remove old Changelog info for cleanup. This is the
1725 information which was there from Janko's original code:
1736 information which was there from Janko's original code:
1726
1737
1727 Changes to Logger: - made the default log filename a parameter
1738 Changes to Logger: - made the default log filename a parameter
1728
1739
1729 - put a check for lines beginning with !@? in log(). Needed
1740 - put a check for lines beginning with !@? in log(). Needed
1730 (even if the handlers properly log their lines) for mid-session
1741 (even if the handlers properly log their lines) for mid-session
1731 logging activation to work properly. Without this, lines logged
1742 logging activation to work properly. Without this, lines logged
1732 in mid session, which get read from the cache, would end up
1743 in mid session, which get read from the cache, would end up
1733 'bare' (with !@? in the open) in the log. Now they are caught
1744 'bare' (with !@? in the open) in the log. Now they are caught
1734 and prepended with a #.
1745 and prepended with a #.
1735
1746
1736 * IPython/iplib.py (InteractiveShell.init_readline): added check
1747 * IPython/iplib.py (InteractiveShell.init_readline): added check
1737 in case MagicCompleter fails to be defined, so we don't crash.
1748 in case MagicCompleter fails to be defined, so we don't crash.
1738
1749
1739 2004-07-13 Fernando Perez <fperez@colorado.edu>
1750 2004-07-13 Fernando Perez <fperez@colorado.edu>
1740
1751
1741 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1752 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1742 of EPS if the requested filename ends in '.eps'.
1753 of EPS if the requested filename ends in '.eps'.
1743
1754
1744 2004-07-04 Fernando Perez <fperez@colorado.edu>
1755 2004-07-04 Fernando Perez <fperez@colorado.edu>
1745
1756
1746 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1757 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1747 escaping of quotes when calling the shell.
1758 escaping of quotes when calling the shell.
1748
1759
1749 2004-07-02 Fernando Perez <fperez@colorado.edu>
1760 2004-07-02 Fernando Perez <fperez@colorado.edu>
1750
1761
1751 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1762 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1752 gettext not working because we were clobbering '_'. Fixes
1763 gettext not working because we were clobbering '_'. Fixes
1753 http://www.scipy.net/roundup/ipython/issue6.
1764 http://www.scipy.net/roundup/ipython/issue6.
1754
1765
1755 2004-07-01 Fernando Perez <fperez@colorado.edu>
1766 2004-07-01 Fernando Perez <fperez@colorado.edu>
1756
1767
1757 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1768 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1758 into @cd. Patch by Ville.
1769 into @cd. Patch by Ville.
1759
1770
1760 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1771 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1761 new function to store things after ipmaker runs. Patch by Ville.
1772 new function to store things after ipmaker runs. Patch by Ville.
1762 Eventually this will go away once ipmaker is removed and the class
1773 Eventually this will go away once ipmaker is removed and the class
1763 gets cleaned up, but for now it's ok. Key functionality here is
1774 gets cleaned up, but for now it's ok. Key functionality here is
1764 the addition of the persistent storage mechanism, a dict for
1775 the addition of the persistent storage mechanism, a dict for
1765 keeping data across sessions (for now just bookmarks, but more can
1776 keeping data across sessions (for now just bookmarks, but more can
1766 be implemented later).
1777 be implemented later).
1767
1778
1768 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1779 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1769 persistent across sections. Patch by Ville, I modified it
1780 persistent across sections. Patch by Ville, I modified it
1770 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1781 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1771 added a '-l' option to list all bookmarks.
1782 added a '-l' option to list all bookmarks.
1772
1783
1773 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1784 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1774 center for cleanup. Registered with atexit.register(). I moved
1785 center for cleanup. Registered with atexit.register(). I moved
1775 here the old exit_cleanup(). After a patch by Ville.
1786 here the old exit_cleanup(). After a patch by Ville.
1776
1787
1777 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1788 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1778 characters in the hacked shlex_split for python 2.2.
1789 characters in the hacked shlex_split for python 2.2.
1779
1790
1780 * IPython/iplib.py (file_matches): more fixes to filenames with
1791 * IPython/iplib.py (file_matches): more fixes to filenames with
1781 whitespace in them. It's not perfect, but limitations in python's
1792 whitespace in them. It's not perfect, but limitations in python's
1782 readline make it impossible to go further.
1793 readline make it impossible to go further.
1783
1794
1784 2004-06-29 Fernando Perez <fperez@colorado.edu>
1795 2004-06-29 Fernando Perez <fperez@colorado.edu>
1785
1796
1786 * IPython/iplib.py (file_matches): escape whitespace correctly in
1797 * IPython/iplib.py (file_matches): escape whitespace correctly in
1787 filename completions. Bug reported by Ville.
1798 filename completions. Bug reported by Ville.
1788
1799
1789 2004-06-28 Fernando Perez <fperez@colorado.edu>
1800 2004-06-28 Fernando Perez <fperez@colorado.edu>
1790
1801
1791 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1802 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1792 the history file will be called 'history-PROFNAME' (or just
1803 the history file will be called 'history-PROFNAME' (or just
1793 'history' if no profile is loaded). I was getting annoyed at
1804 'history' if no profile is loaded). I was getting annoyed at
1794 getting my Numerical work history clobbered by pysh sessions.
1805 getting my Numerical work history clobbered by pysh sessions.
1795
1806
1796 * IPython/iplib.py (InteractiveShell.__init__): Internal
1807 * IPython/iplib.py (InteractiveShell.__init__): Internal
1797 getoutputerror() function so that we can honor the system_verbose
1808 getoutputerror() function so that we can honor the system_verbose
1798 flag for _all_ system calls. I also added escaping of #
1809 flag for _all_ system calls. I also added escaping of #
1799 characters here to avoid confusing Itpl.
1810 characters here to avoid confusing Itpl.
1800
1811
1801 * IPython/Magic.py (shlex_split): removed call to shell in
1812 * IPython/Magic.py (shlex_split): removed call to shell in
1802 parse_options and replaced it with shlex.split(). The annoying
1813 parse_options and replaced it with shlex.split(). The annoying
1803 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1814 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1804 to backport it from 2.3, with several frail hacks (the shlex
1815 to backport it from 2.3, with several frail hacks (the shlex
1805 module is rather limited in 2.2). Thanks to a suggestion by Ville
1816 module is rather limited in 2.2). Thanks to a suggestion by Ville
1806 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1817 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1807 problem.
1818 problem.
1808
1819
1809 (Magic.magic_system_verbose): new toggle to print the actual
1820 (Magic.magic_system_verbose): new toggle to print the actual
1810 system calls made by ipython. Mainly for debugging purposes.
1821 system calls made by ipython. Mainly for debugging purposes.
1811
1822
1812 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1823 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1813 doesn't support persistence. Reported (and fix suggested) by
1824 doesn't support persistence. Reported (and fix suggested) by
1814 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1825 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1815
1826
1816 2004-06-26 Fernando Perez <fperez@colorado.edu>
1827 2004-06-26 Fernando Perez <fperez@colorado.edu>
1817
1828
1818 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1829 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1819 continue prompts.
1830 continue prompts.
1820
1831
1821 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1832 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1822 function (basically a big docstring) and a few more things here to
1833 function (basically a big docstring) and a few more things here to
1823 speedup startup. pysh.py is now very lightweight. We want because
1834 speedup startup. pysh.py is now very lightweight. We want because
1824 it gets execfile'd, while InterpreterExec gets imported, so
1835 it gets execfile'd, while InterpreterExec gets imported, so
1825 byte-compilation saves time.
1836 byte-compilation saves time.
1826
1837
1827 2004-06-25 Fernando Perez <fperez@colorado.edu>
1838 2004-06-25 Fernando Perez <fperez@colorado.edu>
1828
1839
1829 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1840 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1830 -NUM', which was recently broken.
1841 -NUM', which was recently broken.
1831
1842
1832 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1843 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1833 in multi-line input (but not !!, which doesn't make sense there).
1844 in multi-line input (but not !!, which doesn't make sense there).
1834
1845
1835 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1846 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1836 It's just too useful, and people can turn it off in the less
1847 It's just too useful, and people can turn it off in the less
1837 common cases where it's a problem.
1848 common cases where it's a problem.
1838
1849
1839 2004-06-24 Fernando Perez <fperez@colorado.edu>
1850 2004-06-24 Fernando Perez <fperez@colorado.edu>
1840
1851
1841 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1852 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1842 special syntaxes (like alias calling) is now allied in multi-line
1853 special syntaxes (like alias calling) is now allied in multi-line
1843 input. This is still _very_ experimental, but it's necessary for
1854 input. This is still _very_ experimental, but it's necessary for
1844 efficient shell usage combining python looping syntax with system
1855 efficient shell usage combining python looping syntax with system
1845 calls. For now it's restricted to aliases, I don't think it
1856 calls. For now it's restricted to aliases, I don't think it
1846 really even makes sense to have this for magics.
1857 really even makes sense to have this for magics.
1847
1858
1848 2004-06-23 Fernando Perez <fperez@colorado.edu>
1859 2004-06-23 Fernando Perez <fperez@colorado.edu>
1849
1860
1850 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1861 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1851 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1862 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1852
1863
1853 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1864 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1854 extensions under Windows (after code sent by Gary Bishop). The
1865 extensions under Windows (after code sent by Gary Bishop). The
1855 extensions considered 'executable' are stored in IPython's rc
1866 extensions considered 'executable' are stored in IPython's rc
1856 structure as win_exec_ext.
1867 structure as win_exec_ext.
1857
1868
1858 * IPython/genutils.py (shell): new function, like system() but
1869 * IPython/genutils.py (shell): new function, like system() but
1859 without return value. Very useful for interactive shell work.
1870 without return value. Very useful for interactive shell work.
1860
1871
1861 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1872 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1862 delete aliases.
1873 delete aliases.
1863
1874
1864 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1875 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1865 sure that the alias table doesn't contain python keywords.
1876 sure that the alias table doesn't contain python keywords.
1866
1877
1867 2004-06-21 Fernando Perez <fperez@colorado.edu>
1878 2004-06-21 Fernando Perez <fperez@colorado.edu>
1868
1879
1869 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1880 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1870 non-existent items are found in $PATH. Reported by Thorsten.
1881 non-existent items are found in $PATH. Reported by Thorsten.
1871
1882
1872 2004-06-20 Fernando Perez <fperez@colorado.edu>
1883 2004-06-20 Fernando Perez <fperez@colorado.edu>
1873
1884
1874 * IPython/iplib.py (complete): modified the completer so that the
1885 * IPython/iplib.py (complete): modified the completer so that the
1875 order of priorities can be easily changed at runtime.
1886 order of priorities can be easily changed at runtime.
1876
1887
1877 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1888 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1878 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1889 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1879
1890
1880 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1891 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1881 expand Python variables prepended with $ in all system calls. The
1892 expand Python variables prepended with $ in all system calls. The
1882 same was done to InteractiveShell.handle_shell_escape. Now all
1893 same was done to InteractiveShell.handle_shell_escape. Now all
1883 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1894 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1884 expansion of python variables and expressions according to the
1895 expansion of python variables and expressions according to the
1885 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1896 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1886
1897
1887 Though PEP-215 has been rejected, a similar (but simpler) one
1898 Though PEP-215 has been rejected, a similar (but simpler) one
1888 seems like it will go into Python 2.4, PEP-292 -
1899 seems like it will go into Python 2.4, PEP-292 -
1889 http://www.python.org/peps/pep-0292.html.
1900 http://www.python.org/peps/pep-0292.html.
1890
1901
1891 I'll keep the full syntax of PEP-215, since IPython has since the
1902 I'll keep the full syntax of PEP-215, since IPython has since the
1892 start used Ka-Ping Yee's reference implementation discussed there
1903 start used Ka-Ping Yee's reference implementation discussed there
1893 (Itpl), and I actually like the powerful semantics it offers.
1904 (Itpl), and I actually like the powerful semantics it offers.
1894
1905
1895 In order to access normal shell variables, the $ has to be escaped
1906 In order to access normal shell variables, the $ has to be escaped
1896 via an extra $. For example:
1907 via an extra $. For example:
1897
1908
1898 In [7]: PATH='a python variable'
1909 In [7]: PATH='a python variable'
1899
1910
1900 In [8]: !echo $PATH
1911 In [8]: !echo $PATH
1901 a python variable
1912 a python variable
1902
1913
1903 In [9]: !echo $$PATH
1914 In [9]: !echo $$PATH
1904 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1915 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1905
1916
1906 (Magic.parse_options): escape $ so the shell doesn't evaluate
1917 (Magic.parse_options): escape $ so the shell doesn't evaluate
1907 things prematurely.
1918 things prematurely.
1908
1919
1909 * IPython/iplib.py (InteractiveShell.call_alias): added the
1920 * IPython/iplib.py (InteractiveShell.call_alias): added the
1910 ability for aliases to expand python variables via $.
1921 ability for aliases to expand python variables via $.
1911
1922
1912 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1923 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1913 system, now there's a @rehash/@rehashx pair of magics. These work
1924 system, now there's a @rehash/@rehashx pair of magics. These work
1914 like the csh rehash command, and can be invoked at any time. They
1925 like the csh rehash command, and can be invoked at any time. They
1915 build a table of aliases to everything in the user's $PATH
1926 build a table of aliases to everything in the user's $PATH
1916 (@rehash uses everything, @rehashx is slower but only adds
1927 (@rehash uses everything, @rehashx is slower but only adds
1917 executable files). With this, the pysh.py-based shell profile can
1928 executable files). With this, the pysh.py-based shell profile can
1918 now simply call rehash upon startup, and full access to all
1929 now simply call rehash upon startup, and full access to all
1919 programs in the user's path is obtained.
1930 programs in the user's path is obtained.
1920
1931
1921 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1932 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1922 functionality is now fully in place. I removed the old dynamic
1933 functionality is now fully in place. I removed the old dynamic
1923 code generation based approach, in favor of a much lighter one
1934 code generation based approach, in favor of a much lighter one
1924 based on a simple dict. The advantage is that this allows me to
1935 based on a simple dict. The advantage is that this allows me to
1925 now have thousands of aliases with negligible cost (unthinkable
1936 now have thousands of aliases with negligible cost (unthinkable
1926 with the old system).
1937 with the old system).
1927
1938
1928 2004-06-19 Fernando Perez <fperez@colorado.edu>
1939 2004-06-19 Fernando Perez <fperez@colorado.edu>
1929
1940
1930 * IPython/iplib.py (__init__): extended MagicCompleter class to
1941 * IPython/iplib.py (__init__): extended MagicCompleter class to
1931 also complete (last in priority) on user aliases.
1942 also complete (last in priority) on user aliases.
1932
1943
1933 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1944 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1934 call to eval.
1945 call to eval.
1935 (ItplNS.__init__): Added a new class which functions like Itpl,
1946 (ItplNS.__init__): Added a new class which functions like Itpl,
1936 but allows configuring the namespace for the evaluation to occur
1947 but allows configuring the namespace for the evaluation to occur
1937 in.
1948 in.
1938
1949
1939 2004-06-18 Fernando Perez <fperez@colorado.edu>
1950 2004-06-18 Fernando Perez <fperez@colorado.edu>
1940
1951
1941 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1952 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1942 better message when 'exit' or 'quit' are typed (a common newbie
1953 better message when 'exit' or 'quit' are typed (a common newbie
1943 confusion).
1954 confusion).
1944
1955
1945 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1956 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1946 check for Windows users.
1957 check for Windows users.
1947
1958
1948 * IPython/iplib.py (InteractiveShell.user_setup): removed
1959 * IPython/iplib.py (InteractiveShell.user_setup): removed
1949 disabling of colors for Windows. I'll test at runtime and issue a
1960 disabling of colors for Windows. I'll test at runtime and issue a
1950 warning if Gary's readline isn't found, as to nudge users to
1961 warning if Gary's readline isn't found, as to nudge users to
1951 download it.
1962 download it.
1952
1963
1953 2004-06-16 Fernando Perez <fperez@colorado.edu>
1964 2004-06-16 Fernando Perez <fperez@colorado.edu>
1954
1965
1955 * IPython/genutils.py (Stream.__init__): changed to print errors
1966 * IPython/genutils.py (Stream.__init__): changed to print errors
1956 to sys.stderr. I had a circular dependency here. Now it's
1967 to sys.stderr. I had a circular dependency here. Now it's
1957 possible to run ipython as IDLE's shell (consider this pre-alpha,
1968 possible to run ipython as IDLE's shell (consider this pre-alpha,
1958 since true stdout things end up in the starting terminal instead
1969 since true stdout things end up in the starting terminal instead
1959 of IDLE's out).
1970 of IDLE's out).
1960
1971
1961 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1972 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1962 users who haven't # updated their prompt_in2 definitions. Remove
1973 users who haven't # updated their prompt_in2 definitions. Remove
1963 eventually.
1974 eventually.
1964 (multiple_replace): added credit to original ASPN recipe.
1975 (multiple_replace): added credit to original ASPN recipe.
1965
1976
1966 2004-06-15 Fernando Perez <fperez@colorado.edu>
1977 2004-06-15 Fernando Perez <fperez@colorado.edu>
1967
1978
1968 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1979 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1969 list of auto-defined aliases.
1980 list of auto-defined aliases.
1970
1981
1971 2004-06-13 Fernando Perez <fperez@colorado.edu>
1982 2004-06-13 Fernando Perez <fperez@colorado.edu>
1972
1983
1973 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1984 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1974 install was really requested (so setup.py can be used for other
1985 install was really requested (so setup.py can be used for other
1975 things under Windows).
1986 things under Windows).
1976
1987
1977 2004-06-10 Fernando Perez <fperez@colorado.edu>
1988 2004-06-10 Fernando Perez <fperez@colorado.edu>
1978
1989
1979 * IPython/Logger.py (Logger.create_log): Manually remove any old
1990 * IPython/Logger.py (Logger.create_log): Manually remove any old
1980 backup, since os.remove may fail under Windows. Fixes bug
1991 backup, since os.remove may fail under Windows. Fixes bug
1981 reported by Thorsten.
1992 reported by Thorsten.
1982
1993
1983 2004-06-09 Fernando Perez <fperez@colorado.edu>
1994 2004-06-09 Fernando Perez <fperez@colorado.edu>
1984
1995
1985 * examples/example-embed.py: fixed all references to %n (replaced
1996 * examples/example-embed.py: fixed all references to %n (replaced
1986 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1997 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1987 for all examples and the manual as well.
1998 for all examples and the manual as well.
1988
1999
1989 2004-06-08 Fernando Perez <fperez@colorado.edu>
2000 2004-06-08 Fernando Perez <fperez@colorado.edu>
1990
2001
1991 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2002 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1992 alignment and color management. All 3 prompt subsystems now
2003 alignment and color management. All 3 prompt subsystems now
1993 inherit from BasePrompt.
2004 inherit from BasePrompt.
1994
2005
1995 * tools/release: updates for windows installer build and tag rpms
2006 * tools/release: updates for windows installer build and tag rpms
1996 with python version (since paths are fixed).
2007 with python version (since paths are fixed).
1997
2008
1998 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2009 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1999 which will become eventually obsolete. Also fixed the default
2010 which will become eventually obsolete. Also fixed the default
2000 prompt_in2 to use \D, so at least new users start with the correct
2011 prompt_in2 to use \D, so at least new users start with the correct
2001 defaults.
2012 defaults.
2002 WARNING: Users with existing ipythonrc files will need to apply
2013 WARNING: Users with existing ipythonrc files will need to apply
2003 this fix manually!
2014 this fix manually!
2004
2015
2005 * setup.py: make windows installer (.exe). This is finally the
2016 * setup.py: make windows installer (.exe). This is finally the
2006 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2017 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2007 which I hadn't included because it required Python 2.3 (or recent
2018 which I hadn't included because it required Python 2.3 (or recent
2008 distutils).
2019 distutils).
2009
2020
2010 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2021 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2011 usage of new '\D' escape.
2022 usage of new '\D' escape.
2012
2023
2013 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2024 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2014 lacks os.getuid())
2025 lacks os.getuid())
2015 (CachedOutput.set_colors): Added the ability to turn coloring
2026 (CachedOutput.set_colors): Added the ability to turn coloring
2016 on/off with @colors even for manually defined prompt colors. It
2027 on/off with @colors even for manually defined prompt colors. It
2017 uses a nasty global, but it works safely and via the generic color
2028 uses a nasty global, but it works safely and via the generic color
2018 handling mechanism.
2029 handling mechanism.
2019 (Prompt2.__init__): Introduced new escape '\D' for continuation
2030 (Prompt2.__init__): Introduced new escape '\D' for continuation
2020 prompts. It represents the counter ('\#') as dots.
2031 prompts. It represents the counter ('\#') as dots.
2021 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2032 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2022 need to update their ipythonrc files and replace '%n' with '\D' in
2033 need to update their ipythonrc files and replace '%n' with '\D' in
2023 their prompt_in2 settings everywhere. Sorry, but there's
2034 their prompt_in2 settings everywhere. Sorry, but there's
2024 otherwise no clean way to get all prompts to properly align. The
2035 otherwise no clean way to get all prompts to properly align. The
2025 ipythonrc shipped with IPython has been updated.
2036 ipythonrc shipped with IPython has been updated.
2026
2037
2027 2004-06-07 Fernando Perez <fperez@colorado.edu>
2038 2004-06-07 Fernando Perez <fperez@colorado.edu>
2028
2039
2029 * setup.py (isfile): Pass local_icons option to latex2html, so the
2040 * setup.py (isfile): Pass local_icons option to latex2html, so the
2030 resulting HTML file is self-contained. Thanks to
2041 resulting HTML file is self-contained. Thanks to
2031 dryice-AT-liu.com.cn for the tip.
2042 dryice-AT-liu.com.cn for the tip.
2032
2043
2033 * pysh.py: I created a new profile 'shell', which implements a
2044 * pysh.py: I created a new profile 'shell', which implements a
2034 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2045 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2035 system shell, nor will it become one anytime soon. It's mainly
2046 system shell, nor will it become one anytime soon. It's mainly
2036 meant to illustrate the use of the new flexible bash-like prompts.
2047 meant to illustrate the use of the new flexible bash-like prompts.
2037 I guess it could be used by hardy souls for true shell management,
2048 I guess it could be used by hardy souls for true shell management,
2038 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2049 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2039 profile. This uses the InterpreterExec extension provided by
2050 profile. This uses the InterpreterExec extension provided by
2040 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2051 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2041
2052
2042 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2053 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2043 auto-align itself with the length of the previous input prompt
2054 auto-align itself with the length of the previous input prompt
2044 (taking into account the invisible color escapes).
2055 (taking into account the invisible color escapes).
2045 (CachedOutput.__init__): Large restructuring of this class. Now
2056 (CachedOutput.__init__): Large restructuring of this class. Now
2046 all three prompts (primary1, primary2, output) are proper objects,
2057 all three prompts (primary1, primary2, output) are proper objects,
2047 managed by the 'parent' CachedOutput class. The code is still a
2058 managed by the 'parent' CachedOutput class. The code is still a
2048 bit hackish (all prompts share state via a pointer to the cache),
2059 bit hackish (all prompts share state via a pointer to the cache),
2049 but it's overall far cleaner than before.
2060 but it's overall far cleaner than before.
2050
2061
2051 * IPython/genutils.py (getoutputerror): modified to add verbose,
2062 * IPython/genutils.py (getoutputerror): modified to add verbose,
2052 debug and header options. This makes the interface of all getout*
2063 debug and header options. This makes the interface of all getout*
2053 functions uniform.
2064 functions uniform.
2054 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2065 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2055
2066
2056 * IPython/Magic.py (Magic.default_option): added a function to
2067 * IPython/Magic.py (Magic.default_option): added a function to
2057 allow registering default options for any magic command. This
2068 allow registering default options for any magic command. This
2058 makes it easy to have profiles which customize the magics globally
2069 makes it easy to have profiles which customize the magics globally
2059 for a certain use. The values set through this function are
2070 for a certain use. The values set through this function are
2060 picked up by the parse_options() method, which all magics should
2071 picked up by the parse_options() method, which all magics should
2061 use to parse their options.
2072 use to parse their options.
2062
2073
2063 * IPython/genutils.py (warn): modified the warnings framework to
2074 * IPython/genutils.py (warn): modified the warnings framework to
2064 use the Term I/O class. I'm trying to slowly unify all of
2075 use the Term I/O class. I'm trying to slowly unify all of
2065 IPython's I/O operations to pass through Term.
2076 IPython's I/O operations to pass through Term.
2066
2077
2067 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2078 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2068 the secondary prompt to correctly match the length of the primary
2079 the secondary prompt to correctly match the length of the primary
2069 one for any prompt. Now multi-line code will properly line up
2080 one for any prompt. Now multi-line code will properly line up
2070 even for path dependent prompts, such as the new ones available
2081 even for path dependent prompts, such as the new ones available
2071 via the prompt_specials.
2082 via the prompt_specials.
2072
2083
2073 2004-06-06 Fernando Perez <fperez@colorado.edu>
2084 2004-06-06 Fernando Perez <fperez@colorado.edu>
2074
2085
2075 * IPython/Prompts.py (prompt_specials): Added the ability to have
2086 * IPython/Prompts.py (prompt_specials): Added the ability to have
2076 bash-like special sequences in the prompts, which get
2087 bash-like special sequences in the prompts, which get
2077 automatically expanded. Things like hostname, current working
2088 automatically expanded. Things like hostname, current working
2078 directory and username are implemented already, but it's easy to
2089 directory and username are implemented already, but it's easy to
2079 add more in the future. Thanks to a patch by W.J. van der Laan
2090 add more in the future. Thanks to a patch by W.J. van der Laan
2080 <gnufnork-AT-hetdigitalegat.nl>
2091 <gnufnork-AT-hetdigitalegat.nl>
2081 (prompt_specials): Added color support for prompt strings, so
2092 (prompt_specials): Added color support for prompt strings, so
2082 users can define arbitrary color setups for their prompts.
2093 users can define arbitrary color setups for their prompts.
2083
2094
2084 2004-06-05 Fernando Perez <fperez@colorado.edu>
2095 2004-06-05 Fernando Perez <fperez@colorado.edu>
2085
2096
2086 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2097 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2087 code to load Gary Bishop's readline and configure it
2098 code to load Gary Bishop's readline and configure it
2088 automatically. Thanks to Gary for help on this.
2099 automatically. Thanks to Gary for help on this.
2089
2100
2090 2004-06-01 Fernando Perez <fperez@colorado.edu>
2101 2004-06-01 Fernando Perez <fperez@colorado.edu>
2091
2102
2092 * IPython/Logger.py (Logger.create_log): fix bug for logging
2103 * IPython/Logger.py (Logger.create_log): fix bug for logging
2093 with no filename (previous fix was incomplete).
2104 with no filename (previous fix was incomplete).
2094
2105
2095 2004-05-25 Fernando Perez <fperez@colorado.edu>
2106 2004-05-25 Fernando Perez <fperez@colorado.edu>
2096
2107
2097 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2108 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2098 parens would get passed to the shell.
2109 parens would get passed to the shell.
2099
2110
2100 2004-05-20 Fernando Perez <fperez@colorado.edu>
2111 2004-05-20 Fernando Perez <fperez@colorado.edu>
2101
2112
2102 * IPython/Magic.py (Magic.magic_prun): changed default profile
2113 * IPython/Magic.py (Magic.magic_prun): changed default profile
2103 sort order to 'time' (the more common profiling need).
2114 sort order to 'time' (the more common profiling need).
2104
2115
2105 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2116 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2106 so that source code shown is guaranteed in sync with the file on
2117 so that source code shown is guaranteed in sync with the file on
2107 disk (also changed in psource). Similar fix to the one for
2118 disk (also changed in psource). Similar fix to the one for
2108 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2119 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2109 <yann.ledu-AT-noos.fr>.
2120 <yann.ledu-AT-noos.fr>.
2110
2121
2111 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2122 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2112 with a single option would not be correctly parsed. Closes
2123 with a single option would not be correctly parsed. Closes
2113 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2124 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2114 introduced in 0.6.0 (on 2004-05-06).
2125 introduced in 0.6.0 (on 2004-05-06).
2115
2126
2116 2004-05-13 *** Released version 0.6.0
2127 2004-05-13 *** Released version 0.6.0
2117
2128
2118 2004-05-13 Fernando Perez <fperez@colorado.edu>
2129 2004-05-13 Fernando Perez <fperez@colorado.edu>
2119
2130
2120 * debian/: Added debian/ directory to CVS, so that debian support
2131 * debian/: Added debian/ directory to CVS, so that debian support
2121 is publicly accessible. The debian package is maintained by Jack
2132 is publicly accessible. The debian package is maintained by Jack
2122 Moffit <jack-AT-xiph.org>.
2133 Moffit <jack-AT-xiph.org>.
2123
2134
2124 * Documentation: included the notes about an ipython-based system
2135 * Documentation: included the notes about an ipython-based system
2125 shell (the hypothetical 'pysh') into the new_design.pdf document,
2136 shell (the hypothetical 'pysh') into the new_design.pdf document,
2126 so that these ideas get distributed to users along with the
2137 so that these ideas get distributed to users along with the
2127 official documentation.
2138 official documentation.
2128
2139
2129 2004-05-10 Fernando Perez <fperez@colorado.edu>
2140 2004-05-10 Fernando Perez <fperez@colorado.edu>
2130
2141
2131 * IPython/Logger.py (Logger.create_log): fix recently introduced
2142 * IPython/Logger.py (Logger.create_log): fix recently introduced
2132 bug (misindented line) where logstart would fail when not given an
2143 bug (misindented line) where logstart would fail when not given an
2133 explicit filename.
2144 explicit filename.
2134
2145
2135 2004-05-09 Fernando Perez <fperez@colorado.edu>
2146 2004-05-09 Fernando Perez <fperez@colorado.edu>
2136
2147
2137 * IPython/Magic.py (Magic.parse_options): skip system call when
2148 * IPython/Magic.py (Magic.parse_options): skip system call when
2138 there are no options to look for. Faster, cleaner for the common
2149 there are no options to look for. Faster, cleaner for the common
2139 case.
2150 case.
2140
2151
2141 * Documentation: many updates to the manual: describing Windows
2152 * Documentation: many updates to the manual: describing Windows
2142 support better, Gnuplot updates, credits, misc small stuff. Also
2153 support better, Gnuplot updates, credits, misc small stuff. Also
2143 updated the new_design doc a bit.
2154 updated the new_design doc a bit.
2144
2155
2145 2004-05-06 *** Released version 0.6.0.rc1
2156 2004-05-06 *** Released version 0.6.0.rc1
2146
2157
2147 2004-05-06 Fernando Perez <fperez@colorado.edu>
2158 2004-05-06 Fernando Perez <fperez@colorado.edu>
2148
2159
2149 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2160 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2150 operations to use the vastly more efficient list/''.join() method.
2161 operations to use the vastly more efficient list/''.join() method.
2151 (FormattedTB.text): Fix
2162 (FormattedTB.text): Fix
2152 http://www.scipy.net/roundup/ipython/issue12 - exception source
2163 http://www.scipy.net/roundup/ipython/issue12 - exception source
2153 extract not updated after reload. Thanks to Mike Salib
2164 extract not updated after reload. Thanks to Mike Salib
2154 <msalib-AT-mit.edu> for pinning the source of the problem.
2165 <msalib-AT-mit.edu> for pinning the source of the problem.
2155 Fortunately, the solution works inside ipython and doesn't require
2166 Fortunately, the solution works inside ipython and doesn't require
2156 any changes to python proper.
2167 any changes to python proper.
2157
2168
2158 * IPython/Magic.py (Magic.parse_options): Improved to process the
2169 * IPython/Magic.py (Magic.parse_options): Improved to process the
2159 argument list as a true shell would (by actually using the
2170 argument list as a true shell would (by actually using the
2160 underlying system shell). This way, all @magics automatically get
2171 underlying system shell). This way, all @magics automatically get
2161 shell expansion for variables. Thanks to a comment by Alex
2172 shell expansion for variables. Thanks to a comment by Alex
2162 Schmolck.
2173 Schmolck.
2163
2174
2164 2004-04-04 Fernando Perez <fperez@colorado.edu>
2175 2004-04-04 Fernando Perez <fperez@colorado.edu>
2165
2176
2166 * IPython/iplib.py (InteractiveShell.interact): Added a special
2177 * IPython/iplib.py (InteractiveShell.interact): Added a special
2167 trap for a debugger quit exception, which is basically impossible
2178 trap for a debugger quit exception, which is basically impossible
2168 to handle by normal mechanisms, given what pdb does to the stack.
2179 to handle by normal mechanisms, given what pdb does to the stack.
2169 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2180 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2170
2181
2171 2004-04-03 Fernando Perez <fperez@colorado.edu>
2182 2004-04-03 Fernando Perez <fperez@colorado.edu>
2172
2183
2173 * IPython/genutils.py (Term): Standardized the names of the Term
2184 * IPython/genutils.py (Term): Standardized the names of the Term
2174 class streams to cin/cout/cerr, following C++ naming conventions
2185 class streams to cin/cout/cerr, following C++ naming conventions
2175 (I can't use in/out/err because 'in' is not a valid attribute
2186 (I can't use in/out/err because 'in' is not a valid attribute
2176 name).
2187 name).
2177
2188
2178 * IPython/iplib.py (InteractiveShell.interact): don't increment
2189 * IPython/iplib.py (InteractiveShell.interact): don't increment
2179 the prompt if there's no user input. By Daniel 'Dang' Griffith
2190 the prompt if there's no user input. By Daniel 'Dang' Griffith
2180 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2191 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2181 Francois Pinard.
2192 Francois Pinard.
2182
2193
2183 2004-04-02 Fernando Perez <fperez@colorado.edu>
2194 2004-04-02 Fernando Perez <fperez@colorado.edu>
2184
2195
2185 * IPython/genutils.py (Stream.__init__): Modified to survive at
2196 * IPython/genutils.py (Stream.__init__): Modified to survive at
2186 least importing in contexts where stdin/out/err aren't true file
2197 least importing in contexts where stdin/out/err aren't true file
2187 objects, such as PyCrust (they lack fileno() and mode). However,
2198 objects, such as PyCrust (they lack fileno() and mode). However,
2188 the recovery facilities which rely on these things existing will
2199 the recovery facilities which rely on these things existing will
2189 not work.
2200 not work.
2190
2201
2191 2004-04-01 Fernando Perez <fperez@colorado.edu>
2202 2004-04-01 Fernando Perez <fperez@colorado.edu>
2192
2203
2193 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2204 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2194 use the new getoutputerror() function, so it properly
2205 use the new getoutputerror() function, so it properly
2195 distinguishes stdout/err.
2206 distinguishes stdout/err.
2196
2207
2197 * IPython/genutils.py (getoutputerror): added a function to
2208 * IPython/genutils.py (getoutputerror): added a function to
2198 capture separately the standard output and error of a command.
2209 capture separately the standard output and error of a command.
2199 After a comment from dang on the mailing lists. This code is
2210 After a comment from dang on the mailing lists. This code is
2200 basically a modified version of commands.getstatusoutput(), from
2211 basically a modified version of commands.getstatusoutput(), from
2201 the standard library.
2212 the standard library.
2202
2213
2203 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2214 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2204 '!!' as a special syntax (shorthand) to access @sx.
2215 '!!' as a special syntax (shorthand) to access @sx.
2205
2216
2206 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2217 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2207 command and return its output as a list split on '\n'.
2218 command and return its output as a list split on '\n'.
2208
2219
2209 2004-03-31 Fernando Perez <fperez@colorado.edu>
2220 2004-03-31 Fernando Perez <fperez@colorado.edu>
2210
2221
2211 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2222 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2212 method to dictionaries used as FakeModule instances if they lack
2223 method to dictionaries used as FakeModule instances if they lack
2213 it. At least pydoc in python2.3 breaks for runtime-defined
2224 it. At least pydoc in python2.3 breaks for runtime-defined
2214 functions without this hack. At some point I need to _really_
2225 functions without this hack. At some point I need to _really_
2215 understand what FakeModule is doing, because it's a gross hack.
2226 understand what FakeModule is doing, because it's a gross hack.
2216 But it solves Arnd's problem for now...
2227 But it solves Arnd's problem for now...
2217
2228
2218 2004-02-27 Fernando Perez <fperez@colorado.edu>
2229 2004-02-27 Fernando Perez <fperez@colorado.edu>
2219
2230
2220 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2231 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2221 mode would behave erratically. Also increased the number of
2232 mode would behave erratically. Also increased the number of
2222 possible logs in rotate mod to 999. Thanks to Rod Holland
2233 possible logs in rotate mod to 999. Thanks to Rod Holland
2223 <rhh@StructureLABS.com> for the report and fixes.
2234 <rhh@StructureLABS.com> for the report and fixes.
2224
2235
2225 2004-02-26 Fernando Perez <fperez@colorado.edu>
2236 2004-02-26 Fernando Perez <fperez@colorado.edu>
2226
2237
2227 * IPython/genutils.py (page): Check that the curses module really
2238 * IPython/genutils.py (page): Check that the curses module really
2228 has the initscr attribute before trying to use it. For some
2239 has the initscr attribute before trying to use it. For some
2229 reason, the Solaris curses module is missing this. I think this
2240 reason, the Solaris curses module is missing this. I think this
2230 should be considered a Solaris python bug, but I'm not sure.
2241 should be considered a Solaris python bug, but I'm not sure.
2231
2242
2232 2004-01-17 Fernando Perez <fperez@colorado.edu>
2243 2004-01-17 Fernando Perez <fperez@colorado.edu>
2233
2244
2234 * IPython/genutils.py (Stream.__init__): Changes to try to make
2245 * IPython/genutils.py (Stream.__init__): Changes to try to make
2235 ipython robust against stdin/out/err being closed by the user.
2246 ipython robust against stdin/out/err being closed by the user.
2236 This is 'user error' (and blocks a normal python session, at least
2247 This is 'user error' (and blocks a normal python session, at least
2237 the stdout case). However, Ipython should be able to survive such
2248 the stdout case). However, Ipython should be able to survive such
2238 instances of abuse as gracefully as possible. To simplify the
2249 instances of abuse as gracefully as possible. To simplify the
2239 coding and maintain compatibility with Gary Bishop's Term
2250 coding and maintain compatibility with Gary Bishop's Term
2240 contributions, I've made use of classmethods for this. I think
2251 contributions, I've made use of classmethods for this. I think
2241 this introduces a dependency on python 2.2.
2252 this introduces a dependency on python 2.2.
2242
2253
2243 2004-01-13 Fernando Perez <fperez@colorado.edu>
2254 2004-01-13 Fernando Perez <fperez@colorado.edu>
2244
2255
2245 * IPython/numutils.py (exp_safe): simplified the code a bit and
2256 * IPython/numutils.py (exp_safe): simplified the code a bit and
2246 removed the need for importing the kinds module altogether.
2257 removed the need for importing the kinds module altogether.
2247
2258
2248 2004-01-06 Fernando Perez <fperez@colorado.edu>
2259 2004-01-06 Fernando Perez <fperez@colorado.edu>
2249
2260
2250 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2261 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2251 a magic function instead, after some community feedback. No
2262 a magic function instead, after some community feedback. No
2252 special syntax will exist for it, but its name is deliberately
2263 special syntax will exist for it, but its name is deliberately
2253 very short.
2264 very short.
2254
2265
2255 2003-12-20 Fernando Perez <fperez@colorado.edu>
2266 2003-12-20 Fernando Perez <fperez@colorado.edu>
2256
2267
2257 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2268 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2258 new functionality, to automagically assign the result of a shell
2269 new functionality, to automagically assign the result of a shell
2259 command to a variable. I'll solicit some community feedback on
2270 command to a variable. I'll solicit some community feedback on
2260 this before making it permanent.
2271 this before making it permanent.
2261
2272
2262 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2273 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2263 requested about callables for which inspect couldn't obtain a
2274 requested about callables for which inspect couldn't obtain a
2264 proper argspec. Thanks to a crash report sent by Etienne
2275 proper argspec. Thanks to a crash report sent by Etienne
2265 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2276 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2266
2277
2267 2003-12-09 Fernando Perez <fperez@colorado.edu>
2278 2003-12-09 Fernando Perez <fperez@colorado.edu>
2268
2279
2269 * IPython/genutils.py (page): patch for the pager to work across
2280 * IPython/genutils.py (page): patch for the pager to work across
2270 various versions of Windows. By Gary Bishop.
2281 various versions of Windows. By Gary Bishop.
2271
2282
2272 2003-12-04 Fernando Perez <fperez@colorado.edu>
2283 2003-12-04 Fernando Perez <fperez@colorado.edu>
2273
2284
2274 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2285 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2275 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2286 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2276 While I tested this and it looks ok, there may still be corner
2287 While I tested this and it looks ok, there may still be corner
2277 cases I've missed.
2288 cases I've missed.
2278
2289
2279 2003-12-01 Fernando Perez <fperez@colorado.edu>
2290 2003-12-01 Fernando Perez <fperez@colorado.edu>
2280
2291
2281 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2292 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2282 where a line like 'p,q=1,2' would fail because the automagic
2293 where a line like 'p,q=1,2' would fail because the automagic
2283 system would be triggered for @p.
2294 system would be triggered for @p.
2284
2295
2285 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2296 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2286 cleanups, code unmodified.
2297 cleanups, code unmodified.
2287
2298
2288 * IPython/genutils.py (Term): added a class for IPython to handle
2299 * IPython/genutils.py (Term): added a class for IPython to handle
2289 output. In most cases it will just be a proxy for stdout/err, but
2300 output. In most cases it will just be a proxy for stdout/err, but
2290 having this allows modifications to be made for some platforms,
2301 having this allows modifications to be made for some platforms,
2291 such as handling color escapes under Windows. All of this code
2302 such as handling color escapes under Windows. All of this code
2292 was contributed by Gary Bishop, with minor modifications by me.
2303 was contributed by Gary Bishop, with minor modifications by me.
2293 The actual changes affect many files.
2304 The actual changes affect many files.
2294
2305
2295 2003-11-30 Fernando Perez <fperez@colorado.edu>
2306 2003-11-30 Fernando Perez <fperez@colorado.edu>
2296
2307
2297 * IPython/iplib.py (file_matches): new completion code, courtesy
2308 * IPython/iplib.py (file_matches): new completion code, courtesy
2298 of Jeff Collins. This enables filename completion again under
2309 of Jeff Collins. This enables filename completion again under
2299 python 2.3, which disabled it at the C level.
2310 python 2.3, which disabled it at the C level.
2300
2311
2301 2003-11-11 Fernando Perez <fperez@colorado.edu>
2312 2003-11-11 Fernando Perez <fperez@colorado.edu>
2302
2313
2303 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2314 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2304 for Numeric.array(map(...)), but often convenient.
2315 for Numeric.array(map(...)), but often convenient.
2305
2316
2306 2003-11-05 Fernando Perez <fperez@colorado.edu>
2317 2003-11-05 Fernando Perez <fperez@colorado.edu>
2307
2318
2308 * IPython/numutils.py (frange): Changed a call from int() to
2319 * IPython/numutils.py (frange): Changed a call from int() to
2309 int(round()) to prevent a problem reported with arange() in the
2320 int(round()) to prevent a problem reported with arange() in the
2310 numpy list.
2321 numpy list.
2311
2322
2312 2003-10-06 Fernando Perez <fperez@colorado.edu>
2323 2003-10-06 Fernando Perez <fperez@colorado.edu>
2313
2324
2314 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2325 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2315 prevent crashes if sys lacks an argv attribute (it happens with
2326 prevent crashes if sys lacks an argv attribute (it happens with
2316 embedded interpreters which build a bare-bones sys module).
2327 embedded interpreters which build a bare-bones sys module).
2317 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2328 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2318
2329
2319 2003-09-24 Fernando Perez <fperez@colorado.edu>
2330 2003-09-24 Fernando Perez <fperez@colorado.edu>
2320
2331
2321 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2332 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2322 to protect against poorly written user objects where __getattr__
2333 to protect against poorly written user objects where __getattr__
2323 raises exceptions other than AttributeError. Thanks to a bug
2334 raises exceptions other than AttributeError. Thanks to a bug
2324 report by Oliver Sander <osander-AT-gmx.de>.
2335 report by Oliver Sander <osander-AT-gmx.de>.
2325
2336
2326 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2337 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2327 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2338 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2328
2339
2329 2003-09-09 Fernando Perez <fperez@colorado.edu>
2340 2003-09-09 Fernando Perez <fperez@colorado.edu>
2330
2341
2331 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2342 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2332 unpacking a list whith a callable as first element would
2343 unpacking a list whith a callable as first element would
2333 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2344 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2334 Collins.
2345 Collins.
2335
2346
2336 2003-08-25 *** Released version 0.5.0
2347 2003-08-25 *** Released version 0.5.0
2337
2348
2338 2003-08-22 Fernando Perez <fperez@colorado.edu>
2349 2003-08-22 Fernando Perez <fperez@colorado.edu>
2339
2350
2340 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2351 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2341 improperly defined user exceptions. Thanks to feedback from Mark
2352 improperly defined user exceptions. Thanks to feedback from Mark
2342 Russell <mrussell-AT-verio.net>.
2353 Russell <mrussell-AT-verio.net>.
2343
2354
2344 2003-08-20 Fernando Perez <fperez@colorado.edu>
2355 2003-08-20 Fernando Perez <fperez@colorado.edu>
2345
2356
2346 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2357 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2347 printing so that it would print multi-line string forms starting
2358 printing so that it would print multi-line string forms starting
2348 with a new line. This way the formatting is better respected for
2359 with a new line. This way the formatting is better respected for
2349 objects which work hard to make nice string forms.
2360 objects which work hard to make nice string forms.
2350
2361
2351 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2362 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2352 autocall would overtake data access for objects with both
2363 autocall would overtake data access for objects with both
2353 __getitem__ and __call__.
2364 __getitem__ and __call__.
2354
2365
2355 2003-08-19 *** Released version 0.5.0-rc1
2366 2003-08-19 *** Released version 0.5.0-rc1
2356
2367
2357 2003-08-19 Fernando Perez <fperez@colorado.edu>
2368 2003-08-19 Fernando Perez <fperez@colorado.edu>
2358
2369
2359 * IPython/deep_reload.py (load_tail): single tiny change here
2370 * IPython/deep_reload.py (load_tail): single tiny change here
2360 seems to fix the long-standing bug of dreload() failing to work
2371 seems to fix the long-standing bug of dreload() failing to work
2361 for dotted names. But this module is pretty tricky, so I may have
2372 for dotted names. But this module is pretty tricky, so I may have
2362 missed some subtlety. Needs more testing!.
2373 missed some subtlety. Needs more testing!.
2363
2374
2364 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2375 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2365 exceptions which have badly implemented __str__ methods.
2376 exceptions which have badly implemented __str__ methods.
2366 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2377 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2367 which I've been getting reports about from Python 2.3 users. I
2378 which I've been getting reports about from Python 2.3 users. I
2368 wish I had a simple test case to reproduce the problem, so I could
2379 wish I had a simple test case to reproduce the problem, so I could
2369 either write a cleaner workaround or file a bug report if
2380 either write a cleaner workaround or file a bug report if
2370 necessary.
2381 necessary.
2371
2382
2372 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2383 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2373 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2384 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2374 a bug report by Tjabo Kloppenburg.
2385 a bug report by Tjabo Kloppenburg.
2375
2386
2376 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2387 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2377 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2388 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2378 seems rather unstable. Thanks to a bug report by Tjabo
2389 seems rather unstable. Thanks to a bug report by Tjabo
2379 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2390 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2380
2391
2381 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2392 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2382 this out soon because of the critical fixes in the inner loop for
2393 this out soon because of the critical fixes in the inner loop for
2383 generators.
2394 generators.
2384
2395
2385 * IPython/Magic.py (Magic.getargspec): removed. This (and
2396 * IPython/Magic.py (Magic.getargspec): removed. This (and
2386 _get_def) have been obsoleted by OInspect for a long time, I
2397 _get_def) have been obsoleted by OInspect for a long time, I
2387 hadn't noticed that they were dead code.
2398 hadn't noticed that they were dead code.
2388 (Magic._ofind): restored _ofind functionality for a few literals
2399 (Magic._ofind): restored _ofind functionality for a few literals
2389 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2400 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2390 for things like "hello".capitalize?, since that would require a
2401 for things like "hello".capitalize?, since that would require a
2391 potentially dangerous eval() again.
2402 potentially dangerous eval() again.
2392
2403
2393 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2404 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2394 logic a bit more to clean up the escapes handling and minimize the
2405 logic a bit more to clean up the escapes handling and minimize the
2395 use of _ofind to only necessary cases. The interactive 'feel' of
2406 use of _ofind to only necessary cases. The interactive 'feel' of
2396 IPython should have improved quite a bit with the changes in
2407 IPython should have improved quite a bit with the changes in
2397 _prefilter and _ofind (besides being far safer than before).
2408 _prefilter and _ofind (besides being far safer than before).
2398
2409
2399 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2410 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2400 obscure, never reported). Edit would fail to find the object to
2411 obscure, never reported). Edit would fail to find the object to
2401 edit under some circumstances.
2412 edit under some circumstances.
2402 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2413 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2403 which were causing double-calling of generators. Those eval calls
2414 which were causing double-calling of generators. Those eval calls
2404 were _very_ dangerous, since code with side effects could be
2415 were _very_ dangerous, since code with side effects could be
2405 triggered. As they say, 'eval is evil'... These were the
2416 triggered. As they say, 'eval is evil'... These were the
2406 nastiest evals in IPython. Besides, _ofind is now far simpler,
2417 nastiest evals in IPython. Besides, _ofind is now far simpler,
2407 and it should also be quite a bit faster. Its use of inspect is
2418 and it should also be quite a bit faster. Its use of inspect is
2408 also safer, so perhaps some of the inspect-related crashes I've
2419 also safer, so perhaps some of the inspect-related crashes I've
2409 seen lately with Python 2.3 might be taken care of. That will
2420 seen lately with Python 2.3 might be taken care of. That will
2410 need more testing.
2421 need more testing.
2411
2422
2412 2003-08-17 Fernando Perez <fperez@colorado.edu>
2423 2003-08-17 Fernando Perez <fperez@colorado.edu>
2413
2424
2414 * IPython/iplib.py (InteractiveShell._prefilter): significant
2425 * IPython/iplib.py (InteractiveShell._prefilter): significant
2415 simplifications to the logic for handling user escapes. Faster
2426 simplifications to the logic for handling user escapes. Faster
2416 and simpler code.
2427 and simpler code.
2417
2428
2418 2003-08-14 Fernando Perez <fperez@colorado.edu>
2429 2003-08-14 Fernando Perez <fperez@colorado.edu>
2419
2430
2420 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2431 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2421 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2432 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2422 but it should be quite a bit faster. And the recursive version
2433 but it should be quite a bit faster. And the recursive version
2423 generated O(log N) intermediate storage for all rank>1 arrays,
2434 generated O(log N) intermediate storage for all rank>1 arrays,
2424 even if they were contiguous.
2435 even if they were contiguous.
2425 (l1norm): Added this function.
2436 (l1norm): Added this function.
2426 (norm): Added this function for arbitrary norms (including
2437 (norm): Added this function for arbitrary norms (including
2427 l-infinity). l1 and l2 are still special cases for convenience
2438 l-infinity). l1 and l2 are still special cases for convenience
2428 and speed.
2439 and speed.
2429
2440
2430 2003-08-03 Fernando Perez <fperez@colorado.edu>
2441 2003-08-03 Fernando Perez <fperez@colorado.edu>
2431
2442
2432 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2443 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2433 exceptions, which now raise PendingDeprecationWarnings in Python
2444 exceptions, which now raise PendingDeprecationWarnings in Python
2434 2.3. There were some in Magic and some in Gnuplot2.
2445 2.3. There were some in Magic and some in Gnuplot2.
2435
2446
2436 2003-06-30 Fernando Perez <fperez@colorado.edu>
2447 2003-06-30 Fernando Perez <fperez@colorado.edu>
2437
2448
2438 * IPython/genutils.py (page): modified to call curses only for
2449 * IPython/genutils.py (page): modified to call curses only for
2439 terminals where TERM=='xterm'. After problems under many other
2450 terminals where TERM=='xterm'. After problems under many other
2440 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2451 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2441
2452
2442 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2453 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2443 would be triggered when readline was absent. This was just an old
2454 would be triggered when readline was absent. This was just an old
2444 debugging statement I'd forgotten to take out.
2455 debugging statement I'd forgotten to take out.
2445
2456
2446 2003-06-20 Fernando Perez <fperez@colorado.edu>
2457 2003-06-20 Fernando Perez <fperez@colorado.edu>
2447
2458
2448 * IPython/genutils.py (clock): modified to return only user time
2459 * IPython/genutils.py (clock): modified to return only user time
2449 (not counting system time), after a discussion on scipy. While
2460 (not counting system time), after a discussion on scipy. While
2450 system time may be a useful quantity occasionally, it may much
2461 system time may be a useful quantity occasionally, it may much
2451 more easily be skewed by occasional swapping or other similar
2462 more easily be skewed by occasional swapping or other similar
2452 activity.
2463 activity.
2453
2464
2454 2003-06-05 Fernando Perez <fperez@colorado.edu>
2465 2003-06-05 Fernando Perez <fperez@colorado.edu>
2455
2466
2456 * IPython/numutils.py (identity): new function, for building
2467 * IPython/numutils.py (identity): new function, for building
2457 arbitrary rank Kronecker deltas (mostly backwards compatible with
2468 arbitrary rank Kronecker deltas (mostly backwards compatible with
2458 Numeric.identity)
2469 Numeric.identity)
2459
2470
2460 2003-06-03 Fernando Perez <fperez@colorado.edu>
2471 2003-06-03 Fernando Perez <fperez@colorado.edu>
2461
2472
2462 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2473 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2463 arguments passed to magics with spaces, to allow trailing '\' to
2474 arguments passed to magics with spaces, to allow trailing '\' to
2464 work normally (mainly for Windows users).
2475 work normally (mainly for Windows users).
2465
2476
2466 2003-05-29 Fernando Perez <fperez@colorado.edu>
2477 2003-05-29 Fernando Perez <fperez@colorado.edu>
2467
2478
2468 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2479 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2469 instead of pydoc.help. This fixes a bizarre behavior where
2480 instead of pydoc.help. This fixes a bizarre behavior where
2470 printing '%s' % locals() would trigger the help system. Now
2481 printing '%s' % locals() would trigger the help system. Now
2471 ipython behaves like normal python does.
2482 ipython behaves like normal python does.
2472
2483
2473 Note that if one does 'from pydoc import help', the bizarre
2484 Note that if one does 'from pydoc import help', the bizarre
2474 behavior returns, but this will also happen in normal python, so
2485 behavior returns, but this will also happen in normal python, so
2475 it's not an ipython bug anymore (it has to do with how pydoc.help
2486 it's not an ipython bug anymore (it has to do with how pydoc.help
2476 is implemented).
2487 is implemented).
2477
2488
2478 2003-05-22 Fernando Perez <fperez@colorado.edu>
2489 2003-05-22 Fernando Perez <fperez@colorado.edu>
2479
2490
2480 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2491 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2481 return [] instead of None when nothing matches, also match to end
2492 return [] instead of None when nothing matches, also match to end
2482 of line. Patch by Gary Bishop.
2493 of line. Patch by Gary Bishop.
2483
2494
2484 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2495 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2485 protection as before, for files passed on the command line. This
2496 protection as before, for files passed on the command line. This
2486 prevents the CrashHandler from kicking in if user files call into
2497 prevents the CrashHandler from kicking in if user files call into
2487 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2498 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2488 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2499 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2489
2500
2490 2003-05-20 *** Released version 0.4.0
2501 2003-05-20 *** Released version 0.4.0
2491
2502
2492 2003-05-20 Fernando Perez <fperez@colorado.edu>
2503 2003-05-20 Fernando Perez <fperez@colorado.edu>
2493
2504
2494 * setup.py: added support for manpages. It's a bit hackish b/c of
2505 * setup.py: added support for manpages. It's a bit hackish b/c of
2495 a bug in the way the bdist_rpm distutils target handles gzipped
2506 a bug in the way the bdist_rpm distutils target handles gzipped
2496 manpages, but it works. After a patch by Jack.
2507 manpages, but it works. After a patch by Jack.
2497
2508
2498 2003-05-19 Fernando Perez <fperez@colorado.edu>
2509 2003-05-19 Fernando Perez <fperez@colorado.edu>
2499
2510
2500 * IPython/numutils.py: added a mockup of the kinds module, since
2511 * IPython/numutils.py: added a mockup of the kinds module, since
2501 it was recently removed from Numeric. This way, numutils will
2512 it was recently removed from Numeric. This way, numutils will
2502 work for all users even if they are missing kinds.
2513 work for all users even if they are missing kinds.
2503
2514
2504 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2515 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2505 failure, which can occur with SWIG-wrapped extensions. After a
2516 failure, which can occur with SWIG-wrapped extensions. After a
2506 crash report from Prabhu.
2517 crash report from Prabhu.
2507
2518
2508 2003-05-16 Fernando Perez <fperez@colorado.edu>
2519 2003-05-16 Fernando Perez <fperez@colorado.edu>
2509
2520
2510 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2521 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2511 protect ipython from user code which may call directly
2522 protect ipython from user code which may call directly
2512 sys.excepthook (this looks like an ipython crash to the user, even
2523 sys.excepthook (this looks like an ipython crash to the user, even
2513 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2524 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2514 This is especially important to help users of WxWindows, but may
2525 This is especially important to help users of WxWindows, but may
2515 also be useful in other cases.
2526 also be useful in other cases.
2516
2527
2517 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2528 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2518 an optional tb_offset to be specified, and to preserve exception
2529 an optional tb_offset to be specified, and to preserve exception
2519 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2530 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2520
2531
2521 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2532 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2522
2533
2523 2003-05-15 Fernando Perez <fperez@colorado.edu>
2534 2003-05-15 Fernando Perez <fperez@colorado.edu>
2524
2535
2525 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2536 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2526 installing for a new user under Windows.
2537 installing for a new user under Windows.
2527
2538
2528 2003-05-12 Fernando Perez <fperez@colorado.edu>
2539 2003-05-12 Fernando Perez <fperez@colorado.edu>
2529
2540
2530 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2541 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2531 handler for Emacs comint-based lines. Currently it doesn't do
2542 handler for Emacs comint-based lines. Currently it doesn't do
2532 much (but importantly, it doesn't update the history cache). In
2543 much (but importantly, it doesn't update the history cache). In
2533 the future it may be expanded if Alex needs more functionality
2544 the future it may be expanded if Alex needs more functionality
2534 there.
2545 there.
2535
2546
2536 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2547 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2537 info to crash reports.
2548 info to crash reports.
2538
2549
2539 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2550 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2540 just like Python's -c. Also fixed crash with invalid -color
2551 just like Python's -c. Also fixed crash with invalid -color
2541 option value at startup. Thanks to Will French
2552 option value at startup. Thanks to Will French
2542 <wfrench-AT-bestweb.net> for the bug report.
2553 <wfrench-AT-bestweb.net> for the bug report.
2543
2554
2544 2003-05-09 Fernando Perez <fperez@colorado.edu>
2555 2003-05-09 Fernando Perez <fperez@colorado.edu>
2545
2556
2546 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2557 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2547 to EvalDict (it's a mapping, after all) and simplified its code
2558 to EvalDict (it's a mapping, after all) and simplified its code
2548 quite a bit, after a nice discussion on c.l.py where Gustavo
2559 quite a bit, after a nice discussion on c.l.py where Gustavo
2549 Córdova <gcordova-AT-sismex.com> suggested the new version.
2560 Córdova <gcordova-AT-sismex.com> suggested the new version.
2550
2561
2551 2003-04-30 Fernando Perez <fperez@colorado.edu>
2562 2003-04-30 Fernando Perez <fperez@colorado.edu>
2552
2563
2553 * IPython/genutils.py (timings_out): modified it to reduce its
2564 * IPython/genutils.py (timings_out): modified it to reduce its
2554 overhead in the common reps==1 case.
2565 overhead in the common reps==1 case.
2555
2566
2556 2003-04-29 Fernando Perez <fperez@colorado.edu>
2567 2003-04-29 Fernando Perez <fperez@colorado.edu>
2557
2568
2558 * IPython/genutils.py (timings_out): Modified to use the resource
2569 * IPython/genutils.py (timings_out): Modified to use the resource
2559 module, which avoids the wraparound problems of time.clock().
2570 module, which avoids the wraparound problems of time.clock().
2560
2571
2561 2003-04-17 *** Released version 0.2.15pre4
2572 2003-04-17 *** Released version 0.2.15pre4
2562
2573
2563 2003-04-17 Fernando Perez <fperez@colorado.edu>
2574 2003-04-17 Fernando Perez <fperez@colorado.edu>
2564
2575
2565 * setup.py (scriptfiles): Split windows-specific stuff over to a
2576 * setup.py (scriptfiles): Split windows-specific stuff over to a
2566 separate file, in an attempt to have a Windows GUI installer.
2577 separate file, in an attempt to have a Windows GUI installer.
2567 That didn't work, but part of the groundwork is done.
2578 That didn't work, but part of the groundwork is done.
2568
2579
2569 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2580 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2570 indent/unindent with 4 spaces. Particularly useful in combination
2581 indent/unindent with 4 spaces. Particularly useful in combination
2571 with the new auto-indent option.
2582 with the new auto-indent option.
2572
2583
2573 2003-04-16 Fernando Perez <fperez@colorado.edu>
2584 2003-04-16 Fernando Perez <fperez@colorado.edu>
2574
2585
2575 * IPython/Magic.py: various replacements of self.rc for
2586 * IPython/Magic.py: various replacements of self.rc for
2576 self.shell.rc. A lot more remains to be done to fully disentangle
2587 self.shell.rc. A lot more remains to be done to fully disentangle
2577 this class from the main Shell class.
2588 this class from the main Shell class.
2578
2589
2579 * IPython/GnuplotRuntime.py: added checks for mouse support so
2590 * IPython/GnuplotRuntime.py: added checks for mouse support so
2580 that we don't try to enable it if the current gnuplot doesn't
2591 that we don't try to enable it if the current gnuplot doesn't
2581 really support it. Also added checks so that we don't try to
2592 really support it. Also added checks so that we don't try to
2582 enable persist under Windows (where Gnuplot doesn't recognize the
2593 enable persist under Windows (where Gnuplot doesn't recognize the
2583 option).
2594 option).
2584
2595
2585 * IPython/iplib.py (InteractiveShell.interact): Added optional
2596 * IPython/iplib.py (InteractiveShell.interact): Added optional
2586 auto-indenting code, after a patch by King C. Shu
2597 auto-indenting code, after a patch by King C. Shu
2587 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2598 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2588 get along well with pasting indented code. If I ever figure out
2599 get along well with pasting indented code. If I ever figure out
2589 how to make that part go well, it will become on by default.
2600 how to make that part go well, it will become on by default.
2590
2601
2591 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2602 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2592 crash ipython if there was an unmatched '%' in the user's prompt
2603 crash ipython if there was an unmatched '%' in the user's prompt
2593 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2604 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2594
2605
2595 * IPython/iplib.py (InteractiveShell.interact): removed the
2606 * IPython/iplib.py (InteractiveShell.interact): removed the
2596 ability to ask the user whether he wants to crash or not at the
2607 ability to ask the user whether he wants to crash or not at the
2597 'last line' exception handler. Calling functions at that point
2608 'last line' exception handler. Calling functions at that point
2598 changes the stack, and the error reports would have incorrect
2609 changes the stack, and the error reports would have incorrect
2599 tracebacks.
2610 tracebacks.
2600
2611
2601 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2612 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2602 pass through a peger a pretty-printed form of any object. After a
2613 pass through a peger a pretty-printed form of any object. After a
2603 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2614 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2604
2615
2605 2003-04-14 Fernando Perez <fperez@colorado.edu>
2616 2003-04-14 Fernando Perez <fperez@colorado.edu>
2606
2617
2607 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2618 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2608 all files in ~ would be modified at first install (instead of
2619 all files in ~ would be modified at first install (instead of
2609 ~/.ipython). This could be potentially disastrous, as the
2620 ~/.ipython). This could be potentially disastrous, as the
2610 modification (make line-endings native) could damage binary files.
2621 modification (make line-endings native) could damage binary files.
2611
2622
2612 2003-04-10 Fernando Perez <fperez@colorado.edu>
2623 2003-04-10 Fernando Perez <fperez@colorado.edu>
2613
2624
2614 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2625 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2615 handle only lines which are invalid python. This now means that
2626 handle only lines which are invalid python. This now means that
2616 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2627 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2617 for the bug report.
2628 for the bug report.
2618
2629
2619 2003-04-01 Fernando Perez <fperez@colorado.edu>
2630 2003-04-01 Fernando Perez <fperez@colorado.edu>
2620
2631
2621 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2632 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2622 where failing to set sys.last_traceback would crash pdb.pm().
2633 where failing to set sys.last_traceback would crash pdb.pm().
2623 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2634 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2624 report.
2635 report.
2625
2636
2626 2003-03-25 Fernando Perez <fperez@colorado.edu>
2637 2003-03-25 Fernando Perez <fperez@colorado.edu>
2627
2638
2628 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2639 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2629 before printing it (it had a lot of spurious blank lines at the
2640 before printing it (it had a lot of spurious blank lines at the
2630 end).
2641 end).
2631
2642
2632 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2643 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2633 output would be sent 21 times! Obviously people don't use this
2644 output would be sent 21 times! Obviously people don't use this
2634 too often, or I would have heard about it.
2645 too often, or I would have heard about it.
2635
2646
2636 2003-03-24 Fernando Perez <fperez@colorado.edu>
2647 2003-03-24 Fernando Perez <fperez@colorado.edu>
2637
2648
2638 * setup.py (scriptfiles): renamed the data_files parameter from
2649 * setup.py (scriptfiles): renamed the data_files parameter from
2639 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2650 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2640 for the patch.
2651 for the patch.
2641
2652
2642 2003-03-20 Fernando Perez <fperez@colorado.edu>
2653 2003-03-20 Fernando Perez <fperez@colorado.edu>
2643
2654
2644 * IPython/genutils.py (error): added error() and fatal()
2655 * IPython/genutils.py (error): added error() and fatal()
2645 functions.
2656 functions.
2646
2657
2647 2003-03-18 *** Released version 0.2.15pre3
2658 2003-03-18 *** Released version 0.2.15pre3
2648
2659
2649 2003-03-18 Fernando Perez <fperez@colorado.edu>
2660 2003-03-18 Fernando Perez <fperez@colorado.edu>
2650
2661
2651 * setupext/install_data_ext.py
2662 * setupext/install_data_ext.py
2652 (install_data_ext.initialize_options): Class contributed by Jack
2663 (install_data_ext.initialize_options): Class contributed by Jack
2653 Moffit for fixing the old distutils hack. He is sending this to
2664 Moffit for fixing the old distutils hack. He is sending this to
2654 the distutils folks so in the future we may not need it as a
2665 the distutils folks so in the future we may not need it as a
2655 private fix.
2666 private fix.
2656
2667
2657 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2668 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2658 changes for Debian packaging. See his patch for full details.
2669 changes for Debian packaging. See his patch for full details.
2659 The old distutils hack of making the ipythonrc* files carry a
2670 The old distutils hack of making the ipythonrc* files carry a
2660 bogus .py extension is gone, at last. Examples were moved to a
2671 bogus .py extension is gone, at last. Examples were moved to a
2661 separate subdir under doc/, and the separate executable scripts
2672 separate subdir under doc/, and the separate executable scripts
2662 now live in their own directory. Overall a great cleanup. The
2673 now live in their own directory. Overall a great cleanup. The
2663 manual was updated to use the new files, and setup.py has been
2674 manual was updated to use the new files, and setup.py has been
2664 fixed for this setup.
2675 fixed for this setup.
2665
2676
2666 * IPython/PyColorize.py (Parser.usage): made non-executable and
2677 * IPython/PyColorize.py (Parser.usage): made non-executable and
2667 created a pycolor wrapper around it to be included as a script.
2678 created a pycolor wrapper around it to be included as a script.
2668
2679
2669 2003-03-12 *** Released version 0.2.15pre2
2680 2003-03-12 *** Released version 0.2.15pre2
2670
2681
2671 2003-03-12 Fernando Perez <fperez@colorado.edu>
2682 2003-03-12 Fernando Perez <fperez@colorado.edu>
2672
2683
2673 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2684 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2674 long-standing problem with garbage characters in some terminals.
2685 long-standing problem with garbage characters in some terminals.
2675 The issue was really that the \001 and \002 escapes must _only_ be
2686 The issue was really that the \001 and \002 escapes must _only_ be
2676 passed to input prompts (which call readline), but _never_ to
2687 passed to input prompts (which call readline), but _never_ to
2677 normal text to be printed on screen. I changed ColorANSI to have
2688 normal text to be printed on screen. I changed ColorANSI to have
2678 two classes: TermColors and InputTermColors, each with the
2689 two classes: TermColors and InputTermColors, each with the
2679 appropriate escapes for input prompts or normal text. The code in
2690 appropriate escapes for input prompts or normal text. The code in
2680 Prompts.py got slightly more complicated, but this very old and
2691 Prompts.py got slightly more complicated, but this very old and
2681 annoying bug is finally fixed.
2692 annoying bug is finally fixed.
2682
2693
2683 All the credit for nailing down the real origin of this problem
2694 All the credit for nailing down the real origin of this problem
2684 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2695 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2685 *Many* thanks to him for spending quite a bit of effort on this.
2696 *Many* thanks to him for spending quite a bit of effort on this.
2686
2697
2687 2003-03-05 *** Released version 0.2.15pre1
2698 2003-03-05 *** Released version 0.2.15pre1
2688
2699
2689 2003-03-03 Fernando Perez <fperez@colorado.edu>
2700 2003-03-03 Fernando Perez <fperez@colorado.edu>
2690
2701
2691 * IPython/FakeModule.py: Moved the former _FakeModule to a
2702 * IPython/FakeModule.py: Moved the former _FakeModule to a
2692 separate file, because it's also needed by Magic (to fix a similar
2703 separate file, because it's also needed by Magic (to fix a similar
2693 pickle-related issue in @run).
2704 pickle-related issue in @run).
2694
2705
2695 2003-03-02 Fernando Perez <fperez@colorado.edu>
2706 2003-03-02 Fernando Perez <fperez@colorado.edu>
2696
2707
2697 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2708 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2698 the autocall option at runtime.
2709 the autocall option at runtime.
2699 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2710 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2700 across Magic.py to start separating Magic from InteractiveShell.
2711 across Magic.py to start separating Magic from InteractiveShell.
2701 (Magic._ofind): Fixed to return proper namespace for dotted
2712 (Magic._ofind): Fixed to return proper namespace for dotted
2702 names. Before, a dotted name would always return 'not currently
2713 names. Before, a dotted name would always return 'not currently
2703 defined', because it would find the 'parent'. s.x would be found,
2714 defined', because it would find the 'parent'. s.x would be found,
2704 but since 'x' isn't defined by itself, it would get confused.
2715 but since 'x' isn't defined by itself, it would get confused.
2705 (Magic.magic_run): Fixed pickling problems reported by Ralf
2716 (Magic.magic_run): Fixed pickling problems reported by Ralf
2706 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2717 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2707 that I'd used when Mike Heeter reported similar issues at the
2718 that I'd used when Mike Heeter reported similar issues at the
2708 top-level, but now for @run. It boils down to injecting the
2719 top-level, but now for @run. It boils down to injecting the
2709 namespace where code is being executed with something that looks
2720 namespace where code is being executed with something that looks
2710 enough like a module to fool pickle.dump(). Since a pickle stores
2721 enough like a module to fool pickle.dump(). Since a pickle stores
2711 a named reference to the importing module, we need this for
2722 a named reference to the importing module, we need this for
2712 pickles to save something sensible.
2723 pickles to save something sensible.
2713
2724
2714 * IPython/ipmaker.py (make_IPython): added an autocall option.
2725 * IPython/ipmaker.py (make_IPython): added an autocall option.
2715
2726
2716 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2727 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2717 the auto-eval code. Now autocalling is an option, and the code is
2728 the auto-eval code. Now autocalling is an option, and the code is
2718 also vastly safer. There is no more eval() involved at all.
2729 also vastly safer. There is no more eval() involved at all.
2719
2730
2720 2003-03-01 Fernando Perez <fperez@colorado.edu>
2731 2003-03-01 Fernando Perez <fperez@colorado.edu>
2721
2732
2722 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2733 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2723 dict with named keys instead of a tuple.
2734 dict with named keys instead of a tuple.
2724
2735
2725 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2736 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2726
2737
2727 * setup.py (make_shortcut): Fixed message about directories
2738 * setup.py (make_shortcut): Fixed message about directories
2728 created during Windows installation (the directories were ok, just
2739 created during Windows installation (the directories were ok, just
2729 the printed message was misleading). Thanks to Chris Liechti
2740 the printed message was misleading). Thanks to Chris Liechti
2730 <cliechti-AT-gmx.net> for the heads up.
2741 <cliechti-AT-gmx.net> for the heads up.
2731
2742
2732 2003-02-21 Fernando Perez <fperez@colorado.edu>
2743 2003-02-21 Fernando Perez <fperez@colorado.edu>
2733
2744
2734 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2745 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2735 of ValueError exception when checking for auto-execution. This
2746 of ValueError exception when checking for auto-execution. This
2736 one is raised by things like Numeric arrays arr.flat when the
2747 one is raised by things like Numeric arrays arr.flat when the
2737 array is non-contiguous.
2748 array is non-contiguous.
2738
2749
2739 2003-01-31 Fernando Perez <fperez@colorado.edu>
2750 2003-01-31 Fernando Perez <fperez@colorado.edu>
2740
2751
2741 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2752 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2742 not return any value at all (even though the command would get
2753 not return any value at all (even though the command would get
2743 executed).
2754 executed).
2744 (xsys): Flush stdout right after printing the command to ensure
2755 (xsys): Flush stdout right after printing the command to ensure
2745 proper ordering of commands and command output in the total
2756 proper ordering of commands and command output in the total
2746 output.
2757 output.
2747 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2758 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2748 system/getoutput as defaults. The old ones are kept for
2759 system/getoutput as defaults. The old ones are kept for
2749 compatibility reasons, so no code which uses this library needs
2760 compatibility reasons, so no code which uses this library needs
2750 changing.
2761 changing.
2751
2762
2752 2003-01-27 *** Released version 0.2.14
2763 2003-01-27 *** Released version 0.2.14
2753
2764
2754 2003-01-25 Fernando Perez <fperez@colorado.edu>
2765 2003-01-25 Fernando Perez <fperez@colorado.edu>
2755
2766
2756 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2767 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2757 functions defined in previous edit sessions could not be re-edited
2768 functions defined in previous edit sessions could not be re-edited
2758 (because the temp files were immediately removed). Now temp files
2769 (because the temp files were immediately removed). Now temp files
2759 are removed only at IPython's exit.
2770 are removed only at IPython's exit.
2760 (Magic.magic_run): Improved @run to perform shell-like expansions
2771 (Magic.magic_run): Improved @run to perform shell-like expansions
2761 on its arguments (~users and $VARS). With this, @run becomes more
2772 on its arguments (~users and $VARS). With this, @run becomes more
2762 like a normal command-line.
2773 like a normal command-line.
2763
2774
2764 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2775 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2765 bugs related to embedding and cleaned up that code. A fairly
2776 bugs related to embedding and cleaned up that code. A fairly
2766 important one was the impossibility to access the global namespace
2777 important one was the impossibility to access the global namespace
2767 through the embedded IPython (only local variables were visible).
2778 through the embedded IPython (only local variables were visible).
2768
2779
2769 2003-01-14 Fernando Perez <fperez@colorado.edu>
2780 2003-01-14 Fernando Perez <fperez@colorado.edu>
2770
2781
2771 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2782 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2772 auto-calling to be a bit more conservative. Now it doesn't get
2783 auto-calling to be a bit more conservative. Now it doesn't get
2773 triggered if any of '!=()<>' are in the rest of the input line, to
2784 triggered if any of '!=()<>' are in the rest of the input line, to
2774 allow comparing callables. Thanks to Alex for the heads up.
2785 allow comparing callables. Thanks to Alex for the heads up.
2775
2786
2776 2003-01-07 Fernando Perez <fperez@colorado.edu>
2787 2003-01-07 Fernando Perez <fperez@colorado.edu>
2777
2788
2778 * IPython/genutils.py (page): fixed estimation of the number of
2789 * IPython/genutils.py (page): fixed estimation of the number of
2779 lines in a string to be paged to simply count newlines. This
2790 lines in a string to be paged to simply count newlines. This
2780 prevents over-guessing due to embedded escape sequences. A better
2791 prevents over-guessing due to embedded escape sequences. A better
2781 long-term solution would involve stripping out the control chars
2792 long-term solution would involve stripping out the control chars
2782 for the count, but it's potentially so expensive I just don't
2793 for the count, but it's potentially so expensive I just don't
2783 think it's worth doing.
2794 think it's worth doing.
2784
2795
2785 2002-12-19 *** Released version 0.2.14pre50
2796 2002-12-19 *** Released version 0.2.14pre50
2786
2797
2787 2002-12-19 Fernando Perez <fperez@colorado.edu>
2798 2002-12-19 Fernando Perez <fperez@colorado.edu>
2788
2799
2789 * tools/release (version): Changed release scripts to inform
2800 * tools/release (version): Changed release scripts to inform
2790 Andrea and build a NEWS file with a list of recent changes.
2801 Andrea and build a NEWS file with a list of recent changes.
2791
2802
2792 * IPython/ColorANSI.py (__all__): changed terminal detection
2803 * IPython/ColorANSI.py (__all__): changed terminal detection
2793 code. Seems to work better for xterms without breaking
2804 code. Seems to work better for xterms without breaking
2794 konsole. Will need more testing to determine if WinXP and Mac OSX
2805 konsole. Will need more testing to determine if WinXP and Mac OSX
2795 also work ok.
2806 also work ok.
2796
2807
2797 2002-12-18 *** Released version 0.2.14pre49
2808 2002-12-18 *** Released version 0.2.14pre49
2798
2809
2799 2002-12-18 Fernando Perez <fperez@colorado.edu>
2810 2002-12-18 Fernando Perez <fperez@colorado.edu>
2800
2811
2801 * Docs: added new info about Mac OSX, from Andrea.
2812 * Docs: added new info about Mac OSX, from Andrea.
2802
2813
2803 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2814 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2804 allow direct plotting of python strings whose format is the same
2815 allow direct plotting of python strings whose format is the same
2805 of gnuplot data files.
2816 of gnuplot data files.
2806
2817
2807 2002-12-16 Fernando Perez <fperez@colorado.edu>
2818 2002-12-16 Fernando Perez <fperez@colorado.edu>
2808
2819
2809 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2820 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2810 value of exit question to be acknowledged.
2821 value of exit question to be acknowledged.
2811
2822
2812 2002-12-03 Fernando Perez <fperez@colorado.edu>
2823 2002-12-03 Fernando Perez <fperez@colorado.edu>
2813
2824
2814 * IPython/ipmaker.py: removed generators, which had been added
2825 * IPython/ipmaker.py: removed generators, which had been added
2815 by mistake in an earlier debugging run. This was causing trouble
2826 by mistake in an earlier debugging run. This was causing trouble
2816 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2827 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2817 for pointing this out.
2828 for pointing this out.
2818
2829
2819 2002-11-17 Fernando Perez <fperez@colorado.edu>
2830 2002-11-17 Fernando Perez <fperez@colorado.edu>
2820
2831
2821 * Manual: updated the Gnuplot section.
2832 * Manual: updated the Gnuplot section.
2822
2833
2823 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2834 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2824 a much better split of what goes in Runtime and what goes in
2835 a much better split of what goes in Runtime and what goes in
2825 Interactive.
2836 Interactive.
2826
2837
2827 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2838 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2828 being imported from iplib.
2839 being imported from iplib.
2829
2840
2830 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2841 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2831 for command-passing. Now the global Gnuplot instance is called
2842 for command-passing. Now the global Gnuplot instance is called
2832 'gp' instead of 'g', which was really a far too fragile and
2843 'gp' instead of 'g', which was really a far too fragile and
2833 common name.
2844 common name.
2834
2845
2835 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2846 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2836 bounding boxes generated by Gnuplot for square plots.
2847 bounding boxes generated by Gnuplot for square plots.
2837
2848
2838 * IPython/genutils.py (popkey): new function added. I should
2849 * IPython/genutils.py (popkey): new function added. I should
2839 suggest this on c.l.py as a dict method, it seems useful.
2850 suggest this on c.l.py as a dict method, it seems useful.
2840
2851
2841 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2852 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2842 to transparently handle PostScript generation. MUCH better than
2853 to transparently handle PostScript generation. MUCH better than
2843 the previous plot_eps/replot_eps (which I removed now). The code
2854 the previous plot_eps/replot_eps (which I removed now). The code
2844 is also fairly clean and well documented now (including
2855 is also fairly clean and well documented now (including
2845 docstrings).
2856 docstrings).
2846
2857
2847 2002-11-13 Fernando Perez <fperez@colorado.edu>
2858 2002-11-13 Fernando Perez <fperez@colorado.edu>
2848
2859
2849 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2860 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2850 (inconsistent with options).
2861 (inconsistent with options).
2851
2862
2852 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2863 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2853 manually disabled, I don't know why. Fixed it.
2864 manually disabled, I don't know why. Fixed it.
2854 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2865 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2855 eps output.
2866 eps output.
2856
2867
2857 2002-11-12 Fernando Perez <fperez@colorado.edu>
2868 2002-11-12 Fernando Perez <fperez@colorado.edu>
2858
2869
2859 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2870 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2860 don't propagate up to caller. Fixes crash reported by François
2871 don't propagate up to caller. Fixes crash reported by François
2861 Pinard.
2872 Pinard.
2862
2873
2863 2002-11-09 Fernando Perez <fperez@colorado.edu>
2874 2002-11-09 Fernando Perez <fperez@colorado.edu>
2864
2875
2865 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2876 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2866 history file for new users.
2877 history file for new users.
2867 (make_IPython): fixed bug where initial install would leave the
2878 (make_IPython): fixed bug where initial install would leave the
2868 user running in the .ipython dir.
2879 user running in the .ipython dir.
2869 (make_IPython): fixed bug where config dir .ipython would be
2880 (make_IPython): fixed bug where config dir .ipython would be
2870 created regardless of the given -ipythondir option. Thanks to Cory
2881 created regardless of the given -ipythondir option. Thanks to Cory
2871 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2882 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2872
2883
2873 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2884 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2874 type confirmations. Will need to use it in all of IPython's code
2885 type confirmations. Will need to use it in all of IPython's code
2875 consistently.
2886 consistently.
2876
2887
2877 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2888 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2878 context to print 31 lines instead of the default 5. This will make
2889 context to print 31 lines instead of the default 5. This will make
2879 the crash reports extremely detailed in case the problem is in
2890 the crash reports extremely detailed in case the problem is in
2880 libraries I don't have access to.
2891 libraries I don't have access to.
2881
2892
2882 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2893 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2883 line of defense' code to still crash, but giving users fair
2894 line of defense' code to still crash, but giving users fair
2884 warning. I don't want internal errors to go unreported: if there's
2895 warning. I don't want internal errors to go unreported: if there's
2885 an internal problem, IPython should crash and generate a full
2896 an internal problem, IPython should crash and generate a full
2886 report.
2897 report.
2887
2898
2888 2002-11-08 Fernando Perez <fperez@colorado.edu>
2899 2002-11-08 Fernando Perez <fperez@colorado.edu>
2889
2900
2890 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2901 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2891 otherwise uncaught exceptions which can appear if people set
2902 otherwise uncaught exceptions which can appear if people set
2892 sys.stdout to something badly broken. Thanks to a crash report
2903 sys.stdout to something badly broken. Thanks to a crash report
2893 from henni-AT-mail.brainbot.com.
2904 from henni-AT-mail.brainbot.com.
2894
2905
2895 2002-11-04 Fernando Perez <fperez@colorado.edu>
2906 2002-11-04 Fernando Perez <fperez@colorado.edu>
2896
2907
2897 * IPython/iplib.py (InteractiveShell.interact): added
2908 * IPython/iplib.py (InteractiveShell.interact): added
2898 __IPYTHON__active to the builtins. It's a flag which goes on when
2909 __IPYTHON__active to the builtins. It's a flag which goes on when
2899 the interaction starts and goes off again when it stops. This
2910 the interaction starts and goes off again when it stops. This
2900 allows embedding code to detect being inside IPython. Before this
2911 allows embedding code to detect being inside IPython. Before this
2901 was done via __IPYTHON__, but that only shows that an IPython
2912 was done via __IPYTHON__, but that only shows that an IPython
2902 instance has been created.
2913 instance has been created.
2903
2914
2904 * IPython/Magic.py (Magic.magic_env): I realized that in a
2915 * IPython/Magic.py (Magic.magic_env): I realized that in a
2905 UserDict, instance.data holds the data as a normal dict. So I
2916 UserDict, instance.data holds the data as a normal dict. So I
2906 modified @env to return os.environ.data instead of rebuilding a
2917 modified @env to return os.environ.data instead of rebuilding a
2907 dict by hand.
2918 dict by hand.
2908
2919
2909 2002-11-02 Fernando Perez <fperez@colorado.edu>
2920 2002-11-02 Fernando Perez <fperez@colorado.edu>
2910
2921
2911 * IPython/genutils.py (warn): changed so that level 1 prints no
2922 * IPython/genutils.py (warn): changed so that level 1 prints no
2912 header. Level 2 is now the default (with 'WARNING' header, as
2923 header. Level 2 is now the default (with 'WARNING' header, as
2913 before). I think I tracked all places where changes were needed in
2924 before). I think I tracked all places where changes were needed in
2914 IPython, but outside code using the old level numbering may have
2925 IPython, but outside code using the old level numbering may have
2915 broken.
2926 broken.
2916
2927
2917 * IPython/iplib.py (InteractiveShell.runcode): added this to
2928 * IPython/iplib.py (InteractiveShell.runcode): added this to
2918 handle the tracebacks in SystemExit traps correctly. The previous
2929 handle the tracebacks in SystemExit traps correctly. The previous
2919 code (through interact) was printing more of the stack than
2930 code (through interact) was printing more of the stack than
2920 necessary, showing IPython internal code to the user.
2931 necessary, showing IPython internal code to the user.
2921
2932
2922 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2933 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2923 default. Now that the default at the confirmation prompt is yes,
2934 default. Now that the default at the confirmation prompt is yes,
2924 it's not so intrusive. François' argument that ipython sessions
2935 it's not so intrusive. François' argument that ipython sessions
2925 tend to be complex enough not to lose them from an accidental C-d,
2936 tend to be complex enough not to lose them from an accidental C-d,
2926 is a valid one.
2937 is a valid one.
2927
2938
2928 * IPython/iplib.py (InteractiveShell.interact): added a
2939 * IPython/iplib.py (InteractiveShell.interact): added a
2929 showtraceback() call to the SystemExit trap, and modified the exit
2940 showtraceback() call to the SystemExit trap, and modified the exit
2930 confirmation to have yes as the default.
2941 confirmation to have yes as the default.
2931
2942
2932 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2943 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2933 this file. It's been gone from the code for a long time, this was
2944 this file. It's been gone from the code for a long time, this was
2934 simply leftover junk.
2945 simply leftover junk.
2935
2946
2936 2002-11-01 Fernando Perez <fperez@colorado.edu>
2947 2002-11-01 Fernando Perez <fperez@colorado.edu>
2937
2948
2938 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2949 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2939 added. If set, IPython now traps EOF and asks for
2950 added. If set, IPython now traps EOF and asks for
2940 confirmation. After a request by François Pinard.
2951 confirmation. After a request by François Pinard.
2941
2952
2942 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2953 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2943 of @abort, and with a new (better) mechanism for handling the
2954 of @abort, and with a new (better) mechanism for handling the
2944 exceptions.
2955 exceptions.
2945
2956
2946 2002-10-27 Fernando Perez <fperez@colorado.edu>
2957 2002-10-27 Fernando Perez <fperez@colorado.edu>
2947
2958
2948 * IPython/usage.py (__doc__): updated the --help information and
2959 * IPython/usage.py (__doc__): updated the --help information and
2949 the ipythonrc file to indicate that -log generates
2960 the ipythonrc file to indicate that -log generates
2950 ./ipython.log. Also fixed the corresponding info in @logstart.
2961 ./ipython.log. Also fixed the corresponding info in @logstart.
2951 This and several other fixes in the manuals thanks to reports by
2962 This and several other fixes in the manuals thanks to reports by
2952 François Pinard <pinard-AT-iro.umontreal.ca>.
2963 François Pinard <pinard-AT-iro.umontreal.ca>.
2953
2964
2954 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2965 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2955 refer to @logstart (instead of @log, which doesn't exist).
2966 refer to @logstart (instead of @log, which doesn't exist).
2956
2967
2957 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2968 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2958 AttributeError crash. Thanks to Christopher Armstrong
2969 AttributeError crash. Thanks to Christopher Armstrong
2959 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2970 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2960 introduced recently (in 0.2.14pre37) with the fix to the eval
2971 introduced recently (in 0.2.14pre37) with the fix to the eval
2961 problem mentioned below.
2972 problem mentioned below.
2962
2973
2963 2002-10-17 Fernando Perez <fperez@colorado.edu>
2974 2002-10-17 Fernando Perez <fperez@colorado.edu>
2964
2975
2965 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2976 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2966 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2977 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2967
2978
2968 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2979 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2969 this function to fix a problem reported by Alex Schmolck. He saw
2980 this function to fix a problem reported by Alex Schmolck. He saw
2970 it with list comprehensions and generators, which were getting
2981 it with list comprehensions and generators, which were getting
2971 called twice. The real problem was an 'eval' call in testing for
2982 called twice. The real problem was an 'eval' call in testing for
2972 automagic which was evaluating the input line silently.
2983 automagic which was evaluating the input line silently.
2973
2984
2974 This is a potentially very nasty bug, if the input has side
2985 This is a potentially very nasty bug, if the input has side
2975 effects which must not be repeated. The code is much cleaner now,
2986 effects which must not be repeated. The code is much cleaner now,
2976 without any blanket 'except' left and with a regexp test for
2987 without any blanket 'except' left and with a regexp test for
2977 actual function names.
2988 actual function names.
2978
2989
2979 But an eval remains, which I'm not fully comfortable with. I just
2990 But an eval remains, which I'm not fully comfortable with. I just
2980 don't know how to find out if an expression could be a callable in
2991 don't know how to find out if an expression could be a callable in
2981 the user's namespace without doing an eval on the string. However
2992 the user's namespace without doing an eval on the string. However
2982 that string is now much more strictly checked so that no code
2993 that string is now much more strictly checked so that no code
2983 slips by, so the eval should only happen for things that can
2994 slips by, so the eval should only happen for things that can
2984 really be only function/method names.
2995 really be only function/method names.
2985
2996
2986 2002-10-15 Fernando Perez <fperez@colorado.edu>
2997 2002-10-15 Fernando Perez <fperez@colorado.edu>
2987
2998
2988 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2999 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2989 OSX information to main manual, removed README_Mac_OSX file from
3000 OSX information to main manual, removed README_Mac_OSX file from
2990 distribution. Also updated credits for recent additions.
3001 distribution. Also updated credits for recent additions.
2991
3002
2992 2002-10-10 Fernando Perez <fperez@colorado.edu>
3003 2002-10-10 Fernando Perez <fperez@colorado.edu>
2993
3004
2994 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3005 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2995 terminal-related issues. Many thanks to Andrea Riciputi
3006 terminal-related issues. Many thanks to Andrea Riciputi
2996 <andrea.riciputi-AT-libero.it> for writing it.
3007 <andrea.riciputi-AT-libero.it> for writing it.
2997
3008
2998 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3009 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2999 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3010 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3000
3011
3001 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3012 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3002 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3013 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3003 <syver-en-AT-online.no> who both submitted patches for this problem.
3014 <syver-en-AT-online.no> who both submitted patches for this problem.
3004
3015
3005 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3016 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3006 global embedding to make sure that things don't overwrite user
3017 global embedding to make sure that things don't overwrite user
3007 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3018 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3008
3019
3009 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3020 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3010 compatibility. Thanks to Hayden Callow
3021 compatibility. Thanks to Hayden Callow
3011 <h.callow-AT-elec.canterbury.ac.nz>
3022 <h.callow-AT-elec.canterbury.ac.nz>
3012
3023
3013 2002-10-04 Fernando Perez <fperez@colorado.edu>
3024 2002-10-04 Fernando Perez <fperez@colorado.edu>
3014
3025
3015 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3026 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3016 Gnuplot.File objects.
3027 Gnuplot.File objects.
3017
3028
3018 2002-07-23 Fernando Perez <fperez@colorado.edu>
3029 2002-07-23 Fernando Perez <fperez@colorado.edu>
3019
3030
3020 * IPython/genutils.py (timing): Added timings() and timing() for
3031 * IPython/genutils.py (timing): Added timings() and timing() for
3021 quick access to the most commonly needed data, the execution
3032 quick access to the most commonly needed data, the execution
3022 times. Old timing() renamed to timings_out().
3033 times. Old timing() renamed to timings_out().
3023
3034
3024 2002-07-18 Fernando Perez <fperez@colorado.edu>
3035 2002-07-18 Fernando Perez <fperez@colorado.edu>
3025
3036
3026 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3037 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3027 bug with nested instances disrupting the parent's tab completion.
3038 bug with nested instances disrupting the parent's tab completion.
3028
3039
3029 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3040 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3030 all_completions code to begin the emacs integration.
3041 all_completions code to begin the emacs integration.
3031
3042
3032 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3043 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3033 argument to allow titling individual arrays when plotting.
3044 argument to allow titling individual arrays when plotting.
3034
3045
3035 2002-07-15 Fernando Perez <fperez@colorado.edu>
3046 2002-07-15 Fernando Perez <fperez@colorado.edu>
3036
3047
3037 * setup.py (make_shortcut): changed to retrieve the value of
3048 * setup.py (make_shortcut): changed to retrieve the value of
3038 'Program Files' directory from the registry (this value changes in
3049 'Program Files' directory from the registry (this value changes in
3039 non-english versions of Windows). Thanks to Thomas Fanslau
3050 non-english versions of Windows). Thanks to Thomas Fanslau
3040 <tfanslau-AT-gmx.de> for the report.
3051 <tfanslau-AT-gmx.de> for the report.
3041
3052
3042 2002-07-10 Fernando Perez <fperez@colorado.edu>
3053 2002-07-10 Fernando Perez <fperez@colorado.edu>
3043
3054
3044 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3055 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3045 a bug in pdb, which crashes if a line with only whitespace is
3056 a bug in pdb, which crashes if a line with only whitespace is
3046 entered. Bug report submitted to sourceforge.
3057 entered. Bug report submitted to sourceforge.
3047
3058
3048 2002-07-09 Fernando Perez <fperez@colorado.edu>
3059 2002-07-09 Fernando Perez <fperez@colorado.edu>
3049
3060
3050 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3061 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3051 reporting exceptions (it's a bug in inspect.py, I just set a
3062 reporting exceptions (it's a bug in inspect.py, I just set a
3052 workaround).
3063 workaround).
3053
3064
3054 2002-07-08 Fernando Perez <fperez@colorado.edu>
3065 2002-07-08 Fernando Perez <fperez@colorado.edu>
3055
3066
3056 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3067 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3057 __IPYTHON__ in __builtins__ to show up in user_ns.
3068 __IPYTHON__ in __builtins__ to show up in user_ns.
3058
3069
3059 2002-07-03 Fernando Perez <fperez@colorado.edu>
3070 2002-07-03 Fernando Perez <fperez@colorado.edu>
3060
3071
3061 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3072 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3062 name from @gp_set_instance to @gp_set_default.
3073 name from @gp_set_instance to @gp_set_default.
3063
3074
3064 * IPython/ipmaker.py (make_IPython): default editor value set to
3075 * IPython/ipmaker.py (make_IPython): default editor value set to
3065 '0' (a string), to match the rc file. Otherwise will crash when
3076 '0' (a string), to match the rc file. Otherwise will crash when
3066 .strip() is called on it.
3077 .strip() is called on it.
3067
3078
3068
3079
3069 2002-06-28 Fernando Perez <fperez@colorado.edu>
3080 2002-06-28 Fernando Perez <fperez@colorado.edu>
3070
3081
3071 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3082 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3072 of files in current directory when a file is executed via
3083 of files in current directory when a file is executed via
3073 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3084 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3074
3085
3075 * setup.py (manfiles): fix for rpm builds, submitted by RA
3086 * setup.py (manfiles): fix for rpm builds, submitted by RA
3076 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3087 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3077
3088
3078 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3089 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3079 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3090 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3080 string!). A. Schmolck caught this one.
3091 string!). A. Schmolck caught this one.
3081
3092
3082 2002-06-27 Fernando Perez <fperez@colorado.edu>
3093 2002-06-27 Fernando Perez <fperez@colorado.edu>
3083
3094
3084 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3095 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3085 defined files at the cmd line. __name__ wasn't being set to
3096 defined files at the cmd line. __name__ wasn't being set to
3086 __main__.
3097 __main__.
3087
3098
3088 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3099 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3089 regular lists and tuples besides Numeric arrays.
3100 regular lists and tuples besides Numeric arrays.
3090
3101
3091 * IPython/Prompts.py (CachedOutput.__call__): Added output
3102 * IPython/Prompts.py (CachedOutput.__call__): Added output
3092 supression for input ending with ';'. Similar to Mathematica and
3103 supression for input ending with ';'. Similar to Mathematica and
3093 Matlab. The _* vars and Out[] list are still updated, just like
3104 Matlab. The _* vars and Out[] list are still updated, just like
3094 Mathematica behaves.
3105 Mathematica behaves.
3095
3106
3096 2002-06-25 Fernando Perez <fperez@colorado.edu>
3107 2002-06-25 Fernando Perez <fperez@colorado.edu>
3097
3108
3098 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3109 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3099 .ini extensions for profiels under Windows.
3110 .ini extensions for profiels under Windows.
3100
3111
3101 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3112 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3102 string form. Fix contributed by Alexander Schmolck
3113 string form. Fix contributed by Alexander Schmolck
3103 <a.schmolck-AT-gmx.net>
3114 <a.schmolck-AT-gmx.net>
3104
3115
3105 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3116 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3106 pre-configured Gnuplot instance.
3117 pre-configured Gnuplot instance.
3107
3118
3108 2002-06-21 Fernando Perez <fperez@colorado.edu>
3119 2002-06-21 Fernando Perez <fperez@colorado.edu>
3109
3120
3110 * IPython/numutils.py (exp_safe): new function, works around the
3121 * IPython/numutils.py (exp_safe): new function, works around the
3111 underflow problems in Numeric.
3122 underflow problems in Numeric.
3112 (log2): New fn. Safe log in base 2: returns exact integer answer
3123 (log2): New fn. Safe log in base 2: returns exact integer answer
3113 for exact integer powers of 2.
3124 for exact integer powers of 2.
3114
3125
3115 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3126 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3116 properly.
3127 properly.
3117
3128
3118 2002-06-20 Fernando Perez <fperez@colorado.edu>
3129 2002-06-20 Fernando Perez <fperez@colorado.edu>
3119
3130
3120 * IPython/genutils.py (timing): new function like
3131 * IPython/genutils.py (timing): new function like
3121 Mathematica's. Similar to time_test, but returns more info.
3132 Mathematica's. Similar to time_test, but returns more info.
3122
3133
3123 2002-06-18 Fernando Perez <fperez@colorado.edu>
3134 2002-06-18 Fernando Perez <fperez@colorado.edu>
3124
3135
3125 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3136 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3126 according to Mike Heeter's suggestions.
3137 according to Mike Heeter's suggestions.
3127
3138
3128 2002-06-16 Fernando Perez <fperez@colorado.edu>
3139 2002-06-16 Fernando Perez <fperez@colorado.edu>
3129
3140
3130 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3141 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3131 system. GnuplotMagic is gone as a user-directory option. New files
3142 system. GnuplotMagic is gone as a user-directory option. New files
3132 make it easier to use all the gnuplot stuff both from external
3143 make it easier to use all the gnuplot stuff both from external
3133 programs as well as from IPython. Had to rewrite part of
3144 programs as well as from IPython. Had to rewrite part of
3134 hardcopy() b/c of a strange bug: often the ps files simply don't
3145 hardcopy() b/c of a strange bug: often the ps files simply don't
3135 get created, and require a repeat of the command (often several
3146 get created, and require a repeat of the command (often several
3136 times).
3147 times).
3137
3148
3138 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3149 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3139 resolve output channel at call time, so that if sys.stderr has
3150 resolve output channel at call time, so that if sys.stderr has
3140 been redirected by user this gets honored.
3151 been redirected by user this gets honored.
3141
3152
3142 2002-06-13 Fernando Perez <fperez@colorado.edu>
3153 2002-06-13 Fernando Perez <fperez@colorado.edu>
3143
3154
3144 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3155 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3145 IPShell. Kept a copy with the old names to avoid breaking people's
3156 IPShell. Kept a copy with the old names to avoid breaking people's
3146 embedded code.
3157 embedded code.
3147
3158
3148 * IPython/ipython: simplified it to the bare minimum after
3159 * IPython/ipython: simplified it to the bare minimum after
3149 Holger's suggestions. Added info about how to use it in
3160 Holger's suggestions. Added info about how to use it in
3150 PYTHONSTARTUP.
3161 PYTHONSTARTUP.
3151
3162
3152 * IPython/Shell.py (IPythonShell): changed the options passing
3163 * IPython/Shell.py (IPythonShell): changed the options passing
3153 from a string with funky %s replacements to a straight list. Maybe
3164 from a string with funky %s replacements to a straight list. Maybe
3154 a bit more typing, but it follows sys.argv conventions, so there's
3165 a bit more typing, but it follows sys.argv conventions, so there's
3155 less special-casing to remember.
3166 less special-casing to remember.
3156
3167
3157 2002-06-12 Fernando Perez <fperez@colorado.edu>
3168 2002-06-12 Fernando Perez <fperez@colorado.edu>
3158
3169
3159 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3170 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3160 command. Thanks to a suggestion by Mike Heeter.
3171 command. Thanks to a suggestion by Mike Heeter.
3161 (Magic.magic_pfile): added behavior to look at filenames if given
3172 (Magic.magic_pfile): added behavior to look at filenames if given
3162 arg is not a defined object.
3173 arg is not a defined object.
3163 (Magic.magic_save): New @save function to save code snippets. Also
3174 (Magic.magic_save): New @save function to save code snippets. Also
3164 a Mike Heeter idea.
3175 a Mike Heeter idea.
3165
3176
3166 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3177 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3167 plot() and replot(). Much more convenient now, especially for
3178 plot() and replot(). Much more convenient now, especially for
3168 interactive use.
3179 interactive use.
3169
3180
3170 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3181 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3171 filenames.
3182 filenames.
3172
3183
3173 2002-06-02 Fernando Perez <fperez@colorado.edu>
3184 2002-06-02 Fernando Perez <fperez@colorado.edu>
3174
3185
3175 * IPython/Struct.py (Struct.__init__): modified to admit
3186 * IPython/Struct.py (Struct.__init__): modified to admit
3176 initialization via another struct.
3187 initialization via another struct.
3177
3188
3178 * IPython/genutils.py (SystemExec.__init__): New stateful
3189 * IPython/genutils.py (SystemExec.__init__): New stateful
3179 interface to xsys and bq. Useful for writing system scripts.
3190 interface to xsys and bq. Useful for writing system scripts.
3180
3191
3181 2002-05-30 Fernando Perez <fperez@colorado.edu>
3192 2002-05-30 Fernando Perez <fperez@colorado.edu>
3182
3193
3183 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3194 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3184 documents. This will make the user download smaller (it's getting
3195 documents. This will make the user download smaller (it's getting
3185 too big).
3196 too big).
3186
3197
3187 2002-05-29 Fernando Perez <fperez@colorado.edu>
3198 2002-05-29 Fernando Perez <fperez@colorado.edu>
3188
3199
3189 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3200 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3190 fix problems with shelve and pickle. Seems to work, but I don't
3201 fix problems with shelve and pickle. Seems to work, but I don't
3191 know if corner cases break it. Thanks to Mike Heeter
3202 know if corner cases break it. Thanks to Mike Heeter
3192 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3203 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3193
3204
3194 2002-05-24 Fernando Perez <fperez@colorado.edu>
3205 2002-05-24 Fernando Perez <fperez@colorado.edu>
3195
3206
3196 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3207 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3197 macros having broken.
3208 macros having broken.
3198
3209
3199 2002-05-21 Fernando Perez <fperez@colorado.edu>
3210 2002-05-21 Fernando Perez <fperez@colorado.edu>
3200
3211
3201 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3212 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3202 introduced logging bug: all history before logging started was
3213 introduced logging bug: all history before logging started was
3203 being written one character per line! This came from the redesign
3214 being written one character per line! This came from the redesign
3204 of the input history as a special list which slices to strings,
3215 of the input history as a special list which slices to strings,
3205 not to lists.
3216 not to lists.
3206
3217
3207 2002-05-20 Fernando Perez <fperez@colorado.edu>
3218 2002-05-20 Fernando Perez <fperez@colorado.edu>
3208
3219
3209 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3220 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3210 be an attribute of all classes in this module. The design of these
3221 be an attribute of all classes in this module. The design of these
3211 classes needs some serious overhauling.
3222 classes needs some serious overhauling.
3212
3223
3213 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3224 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3214 which was ignoring '_' in option names.
3225 which was ignoring '_' in option names.
3215
3226
3216 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3227 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3217 'Verbose_novars' to 'Context' and made it the new default. It's a
3228 'Verbose_novars' to 'Context' and made it the new default. It's a
3218 bit more readable and also safer than verbose.
3229 bit more readable and also safer than verbose.
3219
3230
3220 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3231 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3221 triple-quoted strings.
3232 triple-quoted strings.
3222
3233
3223 * IPython/OInspect.py (__all__): new module exposing the object
3234 * IPython/OInspect.py (__all__): new module exposing the object
3224 introspection facilities. Now the corresponding magics are dummy
3235 introspection facilities. Now the corresponding magics are dummy
3225 wrappers around this. Having this module will make it much easier
3236 wrappers around this. Having this module will make it much easier
3226 to put these functions into our modified pdb.
3237 to put these functions into our modified pdb.
3227 This new object inspector system uses the new colorizing module,
3238 This new object inspector system uses the new colorizing module,
3228 so source code and other things are nicely syntax highlighted.
3239 so source code and other things are nicely syntax highlighted.
3229
3240
3230 2002-05-18 Fernando Perez <fperez@colorado.edu>
3241 2002-05-18 Fernando Perez <fperez@colorado.edu>
3231
3242
3232 * IPython/ColorANSI.py: Split the coloring tools into a separate
3243 * IPython/ColorANSI.py: Split the coloring tools into a separate
3233 module so I can use them in other code easier (they were part of
3244 module so I can use them in other code easier (they were part of
3234 ultraTB).
3245 ultraTB).
3235
3246
3236 2002-05-17 Fernando Perez <fperez@colorado.edu>
3247 2002-05-17 Fernando Perez <fperez@colorado.edu>
3237
3248
3238 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3249 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3239 fixed it to set the global 'g' also to the called instance, as
3250 fixed it to set the global 'g' also to the called instance, as
3240 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3251 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3241 user's 'g' variables).
3252 user's 'g' variables).
3242
3253
3243 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3254 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3244 global variables (aliases to _ih,_oh) so that users which expect
3255 global variables (aliases to _ih,_oh) so that users which expect
3245 In[5] or Out[7] to work aren't unpleasantly surprised.
3256 In[5] or Out[7] to work aren't unpleasantly surprised.
3246 (InputList.__getslice__): new class to allow executing slices of
3257 (InputList.__getslice__): new class to allow executing slices of
3247 input history directly. Very simple class, complements the use of
3258 input history directly. Very simple class, complements the use of
3248 macros.
3259 macros.
3249
3260
3250 2002-05-16 Fernando Perez <fperez@colorado.edu>
3261 2002-05-16 Fernando Perez <fperez@colorado.edu>
3251
3262
3252 * setup.py (docdirbase): make doc directory be just doc/IPython
3263 * setup.py (docdirbase): make doc directory be just doc/IPython
3253 without version numbers, it will reduce clutter for users.
3264 without version numbers, it will reduce clutter for users.
3254
3265
3255 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3266 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3256 execfile call to prevent possible memory leak. See for details:
3267 execfile call to prevent possible memory leak. See for details:
3257 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3268 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3258
3269
3259 2002-05-15 Fernando Perez <fperez@colorado.edu>
3270 2002-05-15 Fernando Perez <fperez@colorado.edu>
3260
3271
3261 * IPython/Magic.py (Magic.magic_psource): made the object
3272 * IPython/Magic.py (Magic.magic_psource): made the object
3262 introspection names be more standard: pdoc, pdef, pfile and
3273 introspection names be more standard: pdoc, pdef, pfile and
3263 psource. They all print/page their output, and it makes
3274 psource. They all print/page their output, and it makes
3264 remembering them easier. Kept old names for compatibility as
3275 remembering them easier. Kept old names for compatibility as
3265 aliases.
3276 aliases.
3266
3277
3267 2002-05-14 Fernando Perez <fperez@colorado.edu>
3278 2002-05-14 Fernando Perez <fperez@colorado.edu>
3268
3279
3269 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3280 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3270 what the mouse problem was. The trick is to use gnuplot with temp
3281 what the mouse problem was. The trick is to use gnuplot with temp
3271 files and NOT with pipes (for data communication), because having
3282 files and NOT with pipes (for data communication), because having
3272 both pipes and the mouse on is bad news.
3283 both pipes and the mouse on is bad news.
3273
3284
3274 2002-05-13 Fernando Perez <fperez@colorado.edu>
3285 2002-05-13 Fernando Perez <fperez@colorado.edu>
3275
3286
3276 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3287 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3277 bug. Information would be reported about builtins even when
3288 bug. Information would be reported about builtins even when
3278 user-defined functions overrode them.
3289 user-defined functions overrode them.
3279
3290
3280 2002-05-11 Fernando Perez <fperez@colorado.edu>
3291 2002-05-11 Fernando Perez <fperez@colorado.edu>
3281
3292
3282 * IPython/__init__.py (__all__): removed FlexCompleter from
3293 * IPython/__init__.py (__all__): removed FlexCompleter from
3283 __all__ so that things don't fail in platforms without readline.
3294 __all__ so that things don't fail in platforms without readline.
3284
3295
3285 2002-05-10 Fernando Perez <fperez@colorado.edu>
3296 2002-05-10 Fernando Perez <fperez@colorado.edu>
3286
3297
3287 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3298 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3288 it requires Numeric, effectively making Numeric a dependency for
3299 it requires Numeric, effectively making Numeric a dependency for
3289 IPython.
3300 IPython.
3290
3301
3291 * Released 0.2.13
3302 * Released 0.2.13
3292
3303
3293 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3304 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3294 profiler interface. Now all the major options from the profiler
3305 profiler interface. Now all the major options from the profiler
3295 module are directly supported in IPython, both for single
3306 module are directly supported in IPython, both for single
3296 expressions (@prun) and for full programs (@run -p).
3307 expressions (@prun) and for full programs (@run -p).
3297
3308
3298 2002-05-09 Fernando Perez <fperez@colorado.edu>
3309 2002-05-09 Fernando Perez <fperez@colorado.edu>
3299
3310
3300 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3311 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3301 magic properly formatted for screen.
3312 magic properly formatted for screen.
3302
3313
3303 * setup.py (make_shortcut): Changed things to put pdf version in
3314 * setup.py (make_shortcut): Changed things to put pdf version in
3304 doc/ instead of doc/manual (had to change lyxport a bit).
3315 doc/ instead of doc/manual (had to change lyxport a bit).
3305
3316
3306 * IPython/Magic.py (Profile.string_stats): made profile runs go
3317 * IPython/Magic.py (Profile.string_stats): made profile runs go
3307 through pager (they are long and a pager allows searching, saving,
3318 through pager (they are long and a pager allows searching, saving,
3308 etc.)
3319 etc.)
3309
3320
3310 2002-05-08 Fernando Perez <fperez@colorado.edu>
3321 2002-05-08 Fernando Perez <fperez@colorado.edu>
3311
3322
3312 * Released 0.2.12
3323 * Released 0.2.12
3313
3324
3314 2002-05-06 Fernando Perez <fperez@colorado.edu>
3325 2002-05-06 Fernando Perez <fperez@colorado.edu>
3315
3326
3316 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3327 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3317 introduced); 'hist n1 n2' was broken.
3328 introduced); 'hist n1 n2' was broken.
3318 (Magic.magic_pdb): added optional on/off arguments to @pdb
3329 (Magic.magic_pdb): added optional on/off arguments to @pdb
3319 (Magic.magic_run): added option -i to @run, which executes code in
3330 (Magic.magic_run): added option -i to @run, which executes code in
3320 the IPython namespace instead of a clean one. Also added @irun as
3331 the IPython namespace instead of a clean one. Also added @irun as
3321 an alias to @run -i.
3332 an alias to @run -i.
3322
3333
3323 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3334 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3324 fixed (it didn't really do anything, the namespaces were wrong).
3335 fixed (it didn't really do anything, the namespaces were wrong).
3325
3336
3326 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3337 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3327
3338
3328 * IPython/__init__.py (__all__): Fixed package namespace, now
3339 * IPython/__init__.py (__all__): Fixed package namespace, now
3329 'import IPython' does give access to IPython.<all> as
3340 'import IPython' does give access to IPython.<all> as
3330 expected. Also renamed __release__ to Release.
3341 expected. Also renamed __release__ to Release.
3331
3342
3332 * IPython/Debugger.py (__license__): created new Pdb class which
3343 * IPython/Debugger.py (__license__): created new Pdb class which
3333 functions like a drop-in for the normal pdb.Pdb but does NOT
3344 functions like a drop-in for the normal pdb.Pdb but does NOT
3334 import readline by default. This way it doesn't muck up IPython's
3345 import readline by default. This way it doesn't muck up IPython's
3335 readline handling, and now tab-completion finally works in the
3346 readline handling, and now tab-completion finally works in the
3336 debugger -- sort of. It completes things globally visible, but the
3347 debugger -- sort of. It completes things globally visible, but the
3337 completer doesn't track the stack as pdb walks it. That's a bit
3348 completer doesn't track the stack as pdb walks it. That's a bit
3338 tricky, and I'll have to implement it later.
3349 tricky, and I'll have to implement it later.
3339
3350
3340 2002-05-05 Fernando Perez <fperez@colorado.edu>
3351 2002-05-05 Fernando Perez <fperez@colorado.edu>
3341
3352
3342 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3353 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3343 magic docstrings when printed via ? (explicit \'s were being
3354 magic docstrings when printed via ? (explicit \'s were being
3344 printed).
3355 printed).
3345
3356
3346 * IPython/ipmaker.py (make_IPython): fixed namespace
3357 * IPython/ipmaker.py (make_IPython): fixed namespace
3347 identification bug. Now variables loaded via logs or command-line
3358 identification bug. Now variables loaded via logs or command-line
3348 files are recognized in the interactive namespace by @who.
3359 files are recognized in the interactive namespace by @who.
3349
3360
3350 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3361 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3351 log replay system stemming from the string form of Structs.
3362 log replay system stemming from the string form of Structs.
3352
3363
3353 * IPython/Magic.py (Macro.__init__): improved macros to properly
3364 * IPython/Magic.py (Macro.__init__): improved macros to properly
3354 handle magic commands in them.
3365 handle magic commands in them.
3355 (Magic.magic_logstart): usernames are now expanded so 'logstart
3366 (Magic.magic_logstart): usernames are now expanded so 'logstart
3356 ~/mylog' now works.
3367 ~/mylog' now works.
3357
3368
3358 * IPython/iplib.py (complete): fixed bug where paths starting with
3369 * IPython/iplib.py (complete): fixed bug where paths starting with
3359 '/' would be completed as magic names.
3370 '/' would be completed as magic names.
3360
3371
3361 2002-05-04 Fernando Perez <fperez@colorado.edu>
3372 2002-05-04 Fernando Perez <fperez@colorado.edu>
3362
3373
3363 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3374 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3364 allow running full programs under the profiler's control.
3375 allow running full programs under the profiler's control.
3365
3376
3366 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3377 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3367 mode to report exceptions verbosely but without formatting
3378 mode to report exceptions verbosely but without formatting
3368 variables. This addresses the issue of ipython 'freezing' (it's
3379 variables. This addresses the issue of ipython 'freezing' (it's
3369 not frozen, but caught in an expensive formatting loop) when huge
3380 not frozen, but caught in an expensive formatting loop) when huge
3370 variables are in the context of an exception.
3381 variables are in the context of an exception.
3371 (VerboseTB.text): Added '--->' markers at line where exception was
3382 (VerboseTB.text): Added '--->' markers at line where exception was
3372 triggered. Much clearer to read, especially in NoColor modes.
3383 triggered. Much clearer to read, especially in NoColor modes.
3373
3384
3374 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3385 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3375 implemented in reverse when changing to the new parse_options().
3386 implemented in reverse when changing to the new parse_options().
3376
3387
3377 2002-05-03 Fernando Perez <fperez@colorado.edu>
3388 2002-05-03 Fernando Perez <fperez@colorado.edu>
3378
3389
3379 * IPython/Magic.py (Magic.parse_options): new function so that
3390 * IPython/Magic.py (Magic.parse_options): new function so that
3380 magics can parse options easier.
3391 magics can parse options easier.
3381 (Magic.magic_prun): new function similar to profile.run(),
3392 (Magic.magic_prun): new function similar to profile.run(),
3382 suggested by Chris Hart.
3393 suggested by Chris Hart.
3383 (Magic.magic_cd): fixed behavior so that it only changes if
3394 (Magic.magic_cd): fixed behavior so that it only changes if
3384 directory actually is in history.
3395 directory actually is in history.
3385
3396
3386 * IPython/usage.py (__doc__): added information about potential
3397 * IPython/usage.py (__doc__): added information about potential
3387 slowness of Verbose exception mode when there are huge data
3398 slowness of Verbose exception mode when there are huge data
3388 structures to be formatted (thanks to Archie Paulson).
3399 structures to be formatted (thanks to Archie Paulson).
3389
3400
3390 * IPython/ipmaker.py (make_IPython): Changed default logging
3401 * IPython/ipmaker.py (make_IPython): Changed default logging
3391 (when simply called with -log) to use curr_dir/ipython.log in
3402 (when simply called with -log) to use curr_dir/ipython.log in
3392 rotate mode. Fixed crash which was occuring with -log before
3403 rotate mode. Fixed crash which was occuring with -log before
3393 (thanks to Jim Boyle).
3404 (thanks to Jim Boyle).
3394
3405
3395 2002-05-01 Fernando Perez <fperez@colorado.edu>
3406 2002-05-01 Fernando Perez <fperez@colorado.edu>
3396
3407
3397 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3408 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3398 was nasty -- though somewhat of a corner case).
3409 was nasty -- though somewhat of a corner case).
3399
3410
3400 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3411 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3401 text (was a bug).
3412 text (was a bug).
3402
3413
3403 2002-04-30 Fernando Perez <fperez@colorado.edu>
3414 2002-04-30 Fernando Perez <fperez@colorado.edu>
3404
3415
3405 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3416 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3406 a print after ^D or ^C from the user so that the In[] prompt
3417 a print after ^D or ^C from the user so that the In[] prompt
3407 doesn't over-run the gnuplot one.
3418 doesn't over-run the gnuplot one.
3408
3419
3409 2002-04-29 Fernando Perez <fperez@colorado.edu>
3420 2002-04-29 Fernando Perez <fperez@colorado.edu>
3410
3421
3411 * Released 0.2.10
3422 * Released 0.2.10
3412
3423
3413 * IPython/__release__.py (version): get date dynamically.
3424 * IPython/__release__.py (version): get date dynamically.
3414
3425
3415 * Misc. documentation updates thanks to Arnd's comments. Also ran
3426 * Misc. documentation updates thanks to Arnd's comments. Also ran
3416 a full spellcheck on the manual (hadn't been done in a while).
3427 a full spellcheck on the manual (hadn't been done in a while).
3417
3428
3418 2002-04-27 Fernando Perez <fperez@colorado.edu>
3429 2002-04-27 Fernando Perez <fperez@colorado.edu>
3419
3430
3420 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3431 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3421 starting a log in mid-session would reset the input history list.
3432 starting a log in mid-session would reset the input history list.
3422
3433
3423 2002-04-26 Fernando Perez <fperez@colorado.edu>
3434 2002-04-26 Fernando Perez <fperez@colorado.edu>
3424
3435
3425 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3436 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3426 all files were being included in an update. Now anything in
3437 all files were being included in an update. Now anything in
3427 UserConfig that matches [A-Za-z]*.py will go (this excludes
3438 UserConfig that matches [A-Za-z]*.py will go (this excludes
3428 __init__.py)
3439 __init__.py)
3429
3440
3430 2002-04-25 Fernando Perez <fperez@colorado.edu>
3441 2002-04-25 Fernando Perez <fperez@colorado.edu>
3431
3442
3432 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3443 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3433 to __builtins__ so that any form of embedded or imported code can
3444 to __builtins__ so that any form of embedded or imported code can
3434 test for being inside IPython.
3445 test for being inside IPython.
3435
3446
3436 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3447 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3437 changed to GnuplotMagic because it's now an importable module,
3448 changed to GnuplotMagic because it's now an importable module,
3438 this makes the name follow that of the standard Gnuplot module.
3449 this makes the name follow that of the standard Gnuplot module.
3439 GnuplotMagic can now be loaded at any time in mid-session.
3450 GnuplotMagic can now be loaded at any time in mid-session.
3440
3451
3441 2002-04-24 Fernando Perez <fperez@colorado.edu>
3452 2002-04-24 Fernando Perez <fperez@colorado.edu>
3442
3453
3443 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3454 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3444 the globals (IPython has its own namespace) and the
3455 the globals (IPython has its own namespace) and the
3445 PhysicalQuantity stuff is much better anyway.
3456 PhysicalQuantity stuff is much better anyway.
3446
3457
3447 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3458 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3448 embedding example to standard user directory for
3459 embedding example to standard user directory for
3449 distribution. Also put it in the manual.
3460 distribution. Also put it in the manual.
3450
3461
3451 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3462 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3452 instance as first argument (so it doesn't rely on some obscure
3463 instance as first argument (so it doesn't rely on some obscure
3453 hidden global).
3464 hidden global).
3454
3465
3455 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3466 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3456 delimiters. While it prevents ().TAB from working, it allows
3467 delimiters. While it prevents ().TAB from working, it allows
3457 completions in open (... expressions. This is by far a more common
3468 completions in open (... expressions. This is by far a more common
3458 case.
3469 case.
3459
3470
3460 2002-04-23 Fernando Perez <fperez@colorado.edu>
3471 2002-04-23 Fernando Perez <fperez@colorado.edu>
3461
3472
3462 * IPython/Extensions/InterpreterPasteInput.py: new
3473 * IPython/Extensions/InterpreterPasteInput.py: new
3463 syntax-processing module for pasting lines with >>> or ... at the
3474 syntax-processing module for pasting lines with >>> or ... at the
3464 start.
3475 start.
3465
3476
3466 * IPython/Extensions/PhysicalQ_Interactive.py
3477 * IPython/Extensions/PhysicalQ_Interactive.py
3467 (PhysicalQuantityInteractive.__int__): fixed to work with either
3478 (PhysicalQuantityInteractive.__int__): fixed to work with either
3468 Numeric or math.
3479 Numeric or math.
3469
3480
3470 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3481 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3471 provided profiles. Now we have:
3482 provided profiles. Now we have:
3472 -math -> math module as * and cmath with its own namespace.
3483 -math -> math module as * and cmath with its own namespace.
3473 -numeric -> Numeric as *, plus gnuplot & grace
3484 -numeric -> Numeric as *, plus gnuplot & grace
3474 -physics -> same as before
3485 -physics -> same as before
3475
3486
3476 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3487 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3477 user-defined magics wouldn't be found by @magic if they were
3488 user-defined magics wouldn't be found by @magic if they were
3478 defined as class methods. Also cleaned up the namespace search
3489 defined as class methods. Also cleaned up the namespace search
3479 logic and the string building (to use %s instead of many repeated
3490 logic and the string building (to use %s instead of many repeated
3480 string adds).
3491 string adds).
3481
3492
3482 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3493 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3483 of user-defined magics to operate with class methods (cleaner, in
3494 of user-defined magics to operate with class methods (cleaner, in
3484 line with the gnuplot code).
3495 line with the gnuplot code).
3485
3496
3486 2002-04-22 Fernando Perez <fperez@colorado.edu>
3497 2002-04-22 Fernando Perez <fperez@colorado.edu>
3487
3498
3488 * setup.py: updated dependency list so that manual is updated when
3499 * setup.py: updated dependency list so that manual is updated when
3489 all included files change.
3500 all included files change.
3490
3501
3491 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3502 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3492 the delimiter removal option (the fix is ugly right now).
3503 the delimiter removal option (the fix is ugly right now).
3493
3504
3494 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3505 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3495 all of the math profile (quicker loading, no conflict between
3506 all of the math profile (quicker loading, no conflict between
3496 g-9.8 and g-gnuplot).
3507 g-9.8 and g-gnuplot).
3497
3508
3498 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3509 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3499 name of post-mortem files to IPython_crash_report.txt.
3510 name of post-mortem files to IPython_crash_report.txt.
3500
3511
3501 * Cleanup/update of the docs. Added all the new readline info and
3512 * Cleanup/update of the docs. Added all the new readline info and
3502 formatted all lists as 'real lists'.
3513 formatted all lists as 'real lists'.
3503
3514
3504 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3515 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3505 tab-completion options, since the full readline parse_and_bind is
3516 tab-completion options, since the full readline parse_and_bind is
3506 now accessible.
3517 now accessible.
3507
3518
3508 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3519 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3509 handling of readline options. Now users can specify any string to
3520 handling of readline options. Now users can specify any string to
3510 be passed to parse_and_bind(), as well as the delimiters to be
3521 be passed to parse_and_bind(), as well as the delimiters to be
3511 removed.
3522 removed.
3512 (InteractiveShell.__init__): Added __name__ to the global
3523 (InteractiveShell.__init__): Added __name__ to the global
3513 namespace so that things like Itpl which rely on its existence
3524 namespace so that things like Itpl which rely on its existence
3514 don't crash.
3525 don't crash.
3515 (InteractiveShell._prefilter): Defined the default with a _ so
3526 (InteractiveShell._prefilter): Defined the default with a _ so
3516 that prefilter() is easier to override, while the default one
3527 that prefilter() is easier to override, while the default one
3517 remains available.
3528 remains available.
3518
3529
3519 2002-04-18 Fernando Perez <fperez@colorado.edu>
3530 2002-04-18 Fernando Perez <fperez@colorado.edu>
3520
3531
3521 * Added information about pdb in the docs.
3532 * Added information about pdb in the docs.
3522
3533
3523 2002-04-17 Fernando Perez <fperez@colorado.edu>
3534 2002-04-17 Fernando Perez <fperez@colorado.edu>
3524
3535
3525 * IPython/ipmaker.py (make_IPython): added rc_override option to
3536 * IPython/ipmaker.py (make_IPython): added rc_override option to
3526 allow passing config options at creation time which may override
3537 allow passing config options at creation time which may override
3527 anything set in the config files or command line. This is
3538 anything set in the config files or command line. This is
3528 particularly useful for configuring embedded instances.
3539 particularly useful for configuring embedded instances.
3529
3540
3530 2002-04-15 Fernando Perez <fperez@colorado.edu>
3541 2002-04-15 Fernando Perez <fperez@colorado.edu>
3531
3542
3532 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3543 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3533 crash embedded instances because of the input cache falling out of
3544 crash embedded instances because of the input cache falling out of
3534 sync with the output counter.
3545 sync with the output counter.
3535
3546
3536 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3547 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3537 mode which calls pdb after an uncaught exception in IPython itself.
3548 mode which calls pdb after an uncaught exception in IPython itself.
3538
3549
3539 2002-04-14 Fernando Perez <fperez@colorado.edu>
3550 2002-04-14 Fernando Perez <fperez@colorado.edu>
3540
3551
3541 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3552 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3542 readline, fix it back after each call.
3553 readline, fix it back after each call.
3543
3554
3544 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3555 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3545 method to force all access via __call__(), which guarantees that
3556 method to force all access via __call__(), which guarantees that
3546 traceback references are properly deleted.
3557 traceback references are properly deleted.
3547
3558
3548 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3559 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3549 improve printing when pprint is in use.
3560 improve printing when pprint is in use.
3550
3561
3551 2002-04-13 Fernando Perez <fperez@colorado.edu>
3562 2002-04-13 Fernando Perez <fperez@colorado.edu>
3552
3563
3553 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3564 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3554 exceptions aren't caught anymore. If the user triggers one, he
3565 exceptions aren't caught anymore. If the user triggers one, he
3555 should know why he's doing it and it should go all the way up,
3566 should know why he's doing it and it should go all the way up,
3556 just like any other exception. So now @abort will fully kill the
3567 just like any other exception. So now @abort will fully kill the
3557 embedded interpreter and the embedding code (unless that happens
3568 embedded interpreter and the embedding code (unless that happens
3558 to catch SystemExit).
3569 to catch SystemExit).
3559
3570
3560 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3571 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3561 and a debugger() method to invoke the interactive pdb debugger
3572 and a debugger() method to invoke the interactive pdb debugger
3562 after printing exception information. Also added the corresponding
3573 after printing exception information. Also added the corresponding
3563 -pdb option and @pdb magic to control this feature, and updated
3574 -pdb option and @pdb magic to control this feature, and updated
3564 the docs. After a suggestion from Christopher Hart
3575 the docs. After a suggestion from Christopher Hart
3565 (hart-AT-caltech.edu).
3576 (hart-AT-caltech.edu).
3566
3577
3567 2002-04-12 Fernando Perez <fperez@colorado.edu>
3578 2002-04-12 Fernando Perez <fperez@colorado.edu>
3568
3579
3569 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3580 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3570 the exception handlers defined by the user (not the CrashHandler)
3581 the exception handlers defined by the user (not the CrashHandler)
3571 so that user exceptions don't trigger an ipython bug report.
3582 so that user exceptions don't trigger an ipython bug report.
3572
3583
3573 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3584 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3574 configurable (it should have always been so).
3585 configurable (it should have always been so).
3575
3586
3576 2002-03-26 Fernando Perez <fperez@colorado.edu>
3587 2002-03-26 Fernando Perez <fperez@colorado.edu>
3577
3588
3578 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3589 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3579 and there to fix embedding namespace issues. This should all be
3590 and there to fix embedding namespace issues. This should all be
3580 done in a more elegant way.
3591 done in a more elegant way.
3581
3592
3582 2002-03-25 Fernando Perez <fperez@colorado.edu>
3593 2002-03-25 Fernando Perez <fperez@colorado.edu>
3583
3594
3584 * IPython/genutils.py (get_home_dir): Try to make it work under
3595 * IPython/genutils.py (get_home_dir): Try to make it work under
3585 win9x also.
3596 win9x also.
3586
3597
3587 2002-03-20 Fernando Perez <fperez@colorado.edu>
3598 2002-03-20 Fernando Perez <fperez@colorado.edu>
3588
3599
3589 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3600 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3590 sys.displayhook untouched upon __init__.
3601 sys.displayhook untouched upon __init__.
3591
3602
3592 2002-03-19 Fernando Perez <fperez@colorado.edu>
3603 2002-03-19 Fernando Perez <fperez@colorado.edu>
3593
3604
3594 * Released 0.2.9 (for embedding bug, basically).
3605 * Released 0.2.9 (for embedding bug, basically).
3595
3606
3596 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3607 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3597 exceptions so that enclosing shell's state can be restored.
3608 exceptions so that enclosing shell's state can be restored.
3598
3609
3599 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3610 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3600 naming conventions in the .ipython/ dir.
3611 naming conventions in the .ipython/ dir.
3601
3612
3602 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3613 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3603 from delimiters list so filenames with - in them get expanded.
3614 from delimiters list so filenames with - in them get expanded.
3604
3615
3605 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3616 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3606 sys.displayhook not being properly restored after an embedded call.
3617 sys.displayhook not being properly restored after an embedded call.
3607
3618
3608 2002-03-18 Fernando Perez <fperez@colorado.edu>
3619 2002-03-18 Fernando Perez <fperez@colorado.edu>
3609
3620
3610 * Released 0.2.8
3621 * Released 0.2.8
3611
3622
3612 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3623 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3613 some files weren't being included in a -upgrade.
3624 some files weren't being included in a -upgrade.
3614 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3625 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3615 on' so that the first tab completes.
3626 on' so that the first tab completes.
3616 (InteractiveShell.handle_magic): fixed bug with spaces around
3627 (InteractiveShell.handle_magic): fixed bug with spaces around
3617 quotes breaking many magic commands.
3628 quotes breaking many magic commands.
3618
3629
3619 * setup.py: added note about ignoring the syntax error messages at
3630 * setup.py: added note about ignoring the syntax error messages at
3620 installation.
3631 installation.
3621
3632
3622 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3633 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3623 streamlining the gnuplot interface, now there's only one magic @gp.
3634 streamlining the gnuplot interface, now there's only one magic @gp.
3624
3635
3625 2002-03-17 Fernando Perez <fperez@colorado.edu>
3636 2002-03-17 Fernando Perez <fperez@colorado.edu>
3626
3637
3627 * IPython/UserConfig/magic_gnuplot.py: new name for the
3638 * IPython/UserConfig/magic_gnuplot.py: new name for the
3628 example-magic_pm.py file. Much enhanced system, now with a shell
3639 example-magic_pm.py file. Much enhanced system, now with a shell
3629 for communicating directly with gnuplot, one command at a time.
3640 for communicating directly with gnuplot, one command at a time.
3630
3641
3631 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3642 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3632 setting __name__=='__main__'.
3643 setting __name__=='__main__'.
3633
3644
3634 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3645 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3635 mini-shell for accessing gnuplot from inside ipython. Should
3646 mini-shell for accessing gnuplot from inside ipython. Should
3636 extend it later for grace access too. Inspired by Arnd's
3647 extend it later for grace access too. Inspired by Arnd's
3637 suggestion.
3648 suggestion.
3638
3649
3639 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3650 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3640 calling magic functions with () in their arguments. Thanks to Arnd
3651 calling magic functions with () in their arguments. Thanks to Arnd
3641 Baecker for pointing this to me.
3652 Baecker for pointing this to me.
3642
3653
3643 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3654 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3644 infinitely for integer or complex arrays (only worked with floats).
3655 infinitely for integer or complex arrays (only worked with floats).
3645
3656
3646 2002-03-16 Fernando Perez <fperez@colorado.edu>
3657 2002-03-16 Fernando Perez <fperez@colorado.edu>
3647
3658
3648 * setup.py: Merged setup and setup_windows into a single script
3659 * setup.py: Merged setup and setup_windows into a single script
3649 which properly handles things for windows users.
3660 which properly handles things for windows users.
3650
3661
3651 2002-03-15 Fernando Perez <fperez@colorado.edu>
3662 2002-03-15 Fernando Perez <fperez@colorado.edu>
3652
3663
3653 * Big change to the manual: now the magics are all automatically
3664 * Big change to the manual: now the magics are all automatically
3654 documented. This information is generated from their docstrings
3665 documented. This information is generated from their docstrings
3655 and put in a latex file included by the manual lyx file. This way
3666 and put in a latex file included by the manual lyx file. This way
3656 we get always up to date information for the magics. The manual
3667 we get always up to date information for the magics. The manual
3657 now also has proper version information, also auto-synced.
3668 now also has proper version information, also auto-synced.
3658
3669
3659 For this to work, an undocumented --magic_docstrings option was added.
3670 For this to work, an undocumented --magic_docstrings option was added.
3660
3671
3661 2002-03-13 Fernando Perez <fperez@colorado.edu>
3672 2002-03-13 Fernando Perez <fperez@colorado.edu>
3662
3673
3663 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3674 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3664 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3675 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3665
3676
3666 2002-03-12 Fernando Perez <fperez@colorado.edu>
3677 2002-03-12 Fernando Perez <fperez@colorado.edu>
3667
3678
3668 * IPython/ultraTB.py (TermColors): changed color escapes again to
3679 * IPython/ultraTB.py (TermColors): changed color escapes again to
3669 fix the (old, reintroduced) line-wrapping bug. Basically, if
3680 fix the (old, reintroduced) line-wrapping bug. Basically, if
3670 \001..\002 aren't given in the color escapes, lines get wrapped
3681 \001..\002 aren't given in the color escapes, lines get wrapped
3671 weirdly. But giving those screws up old xterms and emacs terms. So
3682 weirdly. But giving those screws up old xterms and emacs terms. So
3672 I added some logic for emacs terms to be ok, but I can't identify old
3683 I added some logic for emacs terms to be ok, but I can't identify old
3673 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3684 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3674
3685
3675 2002-03-10 Fernando Perez <fperez@colorado.edu>
3686 2002-03-10 Fernando Perez <fperez@colorado.edu>
3676
3687
3677 * IPython/usage.py (__doc__): Various documentation cleanups and
3688 * IPython/usage.py (__doc__): Various documentation cleanups and
3678 updates, both in usage docstrings and in the manual.
3689 updates, both in usage docstrings and in the manual.
3679
3690
3680 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3691 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3681 handling of caching. Set minimum acceptabe value for having a
3692 handling of caching. Set minimum acceptabe value for having a
3682 cache at 20 values.
3693 cache at 20 values.
3683
3694
3684 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3695 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3685 install_first_time function to a method, renamed it and added an
3696 install_first_time function to a method, renamed it and added an
3686 'upgrade' mode. Now people can update their config directory with
3697 'upgrade' mode. Now people can update their config directory with
3687 a simple command line switch (-upgrade, also new).
3698 a simple command line switch (-upgrade, also new).
3688
3699
3689 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3700 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3690 @file (convenient for automagic users under Python >= 2.2).
3701 @file (convenient for automagic users under Python >= 2.2).
3691 Removed @files (it seemed more like a plural than an abbrev. of
3702 Removed @files (it seemed more like a plural than an abbrev. of
3692 'file show').
3703 'file show').
3693
3704
3694 * IPython/iplib.py (install_first_time): Fixed crash if there were
3705 * IPython/iplib.py (install_first_time): Fixed crash if there were
3695 backup files ('~') in .ipython/ install directory.
3706 backup files ('~') in .ipython/ install directory.
3696
3707
3697 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3708 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3698 system. Things look fine, but these changes are fairly
3709 system. Things look fine, but these changes are fairly
3699 intrusive. Test them for a few days.
3710 intrusive. Test them for a few days.
3700
3711
3701 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3712 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3702 the prompts system. Now all in/out prompt strings are user
3713 the prompts system. Now all in/out prompt strings are user
3703 controllable. This is particularly useful for embedding, as one
3714 controllable. This is particularly useful for embedding, as one
3704 can tag embedded instances with particular prompts.
3715 can tag embedded instances with particular prompts.
3705
3716
3706 Also removed global use of sys.ps1/2, which now allows nested
3717 Also removed global use of sys.ps1/2, which now allows nested
3707 embeddings without any problems. Added command-line options for
3718 embeddings without any problems. Added command-line options for
3708 the prompt strings.
3719 the prompt strings.
3709
3720
3710 2002-03-08 Fernando Perez <fperez@colorado.edu>
3721 2002-03-08 Fernando Perez <fperez@colorado.edu>
3711
3722
3712 * IPython/UserConfig/example-embed-short.py (ipshell): added
3723 * IPython/UserConfig/example-embed-short.py (ipshell): added
3713 example file with the bare minimum code for embedding.
3724 example file with the bare minimum code for embedding.
3714
3725
3715 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3726 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3716 functionality for the embeddable shell to be activated/deactivated
3727 functionality for the embeddable shell to be activated/deactivated
3717 either globally or at each call.
3728 either globally or at each call.
3718
3729
3719 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3730 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3720 rewriting the prompt with '--->' for auto-inputs with proper
3731 rewriting the prompt with '--->' for auto-inputs with proper
3721 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3732 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3722 this is handled by the prompts class itself, as it should.
3733 this is handled by the prompts class itself, as it should.
3723
3734
3724 2002-03-05 Fernando Perez <fperez@colorado.edu>
3735 2002-03-05 Fernando Perez <fperez@colorado.edu>
3725
3736
3726 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3737 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3727 @logstart to avoid name clashes with the math log function.
3738 @logstart to avoid name clashes with the math log function.
3728
3739
3729 * Big updates to X/Emacs section of the manual.
3740 * Big updates to X/Emacs section of the manual.
3730
3741
3731 * Removed ipython_emacs. Milan explained to me how to pass
3742 * Removed ipython_emacs. Milan explained to me how to pass
3732 arguments to ipython through Emacs. Some day I'm going to end up
3743 arguments to ipython through Emacs. Some day I'm going to end up
3733 learning some lisp...
3744 learning some lisp...
3734
3745
3735 2002-03-04 Fernando Perez <fperez@colorado.edu>
3746 2002-03-04 Fernando Perez <fperez@colorado.edu>
3736
3747
3737 * IPython/ipython_emacs: Created script to be used as the
3748 * IPython/ipython_emacs: Created script to be used as the
3738 py-python-command Emacs variable so we can pass IPython
3749 py-python-command Emacs variable so we can pass IPython
3739 parameters. I can't figure out how to tell Emacs directly to pass
3750 parameters. I can't figure out how to tell Emacs directly to pass
3740 parameters to IPython, so a dummy shell script will do it.
3751 parameters to IPython, so a dummy shell script will do it.
3741
3752
3742 Other enhancements made for things to work better under Emacs'
3753 Other enhancements made for things to work better under Emacs'
3743 various types of terminals. Many thanks to Milan Zamazal
3754 various types of terminals. Many thanks to Milan Zamazal
3744 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3755 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3745
3756
3746 2002-03-01 Fernando Perez <fperez@colorado.edu>
3757 2002-03-01 Fernando Perez <fperez@colorado.edu>
3747
3758
3748 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3759 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3749 that loading of readline is now optional. This gives better
3760 that loading of readline is now optional. This gives better
3750 control to emacs users.
3761 control to emacs users.
3751
3762
3752 * IPython/ultraTB.py (__date__): Modified color escape sequences
3763 * IPython/ultraTB.py (__date__): Modified color escape sequences
3753 and now things work fine under xterm and in Emacs' term buffers
3764 and now things work fine under xterm and in Emacs' term buffers
3754 (though not shell ones). Well, in emacs you get colors, but all
3765 (though not shell ones). Well, in emacs you get colors, but all
3755 seem to be 'light' colors (no difference between dark and light
3766 seem to be 'light' colors (no difference between dark and light
3756 ones). But the garbage chars are gone, and also in xterms. It
3767 ones). But the garbage chars are gone, and also in xterms. It
3757 seems that now I'm using 'cleaner' ansi sequences.
3768 seems that now I'm using 'cleaner' ansi sequences.
3758
3769
3759 2002-02-21 Fernando Perez <fperez@colorado.edu>
3770 2002-02-21 Fernando Perez <fperez@colorado.edu>
3760
3771
3761 * Released 0.2.7 (mainly to publish the scoping fix).
3772 * Released 0.2.7 (mainly to publish the scoping fix).
3762
3773
3763 * IPython/Logger.py (Logger.logstate): added. A corresponding
3774 * IPython/Logger.py (Logger.logstate): added. A corresponding
3764 @logstate magic was created.
3775 @logstate magic was created.
3765
3776
3766 * IPython/Magic.py: fixed nested scoping problem under Python
3777 * IPython/Magic.py: fixed nested scoping problem under Python
3767 2.1.x (automagic wasn't working).
3778 2.1.x (automagic wasn't working).
3768
3779
3769 2002-02-20 Fernando Perez <fperez@colorado.edu>
3780 2002-02-20 Fernando Perez <fperez@colorado.edu>
3770
3781
3771 * Released 0.2.6.
3782 * Released 0.2.6.
3772
3783
3773 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3784 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3774 option so that logs can come out without any headers at all.
3785 option so that logs can come out without any headers at all.
3775
3786
3776 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3787 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3777 SciPy.
3788 SciPy.
3778
3789
3779 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3790 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3780 that embedded IPython calls don't require vars() to be explicitly
3791 that embedded IPython calls don't require vars() to be explicitly
3781 passed. Now they are extracted from the caller's frame (code
3792 passed. Now they are extracted from the caller's frame (code
3782 snatched from Eric Jones' weave). Added better documentation to
3793 snatched from Eric Jones' weave). Added better documentation to
3783 the section on embedding and the example file.
3794 the section on embedding and the example file.
3784
3795
3785 * IPython/genutils.py (page): Changed so that under emacs, it just
3796 * IPython/genutils.py (page): Changed so that under emacs, it just
3786 prints the string. You can then page up and down in the emacs
3797 prints the string. You can then page up and down in the emacs
3787 buffer itself. This is how the builtin help() works.
3798 buffer itself. This is how the builtin help() works.
3788
3799
3789 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3800 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3790 macro scoping: macros need to be executed in the user's namespace
3801 macro scoping: macros need to be executed in the user's namespace
3791 to work as if they had been typed by the user.
3802 to work as if they had been typed by the user.
3792
3803
3793 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3804 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3794 execute automatically (no need to type 'exec...'). They then
3805 execute automatically (no need to type 'exec...'). They then
3795 behave like 'true macros'. The printing system was also modified
3806 behave like 'true macros'. The printing system was also modified
3796 for this to work.
3807 for this to work.
3797
3808
3798 2002-02-19 Fernando Perez <fperez@colorado.edu>
3809 2002-02-19 Fernando Perez <fperez@colorado.edu>
3799
3810
3800 * IPython/genutils.py (page_file): new function for paging files
3811 * IPython/genutils.py (page_file): new function for paging files
3801 in an OS-independent way. Also necessary for file viewing to work
3812 in an OS-independent way. Also necessary for file viewing to work
3802 well inside Emacs buffers.
3813 well inside Emacs buffers.
3803 (page): Added checks for being in an emacs buffer.
3814 (page): Added checks for being in an emacs buffer.
3804 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3815 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3805 same bug in iplib.
3816 same bug in iplib.
3806
3817
3807 2002-02-18 Fernando Perez <fperez@colorado.edu>
3818 2002-02-18 Fernando Perez <fperez@colorado.edu>
3808
3819
3809 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3820 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3810 of readline so that IPython can work inside an Emacs buffer.
3821 of readline so that IPython can work inside an Emacs buffer.
3811
3822
3812 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3823 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3813 method signatures (they weren't really bugs, but it looks cleaner
3824 method signatures (they weren't really bugs, but it looks cleaner
3814 and keeps PyChecker happy).
3825 and keeps PyChecker happy).
3815
3826
3816 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3827 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3817 for implementing various user-defined hooks. Currently only
3828 for implementing various user-defined hooks. Currently only
3818 display is done.
3829 display is done.
3819
3830
3820 * IPython/Prompts.py (CachedOutput._display): changed display
3831 * IPython/Prompts.py (CachedOutput._display): changed display
3821 functions so that they can be dynamically changed by users easily.
3832 functions so that they can be dynamically changed by users easily.
3822
3833
3823 * IPython/Extensions/numeric_formats.py (num_display): added an
3834 * IPython/Extensions/numeric_formats.py (num_display): added an
3824 extension for printing NumPy arrays in flexible manners. It
3835 extension for printing NumPy arrays in flexible manners. It
3825 doesn't do anything yet, but all the structure is in
3836 doesn't do anything yet, but all the structure is in
3826 place. Ultimately the plan is to implement output format control
3837 place. Ultimately the plan is to implement output format control
3827 like in Octave.
3838 like in Octave.
3828
3839
3829 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3840 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3830 methods are found at run-time by all the automatic machinery.
3841 methods are found at run-time by all the automatic machinery.
3831
3842
3832 2002-02-17 Fernando Perez <fperez@colorado.edu>
3843 2002-02-17 Fernando Perez <fperez@colorado.edu>
3833
3844
3834 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3845 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3835 whole file a little.
3846 whole file a little.
3836
3847
3837 * ToDo: closed this document. Now there's a new_design.lyx
3848 * ToDo: closed this document. Now there's a new_design.lyx
3838 document for all new ideas. Added making a pdf of it for the
3849 document for all new ideas. Added making a pdf of it for the
3839 end-user distro.
3850 end-user distro.
3840
3851
3841 * IPython/Logger.py (Logger.switch_log): Created this to replace
3852 * IPython/Logger.py (Logger.switch_log): Created this to replace
3842 logon() and logoff(). It also fixes a nasty crash reported by
3853 logon() and logoff(). It also fixes a nasty crash reported by
3843 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3854 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3844
3855
3845 * IPython/iplib.py (complete): got auto-completion to work with
3856 * IPython/iplib.py (complete): got auto-completion to work with
3846 automagic (I had wanted this for a long time).
3857 automagic (I had wanted this for a long time).
3847
3858
3848 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3859 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3849 to @file, since file() is now a builtin and clashes with automagic
3860 to @file, since file() is now a builtin and clashes with automagic
3850 for @file.
3861 for @file.
3851
3862
3852 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3863 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3853 of this was previously in iplib, which had grown to more than 2000
3864 of this was previously in iplib, which had grown to more than 2000
3854 lines, way too long. No new functionality, but it makes managing
3865 lines, way too long. No new functionality, but it makes managing
3855 the code a bit easier.
3866 the code a bit easier.
3856
3867
3857 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3868 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3858 information to crash reports.
3869 information to crash reports.
3859
3870
3860 2002-02-12 Fernando Perez <fperez@colorado.edu>
3871 2002-02-12 Fernando Perez <fperez@colorado.edu>
3861
3872
3862 * Released 0.2.5.
3873 * Released 0.2.5.
3863
3874
3864 2002-02-11 Fernando Perez <fperez@colorado.edu>
3875 2002-02-11 Fernando Perez <fperez@colorado.edu>
3865
3876
3866 * Wrote a relatively complete Windows installer. It puts
3877 * Wrote a relatively complete Windows installer. It puts
3867 everything in place, creates Start Menu entries and fixes the
3878 everything in place, creates Start Menu entries and fixes the
3868 color issues. Nothing fancy, but it works.
3879 color issues. Nothing fancy, but it works.
3869
3880
3870 2002-02-10 Fernando Perez <fperez@colorado.edu>
3881 2002-02-10 Fernando Perez <fperez@colorado.edu>
3871
3882
3872 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3883 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3873 os.path.expanduser() call so that we can type @run ~/myfile.py and
3884 os.path.expanduser() call so that we can type @run ~/myfile.py and
3874 have thigs work as expected.
3885 have thigs work as expected.
3875
3886
3876 * IPython/genutils.py (page): fixed exception handling so things
3887 * IPython/genutils.py (page): fixed exception handling so things
3877 work both in Unix and Windows correctly. Quitting a pager triggers
3888 work both in Unix and Windows correctly. Quitting a pager triggers
3878 an IOError/broken pipe in Unix, and in windows not finding a pager
3889 an IOError/broken pipe in Unix, and in windows not finding a pager
3879 is also an IOError, so I had to actually look at the return value
3890 is also an IOError, so I had to actually look at the return value
3880 of the exception, not just the exception itself. Should be ok now.
3891 of the exception, not just the exception itself. Should be ok now.
3881
3892
3882 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3893 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3883 modified to allow case-insensitive color scheme changes.
3894 modified to allow case-insensitive color scheme changes.
3884
3895
3885 2002-02-09 Fernando Perez <fperez@colorado.edu>
3896 2002-02-09 Fernando Perez <fperez@colorado.edu>
3886
3897
3887 * IPython/genutils.py (native_line_ends): new function to leave
3898 * IPython/genutils.py (native_line_ends): new function to leave
3888 user config files with os-native line-endings.
3899 user config files with os-native line-endings.
3889
3900
3890 * README and manual updates.
3901 * README and manual updates.
3891
3902
3892 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3903 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3893 instead of StringType to catch Unicode strings.
3904 instead of StringType to catch Unicode strings.
3894
3905
3895 * IPython/genutils.py (filefind): fixed bug for paths with
3906 * IPython/genutils.py (filefind): fixed bug for paths with
3896 embedded spaces (very common in Windows).
3907 embedded spaces (very common in Windows).
3897
3908
3898 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3909 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3899 files under Windows, so that they get automatically associated
3910 files under Windows, so that they get automatically associated
3900 with a text editor. Windows makes it a pain to handle
3911 with a text editor. Windows makes it a pain to handle
3901 extension-less files.
3912 extension-less files.
3902
3913
3903 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3914 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3904 warning about readline only occur for Posix. In Windows there's no
3915 warning about readline only occur for Posix. In Windows there's no
3905 way to get readline, so why bother with the warning.
3916 way to get readline, so why bother with the warning.
3906
3917
3907 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3918 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3908 for __str__ instead of dir(self), since dir() changed in 2.2.
3919 for __str__ instead of dir(self), since dir() changed in 2.2.
3909
3920
3910 * Ported to Windows! Tested on XP, I suspect it should work fine
3921 * Ported to Windows! Tested on XP, I suspect it should work fine
3911 on NT/2000, but I don't think it will work on 98 et al. That
3922 on NT/2000, but I don't think it will work on 98 et al. That
3912 series of Windows is such a piece of junk anyway that I won't try
3923 series of Windows is such a piece of junk anyway that I won't try
3913 porting it there. The XP port was straightforward, showed a few
3924 porting it there. The XP port was straightforward, showed a few
3914 bugs here and there (fixed all), in particular some string
3925 bugs here and there (fixed all), in particular some string
3915 handling stuff which required considering Unicode strings (which
3926 handling stuff which required considering Unicode strings (which
3916 Windows uses). This is good, but hasn't been too tested :) No
3927 Windows uses). This is good, but hasn't been too tested :) No
3917 fancy installer yet, I'll put a note in the manual so people at
3928 fancy installer yet, I'll put a note in the manual so people at
3918 least make manually a shortcut.
3929 least make manually a shortcut.
3919
3930
3920 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3931 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3921 into a single one, "colors". This now controls both prompt and
3932 into a single one, "colors". This now controls both prompt and
3922 exception color schemes, and can be changed both at startup
3933 exception color schemes, and can be changed both at startup
3923 (either via command-line switches or via ipythonrc files) and at
3934 (either via command-line switches or via ipythonrc files) and at
3924 runtime, with @colors.
3935 runtime, with @colors.
3925 (Magic.magic_run): renamed @prun to @run and removed the old
3936 (Magic.magic_run): renamed @prun to @run and removed the old
3926 @run. The two were too similar to warrant keeping both.
3937 @run. The two were too similar to warrant keeping both.
3927
3938
3928 2002-02-03 Fernando Perez <fperez@colorado.edu>
3939 2002-02-03 Fernando Perez <fperez@colorado.edu>
3929
3940
3930 * IPython/iplib.py (install_first_time): Added comment on how to
3941 * IPython/iplib.py (install_first_time): Added comment on how to
3931 configure the color options for first-time users. Put a <return>
3942 configure the color options for first-time users. Put a <return>
3932 request at the end so that small-terminal users get a chance to
3943 request at the end so that small-terminal users get a chance to
3933 read the startup info.
3944 read the startup info.
3934
3945
3935 2002-01-23 Fernando Perez <fperez@colorado.edu>
3946 2002-01-23 Fernando Perez <fperez@colorado.edu>
3936
3947
3937 * IPython/iplib.py (CachedOutput.update): Changed output memory
3948 * IPython/iplib.py (CachedOutput.update): Changed output memory
3938 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3949 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3939 input history we still use _i. Did this b/c these variable are
3950 input history we still use _i. Did this b/c these variable are
3940 very commonly used in interactive work, so the less we need to
3951 very commonly used in interactive work, so the less we need to
3941 type the better off we are.
3952 type the better off we are.
3942 (Magic.magic_prun): updated @prun to better handle the namespaces
3953 (Magic.magic_prun): updated @prun to better handle the namespaces
3943 the file will run in, including a fix for __name__ not being set
3954 the file will run in, including a fix for __name__ not being set
3944 before.
3955 before.
3945
3956
3946 2002-01-20 Fernando Perez <fperez@colorado.edu>
3957 2002-01-20 Fernando Perez <fperez@colorado.edu>
3947
3958
3948 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3959 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3949 extra garbage for Python 2.2. Need to look more carefully into
3960 extra garbage for Python 2.2. Need to look more carefully into
3950 this later.
3961 this later.
3951
3962
3952 2002-01-19 Fernando Perez <fperez@colorado.edu>
3963 2002-01-19 Fernando Perez <fperez@colorado.edu>
3953
3964
3954 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3965 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3955 display SyntaxError exceptions properly formatted when they occur
3966 display SyntaxError exceptions properly formatted when they occur
3956 (they can be triggered by imported code).
3967 (they can be triggered by imported code).
3957
3968
3958 2002-01-18 Fernando Perez <fperez@colorado.edu>
3969 2002-01-18 Fernando Perez <fperez@colorado.edu>
3959
3970
3960 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3971 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3961 SyntaxError exceptions are reported nicely formatted, instead of
3972 SyntaxError exceptions are reported nicely formatted, instead of
3962 spitting out only offset information as before.
3973 spitting out only offset information as before.
3963 (Magic.magic_prun): Added the @prun function for executing
3974 (Magic.magic_prun): Added the @prun function for executing
3964 programs with command line args inside IPython.
3975 programs with command line args inside IPython.
3965
3976
3966 2002-01-16 Fernando Perez <fperez@colorado.edu>
3977 2002-01-16 Fernando Perez <fperez@colorado.edu>
3967
3978
3968 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3979 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3969 to *not* include the last item given in a range. This brings their
3980 to *not* include the last item given in a range. This brings their
3970 behavior in line with Python's slicing:
3981 behavior in line with Python's slicing:
3971 a[n1:n2] -> a[n1]...a[n2-1]
3982 a[n1:n2] -> a[n1]...a[n2-1]
3972 It may be a bit less convenient, but I prefer to stick to Python's
3983 It may be a bit less convenient, but I prefer to stick to Python's
3973 conventions *everywhere*, so users never have to wonder.
3984 conventions *everywhere*, so users never have to wonder.
3974 (Magic.magic_macro): Added @macro function to ease the creation of
3985 (Magic.magic_macro): Added @macro function to ease the creation of
3975 macros.
3986 macros.
3976
3987
3977 2002-01-05 Fernando Perez <fperez@colorado.edu>
3988 2002-01-05 Fernando Perez <fperez@colorado.edu>
3978
3989
3979 * Released 0.2.4.
3990 * Released 0.2.4.
3980
3991
3981 * IPython/iplib.py (Magic.magic_pdef):
3992 * IPython/iplib.py (Magic.magic_pdef):
3982 (InteractiveShell.safe_execfile): report magic lines and error
3993 (InteractiveShell.safe_execfile): report magic lines and error
3983 lines without line numbers so one can easily copy/paste them for
3994 lines without line numbers so one can easily copy/paste them for
3984 re-execution.
3995 re-execution.
3985
3996
3986 * Updated manual with recent changes.
3997 * Updated manual with recent changes.
3987
3998
3988 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3999 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3989 docstring printing when class? is called. Very handy for knowing
4000 docstring printing when class? is called. Very handy for knowing
3990 how to create class instances (as long as __init__ is well
4001 how to create class instances (as long as __init__ is well
3991 documented, of course :)
4002 documented, of course :)
3992 (Magic.magic_doc): print both class and constructor docstrings.
4003 (Magic.magic_doc): print both class and constructor docstrings.
3993 (Magic.magic_pdef): give constructor info if passed a class and
4004 (Magic.magic_pdef): give constructor info if passed a class and
3994 __call__ info for callable object instances.
4005 __call__ info for callable object instances.
3995
4006
3996 2002-01-04 Fernando Perez <fperez@colorado.edu>
4007 2002-01-04 Fernando Perez <fperez@colorado.edu>
3997
4008
3998 * Made deep_reload() off by default. It doesn't always work
4009 * Made deep_reload() off by default. It doesn't always work
3999 exactly as intended, so it's probably safer to have it off. It's
4010 exactly as intended, so it's probably safer to have it off. It's
4000 still available as dreload() anyway, so nothing is lost.
4011 still available as dreload() anyway, so nothing is lost.
4001
4012
4002 2002-01-02 Fernando Perez <fperez@colorado.edu>
4013 2002-01-02 Fernando Perez <fperez@colorado.edu>
4003
4014
4004 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4015 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4005 so I wanted an updated release).
4016 so I wanted an updated release).
4006
4017
4007 2001-12-27 Fernando Perez <fperez@colorado.edu>
4018 2001-12-27 Fernando Perez <fperez@colorado.edu>
4008
4019
4009 * IPython/iplib.py (InteractiveShell.interact): Added the original
4020 * IPython/iplib.py (InteractiveShell.interact): Added the original
4010 code from 'code.py' for this module in order to change the
4021 code from 'code.py' for this module in order to change the
4011 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4022 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4012 the history cache would break when the user hit Ctrl-C, and
4023 the history cache would break when the user hit Ctrl-C, and
4013 interact() offers no way to add any hooks to it.
4024 interact() offers no way to add any hooks to it.
4014
4025
4015 2001-12-23 Fernando Perez <fperez@colorado.edu>
4026 2001-12-23 Fernando Perez <fperez@colorado.edu>
4016
4027
4017 * setup.py: added check for 'MANIFEST' before trying to remove
4028 * setup.py: added check for 'MANIFEST' before trying to remove
4018 it. Thanks to Sean Reifschneider.
4029 it. Thanks to Sean Reifschneider.
4019
4030
4020 2001-12-22 Fernando Perez <fperez@colorado.edu>
4031 2001-12-22 Fernando Perez <fperez@colorado.edu>
4021
4032
4022 * Released 0.2.2.
4033 * Released 0.2.2.
4023
4034
4024 * Finished (reasonably) writing the manual. Later will add the
4035 * Finished (reasonably) writing the manual. Later will add the
4025 python-standard navigation stylesheets, but for the time being
4036 python-standard navigation stylesheets, but for the time being
4026 it's fairly complete. Distribution will include html and pdf
4037 it's fairly complete. Distribution will include html and pdf
4027 versions.
4038 versions.
4028
4039
4029 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4040 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4030 (MayaVi author).
4041 (MayaVi author).
4031
4042
4032 2001-12-21 Fernando Perez <fperez@colorado.edu>
4043 2001-12-21 Fernando Perez <fperez@colorado.edu>
4033
4044
4034 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4045 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4035 good public release, I think (with the manual and the distutils
4046 good public release, I think (with the manual and the distutils
4036 installer). The manual can use some work, but that can go
4047 installer). The manual can use some work, but that can go
4037 slowly. Otherwise I think it's quite nice for end users. Next
4048 slowly. Otherwise I think it's quite nice for end users. Next
4038 summer, rewrite the guts of it...
4049 summer, rewrite the guts of it...
4039
4050
4040 * Changed format of ipythonrc files to use whitespace as the
4051 * Changed format of ipythonrc files to use whitespace as the
4041 separator instead of an explicit '='. Cleaner.
4052 separator instead of an explicit '='. Cleaner.
4042
4053
4043 2001-12-20 Fernando Perez <fperez@colorado.edu>
4054 2001-12-20 Fernando Perez <fperez@colorado.edu>
4044
4055
4045 * Started a manual in LyX. For now it's just a quick merge of the
4056 * Started a manual in LyX. For now it's just a quick merge of the
4046 various internal docstrings and READMEs. Later it may grow into a
4057 various internal docstrings and READMEs. Later it may grow into a
4047 nice, full-blown manual.
4058 nice, full-blown manual.
4048
4059
4049 * Set up a distutils based installer. Installation should now be
4060 * Set up a distutils based installer. Installation should now be
4050 trivially simple for end-users.
4061 trivially simple for end-users.
4051
4062
4052 2001-12-11 Fernando Perez <fperez@colorado.edu>
4063 2001-12-11 Fernando Perez <fperez@colorado.edu>
4053
4064
4054 * Released 0.2.0. First public release, announced it at
4065 * Released 0.2.0. First public release, announced it at
4055 comp.lang.python. From now on, just bugfixes...
4066 comp.lang.python. From now on, just bugfixes...
4056
4067
4057 * Went through all the files, set copyright/license notices and
4068 * Went through all the files, set copyright/license notices and
4058 cleaned up things. Ready for release.
4069 cleaned up things. Ready for release.
4059
4070
4060 2001-12-10 Fernando Perez <fperez@colorado.edu>
4071 2001-12-10 Fernando Perez <fperez@colorado.edu>
4061
4072
4062 * Changed the first-time installer not to use tarfiles. It's more
4073 * Changed the first-time installer not to use tarfiles. It's more
4063 robust now and less unix-dependent. Also makes it easier for
4074 robust now and less unix-dependent. Also makes it easier for
4064 people to later upgrade versions.
4075 people to later upgrade versions.
4065
4076
4066 * Changed @exit to @abort to reflect the fact that it's pretty
4077 * Changed @exit to @abort to reflect the fact that it's pretty
4067 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4078 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4068 becomes significant only when IPyhton is embedded: in that case,
4079 becomes significant only when IPyhton is embedded: in that case,
4069 C-D closes IPython only, but @abort kills the enclosing program
4080 C-D closes IPython only, but @abort kills the enclosing program
4070 too (unless it had called IPython inside a try catching
4081 too (unless it had called IPython inside a try catching
4071 SystemExit).
4082 SystemExit).
4072
4083
4073 * Created Shell module which exposes the actuall IPython Shell
4084 * Created Shell module which exposes the actuall IPython Shell
4074 classes, currently the normal and the embeddable one. This at
4085 classes, currently the normal and the embeddable one. This at
4075 least offers a stable interface we won't need to change when
4086 least offers a stable interface we won't need to change when
4076 (later) the internals are rewritten. That rewrite will be confined
4087 (later) the internals are rewritten. That rewrite will be confined
4077 to iplib and ipmaker, but the Shell interface should remain as is.
4088 to iplib and ipmaker, but the Shell interface should remain as is.
4078
4089
4079 * Added embed module which offers an embeddable IPShell object,
4090 * Added embed module which offers an embeddable IPShell object,
4080 useful to fire up IPython *inside* a running program. Great for
4091 useful to fire up IPython *inside* a running program. Great for
4081 debugging or dynamical data analysis.
4092 debugging or dynamical data analysis.
4082
4093
4083 2001-12-08 Fernando Perez <fperez@colorado.edu>
4094 2001-12-08 Fernando Perez <fperez@colorado.edu>
4084
4095
4085 * Fixed small bug preventing seeing info from methods of defined
4096 * Fixed small bug preventing seeing info from methods of defined
4086 objects (incorrect namespace in _ofind()).
4097 objects (incorrect namespace in _ofind()).
4087
4098
4088 * Documentation cleanup. Moved the main usage docstrings to a
4099 * Documentation cleanup. Moved the main usage docstrings to a
4089 separate file, usage.py (cleaner to maintain, and hopefully in the
4100 separate file, usage.py (cleaner to maintain, and hopefully in the
4090 future some perlpod-like way of producing interactive, man and
4101 future some perlpod-like way of producing interactive, man and
4091 html docs out of it will be found).
4102 html docs out of it will be found).
4092
4103
4093 * Added @profile to see your profile at any time.
4104 * Added @profile to see your profile at any time.
4094
4105
4095 * Added @p as an alias for 'print'. It's especially convenient if
4106 * Added @p as an alias for 'print'. It's especially convenient if
4096 using automagic ('p x' prints x).
4107 using automagic ('p x' prints x).
4097
4108
4098 * Small cleanups and fixes after a pychecker run.
4109 * Small cleanups and fixes after a pychecker run.
4099
4110
4100 * Changed the @cd command to handle @cd - and @cd -<n> for
4111 * Changed the @cd command to handle @cd - and @cd -<n> for
4101 visiting any directory in _dh.
4112 visiting any directory in _dh.
4102
4113
4103 * Introduced _dh, a history of visited directories. @dhist prints
4114 * Introduced _dh, a history of visited directories. @dhist prints
4104 it out with numbers.
4115 it out with numbers.
4105
4116
4106 2001-12-07 Fernando Perez <fperez@colorado.edu>
4117 2001-12-07 Fernando Perez <fperez@colorado.edu>
4107
4118
4108 * Released 0.1.22
4119 * Released 0.1.22
4109
4120
4110 * Made initialization a bit more robust against invalid color
4121 * Made initialization a bit more robust against invalid color
4111 options in user input (exit, not traceback-crash).
4122 options in user input (exit, not traceback-crash).
4112
4123
4113 * Changed the bug crash reporter to write the report only in the
4124 * Changed the bug crash reporter to write the report only in the
4114 user's .ipython directory. That way IPython won't litter people's
4125 user's .ipython directory. That way IPython won't litter people's
4115 hard disks with crash files all over the place. Also print on
4126 hard disks with crash files all over the place. Also print on
4116 screen the necessary mail command.
4127 screen the necessary mail command.
4117
4128
4118 * With the new ultraTB, implemented LightBG color scheme for light
4129 * With the new ultraTB, implemented LightBG color scheme for light
4119 background terminals. A lot of people like white backgrounds, so I
4130 background terminals. A lot of people like white backgrounds, so I
4120 guess we should at least give them something readable.
4131 guess we should at least give them something readable.
4121
4132
4122 2001-12-06 Fernando Perez <fperez@colorado.edu>
4133 2001-12-06 Fernando Perez <fperez@colorado.edu>
4123
4134
4124 * Modified the structure of ultraTB. Now there's a proper class
4135 * Modified the structure of ultraTB. Now there's a proper class
4125 for tables of color schemes which allow adding schemes easily and
4136 for tables of color schemes which allow adding schemes easily and
4126 switching the active scheme without creating a new instance every
4137 switching the active scheme without creating a new instance every
4127 time (which was ridiculous). The syntax for creating new schemes
4138 time (which was ridiculous). The syntax for creating new schemes
4128 is also cleaner. I think ultraTB is finally done, with a clean
4139 is also cleaner. I think ultraTB is finally done, with a clean
4129 class structure. Names are also much cleaner (now there's proper
4140 class structure. Names are also much cleaner (now there's proper
4130 color tables, no need for every variable to also have 'color' in
4141 color tables, no need for every variable to also have 'color' in
4131 its name).
4142 its name).
4132
4143
4133 * Broke down genutils into separate files. Now genutils only
4144 * Broke down genutils into separate files. Now genutils only
4134 contains utility functions, and classes have been moved to their
4145 contains utility functions, and classes have been moved to their
4135 own files (they had enough independent functionality to warrant
4146 own files (they had enough independent functionality to warrant
4136 it): ConfigLoader, OutputTrap, Struct.
4147 it): ConfigLoader, OutputTrap, Struct.
4137
4148
4138 2001-12-05 Fernando Perez <fperez@colorado.edu>
4149 2001-12-05 Fernando Perez <fperez@colorado.edu>
4139
4150
4140 * IPython turns 21! Released version 0.1.21, as a candidate for
4151 * IPython turns 21! Released version 0.1.21, as a candidate for
4141 public consumption. If all goes well, release in a few days.
4152 public consumption. If all goes well, release in a few days.
4142
4153
4143 * Fixed path bug (files in Extensions/ directory wouldn't be found
4154 * Fixed path bug (files in Extensions/ directory wouldn't be found
4144 unless IPython/ was explicitly in sys.path).
4155 unless IPython/ was explicitly in sys.path).
4145
4156
4146 * Extended the FlexCompleter class as MagicCompleter to allow
4157 * Extended the FlexCompleter class as MagicCompleter to allow
4147 completion of @-starting lines.
4158 completion of @-starting lines.
4148
4159
4149 * Created __release__.py file as a central repository for release
4160 * Created __release__.py file as a central repository for release
4150 info that other files can read from.
4161 info that other files can read from.
4151
4162
4152 * Fixed small bug in logging: when logging was turned on in
4163 * Fixed small bug in logging: when logging was turned on in
4153 mid-session, old lines with special meanings (!@?) were being
4164 mid-session, old lines with special meanings (!@?) were being
4154 logged without the prepended comment, which is necessary since
4165 logged without the prepended comment, which is necessary since
4155 they are not truly valid python syntax. This should make session
4166 they are not truly valid python syntax. This should make session
4156 restores produce less errors.
4167 restores produce less errors.
4157
4168
4158 * The namespace cleanup forced me to make a FlexCompleter class
4169 * The namespace cleanup forced me to make a FlexCompleter class
4159 which is nothing but a ripoff of rlcompleter, but with selectable
4170 which is nothing but a ripoff of rlcompleter, but with selectable
4160 namespace (rlcompleter only works in __main__.__dict__). I'll try
4171 namespace (rlcompleter only works in __main__.__dict__). I'll try
4161 to submit a note to the authors to see if this change can be
4172 to submit a note to the authors to see if this change can be
4162 incorporated in future rlcompleter releases (Dec.6: done)
4173 incorporated in future rlcompleter releases (Dec.6: done)
4163
4174
4164 * More fixes to namespace handling. It was a mess! Now all
4175 * More fixes to namespace handling. It was a mess! Now all
4165 explicit references to __main__.__dict__ are gone (except when
4176 explicit references to __main__.__dict__ are gone (except when
4166 really needed) and everything is handled through the namespace
4177 really needed) and everything is handled through the namespace
4167 dicts in the IPython instance. We seem to be getting somewhere
4178 dicts in the IPython instance. We seem to be getting somewhere
4168 with this, finally...
4179 with this, finally...
4169
4180
4170 * Small documentation updates.
4181 * Small documentation updates.
4171
4182
4172 * Created the Extensions directory under IPython (with an
4183 * Created the Extensions directory under IPython (with an
4173 __init__.py). Put the PhysicalQ stuff there. This directory should
4184 __init__.py). Put the PhysicalQ stuff there. This directory should
4174 be used for all special-purpose extensions.
4185 be used for all special-purpose extensions.
4175
4186
4176 * File renaming:
4187 * File renaming:
4177 ipythonlib --> ipmaker
4188 ipythonlib --> ipmaker
4178 ipplib --> iplib
4189 ipplib --> iplib
4179 This makes a bit more sense in terms of what these files actually do.
4190 This makes a bit more sense in terms of what these files actually do.
4180
4191
4181 * Moved all the classes and functions in ipythonlib to ipplib, so
4192 * Moved all the classes and functions in ipythonlib to ipplib, so
4182 now ipythonlib only has make_IPython(). This will ease up its
4193 now ipythonlib only has make_IPython(). This will ease up its
4183 splitting in smaller functional chunks later.
4194 splitting in smaller functional chunks later.
4184
4195
4185 * Cleaned up (done, I think) output of @whos. Better column
4196 * Cleaned up (done, I think) output of @whos. Better column
4186 formatting, and now shows str(var) for as much as it can, which is
4197 formatting, and now shows str(var) for as much as it can, which is
4187 typically what one gets with a 'print var'.
4198 typically what one gets with a 'print var'.
4188
4199
4189 2001-12-04 Fernando Perez <fperez@colorado.edu>
4200 2001-12-04 Fernando Perez <fperez@colorado.edu>
4190
4201
4191 * Fixed namespace problems. Now builtin/IPyhton/user names get
4202 * Fixed namespace problems. Now builtin/IPyhton/user names get
4192 properly reported in their namespace. Internal namespace handling
4203 properly reported in their namespace. Internal namespace handling
4193 is finally getting decent (not perfect yet, but much better than
4204 is finally getting decent (not perfect yet, but much better than
4194 the ad-hoc mess we had).
4205 the ad-hoc mess we had).
4195
4206
4196 * Removed -exit option. If people just want to run a python
4207 * Removed -exit option. If people just want to run a python
4197 script, that's what the normal interpreter is for. Less
4208 script, that's what the normal interpreter is for. Less
4198 unnecessary options, less chances for bugs.
4209 unnecessary options, less chances for bugs.
4199
4210
4200 * Added a crash handler which generates a complete post-mortem if
4211 * Added a crash handler which generates a complete post-mortem if
4201 IPython crashes. This will help a lot in tracking bugs down the
4212 IPython crashes. This will help a lot in tracking bugs down the
4202 road.
4213 road.
4203
4214
4204 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4215 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4205 which were boud to functions being reassigned would bypass the
4216 which were boud to functions being reassigned would bypass the
4206 logger, breaking the sync of _il with the prompt counter. This
4217 logger, breaking the sync of _il with the prompt counter. This
4207 would then crash IPython later when a new line was logged.
4218 would then crash IPython later when a new line was logged.
4208
4219
4209 2001-12-02 Fernando Perez <fperez@colorado.edu>
4220 2001-12-02 Fernando Perez <fperez@colorado.edu>
4210
4221
4211 * Made IPython a package. This means people don't have to clutter
4222 * Made IPython a package. This means people don't have to clutter
4212 their sys.path with yet another directory. Changed the INSTALL
4223 their sys.path with yet another directory. Changed the INSTALL
4213 file accordingly.
4224 file accordingly.
4214
4225
4215 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4226 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4216 sorts its output (so @who shows it sorted) and @whos formats the
4227 sorts its output (so @who shows it sorted) and @whos formats the
4217 table according to the width of the first column. Nicer, easier to
4228 table according to the width of the first column. Nicer, easier to
4218 read. Todo: write a generic table_format() which takes a list of
4229 read. Todo: write a generic table_format() which takes a list of
4219 lists and prints it nicely formatted, with optional row/column
4230 lists and prints it nicely formatted, with optional row/column
4220 separators and proper padding and justification.
4231 separators and proper padding and justification.
4221
4232
4222 * Released 0.1.20
4233 * Released 0.1.20
4223
4234
4224 * Fixed bug in @log which would reverse the inputcache list (a
4235 * Fixed bug in @log which would reverse the inputcache list (a
4225 copy operation was missing).
4236 copy operation was missing).
4226
4237
4227 * Code cleanup. @config was changed to use page(). Better, since
4238 * Code cleanup. @config was changed to use page(). Better, since
4228 its output is always quite long.
4239 its output is always quite long.
4229
4240
4230 * Itpl is back as a dependency. I was having too many problems
4241 * Itpl is back as a dependency. I was having too many problems
4231 getting the parametric aliases to work reliably, and it's just
4242 getting the parametric aliases to work reliably, and it's just
4232 easier to code weird string operations with it than playing %()s
4243 easier to code weird string operations with it than playing %()s
4233 games. It's only ~6k, so I don't think it's too big a deal.
4244 games. It's only ~6k, so I don't think it's too big a deal.
4234
4245
4235 * Found (and fixed) a very nasty bug with history. !lines weren't
4246 * Found (and fixed) a very nasty bug with history. !lines weren't
4236 getting cached, and the out of sync caches would crash
4247 getting cached, and the out of sync caches would crash
4237 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4248 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4238 division of labor a bit better. Bug fixed, cleaner structure.
4249 division of labor a bit better. Bug fixed, cleaner structure.
4239
4250
4240 2001-12-01 Fernando Perez <fperez@colorado.edu>
4251 2001-12-01 Fernando Perez <fperez@colorado.edu>
4241
4252
4242 * Released 0.1.19
4253 * Released 0.1.19
4243
4254
4244 * Added option -n to @hist to prevent line number printing. Much
4255 * Added option -n to @hist to prevent line number printing. Much
4245 easier to copy/paste code this way.
4256 easier to copy/paste code this way.
4246
4257
4247 * Created global _il to hold the input list. Allows easy
4258 * Created global _il to hold the input list. Allows easy
4248 re-execution of blocks of code by slicing it (inspired by Janko's
4259 re-execution of blocks of code by slicing it (inspired by Janko's
4249 comment on 'macros').
4260 comment on 'macros').
4250
4261
4251 * Small fixes and doc updates.
4262 * Small fixes and doc updates.
4252
4263
4253 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4264 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4254 much too fragile with automagic. Handles properly multi-line
4265 much too fragile with automagic. Handles properly multi-line
4255 statements and takes parameters.
4266 statements and takes parameters.
4256
4267
4257 2001-11-30 Fernando Perez <fperez@colorado.edu>
4268 2001-11-30 Fernando Perez <fperez@colorado.edu>
4258
4269
4259 * Version 0.1.18 released.
4270 * Version 0.1.18 released.
4260
4271
4261 * Fixed nasty namespace bug in initial module imports.
4272 * Fixed nasty namespace bug in initial module imports.
4262
4273
4263 * Added copyright/license notes to all code files (except
4274 * Added copyright/license notes to all code files (except
4264 DPyGetOpt). For the time being, LGPL. That could change.
4275 DPyGetOpt). For the time being, LGPL. That could change.
4265
4276
4266 * Rewrote a much nicer README, updated INSTALL, cleaned up
4277 * Rewrote a much nicer README, updated INSTALL, cleaned up
4267 ipythonrc-* samples.
4278 ipythonrc-* samples.
4268
4279
4269 * Overall code/documentation cleanup. Basically ready for
4280 * Overall code/documentation cleanup. Basically ready for
4270 release. Only remaining thing: licence decision (LGPL?).
4281 release. Only remaining thing: licence decision (LGPL?).
4271
4282
4272 * Converted load_config to a class, ConfigLoader. Now recursion
4283 * Converted load_config to a class, ConfigLoader. Now recursion
4273 control is better organized. Doesn't include the same file twice.
4284 control is better organized. Doesn't include the same file twice.
4274
4285
4275 2001-11-29 Fernando Perez <fperez@colorado.edu>
4286 2001-11-29 Fernando Perez <fperez@colorado.edu>
4276
4287
4277 * Got input history working. Changed output history variables from
4288 * Got input history working. Changed output history variables from
4278 _p to _o so that _i is for input and _o for output. Just cleaner
4289 _p to _o so that _i is for input and _o for output. Just cleaner
4279 convention.
4290 convention.
4280
4291
4281 * Implemented parametric aliases. This pretty much allows the
4292 * Implemented parametric aliases. This pretty much allows the
4282 alias system to offer full-blown shell convenience, I think.
4293 alias system to offer full-blown shell convenience, I think.
4283
4294
4284 * Version 0.1.17 released, 0.1.18 opened.
4295 * Version 0.1.17 released, 0.1.18 opened.
4285
4296
4286 * dot_ipython/ipythonrc (alias): added documentation.
4297 * dot_ipython/ipythonrc (alias): added documentation.
4287 (xcolor): Fixed small bug (xcolors -> xcolor)
4298 (xcolor): Fixed small bug (xcolors -> xcolor)
4288
4299
4289 * Changed the alias system. Now alias is a magic command to define
4300 * Changed the alias system. Now alias is a magic command to define
4290 aliases just like the shell. Rationale: the builtin magics should
4301 aliases just like the shell. Rationale: the builtin magics should
4291 be there for things deeply connected to IPython's
4302 be there for things deeply connected to IPython's
4292 architecture. And this is a much lighter system for what I think
4303 architecture. And this is a much lighter system for what I think
4293 is the really important feature: allowing users to define quickly
4304 is the really important feature: allowing users to define quickly
4294 magics that will do shell things for them, so they can customize
4305 magics that will do shell things for them, so they can customize
4295 IPython easily to match their work habits. If someone is really
4306 IPython easily to match their work habits. If someone is really
4296 desperate to have another name for a builtin alias, they can
4307 desperate to have another name for a builtin alias, they can
4297 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4308 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4298 works.
4309 works.
4299
4310
4300 2001-11-28 Fernando Perez <fperez@colorado.edu>
4311 2001-11-28 Fernando Perez <fperez@colorado.edu>
4301
4312
4302 * Changed @file so that it opens the source file at the proper
4313 * Changed @file so that it opens the source file at the proper
4303 line. Since it uses less, if your EDITOR environment is
4314 line. Since it uses less, if your EDITOR environment is
4304 configured, typing v will immediately open your editor of choice
4315 configured, typing v will immediately open your editor of choice
4305 right at the line where the object is defined. Not as quick as
4316 right at the line where the object is defined. Not as quick as
4306 having a direct @edit command, but for all intents and purposes it
4317 having a direct @edit command, but for all intents and purposes it
4307 works. And I don't have to worry about writing @edit to deal with
4318 works. And I don't have to worry about writing @edit to deal with
4308 all the editors, less does that.
4319 all the editors, less does that.
4309
4320
4310 * Version 0.1.16 released, 0.1.17 opened.
4321 * Version 0.1.16 released, 0.1.17 opened.
4311
4322
4312 * Fixed some nasty bugs in the page/page_dumb combo that could
4323 * Fixed some nasty bugs in the page/page_dumb combo that could
4313 crash IPython.
4324 crash IPython.
4314
4325
4315 2001-11-27 Fernando Perez <fperez@colorado.edu>
4326 2001-11-27 Fernando Perez <fperez@colorado.edu>
4316
4327
4317 * Version 0.1.15 released, 0.1.16 opened.
4328 * Version 0.1.15 released, 0.1.16 opened.
4318
4329
4319 * Finally got ? and ?? to work for undefined things: now it's
4330 * Finally got ? and ?? to work for undefined things: now it's
4320 possible to type {}.get? and get information about the get method
4331 possible to type {}.get? and get information about the get method
4321 of dicts, or os.path? even if only os is defined (so technically
4332 of dicts, or os.path? even if only os is defined (so technically
4322 os.path isn't). Works at any level. For example, after import os,
4333 os.path isn't). Works at any level. For example, after import os,
4323 os?, os.path?, os.path.abspath? all work. This is great, took some
4334 os?, os.path?, os.path.abspath? all work. This is great, took some
4324 work in _ofind.
4335 work in _ofind.
4325
4336
4326 * Fixed more bugs with logging. The sanest way to do it was to add
4337 * Fixed more bugs with logging. The sanest way to do it was to add
4327 to @log a 'mode' parameter. Killed two in one shot (this mode
4338 to @log a 'mode' parameter. Killed two in one shot (this mode
4328 option was a request of Janko's). I think it's finally clean
4339 option was a request of Janko's). I think it's finally clean
4329 (famous last words).
4340 (famous last words).
4330
4341
4331 * Added a page_dumb() pager which does a decent job of paging on
4342 * Added a page_dumb() pager which does a decent job of paging on
4332 screen, if better things (like less) aren't available. One less
4343 screen, if better things (like less) aren't available. One less
4333 unix dependency (someday maybe somebody will port this to
4344 unix dependency (someday maybe somebody will port this to
4334 windows).
4345 windows).
4335
4346
4336 * Fixed problem in magic_log: would lock of logging out if log
4347 * Fixed problem in magic_log: would lock of logging out if log
4337 creation failed (because it would still think it had succeeded).
4348 creation failed (because it would still think it had succeeded).
4338
4349
4339 * Improved the page() function using curses to auto-detect screen
4350 * Improved the page() function using curses to auto-detect screen
4340 size. Now it can make a much better decision on whether to print
4351 size. Now it can make a much better decision on whether to print
4341 or page a string. Option screen_length was modified: a value 0
4352 or page a string. Option screen_length was modified: a value 0
4342 means auto-detect, and that's the default now.
4353 means auto-detect, and that's the default now.
4343
4354
4344 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4355 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4345 go out. I'll test it for a few days, then talk to Janko about
4356 go out. I'll test it for a few days, then talk to Janko about
4346 licences and announce it.
4357 licences and announce it.
4347
4358
4348 * Fixed the length of the auto-generated ---> prompt which appears
4359 * Fixed the length of the auto-generated ---> prompt which appears
4349 for auto-parens and auto-quotes. Getting this right isn't trivial,
4360 for auto-parens and auto-quotes. Getting this right isn't trivial,
4350 with all the color escapes, different prompt types and optional
4361 with all the color escapes, different prompt types and optional
4351 separators. But it seems to be working in all the combinations.
4362 separators. But it seems to be working in all the combinations.
4352
4363
4353 2001-11-26 Fernando Perez <fperez@colorado.edu>
4364 2001-11-26 Fernando Perez <fperez@colorado.edu>
4354
4365
4355 * Wrote a regexp filter to get option types from the option names
4366 * Wrote a regexp filter to get option types from the option names
4356 string. This eliminates the need to manually keep two duplicate
4367 string. This eliminates the need to manually keep two duplicate
4357 lists.
4368 lists.
4358
4369
4359 * Removed the unneeded check_option_names. Now options are handled
4370 * Removed the unneeded check_option_names. Now options are handled
4360 in a much saner manner and it's easy to visually check that things
4371 in a much saner manner and it's easy to visually check that things
4361 are ok.
4372 are ok.
4362
4373
4363 * Updated version numbers on all files I modified to carry a
4374 * Updated version numbers on all files I modified to carry a
4364 notice so Janko and Nathan have clear version markers.
4375 notice so Janko and Nathan have clear version markers.
4365
4376
4366 * Updated docstring for ultraTB with my changes. I should send
4377 * Updated docstring for ultraTB with my changes. I should send
4367 this to Nathan.
4378 this to Nathan.
4368
4379
4369 * Lots of small fixes. Ran everything through pychecker again.
4380 * Lots of small fixes. Ran everything through pychecker again.
4370
4381
4371 * Made loading of deep_reload an cmd line option. If it's not too
4382 * Made loading of deep_reload an cmd line option. If it's not too
4372 kosher, now people can just disable it. With -nodeep_reload it's
4383 kosher, now people can just disable it. With -nodeep_reload it's
4373 still available as dreload(), it just won't overwrite reload().
4384 still available as dreload(), it just won't overwrite reload().
4374
4385
4375 * Moved many options to the no| form (-opt and -noopt
4386 * Moved many options to the no| form (-opt and -noopt
4376 accepted). Cleaner.
4387 accepted). Cleaner.
4377
4388
4378 * Changed magic_log so that if called with no parameters, it uses
4389 * Changed magic_log so that if called with no parameters, it uses
4379 'rotate' mode. That way auto-generated logs aren't automatically
4390 'rotate' mode. That way auto-generated logs aren't automatically
4380 over-written. For normal logs, now a backup is made if it exists
4391 over-written. For normal logs, now a backup is made if it exists
4381 (only 1 level of backups). A new 'backup' mode was added to the
4392 (only 1 level of backups). A new 'backup' mode was added to the
4382 Logger class to support this. This was a request by Janko.
4393 Logger class to support this. This was a request by Janko.
4383
4394
4384 * Added @logoff/@logon to stop/restart an active log.
4395 * Added @logoff/@logon to stop/restart an active log.
4385
4396
4386 * Fixed a lot of bugs in log saving/replay. It was pretty
4397 * Fixed a lot of bugs in log saving/replay. It was pretty
4387 broken. Now special lines (!@,/) appear properly in the command
4398 broken. Now special lines (!@,/) appear properly in the command
4388 history after a log replay.
4399 history after a log replay.
4389
4400
4390 * Tried and failed to implement full session saving via pickle. My
4401 * Tried and failed to implement full session saving via pickle. My
4391 idea was to pickle __main__.__dict__, but modules can't be
4402 idea was to pickle __main__.__dict__, but modules can't be
4392 pickled. This would be a better alternative to replaying logs, but
4403 pickled. This would be a better alternative to replaying logs, but
4393 seems quite tricky to get to work. Changed -session to be called
4404 seems quite tricky to get to work. Changed -session to be called
4394 -logplay, which more accurately reflects what it does. And if we
4405 -logplay, which more accurately reflects what it does. And if we
4395 ever get real session saving working, -session is now available.
4406 ever get real session saving working, -session is now available.
4396
4407
4397 * Implemented color schemes for prompts also. As for tracebacks,
4408 * Implemented color schemes for prompts also. As for tracebacks,
4398 currently only NoColor and Linux are supported. But now the
4409 currently only NoColor and Linux are supported. But now the
4399 infrastructure is in place, based on a generic ColorScheme
4410 infrastructure is in place, based on a generic ColorScheme
4400 class. So writing and activating new schemes both for the prompts
4411 class. So writing and activating new schemes both for the prompts
4401 and the tracebacks should be straightforward.
4412 and the tracebacks should be straightforward.
4402
4413
4403 * Version 0.1.13 released, 0.1.14 opened.
4414 * Version 0.1.13 released, 0.1.14 opened.
4404
4415
4405 * Changed handling of options for output cache. Now counter is
4416 * Changed handling of options for output cache. Now counter is
4406 hardwired starting at 1 and one specifies the maximum number of
4417 hardwired starting at 1 and one specifies the maximum number of
4407 entries *in the outcache* (not the max prompt counter). This is
4418 entries *in the outcache* (not the max prompt counter). This is
4408 much better, since many statements won't increase the cache
4419 much better, since many statements won't increase the cache
4409 count. It also eliminated some confusing options, now there's only
4420 count. It also eliminated some confusing options, now there's only
4410 one: cache_size.
4421 one: cache_size.
4411
4422
4412 * Added 'alias' magic function and magic_alias option in the
4423 * Added 'alias' magic function and magic_alias option in the
4413 ipythonrc file. Now the user can easily define whatever names he
4424 ipythonrc file. Now the user can easily define whatever names he
4414 wants for the magic functions without having to play weird
4425 wants for the magic functions without having to play weird
4415 namespace games. This gives IPython a real shell-like feel.
4426 namespace games. This gives IPython a real shell-like feel.
4416
4427
4417 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4428 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4418 @ or not).
4429 @ or not).
4419
4430
4420 This was one of the last remaining 'visible' bugs (that I know
4431 This was one of the last remaining 'visible' bugs (that I know
4421 of). I think if I can clean up the session loading so it works
4432 of). I think if I can clean up the session loading so it works
4422 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4433 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4423 about licensing).
4434 about licensing).
4424
4435
4425 2001-11-25 Fernando Perez <fperez@colorado.edu>
4436 2001-11-25 Fernando Perez <fperez@colorado.edu>
4426
4437
4427 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4438 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4428 there's a cleaner distinction between what ? and ?? show.
4439 there's a cleaner distinction between what ? and ?? show.
4429
4440
4430 * Added screen_length option. Now the user can define his own
4441 * Added screen_length option. Now the user can define his own
4431 screen size for page() operations.
4442 screen size for page() operations.
4432
4443
4433 * Implemented magic shell-like functions with automatic code
4444 * Implemented magic shell-like functions with automatic code
4434 generation. Now adding another function is just a matter of adding
4445 generation. Now adding another function is just a matter of adding
4435 an entry to a dict, and the function is dynamically generated at
4446 an entry to a dict, and the function is dynamically generated at
4436 run-time. Python has some really cool features!
4447 run-time. Python has some really cool features!
4437
4448
4438 * Renamed many options to cleanup conventions a little. Now all
4449 * Renamed many options to cleanup conventions a little. Now all
4439 are lowercase, and only underscores where needed. Also in the code
4450 are lowercase, and only underscores where needed. Also in the code
4440 option name tables are clearer.
4451 option name tables are clearer.
4441
4452
4442 * Changed prompts a little. Now input is 'In [n]:' instead of
4453 * Changed prompts a little. Now input is 'In [n]:' instead of
4443 'In[n]:='. This allows it the numbers to be aligned with the
4454 'In[n]:='. This allows it the numbers to be aligned with the
4444 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4455 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4445 Python (it was a Mathematica thing). The '...' continuation prompt
4456 Python (it was a Mathematica thing). The '...' continuation prompt
4446 was also changed a little to align better.
4457 was also changed a little to align better.
4447
4458
4448 * Fixed bug when flushing output cache. Not all _p<n> variables
4459 * Fixed bug when flushing output cache. Not all _p<n> variables
4449 exist, so their deletion needs to be wrapped in a try:
4460 exist, so their deletion needs to be wrapped in a try:
4450
4461
4451 * Figured out how to properly use inspect.formatargspec() (it
4462 * Figured out how to properly use inspect.formatargspec() (it
4452 requires the args preceded by *). So I removed all the code from
4463 requires the args preceded by *). So I removed all the code from
4453 _get_pdef in Magic, which was just replicating that.
4464 _get_pdef in Magic, which was just replicating that.
4454
4465
4455 * Added test to prefilter to allow redefining magic function names
4466 * Added test to prefilter to allow redefining magic function names
4456 as variables. This is ok, since the @ form is always available,
4467 as variables. This is ok, since the @ form is always available,
4457 but whe should allow the user to define a variable called 'ls' if
4468 but whe should allow the user to define a variable called 'ls' if
4458 he needs it.
4469 he needs it.
4459
4470
4460 * Moved the ToDo information from README into a separate ToDo.
4471 * Moved the ToDo information from README into a separate ToDo.
4461
4472
4462 * General code cleanup and small bugfixes. I think it's close to a
4473 * General code cleanup and small bugfixes. I think it's close to a
4463 state where it can be released, obviously with a big 'beta'
4474 state where it can be released, obviously with a big 'beta'
4464 warning on it.
4475 warning on it.
4465
4476
4466 * Got the magic function split to work. Now all magics are defined
4477 * Got the magic function split to work. Now all magics are defined
4467 in a separate class. It just organizes things a bit, and now
4478 in a separate class. It just organizes things a bit, and now
4468 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4479 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4469 was too long).
4480 was too long).
4470
4481
4471 * Changed @clear to @reset to avoid potential confusions with
4482 * Changed @clear to @reset to avoid potential confusions with
4472 the shell command clear. Also renamed @cl to @clear, which does
4483 the shell command clear. Also renamed @cl to @clear, which does
4473 exactly what people expect it to from their shell experience.
4484 exactly what people expect it to from their shell experience.
4474
4485
4475 Added a check to the @reset command (since it's so
4486 Added a check to the @reset command (since it's so
4476 destructive, it's probably a good idea to ask for confirmation).
4487 destructive, it's probably a good idea to ask for confirmation).
4477 But now reset only works for full namespace resetting. Since the
4488 But now reset only works for full namespace resetting. Since the
4478 del keyword is already there for deleting a few specific
4489 del keyword is already there for deleting a few specific
4479 variables, I don't see the point of having a redundant magic
4490 variables, I don't see the point of having a redundant magic
4480 function for the same task.
4491 function for the same task.
4481
4492
4482 2001-11-24 Fernando Perez <fperez@colorado.edu>
4493 2001-11-24 Fernando Perez <fperez@colorado.edu>
4483
4494
4484 * Updated the builtin docs (esp. the ? ones).
4495 * Updated the builtin docs (esp. the ? ones).
4485
4496
4486 * Ran all the code through pychecker. Not terribly impressed with
4497 * Ran all the code through pychecker. Not terribly impressed with
4487 it: lots of spurious warnings and didn't really find anything of
4498 it: lots of spurious warnings and didn't really find anything of
4488 substance (just a few modules being imported and not used).
4499 substance (just a few modules being imported and not used).
4489
4500
4490 * Implemented the new ultraTB functionality into IPython. New
4501 * Implemented the new ultraTB functionality into IPython. New
4491 option: xcolors. This chooses color scheme. xmode now only selects
4502 option: xcolors. This chooses color scheme. xmode now only selects
4492 between Plain and Verbose. Better orthogonality.
4503 between Plain and Verbose. Better orthogonality.
4493
4504
4494 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4505 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4495 mode and color scheme for the exception handlers. Now it's
4506 mode and color scheme for the exception handlers. Now it's
4496 possible to have the verbose traceback with no coloring.
4507 possible to have the verbose traceback with no coloring.
4497
4508
4498 2001-11-23 Fernando Perez <fperez@colorado.edu>
4509 2001-11-23 Fernando Perez <fperez@colorado.edu>
4499
4510
4500 * Version 0.1.12 released, 0.1.13 opened.
4511 * Version 0.1.12 released, 0.1.13 opened.
4501
4512
4502 * Removed option to set auto-quote and auto-paren escapes by
4513 * Removed option to set auto-quote and auto-paren escapes by
4503 user. The chances of breaking valid syntax are just too high. If
4514 user. The chances of breaking valid syntax are just too high. If
4504 someone *really* wants, they can always dig into the code.
4515 someone *really* wants, they can always dig into the code.
4505
4516
4506 * Made prompt separators configurable.
4517 * Made prompt separators configurable.
4507
4518
4508 2001-11-22 Fernando Perez <fperez@colorado.edu>
4519 2001-11-22 Fernando Perez <fperez@colorado.edu>
4509
4520
4510 * Small bugfixes in many places.
4521 * Small bugfixes in many places.
4511
4522
4512 * Removed the MyCompleter class from ipplib. It seemed redundant
4523 * Removed the MyCompleter class from ipplib. It seemed redundant
4513 with the C-p,C-n history search functionality. Less code to
4524 with the C-p,C-n history search functionality. Less code to
4514 maintain.
4525 maintain.
4515
4526
4516 * Moved all the original ipython.py code into ipythonlib.py. Right
4527 * Moved all the original ipython.py code into ipythonlib.py. Right
4517 now it's just one big dump into a function called make_IPython, so
4528 now it's just one big dump into a function called make_IPython, so
4518 no real modularity has been gained. But at least it makes the
4529 no real modularity has been gained. But at least it makes the
4519 wrapper script tiny, and since ipythonlib is a module, it gets
4530 wrapper script tiny, and since ipythonlib is a module, it gets
4520 compiled and startup is much faster.
4531 compiled and startup is much faster.
4521
4532
4522 This is a reasobably 'deep' change, so we should test it for a
4533 This is a reasobably 'deep' change, so we should test it for a
4523 while without messing too much more with the code.
4534 while without messing too much more with the code.
4524
4535
4525 2001-11-21 Fernando Perez <fperez@colorado.edu>
4536 2001-11-21 Fernando Perez <fperez@colorado.edu>
4526
4537
4527 * Version 0.1.11 released, 0.1.12 opened for further work.
4538 * Version 0.1.11 released, 0.1.12 opened for further work.
4528
4539
4529 * Removed dependency on Itpl. It was only needed in one place. It
4540 * Removed dependency on Itpl. It was only needed in one place. It
4530 would be nice if this became part of python, though. It makes life
4541 would be nice if this became part of python, though. It makes life
4531 *a lot* easier in some cases.
4542 *a lot* easier in some cases.
4532
4543
4533 * Simplified the prefilter code a bit. Now all handlers are
4544 * Simplified the prefilter code a bit. Now all handlers are
4534 expected to explicitly return a value (at least a blank string).
4545 expected to explicitly return a value (at least a blank string).
4535
4546
4536 * Heavy edits in ipplib. Removed the help system altogether. Now
4547 * Heavy edits in ipplib. Removed the help system altogether. Now
4537 obj?/?? is used for inspecting objects, a magic @doc prints
4548 obj?/?? is used for inspecting objects, a magic @doc prints
4538 docstrings, and full-blown Python help is accessed via the 'help'
4549 docstrings, and full-blown Python help is accessed via the 'help'
4539 keyword. This cleans up a lot of code (less to maintain) and does
4550 keyword. This cleans up a lot of code (less to maintain) and does
4540 the job. Since 'help' is now a standard Python component, might as
4551 the job. Since 'help' is now a standard Python component, might as
4541 well use it and remove duplicate functionality.
4552 well use it and remove duplicate functionality.
4542
4553
4543 Also removed the option to use ipplib as a standalone program. By
4554 Also removed the option to use ipplib as a standalone program. By
4544 now it's too dependent on other parts of IPython to function alone.
4555 now it's too dependent on other parts of IPython to function alone.
4545
4556
4546 * Fixed bug in genutils.pager. It would crash if the pager was
4557 * Fixed bug in genutils.pager. It would crash if the pager was
4547 exited immediately after opening (broken pipe).
4558 exited immediately after opening (broken pipe).
4548
4559
4549 * Trimmed down the VerboseTB reporting a little. The header is
4560 * Trimmed down the VerboseTB reporting a little. The header is
4550 much shorter now and the repeated exception arguments at the end
4561 much shorter now and the repeated exception arguments at the end
4551 have been removed. For interactive use the old header seemed a bit
4562 have been removed. For interactive use the old header seemed a bit
4552 excessive.
4563 excessive.
4553
4564
4554 * Fixed small bug in output of @whos for variables with multi-word
4565 * Fixed small bug in output of @whos for variables with multi-word
4555 types (only first word was displayed).
4566 types (only first word was displayed).
4556
4567
4557 2001-11-17 Fernando Perez <fperez@colorado.edu>
4568 2001-11-17 Fernando Perez <fperez@colorado.edu>
4558
4569
4559 * Version 0.1.10 released, 0.1.11 opened for further work.
4570 * Version 0.1.10 released, 0.1.11 opened for further work.
4560
4571
4561 * Modified dirs and friends. dirs now *returns* the stack (not
4572 * Modified dirs and friends. dirs now *returns* the stack (not
4562 prints), so one can manipulate it as a variable. Convenient to
4573 prints), so one can manipulate it as a variable. Convenient to
4563 travel along many directories.
4574 travel along many directories.
4564
4575
4565 * Fixed bug in magic_pdef: would only work with functions with
4576 * Fixed bug in magic_pdef: would only work with functions with
4566 arguments with default values.
4577 arguments with default values.
4567
4578
4568 2001-11-14 Fernando Perez <fperez@colorado.edu>
4579 2001-11-14 Fernando Perez <fperez@colorado.edu>
4569
4580
4570 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4581 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4571 example with IPython. Various other minor fixes and cleanups.
4582 example with IPython. Various other minor fixes and cleanups.
4572
4583
4573 * Version 0.1.9 released, 0.1.10 opened for further work.
4584 * Version 0.1.9 released, 0.1.10 opened for further work.
4574
4585
4575 * Added sys.path to the list of directories searched in the
4586 * Added sys.path to the list of directories searched in the
4576 execfile= option. It used to be the current directory and the
4587 execfile= option. It used to be the current directory and the
4577 user's IPYTHONDIR only.
4588 user's IPYTHONDIR only.
4578
4589
4579 2001-11-13 Fernando Perez <fperez@colorado.edu>
4590 2001-11-13 Fernando Perez <fperez@colorado.edu>
4580
4591
4581 * Reinstated the raw_input/prefilter separation that Janko had
4592 * Reinstated the raw_input/prefilter separation that Janko had
4582 initially. This gives a more convenient setup for extending the
4593 initially. This gives a more convenient setup for extending the
4583 pre-processor from the outside: raw_input always gets a string,
4594 pre-processor from the outside: raw_input always gets a string,
4584 and prefilter has to process it. We can then redefine prefilter
4595 and prefilter has to process it. We can then redefine prefilter
4585 from the outside and implement extensions for special
4596 from the outside and implement extensions for special
4586 purposes.
4597 purposes.
4587
4598
4588 Today I got one for inputting PhysicalQuantity objects
4599 Today I got one for inputting PhysicalQuantity objects
4589 (from Scientific) without needing any function calls at
4600 (from Scientific) without needing any function calls at
4590 all. Extremely convenient, and it's all done as a user-level
4601 all. Extremely convenient, and it's all done as a user-level
4591 extension (no IPython code was touched). Now instead of:
4602 extension (no IPython code was touched). Now instead of:
4592 a = PhysicalQuantity(4.2,'m/s**2')
4603 a = PhysicalQuantity(4.2,'m/s**2')
4593 one can simply say
4604 one can simply say
4594 a = 4.2 m/s**2
4605 a = 4.2 m/s**2
4595 or even
4606 or even
4596 a = 4.2 m/s^2
4607 a = 4.2 m/s^2
4597
4608
4598 I use this, but it's also a proof of concept: IPython really is
4609 I use this, but it's also a proof of concept: IPython really is
4599 fully user-extensible, even at the level of the parsing of the
4610 fully user-extensible, even at the level of the parsing of the
4600 command line. It's not trivial, but it's perfectly doable.
4611 command line. It's not trivial, but it's perfectly doable.
4601
4612
4602 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4613 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4603 the problem of modules being loaded in the inverse order in which
4614 the problem of modules being loaded in the inverse order in which
4604 they were defined in
4615 they were defined in
4605
4616
4606 * Version 0.1.8 released, 0.1.9 opened for further work.
4617 * Version 0.1.8 released, 0.1.9 opened for further work.
4607
4618
4608 * Added magics pdef, source and file. They respectively show the
4619 * Added magics pdef, source and file. They respectively show the
4609 definition line ('prototype' in C), source code and full python
4620 definition line ('prototype' in C), source code and full python
4610 file for any callable object. The object inspector oinfo uses
4621 file for any callable object. The object inspector oinfo uses
4611 these to show the same information.
4622 these to show the same information.
4612
4623
4613 * Version 0.1.7 released, 0.1.8 opened for further work.
4624 * Version 0.1.7 released, 0.1.8 opened for further work.
4614
4625
4615 * Separated all the magic functions into a class called Magic. The
4626 * Separated all the magic functions into a class called Magic. The
4616 InteractiveShell class was becoming too big for Xemacs to handle
4627 InteractiveShell class was becoming too big for Xemacs to handle
4617 (de-indenting a line would lock it up for 10 seconds while it
4628 (de-indenting a line would lock it up for 10 seconds while it
4618 backtracked on the whole class!)
4629 backtracked on the whole class!)
4619
4630
4620 FIXME: didn't work. It can be done, but right now namespaces are
4631 FIXME: didn't work. It can be done, but right now namespaces are
4621 all messed up. Do it later (reverted it for now, so at least
4632 all messed up. Do it later (reverted it for now, so at least
4622 everything works as before).
4633 everything works as before).
4623
4634
4624 * Got the object introspection system (magic_oinfo) working! I
4635 * Got the object introspection system (magic_oinfo) working! I
4625 think this is pretty much ready for release to Janko, so he can
4636 think this is pretty much ready for release to Janko, so he can
4626 test it for a while and then announce it. Pretty much 100% of what
4637 test it for a while and then announce it. Pretty much 100% of what
4627 I wanted for the 'phase 1' release is ready. Happy, tired.
4638 I wanted for the 'phase 1' release is ready. Happy, tired.
4628
4639
4629 2001-11-12 Fernando Perez <fperez@colorado.edu>
4640 2001-11-12 Fernando Perez <fperez@colorado.edu>
4630
4641
4631 * Version 0.1.6 released, 0.1.7 opened for further work.
4642 * Version 0.1.6 released, 0.1.7 opened for further work.
4632
4643
4633 * Fixed bug in printing: it used to test for truth before
4644 * Fixed bug in printing: it used to test for truth before
4634 printing, so 0 wouldn't print. Now checks for None.
4645 printing, so 0 wouldn't print. Now checks for None.
4635
4646
4636 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4647 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4637 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4648 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4638 reaches by hand into the outputcache. Think of a better way to do
4649 reaches by hand into the outputcache. Think of a better way to do
4639 this later.
4650 this later.
4640
4651
4641 * Various small fixes thanks to Nathan's comments.
4652 * Various small fixes thanks to Nathan's comments.
4642
4653
4643 * Changed magic_pprint to magic_Pprint. This way it doesn't
4654 * Changed magic_pprint to magic_Pprint. This way it doesn't
4644 collide with pprint() and the name is consistent with the command
4655 collide with pprint() and the name is consistent with the command
4645 line option.
4656 line option.
4646
4657
4647 * Changed prompt counter behavior to be fully like
4658 * Changed prompt counter behavior to be fully like
4648 Mathematica's. That is, even input that doesn't return a result
4659 Mathematica's. That is, even input that doesn't return a result
4649 raises the prompt counter. The old behavior was kind of confusing
4660 raises the prompt counter. The old behavior was kind of confusing
4650 (getting the same prompt number several times if the operation
4661 (getting the same prompt number several times if the operation
4651 didn't return a result).
4662 didn't return a result).
4652
4663
4653 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4664 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4654
4665
4655 * Fixed -Classic mode (wasn't working anymore).
4666 * Fixed -Classic mode (wasn't working anymore).
4656
4667
4657 * Added colored prompts using Nathan's new code. Colors are
4668 * Added colored prompts using Nathan's new code. Colors are
4658 currently hardwired, they can be user-configurable. For
4669 currently hardwired, they can be user-configurable. For
4659 developers, they can be chosen in file ipythonlib.py, at the
4670 developers, they can be chosen in file ipythonlib.py, at the
4660 beginning of the CachedOutput class def.
4671 beginning of the CachedOutput class def.
4661
4672
4662 2001-11-11 Fernando Perez <fperez@colorado.edu>
4673 2001-11-11 Fernando Perez <fperez@colorado.edu>
4663
4674
4664 * Version 0.1.5 released, 0.1.6 opened for further work.
4675 * Version 0.1.5 released, 0.1.6 opened for further work.
4665
4676
4666 * Changed magic_env to *return* the environment as a dict (not to
4677 * Changed magic_env to *return* the environment as a dict (not to
4667 print it). This way it prints, but it can also be processed.
4678 print it). This way it prints, but it can also be processed.
4668
4679
4669 * Added Verbose exception reporting to interactive
4680 * Added Verbose exception reporting to interactive
4670 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4681 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4671 traceback. Had to make some changes to the ultraTB file. This is
4682 traceback. Had to make some changes to the ultraTB file. This is
4672 probably the last 'big' thing in my mental todo list. This ties
4683 probably the last 'big' thing in my mental todo list. This ties
4673 in with the next entry:
4684 in with the next entry:
4674
4685
4675 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4686 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4676 has to specify is Plain, Color or Verbose for all exception
4687 has to specify is Plain, Color or Verbose for all exception
4677 handling.
4688 handling.
4678
4689
4679 * Removed ShellServices option. All this can really be done via
4690 * Removed ShellServices option. All this can really be done via
4680 the magic system. It's easier to extend, cleaner and has automatic
4691 the magic system. It's easier to extend, cleaner and has automatic
4681 namespace protection and documentation.
4692 namespace protection and documentation.
4682
4693
4683 2001-11-09 Fernando Perez <fperez@colorado.edu>
4694 2001-11-09 Fernando Perez <fperez@colorado.edu>
4684
4695
4685 * Fixed bug in output cache flushing (missing parameter to
4696 * Fixed bug in output cache flushing (missing parameter to
4686 __init__). Other small bugs fixed (found using pychecker).
4697 __init__). Other small bugs fixed (found using pychecker).
4687
4698
4688 * Version 0.1.4 opened for bugfixing.
4699 * Version 0.1.4 opened for bugfixing.
4689
4700
4690 2001-11-07 Fernando Perez <fperez@colorado.edu>
4701 2001-11-07 Fernando Perez <fperez@colorado.edu>
4691
4702
4692 * Version 0.1.3 released, mainly because of the raw_input bug.
4703 * Version 0.1.3 released, mainly because of the raw_input bug.
4693
4704
4694 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4705 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4695 and when testing for whether things were callable, a call could
4706 and when testing for whether things were callable, a call could
4696 actually be made to certain functions. They would get called again
4707 actually be made to certain functions. They would get called again
4697 once 'really' executed, with a resulting double call. A disaster
4708 once 'really' executed, with a resulting double call. A disaster
4698 in many cases (list.reverse() would never work!).
4709 in many cases (list.reverse() would never work!).
4699
4710
4700 * Removed prefilter() function, moved its code to raw_input (which
4711 * Removed prefilter() function, moved its code to raw_input (which
4701 after all was just a near-empty caller for prefilter). This saves
4712 after all was just a near-empty caller for prefilter). This saves
4702 a function call on every prompt, and simplifies the class a tiny bit.
4713 a function call on every prompt, and simplifies the class a tiny bit.
4703
4714
4704 * Fix _ip to __ip name in magic example file.
4715 * Fix _ip to __ip name in magic example file.
4705
4716
4706 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4717 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4707 work with non-gnu versions of tar.
4718 work with non-gnu versions of tar.
4708
4719
4709 2001-11-06 Fernando Perez <fperez@colorado.edu>
4720 2001-11-06 Fernando Perez <fperez@colorado.edu>
4710
4721
4711 * Version 0.1.2. Just to keep track of the recent changes.
4722 * Version 0.1.2. Just to keep track of the recent changes.
4712
4723
4713 * Fixed nasty bug in output prompt routine. It used to check 'if
4724 * Fixed nasty bug in output prompt routine. It used to check 'if
4714 arg != None...'. Problem is, this fails if arg implements a
4725 arg != None...'. Problem is, this fails if arg implements a
4715 special comparison (__cmp__) which disallows comparing to
4726 special comparison (__cmp__) which disallows comparing to
4716 None. Found it when trying to use the PhysicalQuantity module from
4727 None. Found it when trying to use the PhysicalQuantity module from
4717 ScientificPython.
4728 ScientificPython.
4718
4729
4719 2001-11-05 Fernando Perez <fperez@colorado.edu>
4730 2001-11-05 Fernando Perez <fperez@colorado.edu>
4720
4731
4721 * Also added dirs. Now the pushd/popd/dirs family functions
4732 * Also added dirs. Now the pushd/popd/dirs family functions
4722 basically like the shell, with the added convenience of going home
4733 basically like the shell, with the added convenience of going home
4723 when called with no args.
4734 when called with no args.
4724
4735
4725 * pushd/popd slightly modified to mimic shell behavior more
4736 * pushd/popd slightly modified to mimic shell behavior more
4726 closely.
4737 closely.
4727
4738
4728 * Added env,pushd,popd from ShellServices as magic functions. I
4739 * Added env,pushd,popd from ShellServices as magic functions. I
4729 think the cleanest will be to port all desired functions from
4740 think the cleanest will be to port all desired functions from
4730 ShellServices as magics and remove ShellServices altogether. This
4741 ShellServices as magics and remove ShellServices altogether. This
4731 will provide a single, clean way of adding functionality
4742 will provide a single, clean way of adding functionality
4732 (shell-type or otherwise) to IP.
4743 (shell-type or otherwise) to IP.
4733
4744
4734 2001-11-04 Fernando Perez <fperez@colorado.edu>
4745 2001-11-04 Fernando Perez <fperez@colorado.edu>
4735
4746
4736 * Added .ipython/ directory to sys.path. This way users can keep
4747 * Added .ipython/ directory to sys.path. This way users can keep
4737 customizations there and access them via import.
4748 customizations there and access them via import.
4738
4749
4739 2001-11-03 Fernando Perez <fperez@colorado.edu>
4750 2001-11-03 Fernando Perez <fperez@colorado.edu>
4740
4751
4741 * Opened version 0.1.1 for new changes.
4752 * Opened version 0.1.1 for new changes.
4742
4753
4743 * Changed version number to 0.1.0: first 'public' release, sent to
4754 * Changed version number to 0.1.0: first 'public' release, sent to
4744 Nathan and Janko.
4755 Nathan and Janko.
4745
4756
4746 * Lots of small fixes and tweaks.
4757 * Lots of small fixes and tweaks.
4747
4758
4748 * Minor changes to whos format. Now strings are shown, snipped if
4759 * Minor changes to whos format. Now strings are shown, snipped if
4749 too long.
4760 too long.
4750
4761
4751 * Changed ShellServices to work on __main__ so they show up in @who
4762 * Changed ShellServices to work on __main__ so they show up in @who
4752
4763
4753 * Help also works with ? at the end of a line:
4764 * Help also works with ? at the end of a line:
4754 ?sin and sin?
4765 ?sin and sin?
4755 both produce the same effect. This is nice, as often I use the
4766 both produce the same effect. This is nice, as often I use the
4756 tab-complete to find the name of a method, but I used to then have
4767 tab-complete to find the name of a method, but I used to then have
4757 to go to the beginning of the line to put a ? if I wanted more
4768 to go to the beginning of the line to put a ? if I wanted more
4758 info. Now I can just add the ? and hit return. Convenient.
4769 info. Now I can just add the ? and hit return. Convenient.
4759
4770
4760 2001-11-02 Fernando Perez <fperez@colorado.edu>
4771 2001-11-02 Fernando Perez <fperez@colorado.edu>
4761
4772
4762 * Python version check (>=2.1) added.
4773 * Python version check (>=2.1) added.
4763
4774
4764 * Added LazyPython documentation. At this point the docs are quite
4775 * Added LazyPython documentation. At this point the docs are quite
4765 a mess. A cleanup is in order.
4776 a mess. A cleanup is in order.
4766
4777
4767 * Auto-installer created. For some bizarre reason, the zipfiles
4778 * Auto-installer created. For some bizarre reason, the zipfiles
4768 module isn't working on my system. So I made a tar version
4779 module isn't working on my system. So I made a tar version
4769 (hopefully the command line options in various systems won't kill
4780 (hopefully the command line options in various systems won't kill
4770 me).
4781 me).
4771
4782
4772 * Fixes to Struct in genutils. Now all dictionary-like methods are
4783 * Fixes to Struct in genutils. Now all dictionary-like methods are
4773 protected (reasonably).
4784 protected (reasonably).
4774
4785
4775 * Added pager function to genutils and changed ? to print usage
4786 * Added pager function to genutils and changed ? to print usage
4776 note through it (it was too long).
4787 note through it (it was too long).
4777
4788
4778 * Added the LazyPython functionality. Works great! I changed the
4789 * Added the LazyPython functionality. Works great! I changed the
4779 auto-quote escape to ';', it's on home row and next to '. But
4790 auto-quote escape to ';', it's on home row and next to '. But
4780 both auto-quote and auto-paren (still /) escapes are command-line
4791 both auto-quote and auto-paren (still /) escapes are command-line
4781 parameters.
4792 parameters.
4782
4793
4783
4794
4784 2001-11-01 Fernando Perez <fperez@colorado.edu>
4795 2001-11-01 Fernando Perez <fperez@colorado.edu>
4785
4796
4786 * Version changed to 0.0.7. Fairly large change: configuration now
4797 * Version changed to 0.0.7. Fairly large change: configuration now
4787 is all stored in a directory, by default .ipython. There, all
4798 is all stored in a directory, by default .ipython. There, all
4788 config files have normal looking names (not .names)
4799 config files have normal looking names (not .names)
4789
4800
4790 * Version 0.0.6 Released first to Lucas and Archie as a test
4801 * Version 0.0.6 Released first to Lucas and Archie as a test
4791 run. Since it's the first 'semi-public' release, change version to
4802 run. Since it's the first 'semi-public' release, change version to
4792 > 0.0.6 for any changes now.
4803 > 0.0.6 for any changes now.
4793
4804
4794 * Stuff I had put in the ipplib.py changelog:
4805 * Stuff I had put in the ipplib.py changelog:
4795
4806
4796 Changes to InteractiveShell:
4807 Changes to InteractiveShell:
4797
4808
4798 - Made the usage message a parameter.
4809 - Made the usage message a parameter.
4799
4810
4800 - Require the name of the shell variable to be given. It's a bit
4811 - Require the name of the shell variable to be given. It's a bit
4801 of a hack, but allows the name 'shell' not to be hardwire in the
4812 of a hack, but allows the name 'shell' not to be hardwire in the
4802 magic (@) handler, which is problematic b/c it requires
4813 magic (@) handler, which is problematic b/c it requires
4803 polluting the global namespace with 'shell'. This in turn is
4814 polluting the global namespace with 'shell'. This in turn is
4804 fragile: if a user redefines a variable called shell, things
4815 fragile: if a user redefines a variable called shell, things
4805 break.
4816 break.
4806
4817
4807 - magic @: all functions available through @ need to be defined
4818 - magic @: all functions available through @ need to be defined
4808 as magic_<name>, even though they can be called simply as
4819 as magic_<name>, even though they can be called simply as
4809 @<name>. This allows the special command @magic to gather
4820 @<name>. This allows the special command @magic to gather
4810 information automatically about all existing magic functions,
4821 information automatically about all existing magic functions,
4811 even if they are run-time user extensions, by parsing the shell
4822 even if they are run-time user extensions, by parsing the shell
4812 instance __dict__ looking for special magic_ names.
4823 instance __dict__ looking for special magic_ names.
4813
4824
4814 - mainloop: added *two* local namespace parameters. This allows
4825 - mainloop: added *two* local namespace parameters. This allows
4815 the class to differentiate between parameters which were there
4826 the class to differentiate between parameters which were there
4816 before and after command line initialization was processed. This
4827 before and after command line initialization was processed. This
4817 way, later @who can show things loaded at startup by the
4828 way, later @who can show things loaded at startup by the
4818 user. This trick was necessary to make session saving/reloading
4829 user. This trick was necessary to make session saving/reloading
4819 really work: ideally after saving/exiting/reloading a session,
4830 really work: ideally after saving/exiting/reloading a session,
4820 *everythin* should look the same, including the output of @who. I
4831 *everythin* should look the same, including the output of @who. I
4821 was only able to make this work with this double namespace
4832 was only able to make this work with this double namespace
4822 trick.
4833 trick.
4823
4834
4824 - added a header to the logfile which allows (almost) full
4835 - added a header to the logfile which allows (almost) full
4825 session restoring.
4836 session restoring.
4826
4837
4827 - prepend lines beginning with @ or !, with a and log
4838 - prepend lines beginning with @ or !, with a and log
4828 them. Why? !lines: may be useful to know what you did @lines:
4839 them. Why? !lines: may be useful to know what you did @lines:
4829 they may affect session state. So when restoring a session, at
4840 they may affect session state. So when restoring a session, at
4830 least inform the user of their presence. I couldn't quite get
4841 least inform the user of their presence. I couldn't quite get
4831 them to properly re-execute, but at least the user is warned.
4842 them to properly re-execute, but at least the user is warned.
4832
4843
4833 * Started ChangeLog.
4844 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now