##// END OF EJS Templates
_tentative_ fixes to pasting of multiline code with autoindent on. Needs...
fperez -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,1764 +1,1768 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 1028 2006-01-16 21:42:33Z vivainio $"""
8 $Id: genutils.py 1032 2006-01-20 09:03:57Z fperez $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 #
12 #
13 # Distributed under the terms of the BSD License. The full license is in
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
15 #*****************************************************************************
15 #*****************************************************************************
16
16
17 from __future__ import generators # 2.2 compatibility
17 from __future__ import generators # 2.2 compatibility
18
18
19 from IPython import Release
19 from IPython import Release
20 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __author__ = '%s <%s>' % Release.authors['Fernando']
21 __license__ = Release.license
21 __license__ = Release.license
22
22
23 #****************************************************************************
23 #****************************************************************************
24 # required modules from the Python standard library
24 # required modules from the Python standard library
25 import __main__
25 import __main__
26 import commands
26 import commands
27 import os
27 import os
28 import re
28 import re
29 import shlex
29 import shlex
30 import shutil
30 import shutil
31 import sys
31 import sys
32 import tempfile
32 import tempfile
33 import time
33 import time
34 import types
34 import types
35
35
36 # Other IPython utilities
36 # Other IPython utilities
37 from IPython.Itpl import Itpl,itpl,printpl
37 from IPython.Itpl import Itpl,itpl,printpl
38 from IPython import DPyGetOpt
38 from IPython import DPyGetOpt
39 from IPython.path import path
39 from IPython.path import path
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,pre_msg=''):
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 %s -> %r' % (pre_msg,expr,
221 eval(expr,cf.f_globals,cf.f_locals))
222
223 # deactivate it from here:
224 def debugp(expr,pre_msg=''): pass
221
225
222 #----------------------------------------------------------------------------
226 #----------------------------------------------------------------------------
223 StringTypes = types.StringTypes
227 StringTypes = types.StringTypes
224
228
225 # Basic timing functionality
229 # Basic timing functionality
226
230
227 # If possible (Unix), use the resource module instead of time.clock()
231 # If possible (Unix), use the resource module instead of time.clock()
228 try:
232 try:
229 import resource
233 import resource
230 def clock():
234 def clock():
231 """clock() -> floating point number
235 """clock() -> floating point number
232
236
233 Return the CPU time in seconds (user time only, system time is
237 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
238 ignored) since the start of the process. This is done via a call to
235 resource.getrusage, so it avoids the wraparound problems in
239 resource.getrusage, so it avoids the wraparound problems in
236 time.clock()."""
240 time.clock()."""
237
241
238 return resource.getrusage(resource.RUSAGE_SELF)[0]
242 return resource.getrusage(resource.RUSAGE_SELF)[0]
239
243
240 def clock2():
244 def clock2():
241 """clock2() -> (t_user,t_system)
245 """clock2() -> (t_user,t_system)
242
246
243 Similar to clock(), but return a tuple of user/system times."""
247 Similar to clock(), but return a tuple of user/system times."""
244 return resource.getrusage(resource.RUSAGE_SELF)[:2]
248 return resource.getrusage(resource.RUSAGE_SELF)[:2]
245
249
246 except ImportError:
250 except ImportError:
247 clock = time.clock
251 clock = time.clock
248 def clock2():
252 def clock2():
249 """Under windows, system CPU time can't be measured.
253 """Under windows, system CPU time can't be measured.
250
254
251 This just returns clock() and zero."""
255 This just returns clock() and zero."""
252 return time.clock(),0.0
256 return time.clock(),0.0
253
257
254 def timings_out(reps,func,*args,**kw):
258 def timings_out(reps,func,*args,**kw):
255 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
259 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
256
260
257 Execute a function reps times, return a tuple with the elapsed total
261 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.
262 CPU time in seconds, the time per call and the function's output.
259
263
260 Under Unix, the return value is the sum of user+system time consumed by
264 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
265 the process, computed via the resource module. This prevents problems
262 related to the wraparound effect which the time.clock() function has.
266 related to the wraparound effect which the time.clock() function has.
263
267
264 Under Windows the return value is in wall clock seconds. See the
268 Under Windows the return value is in wall clock seconds. See the
265 documentation for the time module for more details."""
269 documentation for the time module for more details."""
266
270
267 reps = int(reps)
271 reps = int(reps)
268 assert reps >=1, 'reps must be >= 1'
272 assert reps >=1, 'reps must be >= 1'
269 if reps==1:
273 if reps==1:
270 start = clock()
274 start = clock()
271 out = func(*args,**kw)
275 out = func(*args,**kw)
272 tot_time = clock()-start
276 tot_time = clock()-start
273 else:
277 else:
274 rng = xrange(reps-1) # the last time is executed separately to store output
278 rng = xrange(reps-1) # the last time is executed separately to store output
275 start = clock()
279 start = clock()
276 for dummy in rng: func(*args,**kw)
280 for dummy in rng: func(*args,**kw)
277 out = func(*args,**kw) # one last time
281 out = func(*args,**kw) # one last time
278 tot_time = clock()-start
282 tot_time = clock()-start
279 av_time = tot_time / reps
283 av_time = tot_time / reps
280 return tot_time,av_time,out
284 return tot_time,av_time,out
281
285
282 def timings(reps,func,*args,**kw):
286 def timings(reps,func,*args,**kw):
283 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
287 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
284
288
285 Execute a function reps times, return a tuple with the elapsed total CPU
289 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
290 time in seconds and the time per call. These are just the first two values
287 in timings_out()."""
291 in timings_out()."""
288
292
289 return timings_out(reps,func,*args,**kw)[0:2]
293 return timings_out(reps,func,*args,**kw)[0:2]
290
294
291 def timing(func,*args,**kw):
295 def timing(func,*args,**kw):
292 """timing(func,*args,**kw) -> t_total
296 """timing(func,*args,**kw) -> t_total
293
297
294 Execute a function once, return the elapsed total CPU time in
298 Execute a function once, return the elapsed total CPU time in
295 seconds. This is just the first value in timings_out()."""
299 seconds. This is just the first value in timings_out()."""
296
300
297 return timings_out(1,func,*args,**kw)[0]
301 return timings_out(1,func,*args,**kw)[0]
298
302
299 #****************************************************************************
303 #****************************************************************************
300 # file and system
304 # file and system
301
305
302 def system(cmd,verbose=0,debug=0,header=''):
306 def system(cmd,verbose=0,debug=0,header=''):
303 """Execute a system command, return its exit status.
307 """Execute a system command, return its exit status.
304
308
305 Options:
309 Options:
306
310
307 - verbose (0): print the command to be executed.
311 - verbose (0): print the command to be executed.
308
312
309 - debug (0): only print, do not actually execute.
313 - debug (0): only print, do not actually execute.
310
314
311 - header (''): Header to print on screen prior to the executed command (it
315 - header (''): Header to print on screen prior to the executed command (it
312 is only prepended to the command, no newlines are added).
316 is only prepended to the command, no newlines are added).
313
317
314 Note: a stateful version of this function is available through the
318 Note: a stateful version of this function is available through the
315 SystemExec class."""
319 SystemExec class."""
316
320
317 stat = 0
321 stat = 0
318 if verbose or debug: print header+cmd
322 if verbose or debug: print header+cmd
319 sys.stdout.flush()
323 sys.stdout.flush()
320 if not debug: stat = os.system(cmd)
324 if not debug: stat = os.system(cmd)
321 return stat
325 return stat
322
326
323 # This function is used by ipython in a lot of places to make system calls.
327 # 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
328 # We need it to be slightly different under win32, due to the vagaries of
325 # 'network shares'. A win32 override is below.
329 # 'network shares'. A win32 override is below.
326
330
327 def shell(cmd,verbose=0,debug=0,header=''):
331 def shell(cmd,verbose=0,debug=0,header=''):
328 """Execute a command in the system shell, always return None.
332 """Execute a command in the system shell, always return None.
329
333
330 Options:
334 Options:
331
335
332 - verbose (0): print the command to be executed.
336 - verbose (0): print the command to be executed.
333
337
334 - debug (0): only print, do not actually execute.
338 - debug (0): only print, do not actually execute.
335
339
336 - header (''): Header to print on screen prior to the executed command (it
340 - header (''): Header to print on screen prior to the executed command (it
337 is only prepended to the command, no newlines are added).
341 is only prepended to the command, no newlines are added).
338
342
339 Note: this is similar to genutils.system(), but it returns None so it can
343 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
344 be conveniently used in interactive loops without getting the return value
341 (typically 0) printed many times."""
345 (typically 0) printed many times."""
342
346
343 stat = 0
347 stat = 0
344 if verbose or debug: print header+cmd
348 if verbose or debug: print header+cmd
345 # flush stdout so we don't mangle python's buffering
349 # flush stdout so we don't mangle python's buffering
346 sys.stdout.flush()
350 sys.stdout.flush()
347 if not debug:
351 if not debug:
348 os.system(cmd)
352 os.system(cmd)
349
353
350 # override shell() for win32 to deal with network shares
354 # override shell() for win32 to deal with network shares
351 if os.name in ('nt','dos'):
355 if os.name in ('nt','dos'):
352
356
353 shell_ori = shell
357 shell_ori = shell
354
358
355 def shell(cmd,verbose=0,debug=0,header=''):
359 def shell(cmd,verbose=0,debug=0,header=''):
356 if os.getcwd().startswith(r"\\"):
360 if os.getcwd().startswith(r"\\"):
357 path = os.getcwd()
361 path = os.getcwd()
358 # change to c drive (cannot be on UNC-share when issuing os.system,
362 # change to c drive (cannot be on UNC-share when issuing os.system,
359 # as cmd.exe cannot handle UNC addresses)
363 # as cmd.exe cannot handle UNC addresses)
360 os.chdir("c:")
364 os.chdir("c:")
361 # issue pushd to the UNC-share and then run the command
365 # issue pushd to the UNC-share and then run the command
362 try:
366 try:
363 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
367 shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header)
364 finally:
368 finally:
365 os.chdir(path)
369 os.chdir(path)
366 else:
370 else:
367 shell_ori(cmd,verbose,debug,header)
371 shell_ori(cmd,verbose,debug,header)
368
372
369 shell.__doc__ = shell_ori.__doc__
373 shell.__doc__ = shell_ori.__doc__
370
374
371 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
375 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
372 """Dummy substitute for perl's backquotes.
376 """Dummy substitute for perl's backquotes.
373
377
374 Executes a command and returns the output.
378 Executes a command and returns the output.
375
379
376 Accepts the same arguments as system(), plus:
380 Accepts the same arguments as system(), plus:
377
381
378 - split(0): if true, the output is returned as a list split on newlines.
382 - split(0): if true, the output is returned as a list split on newlines.
379
383
380 Note: a stateful version of this function is available through the
384 Note: a stateful version of this function is available through the
381 SystemExec class."""
385 SystemExec class."""
382
386
383 if verbose or debug: print header+cmd
387 if verbose or debug: print header+cmd
384 if not debug:
388 if not debug:
385 output = commands.getoutput(cmd)
389 output = commands.getoutput(cmd)
386 if split:
390 if split:
387 return output.split('\n')
391 return output.split('\n')
388 else:
392 else:
389 return output
393 return output
390
394
391 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
395 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
392 """Return (standard output,standard error) of executing cmd in a shell.
396 """Return (standard output,standard error) of executing cmd in a shell.
393
397
394 Accepts the same arguments as system(), plus:
398 Accepts the same arguments as system(), plus:
395
399
396 - split(0): if true, each of stdout/err is returned as a list split on
400 - split(0): if true, each of stdout/err is returned as a list split on
397 newlines.
401 newlines.
398
402
399 Note: a stateful version of this function is available through the
403 Note: a stateful version of this function is available through the
400 SystemExec class."""
404 SystemExec class."""
401
405
402 if verbose or debug: print header+cmd
406 if verbose or debug: print header+cmd
403 if not cmd:
407 if not cmd:
404 if split:
408 if split:
405 return [],[]
409 return [],[]
406 else:
410 else:
407 return '',''
411 return '',''
408 if not debug:
412 if not debug:
409 pin,pout,perr = os.popen3(cmd)
413 pin,pout,perr = os.popen3(cmd)
410 tout = pout.read().rstrip()
414 tout = pout.read().rstrip()
411 terr = perr.read().rstrip()
415 terr = perr.read().rstrip()
412 pin.close()
416 pin.close()
413 pout.close()
417 pout.close()
414 perr.close()
418 perr.close()
415 if split:
419 if split:
416 return tout.split('\n'),terr.split('\n')
420 return tout.split('\n'),terr.split('\n')
417 else:
421 else:
418 return tout,terr
422 return tout,terr
419
423
420 # for compatibility with older naming conventions
424 # for compatibility with older naming conventions
421 xsys = system
425 xsys = system
422 bq = getoutput
426 bq = getoutput
423
427
424 class SystemExec:
428 class SystemExec:
425 """Access the system and getoutput functions through a stateful interface.
429 """Access the system and getoutput functions through a stateful interface.
426
430
427 Note: here we refer to the system and getoutput functions from this
431 Note: here we refer to the system and getoutput functions from this
428 library, not the ones from the standard python library.
432 library, not the ones from the standard python library.
429
433
430 This class offers the system and getoutput functions as methods, but the
434 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
435 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
436 creation time or later) so that they don't need to be specified on each
433 call.
437 call.
434
438
435 For efficiency reasons, there's no way to override the parameters on a
439 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
440 per-call basis other than by setting instance attributes. If you need
437 local overrides, it's best to directly call system() or getoutput().
441 local overrides, it's best to directly call system() or getoutput().
438
442
439 The following names are provided as alternate options:
443 The following names are provided as alternate options:
440 - xsys: alias to system
444 - xsys: alias to system
441 - bq: alias to getoutput
445 - bq: alias to getoutput
442
446
443 An instance can then be created as:
447 An instance can then be created as:
444 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
448 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
445
449
446 And used as:
450 And used as:
447 >>> sysexec.xsys('pwd')
451 >>> sysexec.xsys('pwd')
448 >>> dirlist = sysexec.bq('ls -l')
452 >>> dirlist = sysexec.bq('ls -l')
449 """
453 """
450
454
451 def __init__(self,verbose=0,debug=0,header='',split=0):
455 def __init__(self,verbose=0,debug=0,header='',split=0):
452 """Specify the instance's values for verbose, debug and header."""
456 """Specify the instance's values for verbose, debug and header."""
453 setattr_list(self,'verbose debug header split')
457 setattr_list(self,'verbose debug header split')
454
458
455 def system(self,cmd):
459 def system(self,cmd):
456 """Stateful interface to system(), with the same keyword parameters."""
460 """Stateful interface to system(), with the same keyword parameters."""
457
461
458 system(cmd,self.verbose,self.debug,self.header)
462 system(cmd,self.verbose,self.debug,self.header)
459
463
460 def shell(self,cmd):
464 def shell(self,cmd):
461 """Stateful interface to shell(), with the same keyword parameters."""
465 """Stateful interface to shell(), with the same keyword parameters."""
462
466
463 shell(cmd,self.verbose,self.debug,self.header)
467 shell(cmd,self.verbose,self.debug,self.header)
464
468
465 xsys = system # alias
469 xsys = system # alias
466
470
467 def getoutput(self,cmd):
471 def getoutput(self,cmd):
468 """Stateful interface to getoutput()."""
472 """Stateful interface to getoutput()."""
469
473
470 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
474 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
471
475
472 def getoutputerror(self,cmd):
476 def getoutputerror(self,cmd):
473 """Stateful interface to getoutputerror()."""
477 """Stateful interface to getoutputerror()."""
474
478
475 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
479 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
476
480
477 bq = getoutput # alias
481 bq = getoutput # alias
478
482
479 #-----------------------------------------------------------------------------
483 #-----------------------------------------------------------------------------
480 def mutex_opts(dict,ex_op):
484 def mutex_opts(dict,ex_op):
481 """Check for presence of mutually exclusive keys in a dict.
485 """Check for presence of mutually exclusive keys in a dict.
482
486
483 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
487 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
484 for op1,op2 in ex_op:
488 for op1,op2 in ex_op:
485 if op1 in dict and op2 in dict:
489 if op1 in dict and op2 in dict:
486 raise ValueError,'\n*** ERROR in Arguments *** '\
490 raise ValueError,'\n*** ERROR in Arguments *** '\
487 'Options '+op1+' and '+op2+' are mutually exclusive.'
491 'Options '+op1+' and '+op2+' are mutually exclusive.'
488
492
489 #-----------------------------------------------------------------------------
493 #-----------------------------------------------------------------------------
490 def get_py_filename(name):
494 def get_py_filename(name):
491 """Return a valid python filename in the current directory.
495 """Return a valid python filename in the current directory.
492
496
493 If the given name is not a file, it adds '.py' and searches again.
497 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."""
498 Raises IOError with an informative message if the file isn't found."""
495
499
496 name = os.path.expanduser(name)
500 name = os.path.expanduser(name)
497 if not os.path.isfile(name) and not name.endswith('.py'):
501 if not os.path.isfile(name) and not name.endswith('.py'):
498 name += '.py'
502 name += '.py'
499 if os.path.isfile(name):
503 if os.path.isfile(name):
500 return name
504 return name
501 else:
505 else:
502 raise IOError,'File `%s` not found.' % name
506 raise IOError,'File `%s` not found.' % name
503
507
504 #-----------------------------------------------------------------------------
508 #-----------------------------------------------------------------------------
505 def filefind(fname,alt_dirs = None):
509 def filefind(fname,alt_dirs = None):
506 """Return the given filename either in the current directory, if it
510 """Return the given filename either in the current directory, if it
507 exists, or in a specified list of directories.
511 exists, or in a specified list of directories.
508
512
509 ~ expansion is done on all file and directory names.
513 ~ expansion is done on all file and directory names.
510
514
511 Upon an unsuccessful search, raise an IOError exception."""
515 Upon an unsuccessful search, raise an IOError exception."""
512
516
513 if alt_dirs is None:
517 if alt_dirs is None:
514 try:
518 try:
515 alt_dirs = get_home_dir()
519 alt_dirs = get_home_dir()
516 except HomeDirError:
520 except HomeDirError:
517 alt_dirs = os.getcwd()
521 alt_dirs = os.getcwd()
518 search = [fname] + list_strings(alt_dirs)
522 search = [fname] + list_strings(alt_dirs)
519 search = map(os.path.expanduser,search)
523 search = map(os.path.expanduser,search)
520 #print 'search list for',fname,'list:',search # dbg
524 #print 'search list for',fname,'list:',search # dbg
521 fname = search[0]
525 fname = search[0]
522 if os.path.isfile(fname):
526 if os.path.isfile(fname):
523 return fname
527 return fname
524 for direc in search[1:]:
528 for direc in search[1:]:
525 testname = os.path.join(direc,fname)
529 testname = os.path.join(direc,fname)
526 #print 'testname',testname # dbg
530 #print 'testname',testname # dbg
527 if os.path.isfile(testname):
531 if os.path.isfile(testname):
528 return testname
532 return testname
529 raise IOError,'File' + `fname` + \
533 raise IOError,'File' + `fname` + \
530 ' not found in current or supplied directories:' + `alt_dirs`
534 ' not found in current or supplied directories:' + `alt_dirs`
531
535
532 #----------------------------------------------------------------------------
536 #----------------------------------------------------------------------------
533 def file_read(filename):
537 def file_read(filename):
534 """Read a file and close it. Returns the file source."""
538 """Read a file and close it. Returns the file source."""
535 fobj=open(filename,'r');
539 fobj=open(filename,'r');
536 source = fobj.read();
540 source = fobj.read();
537 fobj.close()
541 fobj.close()
538 return source
542 return source
539
543
540 #----------------------------------------------------------------------------
544 #----------------------------------------------------------------------------
541 def target_outdated(target,deps):
545 def target_outdated(target,deps):
542 """Determine whether a target is out of date.
546 """Determine whether a target is out of date.
543
547
544 target_outdated(target,deps) -> 1/0
548 target_outdated(target,deps) -> 1/0
545
549
546 deps: list of filenames which MUST exist.
550 deps: list of filenames which MUST exist.
547 target: single filename which may or may not exist.
551 target: single filename which may or may not exist.
548
552
549 If target doesn't exist or is older than any file listed in deps, return
553 If target doesn't exist or is older than any file listed in deps, return
550 true, otherwise return false.
554 true, otherwise return false.
551 """
555 """
552 try:
556 try:
553 target_time = os.path.getmtime(target)
557 target_time = os.path.getmtime(target)
554 except os.error:
558 except os.error:
555 return 1
559 return 1
556 for dep in deps:
560 for dep in deps:
557 dep_time = os.path.getmtime(dep)
561 dep_time = os.path.getmtime(dep)
558 if dep_time > target_time:
562 if dep_time > target_time:
559 #print "For target",target,"Dep failed:",dep # dbg
563 #print "For target",target,"Dep failed:",dep # dbg
560 #print "times (dep,tar):",dep_time,target_time # dbg
564 #print "times (dep,tar):",dep_time,target_time # dbg
561 return 1
565 return 1
562 return 0
566 return 0
563
567
564 #-----------------------------------------------------------------------------
568 #-----------------------------------------------------------------------------
565 def target_update(target,deps,cmd):
569 def target_update(target,deps,cmd):
566 """Update a target with a given command given a list of dependencies.
570 """Update a target with a given command given a list of dependencies.
567
571
568 target_update(target,deps,cmd) -> runs cmd if target is outdated.
572 target_update(target,deps,cmd) -> runs cmd if target is outdated.
569
573
570 This is just a wrapper around target_outdated() which calls the given
574 This is just a wrapper around target_outdated() which calls the given
571 command if target is outdated."""
575 command if target is outdated."""
572
576
573 if target_outdated(target,deps):
577 if target_outdated(target,deps):
574 xsys(cmd)
578 xsys(cmd)
575
579
576 #----------------------------------------------------------------------------
580 #----------------------------------------------------------------------------
577 def unquote_ends(istr):
581 def unquote_ends(istr):
578 """Remove a single pair of quotes from the endpoints of a string."""
582 """Remove a single pair of quotes from the endpoints of a string."""
579
583
580 if not istr:
584 if not istr:
581 return istr
585 return istr
582 if (istr[0]=="'" and istr[-1]=="'") or \
586 if (istr[0]=="'" and istr[-1]=="'") or \
583 (istr[0]=='"' and istr[-1]=='"'):
587 (istr[0]=='"' and istr[-1]=='"'):
584 return istr[1:-1]
588 return istr[1:-1]
585 else:
589 else:
586 return istr
590 return istr
587
591
588 #----------------------------------------------------------------------------
592 #----------------------------------------------------------------------------
589 def process_cmdline(argv,names=[],defaults={},usage=''):
593 def process_cmdline(argv,names=[],defaults={},usage=''):
590 """ Process command-line options and arguments.
594 """ Process command-line options and arguments.
591
595
592 Arguments:
596 Arguments:
593
597
594 - argv: list of arguments, typically sys.argv.
598 - argv: list of arguments, typically sys.argv.
595
599
596 - names: list of option names. See DPyGetOpt docs for details on options
600 - names: list of option names. See DPyGetOpt docs for details on options
597 syntax.
601 syntax.
598
602
599 - defaults: dict of default values.
603 - defaults: dict of default values.
600
604
601 - usage: optional usage notice to print if a wrong argument is passed.
605 - usage: optional usage notice to print if a wrong argument is passed.
602
606
603 Return a dict of options and a list of free arguments."""
607 Return a dict of options and a list of free arguments."""
604
608
605 getopt = DPyGetOpt.DPyGetOpt()
609 getopt = DPyGetOpt.DPyGetOpt()
606 getopt.setIgnoreCase(0)
610 getopt.setIgnoreCase(0)
607 getopt.parseConfiguration(names)
611 getopt.parseConfiguration(names)
608
612
609 try:
613 try:
610 getopt.processArguments(argv)
614 getopt.processArguments(argv)
611 except:
615 except:
612 print usage
616 print usage
613 warn(`sys.exc_value`,level=4)
617 warn(`sys.exc_value`,level=4)
614
618
615 defaults.update(getopt.optionValues)
619 defaults.update(getopt.optionValues)
616 args = getopt.freeValues
620 args = getopt.freeValues
617
621
618 return defaults,args
622 return defaults,args
619
623
620 #----------------------------------------------------------------------------
624 #----------------------------------------------------------------------------
621 def optstr2types(ostr):
625 def optstr2types(ostr):
622 """Convert a string of option names to a dict of type mappings.
626 """Convert a string of option names to a dict of type mappings.
623
627
624 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
628 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
625
629
626 This is used to get the types of all the options in a string formatted
630 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
631 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
632 which are strings (they need no further conversion). This function's main
629 use is to get a typemap for use with read_dict().
633 use is to get a typemap for use with read_dict().
630 """
634 """
631
635
632 typeconv = {None:'',int:'',float:''}
636 typeconv = {None:'',int:'',float:''}
633 typemap = {'s':None,'i':int,'f':float}
637 typemap = {'s':None,'i':int,'f':float}
634 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
638 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
635
639
636 for w in ostr.split():
640 for w in ostr.split():
637 oname,alias,otype = opt_re.match(w).groups()
641 oname,alias,otype = opt_re.match(w).groups()
638 if otype == '' or alias == '!': # simple switches are integers too
642 if otype == '' or alias == '!': # simple switches are integers too
639 otype = 'i'
643 otype = 'i'
640 typeconv[typemap[otype]] += oname + ' '
644 typeconv[typemap[otype]] += oname + ' '
641 return typeconv
645 return typeconv
642
646
643 #----------------------------------------------------------------------------
647 #----------------------------------------------------------------------------
644 def read_dict(filename,type_conv=None,**opt):
648 def read_dict(filename,type_conv=None,**opt):
645
649
646 """Read a dictionary of key=value pairs from an input file, optionally
650 """Read a dictionary of key=value pairs from an input file, optionally
647 performing conversions on the resulting values.
651 performing conversions on the resulting values.
648
652
649 read_dict(filename,type_conv,**opt) -> dict
653 read_dict(filename,type_conv,**opt) -> dict
650
654
651 Only one value per line is accepted, the format should be
655 Only one value per line is accepted, the format should be
652 # optional comments are ignored
656 # optional comments are ignored
653 key value\n
657 key value\n
654
658
655 Args:
659 Args:
656
660
657 - type_conv: A dictionary specifying which keys need to be converted to
661 - 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
662 which types. By default all keys are read as strings. This dictionary
659 should have as its keys valid conversion functions for strings
663 should have as its keys valid conversion functions for strings
660 (int,long,float,complex, or your own). The value for each key
664 (int,long,float,complex, or your own). The value for each key
661 (converter) should be a whitespace separated string containing the names
665 (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
666 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
667 keys to be left alone, use None as the conversion function (only needed
664 with purge=1, see below).
668 with purge=1, see below).
665
669
666 - opt: dictionary with extra options as below (default in parens)
670 - opt: dictionary with extra options as below (default in parens)
667
671
668 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
672 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
673 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
674 set of keys to be left as strings also has to be explicitly specified
671 using the (non-existent) conversion function None.
675 using the (non-existent) conversion function None.
672
676
673 fs(None): field separator. This is the key/value separator to be used
677 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
678 when parsing the file. The None default means any whitespace [behavior
675 of string.split()].
679 of string.split()].
676
680
677 strip(0): if 1, strip string values of leading/trailinig whitespace.
681 strip(0): if 1, strip string values of leading/trailinig whitespace.
678
682
679 warn(1): warning level if requested keys are not found in file.
683 warn(1): warning level if requested keys are not found in file.
680 - 0: silently ignore.
684 - 0: silently ignore.
681 - 1: inform but proceed.
685 - 1: inform but proceed.
682 - 2: raise KeyError exception.
686 - 2: raise KeyError exception.
683
687
684 no_empty(0): if 1, remove keys with whitespace strings as a value.
688 no_empty(0): if 1, remove keys with whitespace strings as a value.
685
689
686 unique([]): list of keys (or space separated string) which can't be
690 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
691 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
692 overwrites the previous one. For keys not listed here, the behavior is
689 to make a list of all appearances.
693 to make a list of all appearances.
690
694
691 Example:
695 Example:
692 If the input file test.ini has:
696 If the input file test.ini has:
693 i 3
697 i 3
694 x 4.5
698 x 4.5
695 y 5.5
699 y 5.5
696 s hi ho
700 s hi ho
697 Then:
701 Then:
698
702
699 >>> type_conv={int:'i',float:'x',None:'s'}
703 >>> type_conv={int:'i',float:'x',None:'s'}
700 >>> read_dict('test.ini')
704 >>> read_dict('test.ini')
701 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
705 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
702 >>> read_dict('test.ini',type_conv)
706 >>> read_dict('test.ini',type_conv)
703 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
707 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
704 >>> read_dict('test.ini',type_conv,purge=1)
708 >>> read_dict('test.ini',type_conv,purge=1)
705 {'i': 3, 's': 'hi ho', 'x': 4.5}
709 {'i': 3, 's': 'hi ho', 'x': 4.5}
706 """
710 """
707
711
708 # starting config
712 # starting config
709 opt.setdefault('purge',0)
713 opt.setdefault('purge',0)
710 opt.setdefault('fs',None) # field sep defaults to any whitespace
714 opt.setdefault('fs',None) # field sep defaults to any whitespace
711 opt.setdefault('strip',0)
715 opt.setdefault('strip',0)
712 opt.setdefault('warn',1)
716 opt.setdefault('warn',1)
713 opt.setdefault('no_empty',0)
717 opt.setdefault('no_empty',0)
714 opt.setdefault('unique','')
718 opt.setdefault('unique','')
715 if type(opt['unique']) in StringTypes:
719 if type(opt['unique']) in StringTypes:
716 unique_keys = qw(opt['unique'])
720 unique_keys = qw(opt['unique'])
717 elif type(opt['unique']) in (types.TupleType,types.ListType):
721 elif type(opt['unique']) in (types.TupleType,types.ListType):
718 unique_keys = opt['unique']
722 unique_keys = opt['unique']
719 else:
723 else:
720 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
724 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
721
725
722 dict = {}
726 dict = {}
723 # first read in table of values as strings
727 # first read in table of values as strings
724 file = open(filename,'r')
728 file = open(filename,'r')
725 for line in file.readlines():
729 for line in file.readlines():
726 line = line.strip()
730 line = line.strip()
727 if len(line) and line[0]=='#': continue
731 if len(line) and line[0]=='#': continue
728 if len(line)>0:
732 if len(line)>0:
729 lsplit = line.split(opt['fs'],1)
733 lsplit = line.split(opt['fs'],1)
730 try:
734 try:
731 key,val = lsplit
735 key,val = lsplit
732 except ValueError:
736 except ValueError:
733 key,val = lsplit[0],''
737 key,val = lsplit[0],''
734 key = key.strip()
738 key = key.strip()
735 if opt['strip']: val = val.strip()
739 if opt['strip']: val = val.strip()
736 if val == "''" or val == '""': val = ''
740 if val == "''" or val == '""': val = ''
737 if opt['no_empty'] and (val=='' or val.isspace()):
741 if opt['no_empty'] and (val=='' or val.isspace()):
738 continue
742 continue
739 # if a key is found more than once in the file, build a list
743 # 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
744 # unless it's in the 'unique' list. In that case, last found in file
741 # takes precedence. User beware.
745 # takes precedence. User beware.
742 try:
746 try:
743 if dict[key] and key in unique_keys:
747 if dict[key] and key in unique_keys:
744 dict[key] = val
748 dict[key] = val
745 elif type(dict[key]) is types.ListType:
749 elif type(dict[key]) is types.ListType:
746 dict[key].append(val)
750 dict[key].append(val)
747 else:
751 else:
748 dict[key] = [dict[key],val]
752 dict[key] = [dict[key],val]
749 except KeyError:
753 except KeyError:
750 dict[key] = val
754 dict[key] = val
751 # purge if requested
755 # purge if requested
752 if opt['purge']:
756 if opt['purge']:
753 accepted_keys = qwflat(type_conv.values())
757 accepted_keys = qwflat(type_conv.values())
754 for key in dict.keys():
758 for key in dict.keys():
755 if key in accepted_keys: continue
759 if key in accepted_keys: continue
756 del(dict[key])
760 del(dict[key])
757 # now convert if requested
761 # now convert if requested
758 if type_conv==None: return dict
762 if type_conv==None: return dict
759 conversions = type_conv.keys()
763 conversions = type_conv.keys()
760 try: conversions.remove(None)
764 try: conversions.remove(None)
761 except: pass
765 except: pass
762 for convert in conversions:
766 for convert in conversions:
763 for val in qw(type_conv[convert]):
767 for val in qw(type_conv[convert]):
764 try:
768 try:
765 dict[val] = convert(dict[val])
769 dict[val] = convert(dict[val])
766 except KeyError,e:
770 except KeyError,e:
767 if opt['warn'] == 0:
771 if opt['warn'] == 0:
768 pass
772 pass
769 elif opt['warn'] == 1:
773 elif opt['warn'] == 1:
770 print >>sys.stderr, 'Warning: key',val,\
774 print >>sys.stderr, 'Warning: key',val,\
771 'not found in file',filename
775 'not found in file',filename
772 elif opt['warn'] == 2:
776 elif opt['warn'] == 2:
773 raise KeyError,e
777 raise KeyError,e
774 else:
778 else:
775 raise ValueError,'Warning level must be 0,1 or 2'
779 raise ValueError,'Warning level must be 0,1 or 2'
776
780
777 return dict
781 return dict
778
782
779 #----------------------------------------------------------------------------
783 #----------------------------------------------------------------------------
780 def flag_calls(func):
784 def flag_calls(func):
781 """Wrap a function to detect and flag when it gets called.
785 """Wrap a function to detect and flag when it gets called.
782
786
783 This is a decorator which takes a function and wraps it in a function with
787 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.
788 a 'called' attribute. wrapper.called is initialized to False.
785
789
786 The wrapper.called attribute is set to False right before each call to the
790 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
791 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.
792 completes, wrapper.called is set to True and the output is returned.
789
793
790 Testing for truth in wrapper.called allows you to determine if a call to
794 Testing for truth in wrapper.called allows you to determine if a call to
791 func() was attempted and succeeded."""
795 func() was attempted and succeeded."""
792
796
793 def wrapper(*args,**kw):
797 def wrapper(*args,**kw):
794 wrapper.called = False
798 wrapper.called = False
795 out = func(*args,**kw)
799 out = func(*args,**kw)
796 wrapper.called = True
800 wrapper.called = True
797 return out
801 return out
798
802
799 wrapper.called = False
803 wrapper.called = False
800 wrapper.__doc__ = func.__doc__
804 wrapper.__doc__ = func.__doc__
801 return wrapper
805 return wrapper
802
806
803 #----------------------------------------------------------------------------
807 #----------------------------------------------------------------------------
804 class HomeDirError(Error):
808 class HomeDirError(Error):
805 pass
809 pass
806
810
807 def get_home_dir():
811 def get_home_dir():
808 """Return the closest possible equivalent to a 'home' directory.
812 """Return the closest possible equivalent to a 'home' directory.
809
813
810 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
814 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
811
815
812 Currently only Posix and NT are implemented, a HomeDirError exception is
816 Currently only Posix and NT are implemented, a HomeDirError exception is
813 raised for all other OSes. """
817 raised for all other OSes. """
814
818
815 isdir = os.path.isdir
819 isdir = os.path.isdir
816 env = os.environ
820 env = os.environ
817 try:
821 try:
818 homedir = env['HOME']
822 homedir = env['HOME']
819 if not isdir(homedir):
823 if not isdir(homedir):
820 # in case a user stuck some string which does NOT resolve to a
824 # 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
825 # valid path, it's as good as if we hadn't foud it
822 raise KeyError
826 raise KeyError
823 return homedir
827 return homedir
824 except KeyError:
828 except KeyError:
825 if os.name == 'posix':
829 if os.name == 'posix':
826 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
830 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
827 elif os.name == 'nt':
831 elif os.name == 'nt':
828 # For some strange reason, win9x returns 'nt' for os.name.
832 # For some strange reason, win9x returns 'nt' for os.name.
829 try:
833 try:
830 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
834 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
831 if not isdir(homedir):
835 if not isdir(homedir):
832 homedir = os.path.join(env['USERPROFILE'])
836 homedir = os.path.join(env['USERPROFILE'])
833 if not isdir(homedir):
837 if not isdir(homedir):
834 raise HomeDirError
838 raise HomeDirError
835 return homedir
839 return homedir
836 except:
840 except:
837 try:
841 try:
838 # Use the registry to get the 'My Documents' folder.
842 # Use the registry to get the 'My Documents' folder.
839 import _winreg as wreg
843 import _winreg as wreg
840 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
844 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
841 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
845 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
842 homedir = wreg.QueryValueEx(key,'Personal')[0]
846 homedir = wreg.QueryValueEx(key,'Personal')[0]
843 key.Close()
847 key.Close()
844 if not isdir(homedir):
848 if not isdir(homedir):
845 e = ('Invalid "Personal" folder registry key '
849 e = ('Invalid "Personal" folder registry key '
846 'typically "My Documents".\n'
850 'typically "My Documents".\n'
847 'Value: %s\n'
851 'Value: %s\n'
848 'This is not a valid directory on your system.' %
852 'This is not a valid directory on your system.' %
849 homedir)
853 homedir)
850 raise HomeDirError(e)
854 raise HomeDirError(e)
851 return homedir
855 return homedir
852 except HomeDirError:
856 except HomeDirError:
853 raise
857 raise
854 except:
858 except:
855 return 'C:\\'
859 return 'C:\\'
856 elif os.name == 'dos':
860 elif os.name == 'dos':
857 # Desperate, may do absurd things in classic MacOS. May work under DOS.
861 # Desperate, may do absurd things in classic MacOS. May work under DOS.
858 return 'C:\\'
862 return 'C:\\'
859 else:
863 else:
860 raise HomeDirError,'support for your operating system not implemented.'
864 raise HomeDirError,'support for your operating system not implemented.'
861
865
862 #****************************************************************************
866 #****************************************************************************
863 # strings and text
867 # strings and text
864
868
865 class LSString(str):
869 class LSString(str):
866 """String derivative with a special access attributes.
870 """String derivative with a special access attributes.
867
871
868 These are normal strings, but with the special attributes:
872 These are normal strings, but with the special attributes:
869
873
870 .l (or .list) : value as list (split on newlines).
874 .l (or .list) : value as list (split on newlines).
871 .n (or .nlstr): original value (the string itself).
875 .n (or .nlstr): original value (the string itself).
872 .s (or .spstr): value as whitespace-separated string.
876 .s (or .spstr): value as whitespace-separated string.
873
877
874 Any values which require transformations are computed only once and
878 Any values which require transformations are computed only once and
875 cached.
879 cached.
876
880
877 Such strings are very useful to efficiently interact with the shell, which
881 Such strings are very useful to efficiently interact with the shell, which
878 typically only understands whitespace-separated options for commands."""
882 typically only understands whitespace-separated options for commands."""
879
883
880 def get_list(self):
884 def get_list(self):
881 try:
885 try:
882 return self.__list
886 return self.__list
883 except AttributeError:
887 except AttributeError:
884 self.__list = self.split('\n')
888 self.__list = self.split('\n')
885 return self.__list
889 return self.__list
886
890
887 l = list = property(get_list)
891 l = list = property(get_list)
888
892
889 def get_spstr(self):
893 def get_spstr(self):
890 try:
894 try:
891 return self.__spstr
895 return self.__spstr
892 except AttributeError:
896 except AttributeError:
893 self.__spstr = self.replace('\n',' ')
897 self.__spstr = self.replace('\n',' ')
894 return self.__spstr
898 return self.__spstr
895
899
896 s = spstr = property(get_spstr)
900 s = spstr = property(get_spstr)
897
901
898 def get_nlstr(self):
902 def get_nlstr(self):
899 return self
903 return self
900
904
901 n = nlstr = property(get_nlstr)
905 n = nlstr = property(get_nlstr)
902
906
903 def get_paths(self):
907 def get_paths(self):
904 try:
908 try:
905 return self.__paths
909 return self.__paths
906 except AttributeError:
910 except AttributeError:
907 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
911 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
908 return self.__paths
912 return self.__paths
909
913
910 p = paths = property(get_paths)
914 p = paths = property(get_paths)
911
915
912
916
913 #----------------------------------------------------------------------------
917 #----------------------------------------------------------------------------
914 class SList(list):
918 class SList(list):
915 """List derivative with a special access attributes.
919 """List derivative with a special access attributes.
916
920
917 These are normal lists, but with the special attributes:
921 These are normal lists, but with the special attributes:
918
922
919 .l (or .list) : value as list (the list itself).
923 .l (or .list) : value as list (the list itself).
920 .n (or .nlstr): value as a string, joined on newlines.
924 .n (or .nlstr): value as a string, joined on newlines.
921 .s (or .spstr): value as a string, joined on spaces.
925 .s (or .spstr): value as a string, joined on spaces.
922
926
923 Any values which require transformations are computed only once and
927 Any values which require transformations are computed only once and
924 cached."""
928 cached."""
925
929
926 def get_list(self):
930 def get_list(self):
927 return self
931 return self
928
932
929 l = list = property(get_list)
933 l = list = property(get_list)
930
934
931 def get_spstr(self):
935 def get_spstr(self):
932 try:
936 try:
933 return self.__spstr
937 return self.__spstr
934 except AttributeError:
938 except AttributeError:
935 self.__spstr = ' '.join(self)
939 self.__spstr = ' '.join(self)
936 return self.__spstr
940 return self.__spstr
937
941
938 s = spstr = property(get_spstr)
942 s = spstr = property(get_spstr)
939
943
940 def get_nlstr(self):
944 def get_nlstr(self):
941 try:
945 try:
942 return self.__nlstr
946 return self.__nlstr
943 except AttributeError:
947 except AttributeError:
944 self.__nlstr = '\n'.join(self)
948 self.__nlstr = '\n'.join(self)
945 return self.__nlstr
949 return self.__nlstr
946
950
947 n = nlstr = property(get_nlstr)
951 n = nlstr = property(get_nlstr)
948
952
949 def get_paths(self):
953 def get_paths(self):
950 try:
954 try:
951 return self.__paths
955 return self.__paths
952 except AttributeError:
956 except AttributeError:
953 self.__paths = [path(p) for p in self if os.path.exists(p)]
957 self.__paths = [path(p) for p in self if os.path.exists(p)]
954 return self.__paths
958 return self.__paths
955
959
956 p = paths = property(get_paths)
960 p = paths = property(get_paths)
957
961
958 #----------------------------------------------------------------------------
962 #----------------------------------------------------------------------------
959 def esc_quotes(strng):
963 def esc_quotes(strng):
960 """Return the input string with single and double quotes escaped out"""
964 """Return the input string with single and double quotes escaped out"""
961
965
962 return strng.replace('"','\\"').replace("'","\\'")
966 return strng.replace('"','\\"').replace("'","\\'")
963
967
964 #----------------------------------------------------------------------------
968 #----------------------------------------------------------------------------
965 def make_quoted_expr(s):
969 def make_quoted_expr(s):
966 """Return string s in appropriate quotes, using raw string if possible.
970 """Return string s in appropriate quotes, using raw string if possible.
967
971
968 Effectively this turns string: cd \ao\ao\
972 Effectively this turns string: cd \ao\ao\
969 to: r"cd \ao\ao\_"[:-1]
973 to: r"cd \ao\ao\_"[:-1]
970
974
971 Note the use of raw string and padding at the end to allow trailing backslash.
975 Note the use of raw string and padding at the end to allow trailing backslash.
972
976
973 """
977 """
974
978
975 tail = ''
979 tail = ''
976 tailpadding = ''
980 tailpadding = ''
977 raw = ''
981 raw = ''
978 if "\\" in s:
982 if "\\" in s:
979 raw = 'r'
983 raw = 'r'
980 if s.endswith('\\'):
984 if s.endswith('\\'):
981 tail = '[:-1]'
985 tail = '[:-1]'
982 tailpadding = '_'
986 tailpadding = '_'
983 if '"' not in s:
987 if '"' not in s:
984 quote = '"'
988 quote = '"'
985 elif "'" not in s:
989 elif "'" not in s:
986 quote = "'"
990 quote = "'"
987 elif '"""' not in s and not s.endswith('"'):
991 elif '"""' not in s and not s.endswith('"'):
988 quote = '"""'
992 quote = '"""'
989 elif "'''" not in s and not s.endswith("'"):
993 elif "'''" not in s and not s.endswith("'"):
990 quote = "'''"
994 quote = "'''"
991 else:
995 else:
992 # give up, backslash-escaped string will do
996 # give up, backslash-escaped string will do
993 return '"%s"' % esc_quotes(s)
997 return '"%s"' % esc_quotes(s)
994 res = itpl("$raw$quote$s$tailpadding$quote$tail")
998 res = itpl("$raw$quote$s$tailpadding$quote$tail")
995 return res
999 return res
996
1000
997
1001
998 #----------------------------------------------------------------------------
1002 #----------------------------------------------------------------------------
999 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1003 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1000 """Take multiple lines of input.
1004 """Take multiple lines of input.
1001
1005
1002 A list with each line of input as a separate element is returned when a
1006 A list with each line of input as a separate element is returned when a
1003 termination string is entered (defaults to a single '.'). Input can also
1007 termination string is entered (defaults to a single '.'). Input can also
1004 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1008 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1005
1009
1006 Lines of input which end in \\ are joined into single entries (and a
1010 Lines of input which end in \\ are joined into single entries (and a
1007 secondary continuation prompt is issued as long as the user terminates
1011 secondary continuation prompt is issued as long as the user terminates
1008 lines with \\). This allows entering very long strings which are still
1012 lines with \\). This allows entering very long strings which are still
1009 meant to be treated as single entities.
1013 meant to be treated as single entities.
1010 """
1014 """
1011
1015
1012 try:
1016 try:
1013 if header:
1017 if header:
1014 header += '\n'
1018 header += '\n'
1015 lines = [raw_input(header + ps1)]
1019 lines = [raw_input(header + ps1)]
1016 except EOFError:
1020 except EOFError:
1017 return []
1021 return []
1018 terminate = [terminate_str]
1022 terminate = [terminate_str]
1019 try:
1023 try:
1020 while lines[-1:] != terminate:
1024 while lines[-1:] != terminate:
1021 new_line = raw_input(ps1)
1025 new_line = raw_input(ps1)
1022 while new_line.endswith('\\'):
1026 while new_line.endswith('\\'):
1023 new_line = new_line[:-1] + raw_input(ps2)
1027 new_line = new_line[:-1] + raw_input(ps2)
1024 lines.append(new_line)
1028 lines.append(new_line)
1025
1029
1026 return lines[:-1] # don't return the termination command
1030 return lines[:-1] # don't return the termination command
1027 except EOFError:
1031 except EOFError:
1028 print
1032 print
1029 return lines
1033 return lines
1030
1034
1031 #----------------------------------------------------------------------------
1035 #----------------------------------------------------------------------------
1032 def raw_input_ext(prompt='', ps2='... '):
1036 def raw_input_ext(prompt='', ps2='... '):
1033 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1037 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1034
1038
1035 line = raw_input(prompt)
1039 line = raw_input(prompt)
1036 while line.endswith('\\'):
1040 while line.endswith('\\'):
1037 line = line[:-1] + raw_input(ps2)
1041 line = line[:-1] + raw_input(ps2)
1038 return line
1042 return line
1039
1043
1040 #----------------------------------------------------------------------------
1044 #----------------------------------------------------------------------------
1041 def ask_yes_no(prompt,default=None):
1045 def ask_yes_no(prompt,default=None):
1042 """Asks a question and returns an integer 1/0 (y/n) answer.
1046 """Asks a question and returns an integer 1/0 (y/n) answer.
1043
1047
1044 If default is given (one of 'y','n'), it is used if the user input is
1048 If default is given (one of 'y','n'), it is used if the user input is
1045 empty. Otherwise the question is repeated until an answer is given.
1049 empty. Otherwise the question is repeated until an answer is given.
1046 If EOF occurs 20 times consecutively, the default answer is assumed,
1050 If EOF occurs 20 times consecutively, the default answer is assumed,
1047 or if there is no default, an exception is raised to prevent infinite
1051 or if there is no default, an exception is raised to prevent infinite
1048 loops.
1052 loops.
1049
1053
1050 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1054 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1051
1055
1052 answers = {'y':True,'n':False,'yes':True,'no':False}
1056 answers = {'y':True,'n':False,'yes':True,'no':False}
1053 ans = None
1057 ans = None
1054 eofs, max_eofs = 0, 20
1058 eofs, max_eofs = 0, 20
1055 while ans not in answers.keys():
1059 while ans not in answers.keys():
1056 try:
1060 try:
1057 ans = raw_input(prompt+' ').lower()
1061 ans = raw_input(prompt+' ').lower()
1058 if not ans: # response was an empty string
1062 if not ans: # response was an empty string
1059 ans = default
1063 ans = default
1060 eofs = 0
1064 eofs = 0
1061 except (EOFError,KeyboardInterrupt):
1065 except (EOFError,KeyboardInterrupt):
1062 eofs = eofs + 1
1066 eofs = eofs + 1
1063 if eofs >= max_eofs:
1067 if eofs >= max_eofs:
1064 if default in answers.keys():
1068 if default in answers.keys():
1065 ans = default
1069 ans = default
1066 else:
1070 else:
1067 raise
1071 raise
1068
1072
1069 return answers[ans]
1073 return answers[ans]
1070
1074
1071 #----------------------------------------------------------------------------
1075 #----------------------------------------------------------------------------
1072 def marquee(txt='',width=78,mark='*'):
1076 def marquee(txt='',width=78,mark='*'):
1073 """Return the input string centered in a 'marquee'."""
1077 """Return the input string centered in a 'marquee'."""
1074 if not txt:
1078 if not txt:
1075 return (mark*width)[:width]
1079 return (mark*width)[:width]
1076 nmark = (width-len(txt)-2)/len(mark)/2
1080 nmark = (width-len(txt)-2)/len(mark)/2
1077 if nmark < 0: nmark =0
1081 if nmark < 0: nmark =0
1078 marks = mark*nmark
1082 marks = mark*nmark
1079 return '%s %s %s' % (marks,txt,marks)
1083 return '%s %s %s' % (marks,txt,marks)
1080
1084
1081 #----------------------------------------------------------------------------
1085 #----------------------------------------------------------------------------
1082 class EvalDict:
1086 class EvalDict:
1083 """
1087 """
1084 Emulate a dict which evaluates its contents in the caller's frame.
1088 Emulate a dict which evaluates its contents in the caller's frame.
1085
1089
1086 Usage:
1090 Usage:
1087 >>>number = 19
1091 >>>number = 19
1088 >>>text = "python"
1092 >>>text = "python"
1089 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1093 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1090 """
1094 """
1091
1095
1092 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1096 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1093 # modified (shorter) version of:
1097 # modified (shorter) version of:
1094 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1098 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1095 # Skip Montanaro (skip@pobox.com).
1099 # Skip Montanaro (skip@pobox.com).
1096
1100
1097 def __getitem__(self, name):
1101 def __getitem__(self, name):
1098 frame = sys._getframe(1)
1102 frame = sys._getframe(1)
1099 return eval(name, frame.f_globals, frame.f_locals)
1103 return eval(name, frame.f_globals, frame.f_locals)
1100
1104
1101 EvalString = EvalDict # for backwards compatibility
1105 EvalString = EvalDict # for backwards compatibility
1102 #----------------------------------------------------------------------------
1106 #----------------------------------------------------------------------------
1103 def qw(words,flat=0,sep=None,maxsplit=-1):
1107 def qw(words,flat=0,sep=None,maxsplit=-1):
1104 """Similar to Perl's qw() operator, but with some more options.
1108 """Similar to Perl's qw() operator, but with some more options.
1105
1109
1106 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1110 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1107
1111
1108 words can also be a list itself, and with flat=1, the output will be
1112 words can also be a list itself, and with flat=1, the output will be
1109 recursively flattened. Examples:
1113 recursively flattened. Examples:
1110
1114
1111 >>> qw('1 2')
1115 >>> qw('1 2')
1112 ['1', '2']
1116 ['1', '2']
1113 >>> qw(['a b','1 2',['m n','p q']])
1117 >>> qw(['a b','1 2',['m n','p q']])
1114 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1118 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1115 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1119 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1116 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1120 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1117
1121
1118 if type(words) in StringTypes:
1122 if type(words) in StringTypes:
1119 return [word.strip() for word in words.split(sep,maxsplit)
1123 return [word.strip() for word in words.split(sep,maxsplit)
1120 if word and not word.isspace() ]
1124 if word and not word.isspace() ]
1121 if flat:
1125 if flat:
1122 return flatten(map(qw,words,[1]*len(words)))
1126 return flatten(map(qw,words,[1]*len(words)))
1123 return map(qw,words)
1127 return map(qw,words)
1124
1128
1125 #----------------------------------------------------------------------------
1129 #----------------------------------------------------------------------------
1126 def qwflat(words,sep=None,maxsplit=-1):
1130 def qwflat(words,sep=None,maxsplit=-1):
1127 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1131 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1128 return qw(words,1,sep,maxsplit)
1132 return qw(words,1,sep,maxsplit)
1129
1133
1130 #----------------------------------------------------------------------------
1134 #----------------------------------------------------------------------------
1131 def qw_lol(indata):
1135 def qw_lol(indata):
1132 """qw_lol('a b') -> [['a','b']],
1136 """qw_lol('a b') -> [['a','b']],
1133 otherwise it's just a call to qw().
1137 otherwise it's just a call to qw().
1134
1138
1135 We need this to make sure the modules_some keys *always* end up as a
1139 We need this to make sure the modules_some keys *always* end up as a
1136 list of lists."""
1140 list of lists."""
1137
1141
1138 if type(indata) in StringTypes:
1142 if type(indata) in StringTypes:
1139 return [qw(indata)]
1143 return [qw(indata)]
1140 else:
1144 else:
1141 return qw(indata)
1145 return qw(indata)
1142
1146
1143 #-----------------------------------------------------------------------------
1147 #-----------------------------------------------------------------------------
1144 def list_strings(arg):
1148 def list_strings(arg):
1145 """Always return a list of strings, given a string or list of strings
1149 """Always return a list of strings, given a string or list of strings
1146 as input."""
1150 as input."""
1147
1151
1148 if type(arg) in StringTypes: return [arg]
1152 if type(arg) in StringTypes: return [arg]
1149 else: return arg
1153 else: return arg
1150
1154
1151 #----------------------------------------------------------------------------
1155 #----------------------------------------------------------------------------
1152 def grep(pat,list,case=1):
1156 def grep(pat,list,case=1):
1153 """Simple minded grep-like function.
1157 """Simple minded grep-like function.
1154 grep(pat,list) returns occurrences of pat in list, None on failure.
1158 grep(pat,list) returns occurrences of pat in list, None on failure.
1155
1159
1156 It only does simple string matching, with no support for regexps. Use the
1160 It only does simple string matching, with no support for regexps. Use the
1157 option case=0 for case-insensitive matching."""
1161 option case=0 for case-insensitive matching."""
1158
1162
1159 # This is pretty crude. At least it should implement copying only references
1163 # This is pretty crude. At least it should implement copying only references
1160 # to the original data in case it's big. Now it copies the data for output.
1164 # to the original data in case it's big. Now it copies the data for output.
1161 out=[]
1165 out=[]
1162 if case:
1166 if case:
1163 for term in list:
1167 for term in list:
1164 if term.find(pat)>-1: out.append(term)
1168 if term.find(pat)>-1: out.append(term)
1165 else:
1169 else:
1166 lpat=pat.lower()
1170 lpat=pat.lower()
1167 for term in list:
1171 for term in list:
1168 if term.lower().find(lpat)>-1: out.append(term)
1172 if term.lower().find(lpat)>-1: out.append(term)
1169
1173
1170 if len(out): return out
1174 if len(out): return out
1171 else: return None
1175 else: return None
1172
1176
1173 #----------------------------------------------------------------------------
1177 #----------------------------------------------------------------------------
1174 def dgrep(pat,*opts):
1178 def dgrep(pat,*opts):
1175 """Return grep() on dir()+dir(__builtins__).
1179 """Return grep() on dir()+dir(__builtins__).
1176
1180
1177 A very common use of grep() when working interactively."""
1181 A very common use of grep() when working interactively."""
1178
1182
1179 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1183 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1180
1184
1181 #----------------------------------------------------------------------------
1185 #----------------------------------------------------------------------------
1182 def idgrep(pat):
1186 def idgrep(pat):
1183 """Case-insensitive dgrep()"""
1187 """Case-insensitive dgrep()"""
1184
1188
1185 return dgrep(pat,0)
1189 return dgrep(pat,0)
1186
1190
1187 #----------------------------------------------------------------------------
1191 #----------------------------------------------------------------------------
1188 def igrep(pat,list):
1192 def igrep(pat,list):
1189 """Synonym for case-insensitive grep."""
1193 """Synonym for case-insensitive grep."""
1190
1194
1191 return grep(pat,list,case=0)
1195 return grep(pat,list,case=0)
1192
1196
1193 #----------------------------------------------------------------------------
1197 #----------------------------------------------------------------------------
1194 def indent(str,nspaces=4,ntabs=0):
1198 def indent(str,nspaces=4,ntabs=0):
1195 """Indent a string a given number of spaces or tabstops.
1199 """Indent a string a given number of spaces or tabstops.
1196
1200
1197 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1201 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1198 """
1202 """
1199 if str is None:
1203 if str is None:
1200 return
1204 return
1201 ind = '\t'*ntabs+' '*nspaces
1205 ind = '\t'*ntabs+' '*nspaces
1202 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1206 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1203 if outstr.endswith(os.linesep+ind):
1207 if outstr.endswith(os.linesep+ind):
1204 return outstr[:-len(ind)]
1208 return outstr[:-len(ind)]
1205 else:
1209 else:
1206 return outstr
1210 return outstr
1207
1211
1208 #-----------------------------------------------------------------------------
1212 #-----------------------------------------------------------------------------
1209 def native_line_ends(filename,backup=1):
1213 def native_line_ends(filename,backup=1):
1210 """Convert (in-place) a file to line-ends native to the current OS.
1214 """Convert (in-place) a file to line-ends native to the current OS.
1211
1215
1212 If the optional backup argument is given as false, no backup of the
1216 If the optional backup argument is given as false, no backup of the
1213 original file is left. """
1217 original file is left. """
1214
1218
1215 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1219 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1216
1220
1217 bak_filename = filename + backup_suffixes[os.name]
1221 bak_filename = filename + backup_suffixes[os.name]
1218
1222
1219 original = open(filename).read()
1223 original = open(filename).read()
1220 shutil.copy2(filename,bak_filename)
1224 shutil.copy2(filename,bak_filename)
1221 try:
1225 try:
1222 new = open(filename,'wb')
1226 new = open(filename,'wb')
1223 new.write(os.linesep.join(original.splitlines()))
1227 new.write(os.linesep.join(original.splitlines()))
1224 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1228 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1225 new.close()
1229 new.close()
1226 except:
1230 except:
1227 os.rename(bak_filename,filename)
1231 os.rename(bak_filename,filename)
1228 if not backup:
1232 if not backup:
1229 try:
1233 try:
1230 os.remove(bak_filename)
1234 os.remove(bak_filename)
1231 except:
1235 except:
1232 pass
1236 pass
1233
1237
1234 #----------------------------------------------------------------------------
1238 #----------------------------------------------------------------------------
1235 def get_pager_cmd(pager_cmd = None):
1239 def get_pager_cmd(pager_cmd = None):
1236 """Return a pager command.
1240 """Return a pager command.
1237
1241
1238 Makes some attempts at finding an OS-correct one."""
1242 Makes some attempts at finding an OS-correct one."""
1239
1243
1240 if os.name == 'posix':
1244 if os.name == 'posix':
1241 default_pager_cmd = 'less -r' # -r for color control sequences
1245 default_pager_cmd = 'less -r' # -r for color control sequences
1242 elif os.name in ['nt','dos']:
1246 elif os.name in ['nt','dos']:
1243 default_pager_cmd = 'type'
1247 default_pager_cmd = 'type'
1244
1248
1245 if pager_cmd is None:
1249 if pager_cmd is None:
1246 try:
1250 try:
1247 pager_cmd = os.environ['PAGER']
1251 pager_cmd = os.environ['PAGER']
1248 except:
1252 except:
1249 pager_cmd = default_pager_cmd
1253 pager_cmd = default_pager_cmd
1250 return pager_cmd
1254 return pager_cmd
1251
1255
1252 #-----------------------------------------------------------------------------
1256 #-----------------------------------------------------------------------------
1253 def get_pager_start(pager,start):
1257 def get_pager_start(pager,start):
1254 """Return the string for paging files with an offset.
1258 """Return the string for paging files with an offset.
1255
1259
1256 This is the '+N' argument which less and more (under Unix) accept.
1260 This is the '+N' argument which less and more (under Unix) accept.
1257 """
1261 """
1258
1262
1259 if pager in ['less','more']:
1263 if pager in ['less','more']:
1260 if start:
1264 if start:
1261 start_string = '+' + str(start)
1265 start_string = '+' + str(start)
1262 else:
1266 else:
1263 start_string = ''
1267 start_string = ''
1264 else:
1268 else:
1265 start_string = ''
1269 start_string = ''
1266 return start_string
1270 return start_string
1267
1271
1268 #----------------------------------------------------------------------------
1272 #----------------------------------------------------------------------------
1269 if os.name == "nt":
1273 if os.name == "nt":
1270 import msvcrt
1274 import msvcrt
1271 def page_more():
1275 def page_more():
1272 """ Smart pausing between pages
1276 """ Smart pausing between pages
1273
1277
1274 @return: True if need print more lines, False if quit
1278 @return: True if need print more lines, False if quit
1275 """
1279 """
1276 Term.cout.write('---Return to continue, q to quit--- ')
1280 Term.cout.write('---Return to continue, q to quit--- ')
1277 ans = msvcrt.getch()
1281 ans = msvcrt.getch()
1278 if ans in ("q", "Q"):
1282 if ans in ("q", "Q"):
1279 result = False
1283 result = False
1280 else:
1284 else:
1281 result = True
1285 result = True
1282 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1286 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1283 return result
1287 return result
1284 else:
1288 else:
1285 def page_more():
1289 def page_more():
1286 ans = raw_input('---Return to continue, q to quit--- ')
1290 ans = raw_input('---Return to continue, q to quit--- ')
1287 if ans.lower().startswith('q'):
1291 if ans.lower().startswith('q'):
1288 return False
1292 return False
1289 else:
1293 else:
1290 return True
1294 return True
1291
1295
1292 esc_re = re.compile(r"(\x1b[^m]+m)")
1296 esc_re = re.compile(r"(\x1b[^m]+m)")
1293
1297
1294 def page_dumb(strng,start=0,screen_lines=25):
1298 def page_dumb(strng,start=0,screen_lines=25):
1295 """Very dumb 'pager' in Python, for when nothing else works.
1299 """Very dumb 'pager' in Python, for when nothing else works.
1296
1300
1297 Only moves forward, same interface as page(), except for pager_cmd and
1301 Only moves forward, same interface as page(), except for pager_cmd and
1298 mode."""
1302 mode."""
1299
1303
1300 out_ln = strng.splitlines()[start:]
1304 out_ln = strng.splitlines()[start:]
1301 screens = chop(out_ln,screen_lines-1)
1305 screens = chop(out_ln,screen_lines-1)
1302 if len(screens) == 1:
1306 if len(screens) == 1:
1303 print >>Term.cout, os.linesep.join(screens[0])
1307 print >>Term.cout, os.linesep.join(screens[0])
1304 else:
1308 else:
1305 last_escape = ""
1309 last_escape = ""
1306 for scr in screens[0:-1]:
1310 for scr in screens[0:-1]:
1307 hunk = os.linesep.join(scr)
1311 hunk = os.linesep.join(scr)
1308 print >>Term.cout, last_escape + hunk
1312 print >>Term.cout, last_escape + hunk
1309 if not page_more():
1313 if not page_more():
1310 return
1314 return
1311 esc_list = esc_re.findall(hunk)
1315 esc_list = esc_re.findall(hunk)
1312 if len(esc_list) > 0:
1316 if len(esc_list) > 0:
1313 last_escape = esc_list[-1]
1317 last_escape = esc_list[-1]
1314 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1318 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1315
1319
1316 #----------------------------------------------------------------------------
1320 #----------------------------------------------------------------------------
1317 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1321 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1318 """Print a string, piping through a pager after a certain length.
1322 """Print a string, piping through a pager after a certain length.
1319
1323
1320 The screen_lines parameter specifies the number of *usable* lines of your
1324 The screen_lines parameter specifies the number of *usable* lines of your
1321 terminal screen (total lines minus lines you need to reserve to show other
1325 terminal screen (total lines minus lines you need to reserve to show other
1322 information).
1326 information).
1323
1327
1324 If you set screen_lines to a number <=0, page() will try to auto-determine
1328 If you set screen_lines to a number <=0, page() will try to auto-determine
1325 your screen size and will only use up to (screen_size+screen_lines) for
1329 your screen size and will only use up to (screen_size+screen_lines) for
1326 printing, paging after that. That is, if you want auto-detection but need
1330 printing, paging after that. That is, if you want auto-detection but need
1327 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1331 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1328 auto-detection without any lines reserved simply use screen_lines = 0.
1332 auto-detection without any lines reserved simply use screen_lines = 0.
1329
1333
1330 If a string won't fit in the allowed lines, it is sent through the
1334 If a string won't fit in the allowed lines, it is sent through the
1331 specified pager command. If none given, look for PAGER in the environment,
1335 specified pager command. If none given, look for PAGER in the environment,
1332 and ultimately default to less.
1336 and ultimately default to less.
1333
1337
1334 If no system pager works, the string is sent through a 'dumb pager'
1338 If no system pager works, the string is sent through a 'dumb pager'
1335 written in python, very simplistic.
1339 written in python, very simplistic.
1336 """
1340 """
1337
1341
1338 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1342 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1339 TERM = os.environ.get('TERM','dumb')
1343 TERM = os.environ.get('TERM','dumb')
1340 if TERM in ['dumb','emacs'] and os.name != 'nt':
1344 if TERM in ['dumb','emacs'] and os.name != 'nt':
1341 print strng
1345 print strng
1342 return
1346 return
1343 # chop off the topmost part of the string we don't want to see
1347 # chop off the topmost part of the string we don't want to see
1344 str_lines = strng.split(os.linesep)[start:]
1348 str_lines = strng.split(os.linesep)[start:]
1345 str_toprint = os.linesep.join(str_lines)
1349 str_toprint = os.linesep.join(str_lines)
1346 num_newlines = len(str_lines)
1350 num_newlines = len(str_lines)
1347 len_str = len(str_toprint)
1351 len_str = len(str_toprint)
1348
1352
1349 # Dumb heuristics to guesstimate number of on-screen lines the string
1353 # Dumb heuristics to guesstimate number of on-screen lines the string
1350 # takes. Very basic, but good enough for docstrings in reasonable
1354 # takes. Very basic, but good enough for docstrings in reasonable
1351 # terminals. If someone later feels like refining it, it's not hard.
1355 # terminals. If someone later feels like refining it, it's not hard.
1352 numlines = max(num_newlines,int(len_str/80)+1)
1356 numlines = max(num_newlines,int(len_str/80)+1)
1353
1357
1354 if os.name == "nt":
1358 if os.name == "nt":
1355 screen_lines_def = get_console_size(defaulty=25)[1]
1359 screen_lines_def = get_console_size(defaulty=25)[1]
1356 else:
1360 else:
1357 screen_lines_def = 25 # default value if we can't auto-determine
1361 screen_lines_def = 25 # default value if we can't auto-determine
1358
1362
1359 # auto-determine screen size
1363 # auto-determine screen size
1360 if screen_lines <= 0:
1364 if screen_lines <= 0:
1361 if TERM=='xterm':
1365 if TERM=='xterm':
1362 try:
1366 try:
1363 import curses
1367 import curses
1364 if hasattr(curses,'initscr'):
1368 if hasattr(curses,'initscr'):
1365 use_curses = 1
1369 use_curses = 1
1366 else:
1370 else:
1367 use_curses = 0
1371 use_curses = 0
1368 except ImportError:
1372 except ImportError:
1369 use_curses = 0
1373 use_curses = 0
1370 else:
1374 else:
1371 # curses causes problems on many terminals other than xterm.
1375 # curses causes problems on many terminals other than xterm.
1372 use_curses = 0
1376 use_curses = 0
1373 if use_curses:
1377 if use_curses:
1374 scr = curses.initscr()
1378 scr = curses.initscr()
1375 screen_lines_real,screen_cols = scr.getmaxyx()
1379 screen_lines_real,screen_cols = scr.getmaxyx()
1376 curses.endwin()
1380 curses.endwin()
1377 screen_lines += screen_lines_real
1381 screen_lines += screen_lines_real
1378 #print '***Screen size:',screen_lines_real,'lines x',\
1382 #print '***Screen size:',screen_lines_real,'lines x',\
1379 #screen_cols,'columns.' # dbg
1383 #screen_cols,'columns.' # dbg
1380 else:
1384 else:
1381 screen_lines += screen_lines_def
1385 screen_lines += screen_lines_def
1382
1386
1383 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1387 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1384 if numlines <= screen_lines :
1388 if numlines <= screen_lines :
1385 #print '*** normal print' # dbg
1389 #print '*** normal print' # dbg
1386 print >>Term.cout, str_toprint
1390 print >>Term.cout, str_toprint
1387 else:
1391 else:
1388 # Try to open pager and default to internal one if that fails.
1392 # Try to open pager and default to internal one if that fails.
1389 # All failure modes are tagged as 'retval=1', to match the return
1393 # All failure modes are tagged as 'retval=1', to match the return
1390 # value of a failed system command. If any intermediate attempt
1394 # value of a failed system command. If any intermediate attempt
1391 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1395 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1392 pager_cmd = get_pager_cmd(pager_cmd)
1396 pager_cmd = get_pager_cmd(pager_cmd)
1393 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1397 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1394 if os.name == 'nt':
1398 if os.name == 'nt':
1395 if pager_cmd.startswith('type'):
1399 if pager_cmd.startswith('type'):
1396 # The default WinXP 'type' command is failing on complex strings.
1400 # The default WinXP 'type' command is failing on complex strings.
1397 retval = 1
1401 retval = 1
1398 else:
1402 else:
1399 tmpname = tempfile.mktemp('.txt')
1403 tmpname = tempfile.mktemp('.txt')
1400 tmpfile = file(tmpname,'wt')
1404 tmpfile = file(tmpname,'wt')
1401 tmpfile.write(strng)
1405 tmpfile.write(strng)
1402 tmpfile.close()
1406 tmpfile.close()
1403 cmd = "%s < %s" % (pager_cmd,tmpname)
1407 cmd = "%s < %s" % (pager_cmd,tmpname)
1404 if os.system(cmd):
1408 if os.system(cmd):
1405 retval = 1
1409 retval = 1
1406 else:
1410 else:
1407 retval = None
1411 retval = None
1408 os.remove(tmpname)
1412 os.remove(tmpname)
1409 else:
1413 else:
1410 try:
1414 try:
1411 retval = None
1415 retval = None
1412 # if I use popen4, things hang. No idea why.
1416 # if I use popen4, things hang. No idea why.
1413 #pager,shell_out = os.popen4(pager_cmd)
1417 #pager,shell_out = os.popen4(pager_cmd)
1414 pager = os.popen(pager_cmd,'w')
1418 pager = os.popen(pager_cmd,'w')
1415 pager.write(strng)
1419 pager.write(strng)
1416 pager.close()
1420 pager.close()
1417 retval = pager.close() # success returns None
1421 retval = pager.close() # success returns None
1418 except IOError,msg: # broken pipe when user quits
1422 except IOError,msg: # broken pipe when user quits
1419 if msg.args == (32,'Broken pipe'):
1423 if msg.args == (32,'Broken pipe'):
1420 retval = None
1424 retval = None
1421 else:
1425 else:
1422 retval = 1
1426 retval = 1
1423 except OSError:
1427 except OSError:
1424 # Other strange problems, sometimes seen in Win2k/cygwin
1428 # Other strange problems, sometimes seen in Win2k/cygwin
1425 retval = 1
1429 retval = 1
1426 if retval is not None:
1430 if retval is not None:
1427 page_dumb(strng,screen_lines=screen_lines)
1431 page_dumb(strng,screen_lines=screen_lines)
1428
1432
1429 #----------------------------------------------------------------------------
1433 #----------------------------------------------------------------------------
1430 def page_file(fname,start = 0, pager_cmd = None):
1434 def page_file(fname,start = 0, pager_cmd = None):
1431 """Page a file, using an optional pager command and starting line.
1435 """Page a file, using an optional pager command and starting line.
1432 """
1436 """
1433
1437
1434 pager_cmd = get_pager_cmd(pager_cmd)
1438 pager_cmd = get_pager_cmd(pager_cmd)
1435 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1439 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1436
1440
1437 try:
1441 try:
1438 if os.environ['TERM'] in ['emacs','dumb']:
1442 if os.environ['TERM'] in ['emacs','dumb']:
1439 raise EnvironmentError
1443 raise EnvironmentError
1440 xsys(pager_cmd + ' ' + fname)
1444 xsys(pager_cmd + ' ' + fname)
1441 except:
1445 except:
1442 try:
1446 try:
1443 if start > 0:
1447 if start > 0:
1444 start -= 1
1448 start -= 1
1445 page(open(fname).read(),start)
1449 page(open(fname).read(),start)
1446 except:
1450 except:
1447 print 'Unable to show file',`fname`
1451 print 'Unable to show file',`fname`
1448
1452
1449 #----------------------------------------------------------------------------
1453 #----------------------------------------------------------------------------
1450 def snip_print(str,width = 75,print_full = 0,header = ''):
1454 def snip_print(str,width = 75,print_full = 0,header = ''):
1451 """Print a string snipping the midsection to fit in width.
1455 """Print a string snipping the midsection to fit in width.
1452
1456
1453 print_full: mode control:
1457 print_full: mode control:
1454 - 0: only snip long strings
1458 - 0: only snip long strings
1455 - 1: send to page() directly.
1459 - 1: send to page() directly.
1456 - 2: snip long strings and ask for full length viewing with page()
1460 - 2: snip long strings and ask for full length viewing with page()
1457 Return 1 if snipping was necessary, 0 otherwise."""
1461 Return 1 if snipping was necessary, 0 otherwise."""
1458
1462
1459 if print_full == 1:
1463 if print_full == 1:
1460 page(header+str)
1464 page(header+str)
1461 return 0
1465 return 0
1462
1466
1463 print header,
1467 print header,
1464 if len(str) < width:
1468 if len(str) < width:
1465 print str
1469 print str
1466 snip = 0
1470 snip = 0
1467 else:
1471 else:
1468 whalf = int((width -5)/2)
1472 whalf = int((width -5)/2)
1469 print str[:whalf] + ' <...> ' + str[-whalf:]
1473 print str[:whalf] + ' <...> ' + str[-whalf:]
1470 snip = 1
1474 snip = 1
1471 if snip and print_full == 2:
1475 if snip and print_full == 2:
1472 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1476 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1473 page(str)
1477 page(str)
1474 return snip
1478 return snip
1475
1479
1476 #****************************************************************************
1480 #****************************************************************************
1477 # lists, dicts and structures
1481 # lists, dicts and structures
1478
1482
1479 def belong(candidates,checklist):
1483 def belong(candidates,checklist):
1480 """Check whether a list of items appear in a given list of options.
1484 """Check whether a list of items appear in a given list of options.
1481
1485
1482 Returns a list of 1 and 0, one for each candidate given."""
1486 Returns a list of 1 and 0, one for each candidate given."""
1483
1487
1484 return [x in checklist for x in candidates]
1488 return [x in checklist for x in candidates]
1485
1489
1486 #----------------------------------------------------------------------------
1490 #----------------------------------------------------------------------------
1487 def uniq_stable(elems):
1491 def uniq_stable(elems):
1488 """uniq_stable(elems) -> list
1492 """uniq_stable(elems) -> list
1489
1493
1490 Return from an iterable, a list of all the unique elements in the input,
1494 Return from an iterable, a list of all the unique elements in the input,
1491 but maintaining the order in which they first appear.
1495 but maintaining the order in which they first appear.
1492
1496
1493 A naive solution to this problem which just makes a dictionary with the
1497 A naive solution to this problem which just makes a dictionary with the
1494 elements as keys fails to respect the stability condition, since
1498 elements as keys fails to respect the stability condition, since
1495 dictionaries are unsorted by nature.
1499 dictionaries are unsorted by nature.
1496
1500
1497 Note: All elements in the input must be valid dictionary keys for this
1501 Note: All elements in the input must be valid dictionary keys for this
1498 routine to work, as it internally uses a dictionary for efficiency
1502 routine to work, as it internally uses a dictionary for efficiency
1499 reasons."""
1503 reasons."""
1500
1504
1501 unique = []
1505 unique = []
1502 unique_dict = {}
1506 unique_dict = {}
1503 for nn in elems:
1507 for nn in elems:
1504 if nn not in unique_dict:
1508 if nn not in unique_dict:
1505 unique.append(nn)
1509 unique.append(nn)
1506 unique_dict[nn] = None
1510 unique_dict[nn] = None
1507 return unique
1511 return unique
1508
1512
1509 #----------------------------------------------------------------------------
1513 #----------------------------------------------------------------------------
1510 class NLprinter:
1514 class NLprinter:
1511 """Print an arbitrarily nested list, indicating index numbers.
1515 """Print an arbitrarily nested list, indicating index numbers.
1512
1516
1513 An instance of this class called nlprint is available and callable as a
1517 An instance of this class called nlprint is available and callable as a
1514 function.
1518 function.
1515
1519
1516 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1520 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1517 and using 'sep' to separate the index from the value. """
1521 and using 'sep' to separate the index from the value. """
1518
1522
1519 def __init__(self):
1523 def __init__(self):
1520 self.depth = 0
1524 self.depth = 0
1521
1525
1522 def __call__(self,lst,pos='',**kw):
1526 def __call__(self,lst,pos='',**kw):
1523 """Prints the nested list numbering levels."""
1527 """Prints the nested list numbering levels."""
1524 kw.setdefault('indent',' ')
1528 kw.setdefault('indent',' ')
1525 kw.setdefault('sep',': ')
1529 kw.setdefault('sep',': ')
1526 kw.setdefault('start',0)
1530 kw.setdefault('start',0)
1527 kw.setdefault('stop',len(lst))
1531 kw.setdefault('stop',len(lst))
1528 # we need to remove start and stop from kw so they don't propagate
1532 # we need to remove start and stop from kw so they don't propagate
1529 # into a recursive call for a nested list.
1533 # into a recursive call for a nested list.
1530 start = kw['start']; del kw['start']
1534 start = kw['start']; del kw['start']
1531 stop = kw['stop']; del kw['stop']
1535 stop = kw['stop']; del kw['stop']
1532 if self.depth == 0 and 'header' in kw.keys():
1536 if self.depth == 0 and 'header' in kw.keys():
1533 print kw['header']
1537 print kw['header']
1534
1538
1535 for idx in range(start,stop):
1539 for idx in range(start,stop):
1536 elem = lst[idx]
1540 elem = lst[idx]
1537 if type(elem)==type([]):
1541 if type(elem)==type([]):
1538 self.depth += 1
1542 self.depth += 1
1539 self.__call__(elem,itpl('$pos$idx,'),**kw)
1543 self.__call__(elem,itpl('$pos$idx,'),**kw)
1540 self.depth -= 1
1544 self.depth -= 1
1541 else:
1545 else:
1542 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1546 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1543
1547
1544 nlprint = NLprinter()
1548 nlprint = NLprinter()
1545 #----------------------------------------------------------------------------
1549 #----------------------------------------------------------------------------
1546 def all_belong(candidates,checklist):
1550 def all_belong(candidates,checklist):
1547 """Check whether a list of items ALL appear in a given list of options.
1551 """Check whether a list of items ALL appear in a given list of options.
1548
1552
1549 Returns a single 1 or 0 value."""
1553 Returns a single 1 or 0 value."""
1550
1554
1551 return 1-(0 in [x in checklist for x in candidates])
1555 return 1-(0 in [x in checklist for x in candidates])
1552
1556
1553 #----------------------------------------------------------------------------
1557 #----------------------------------------------------------------------------
1554 def sort_compare(lst1,lst2,inplace = 1):
1558 def sort_compare(lst1,lst2,inplace = 1):
1555 """Sort and compare two lists.
1559 """Sort and compare two lists.
1556
1560
1557 By default it does it in place, thus modifying the lists. Use inplace = 0
1561 By default it does it in place, thus modifying the lists. Use inplace = 0
1558 to avoid that (at the cost of temporary copy creation)."""
1562 to avoid that (at the cost of temporary copy creation)."""
1559 if not inplace:
1563 if not inplace:
1560 lst1 = lst1[:]
1564 lst1 = lst1[:]
1561 lst2 = lst2[:]
1565 lst2 = lst2[:]
1562 lst1.sort(); lst2.sort()
1566 lst1.sort(); lst2.sort()
1563 return lst1 == lst2
1567 return lst1 == lst2
1564
1568
1565 #----------------------------------------------------------------------------
1569 #----------------------------------------------------------------------------
1566 def mkdict(**kwargs):
1570 def mkdict(**kwargs):
1567 """Return a dict from a keyword list.
1571 """Return a dict from a keyword list.
1568
1572
1569 It's just syntactic sugar for making ditcionary creation more convenient:
1573 It's just syntactic sugar for making ditcionary creation more convenient:
1570 # the standard way
1574 # the standard way
1571 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1575 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1572 # a cleaner way
1576 # a cleaner way
1573 >>>data = dict(red=1, green=2, blue=3)
1577 >>>data = dict(red=1, green=2, blue=3)
1574
1578
1575 If you need more than this, look at the Struct() class."""
1579 If you need more than this, look at the Struct() class."""
1576
1580
1577 return kwargs
1581 return kwargs
1578
1582
1579 #----------------------------------------------------------------------------
1583 #----------------------------------------------------------------------------
1580 def list2dict(lst):
1584 def list2dict(lst):
1581 """Takes a list of (key,value) pairs and turns it into a dict."""
1585 """Takes a list of (key,value) pairs and turns it into a dict."""
1582
1586
1583 dic = {}
1587 dic = {}
1584 for k,v in lst: dic[k] = v
1588 for k,v in lst: dic[k] = v
1585 return dic
1589 return dic
1586
1590
1587 #----------------------------------------------------------------------------
1591 #----------------------------------------------------------------------------
1588 def list2dict2(lst,default=''):
1592 def list2dict2(lst,default=''):
1589 """Takes a list and turns it into a dict.
1593 """Takes a list and turns it into a dict.
1590 Much slower than list2dict, but more versatile. This version can take
1594 Much slower than list2dict, but more versatile. This version can take
1591 lists with sublists of arbitrary length (including sclars)."""
1595 lists with sublists of arbitrary length (including sclars)."""
1592
1596
1593 dic = {}
1597 dic = {}
1594 for elem in lst:
1598 for elem in lst:
1595 if type(elem) in (types.ListType,types.TupleType):
1599 if type(elem) in (types.ListType,types.TupleType):
1596 size = len(elem)
1600 size = len(elem)
1597 if size == 0:
1601 if size == 0:
1598 pass
1602 pass
1599 elif size == 1:
1603 elif size == 1:
1600 dic[elem] = default
1604 dic[elem] = default
1601 else:
1605 else:
1602 k,v = elem[0], elem[1:]
1606 k,v = elem[0], elem[1:]
1603 if len(v) == 1: v = v[0]
1607 if len(v) == 1: v = v[0]
1604 dic[k] = v
1608 dic[k] = v
1605 else:
1609 else:
1606 dic[elem] = default
1610 dic[elem] = default
1607 return dic
1611 return dic
1608
1612
1609 #----------------------------------------------------------------------------
1613 #----------------------------------------------------------------------------
1610 def flatten(seq):
1614 def flatten(seq):
1611 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1615 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1612
1616
1613 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1617 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1614
1618
1615 # if the x=0 isn't made, a *global* variable x is left over after calling
1619 # if the x=0 isn't made, a *global* variable x is left over after calling
1616 # this function, with the value of the last element in the return
1620 # this function, with the value of the last element in the return
1617 # list. This does seem like a bug big time to me.
1621 # list. This does seem like a bug big time to me.
1618
1622
1619 # the problem is fixed with the x=0, which seems to force the creation of
1623 # the problem is fixed with the x=0, which seems to force the creation of
1620 # a local name
1624 # a local name
1621
1625
1622 x = 0
1626 x = 0
1623 return [x for subseq in seq for x in subseq]
1627 return [x for subseq in seq for x in subseq]
1624
1628
1625 #----------------------------------------------------------------------------
1629 #----------------------------------------------------------------------------
1626 def get_slice(seq,start=0,stop=None,step=1):
1630 def get_slice(seq,start=0,stop=None,step=1):
1627 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1631 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1628 if stop == None:
1632 if stop == None:
1629 stop = len(seq)
1633 stop = len(seq)
1630 item = lambda i: seq[i]
1634 item = lambda i: seq[i]
1631 return map(item,xrange(start,stop,step))
1635 return map(item,xrange(start,stop,step))
1632
1636
1633 #----------------------------------------------------------------------------
1637 #----------------------------------------------------------------------------
1634 def chop(seq,size):
1638 def chop(seq,size):
1635 """Chop a sequence into chunks of the given size."""
1639 """Chop a sequence into chunks of the given size."""
1636 chunk = lambda i: seq[i:i+size]
1640 chunk = lambda i: seq[i:i+size]
1637 return map(chunk,xrange(0,len(seq),size))
1641 return map(chunk,xrange(0,len(seq),size))
1638
1642
1639 #----------------------------------------------------------------------------
1643 #----------------------------------------------------------------------------
1640 def with(object, **args):
1644 def with(object, **args):
1641 """Set multiple attributes for an object, similar to Pascal's with.
1645 """Set multiple attributes for an object, similar to Pascal's with.
1642
1646
1643 Example:
1647 Example:
1644 with(jim,
1648 with(jim,
1645 born = 1960,
1649 born = 1960,
1646 haircolour = 'Brown',
1650 haircolour = 'Brown',
1647 eyecolour = 'Green')
1651 eyecolour = 'Green')
1648
1652
1649 Credit: Greg Ewing, in
1653 Credit: Greg Ewing, in
1650 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1654 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1651
1655
1652 object.__dict__.update(args)
1656 object.__dict__.update(args)
1653
1657
1654 #----------------------------------------------------------------------------
1658 #----------------------------------------------------------------------------
1655 def setattr_list(obj,alist,nspace = None):
1659 def setattr_list(obj,alist,nspace = None):
1656 """Set a list of attributes for an object taken from a namespace.
1660 """Set a list of attributes for an object taken from a namespace.
1657
1661
1658 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1662 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1659 alist with their values taken from nspace, which must be a dict (something
1663 alist with their values taken from nspace, which must be a dict (something
1660 like locals() will often do) If nspace isn't given, locals() of the
1664 like locals() will often do) If nspace isn't given, locals() of the
1661 *caller* is used, so in most cases you can omit it.
1665 *caller* is used, so in most cases you can omit it.
1662
1666
1663 Note that alist can be given as a string, which will be automatically
1667 Note that alist can be given as a string, which will be automatically
1664 split into a list on whitespace. If given as a list, it must be a list of
1668 split into a list on whitespace. If given as a list, it must be a list of
1665 *strings* (the variable names themselves), not of variables."""
1669 *strings* (the variable names themselves), not of variables."""
1666
1670
1667 # this grabs the local variables from the *previous* call frame -- that is
1671 # this grabs the local variables from the *previous* call frame -- that is
1668 # the locals from the function that called setattr_list().
1672 # the locals from the function that called setattr_list().
1669 # - snipped from weave.inline()
1673 # - snipped from weave.inline()
1670 if nspace is None:
1674 if nspace is None:
1671 call_frame = sys._getframe().f_back
1675 call_frame = sys._getframe().f_back
1672 nspace = call_frame.f_locals
1676 nspace = call_frame.f_locals
1673
1677
1674 if type(alist) in StringTypes:
1678 if type(alist) in StringTypes:
1675 alist = alist.split()
1679 alist = alist.split()
1676 for attr in alist:
1680 for attr in alist:
1677 val = eval(attr,nspace)
1681 val = eval(attr,nspace)
1678 setattr(obj,attr,val)
1682 setattr(obj,attr,val)
1679
1683
1680 #----------------------------------------------------------------------------
1684 #----------------------------------------------------------------------------
1681 def getattr_list(obj,alist,*args):
1685 def getattr_list(obj,alist,*args):
1682 """getattr_list(obj,alist[, default]) -> attribute list.
1686 """getattr_list(obj,alist[, default]) -> attribute list.
1683
1687
1684 Get a list of named attributes for an object. When a default argument is
1688 Get a list of named attributes for an object. When a default argument is
1685 given, it is returned when the attribute doesn't exist; without it, an
1689 given, it is returned when the attribute doesn't exist; without it, an
1686 exception is raised in that case.
1690 exception is raised in that case.
1687
1691
1688 Note that alist can be given as a string, which will be automatically
1692 Note that alist can be given as a string, which will be automatically
1689 split into a list on whitespace. If given as a list, it must be a list of
1693 split into a list on whitespace. If given as a list, it must be a list of
1690 *strings* (the variable names themselves), not of variables."""
1694 *strings* (the variable names themselves), not of variables."""
1691
1695
1692 if type(alist) in StringTypes:
1696 if type(alist) in StringTypes:
1693 alist = alist.split()
1697 alist = alist.split()
1694 if args:
1698 if args:
1695 if len(args)==1:
1699 if len(args)==1:
1696 default = args[0]
1700 default = args[0]
1697 return map(lambda attr: getattr(obj,attr,default),alist)
1701 return map(lambda attr: getattr(obj,attr,default),alist)
1698 else:
1702 else:
1699 raise ValueError,'getattr_list() takes only one optional argument'
1703 raise ValueError,'getattr_list() takes only one optional argument'
1700 else:
1704 else:
1701 return map(lambda attr: getattr(obj,attr),alist)
1705 return map(lambda attr: getattr(obj,attr),alist)
1702
1706
1703 #----------------------------------------------------------------------------
1707 #----------------------------------------------------------------------------
1704 def map_method(method,object_list,*argseq,**kw):
1708 def map_method(method,object_list,*argseq,**kw):
1705 """map_method(method,object_list,*args,**kw) -> list
1709 """map_method(method,object_list,*args,**kw) -> list
1706
1710
1707 Return a list of the results of applying the methods to the items of the
1711 Return a list of the results of applying the methods to the items of the
1708 argument sequence(s). If more than one sequence is given, the method is
1712 argument sequence(s). If more than one sequence is given, the method is
1709 called with an argument list consisting of the corresponding item of each
1713 called with an argument list consisting of the corresponding item of each
1710 sequence. All sequences must be of the same length.
1714 sequence. All sequences must be of the same length.
1711
1715
1712 Keyword arguments are passed verbatim to all objects called.
1716 Keyword arguments are passed verbatim to all objects called.
1713
1717
1714 This is Python code, so it's not nearly as fast as the builtin map()."""
1718 This is Python code, so it's not nearly as fast as the builtin map()."""
1715
1719
1716 out_list = []
1720 out_list = []
1717 idx = 0
1721 idx = 0
1718 for object in object_list:
1722 for object in object_list:
1719 try:
1723 try:
1720 handler = getattr(object, method)
1724 handler = getattr(object, method)
1721 except AttributeError:
1725 except AttributeError:
1722 out_list.append(None)
1726 out_list.append(None)
1723 else:
1727 else:
1724 if argseq:
1728 if argseq:
1725 args = map(lambda lst:lst[idx],argseq)
1729 args = map(lambda lst:lst[idx],argseq)
1726 #print 'ob',object,'hand',handler,'ar',args # dbg
1730 #print 'ob',object,'hand',handler,'ar',args # dbg
1727 out_list.append(handler(args,**kw))
1731 out_list.append(handler(args,**kw))
1728 else:
1732 else:
1729 out_list.append(handler(**kw))
1733 out_list.append(handler(**kw))
1730 idx += 1
1734 idx += 1
1731 return out_list
1735 return out_list
1732
1736
1733 #----------------------------------------------------------------------------
1737 #----------------------------------------------------------------------------
1734 def import_fail_info(mod_name,fns=None):
1738 def import_fail_info(mod_name,fns=None):
1735 """Inform load failure for a module."""
1739 """Inform load failure for a module."""
1736
1740
1737 if fns == None:
1741 if fns == None:
1738 warn("Loading of %s failed.\n" % (mod_name,))
1742 warn("Loading of %s failed.\n" % (mod_name,))
1739 else:
1743 else:
1740 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1744 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1741
1745
1742 #----------------------------------------------------------------------------
1746 #----------------------------------------------------------------------------
1743 # Proposed popitem() extension, written as a method
1747 # Proposed popitem() extension, written as a method
1744
1748
1745 class NotGiven: pass
1749 class NotGiven: pass
1746
1750
1747 def popkey(dct,key,default=NotGiven):
1751 def popkey(dct,key,default=NotGiven):
1748 """Return dct[key] and delete dct[key].
1752 """Return dct[key] and delete dct[key].
1749
1753
1750 If default is given, return it if dct[key] doesn't exist, otherwise raise
1754 If default is given, return it if dct[key] doesn't exist, otherwise raise
1751 KeyError. """
1755 KeyError. """
1752
1756
1753 try:
1757 try:
1754 val = dct[key]
1758 val = dct[key]
1755 except KeyError:
1759 except KeyError:
1756 if default is NotGiven:
1760 if default is NotGiven:
1757 raise
1761 raise
1758 else:
1762 else:
1759 return default
1763 return default
1760 else:
1764 else:
1761 del dct[key]
1765 del dct[key]
1762 return val
1766 return val
1763 #*************************** end of file <genutils.py> **********************
1767 #*************************** end of file <genutils.py> **********************
1764
1768
@@ -1,2219 +1,2214 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.3 or newer.
5 Requires Python 2.3 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 1031 2006-01-18 20:20:39Z vivainio $
9 $Id: iplib.py 1032 2006-01-20 09:03:57Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from __future__ import generators # for 2.2 backwards-compatibility
31 from __future__ import generators # for 2.2 backwards-compatibility
32
32
33 from IPython import Release
33 from IPython import Release
34 __author__ = '%s <%s>\n%s <%s>' % \
34 __author__ = '%s <%s>\n%s <%s>' % \
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
35 ( Release.authors['Janko'] + Release.authors['Fernando'] )
36 __license__ = Release.license
36 __license__ = Release.license
37 __version__ = Release.version
37 __version__ = Release.version
38
38
39 # Python standard modules
39 # Python standard modules
40 import __main__
40 import __main__
41 import __builtin__
41 import __builtin__
42 import StringIO
42 import StringIO
43 import bdb
43 import bdb
44 import cPickle as pickle
44 import cPickle as pickle
45 import codeop
45 import codeop
46 import exceptions
46 import exceptions
47 import glob
47 import glob
48 import inspect
48 import inspect
49 import keyword
49 import keyword
50 import new
50 import new
51 import os
51 import os
52 import pdb
52 import pdb
53 import pydoc
53 import pydoc
54 import re
54 import re
55 import shutil
55 import shutil
56 import string
56 import string
57 import sys
57 import sys
58 import tempfile
58 import tempfile
59 import traceback
59 import traceback
60 import types
60 import types
61
61
62 from pprint import pprint, pformat
62 from pprint import pprint, pformat
63
63
64 # IPython's own modules
64 # IPython's own modules
65 import IPython
65 import IPython
66 from IPython import OInspect,PyColorize,ultraTB
66 from IPython import OInspect,PyColorize,ultraTB
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
68 from IPython.FakeModule import FakeModule
68 from IPython.FakeModule import FakeModule
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
70 from IPython.Logger import Logger
70 from IPython.Logger import Logger
71 from IPython.Magic import Magic
71 from IPython.Magic import Magic
72 from IPython.Prompts import CachedOutput
72 from IPython.Prompts import CachedOutput
73 from IPython.ipstruct import Struct
73 from IPython.ipstruct import Struct
74 from IPython.background_jobs import BackgroundJobManager
74 from IPython.background_jobs import BackgroundJobManager
75 from IPython.usage import cmd_line_usage,interactive_usage
75 from IPython.usage import cmd_line_usage,interactive_usage
76 from IPython.genutils import *
76 from IPython.genutils import *
77 import IPython.ipapi
77 import IPython.ipapi
78
78
79 # Globals
79 # Globals
80
80
81 # store the builtin raw_input globally, and use this always, in case user code
81 # store the builtin raw_input globally, and use this always, in case user code
82 # overwrites it (like wx.py.PyShell does)
82 # overwrites it (like wx.py.PyShell does)
83 raw_input_original = raw_input
83 raw_input_original = raw_input
84
84
85 # compiled regexps for autoindent management
85 # compiled regexps for autoindent management
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 ini_spaces_re = re.compile(r'^(\s+)')
92 ini_spaces_re = re.compile(r'^(\s+)')
93
93
94 def num_ini_spaces(strng):
94 def num_ini_spaces(strng):
95 """Return the number of initial spaces in a string"""
95 """Return the number of initial spaces in a string"""
96
96
97 ini_spaces = ini_spaces_re.match(strng)
97 ini_spaces = ini_spaces_re.match(strng)
98 if ini_spaces:
98 if ini_spaces:
99 return ini_spaces.end()
99 return ini_spaces.end()
100 else:
100 else:
101 return 0
101 return 0
102
102
103 def softspace(file, newvalue):
103 def softspace(file, newvalue):
104 """Copied from code.py, to remove the dependency"""
104 """Copied from code.py, to remove the dependency"""
105
105
106 oldvalue = 0
106 oldvalue = 0
107 try:
107 try:
108 oldvalue = file.softspace
108 oldvalue = file.softspace
109 except AttributeError:
109 except AttributeError:
110 pass
110 pass
111 try:
111 try:
112 file.softspace = newvalue
112 file.softspace = newvalue
113 except (AttributeError, TypeError):
113 except (AttributeError, TypeError):
114 # "attribute-less object" or "read-only attributes"
114 # "attribute-less object" or "read-only attributes"
115 pass
115 pass
116 return oldvalue
116 return oldvalue
117
117
118
118
119 #****************************************************************************
119 #****************************************************************************
120 # Local use exceptions
120 # Local use exceptions
121 class SpaceInInput(exceptions.Exception): pass
121 class SpaceInInput(exceptions.Exception): pass
122
122
123
123
124 #****************************************************************************
124 #****************************************************************************
125 # Local use classes
125 # Local use classes
126 class Bunch: pass
126 class Bunch: pass
127
127
128 class Undefined: pass
128 class Undefined: pass
129
129
130 class InputList(list):
130 class InputList(list):
131 """Class to store user input.
131 """Class to store user input.
132
132
133 It's basically a list, but slices return a string instead of a list, thus
133 It's basically a list, but slices return a string instead of a list, thus
134 allowing things like (assuming 'In' is an instance):
134 allowing things like (assuming 'In' is an instance):
135
135
136 exec In[4:7]
136 exec In[4:7]
137
137
138 or
138 or
139
139
140 exec In[5:9] + In[14] + In[21:25]"""
140 exec In[5:9] + In[14] + In[21:25]"""
141
141
142 def __getslice__(self,i,j):
142 def __getslice__(self,i,j):
143 return ''.join(list.__getslice__(self,i,j))
143 return ''.join(list.__getslice__(self,i,j))
144
144
145 class SyntaxTB(ultraTB.ListTB):
145 class SyntaxTB(ultraTB.ListTB):
146 """Extension which holds some state: the last exception value"""
146 """Extension which holds some state: the last exception value"""
147
147
148 def __init__(self,color_scheme = 'NoColor'):
148 def __init__(self,color_scheme = 'NoColor'):
149 ultraTB.ListTB.__init__(self,color_scheme)
149 ultraTB.ListTB.__init__(self,color_scheme)
150 self.last_syntax_error = None
150 self.last_syntax_error = None
151
151
152 def __call__(self, etype, value, elist):
152 def __call__(self, etype, value, elist):
153 self.last_syntax_error = value
153 self.last_syntax_error = value
154 ultraTB.ListTB.__call__(self,etype,value,elist)
154 ultraTB.ListTB.__call__(self,etype,value,elist)
155
155
156 def clear_err_state(self):
156 def clear_err_state(self):
157 """Return the current error state and clear it"""
157 """Return the current error state and clear it"""
158 e = self.last_syntax_error
158 e = self.last_syntax_error
159 self.last_syntax_error = None
159 self.last_syntax_error = None
160 return e
160 return e
161
161
162 #****************************************************************************
162 #****************************************************************************
163 # Main IPython class
163 # Main IPython class
164
164
165 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
165 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
166 # until a full rewrite is made. I've cleaned all cross-class uses of
166 # until a full rewrite is made. I've cleaned all cross-class uses of
167 # attributes and methods, but too much user code out there relies on the
167 # attributes and methods, but too much user code out there relies on the
168 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
168 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
169 #
169 #
170 # But at least now, all the pieces have been separated and we could, in
170 # But at least now, all the pieces have been separated and we could, in
171 # principle, stop using the mixin. This will ease the transition to the
171 # principle, stop using the mixin. This will ease the transition to the
172 # chainsaw branch.
172 # chainsaw branch.
173
173
174 # For reference, the following is the list of 'self.foo' uses in the Magic
174 # For reference, the following is the list of 'self.foo' uses in the Magic
175 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
175 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
176 # class, to prevent clashes.
176 # class, to prevent clashes.
177
177
178 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
178 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
179 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
179 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
180 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
180 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
181 # 'self.value']
181 # 'self.value']
182
182
183 class InteractiveShell(object,Magic):
183 class InteractiveShell(object,Magic):
184 """An enhanced console for Python."""
184 """An enhanced console for Python."""
185
185
186 # class attribute to indicate whether the class supports threads or not.
186 # class attribute to indicate whether the class supports threads or not.
187 # Subclasses with thread support should override this as needed.
187 # Subclasses with thread support should override this as needed.
188 isthreaded = False
188 isthreaded = False
189
189
190 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
190 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
191 user_ns = None,user_global_ns=None,banner2='',
191 user_ns = None,user_global_ns=None,banner2='',
192 custom_exceptions=((),None),embedded=False):
192 custom_exceptions=((),None),embedded=False):
193
193
194 # log system
194 # log system
195 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
195 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
196
196
197 # introduce ourselves to IPython.ipapi which is uncallable
197 # introduce ourselves to IPython.ipapi which is uncallable
198 # before it knows an InteractiveShell object.
198 # before it knows an InteractiveShell object.
199 IPython.ipapi._init_with_shell(self)
199 IPython.ipapi._init_with_shell(self)
200
200
201 # some minimal strict typechecks. For some core data structures, I
201 # some minimal strict typechecks. For some core data structures, I
202 # want actual basic python types, not just anything that looks like
202 # want actual basic python types, not just anything that looks like
203 # one. This is especially true for namespaces.
203 # one. This is especially true for namespaces.
204 for ns in (user_ns,user_global_ns):
204 for ns in (user_ns,user_global_ns):
205 if ns is not None and type(ns) != types.DictType:
205 if ns is not None and type(ns) != types.DictType:
206 raise TypeError,'namespace must be a dictionary'
206 raise TypeError,'namespace must be a dictionary'
207
207
208 # Job manager (for jobs run as background threads)
208 # Job manager (for jobs run as background threads)
209 self.jobs = BackgroundJobManager()
209 self.jobs = BackgroundJobManager()
210
210
211 # track which builtins we add, so we can clean up later
211 # track which builtins we add, so we can clean up later
212 self.builtins_added = {}
212 self.builtins_added = {}
213 # This method will add the necessary builtins for operation, but
213 # This method will add the necessary builtins for operation, but
214 # tracking what it did via the builtins_added dict.
214 # tracking what it did via the builtins_added dict.
215 self.add_builtins()
215 self.add_builtins()
216
216
217 # Do the intuitively correct thing for quit/exit: we remove the
217 # Do the intuitively correct thing for quit/exit: we remove the
218 # builtins if they exist, and our own magics will deal with this
218 # builtins if they exist, and our own magics will deal with this
219 try:
219 try:
220 del __builtin__.exit, __builtin__.quit
220 del __builtin__.exit, __builtin__.quit
221 except AttributeError:
221 except AttributeError:
222 pass
222 pass
223
223
224 # Store the actual shell's name
224 # Store the actual shell's name
225 self.name = name
225 self.name = name
226
226
227 # We need to know whether the instance is meant for embedding, since
227 # We need to know whether the instance is meant for embedding, since
228 # global/local namespaces need to be handled differently in that case
228 # global/local namespaces need to be handled differently in that case
229 self.embedded = embedded
229 self.embedded = embedded
230
230
231 # command compiler
231 # command compiler
232 self.compile = codeop.CommandCompiler()
232 self.compile = codeop.CommandCompiler()
233
233
234 # User input buffer
234 # User input buffer
235 self.buffer = []
235 self.buffer = []
236
236
237 # Default name given in compilation of code
237 # Default name given in compilation of code
238 self.filename = '<ipython console>'
238 self.filename = '<ipython console>'
239
239
240 # Make an empty namespace, which extension writers can rely on both
240 # Make an empty namespace, which extension writers can rely on both
241 # existing and NEVER being used by ipython itself. This gives them a
241 # existing and NEVER being used by ipython itself. This gives them a
242 # convenient location for storing additional information and state
242 # convenient location for storing additional information and state
243 # their extensions may require, without fear of collisions with other
243 # their extensions may require, without fear of collisions with other
244 # ipython names that may develop later.
244 # ipython names that may develop later.
245 self.meta = Bunch()
245 self.meta = Bunch()
246
246
247 # Create the namespace where the user will operate. user_ns is
247 # Create the namespace where the user will operate. user_ns is
248 # normally the only one used, and it is passed to the exec calls as
248 # normally the only one used, and it is passed to the exec calls as
249 # the locals argument. But we do carry a user_global_ns namespace
249 # the locals argument. But we do carry a user_global_ns namespace
250 # given as the exec 'globals' argument, This is useful in embedding
250 # given as the exec 'globals' argument, This is useful in embedding
251 # situations where the ipython shell opens in a context where the
251 # situations where the ipython shell opens in a context where the
252 # distinction between locals and globals is meaningful.
252 # distinction between locals and globals is meaningful.
253
253
254 # FIXME. For some strange reason, __builtins__ is showing up at user
254 # FIXME. For some strange reason, __builtins__ is showing up at user
255 # level as a dict instead of a module. This is a manual fix, but I
255 # level as a dict instead of a module. This is a manual fix, but I
256 # should really track down where the problem is coming from. Alex
256 # should really track down where the problem is coming from. Alex
257 # Schmolck reported this problem first.
257 # Schmolck reported this problem first.
258
258
259 # A useful post by Alex Martelli on this topic:
259 # A useful post by Alex Martelli on this topic:
260 # Re: inconsistent value from __builtins__
260 # Re: inconsistent value from __builtins__
261 # Von: Alex Martelli <aleaxit@yahoo.com>
261 # Von: Alex Martelli <aleaxit@yahoo.com>
262 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
262 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
263 # Gruppen: comp.lang.python
263 # Gruppen: comp.lang.python
264
264
265 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
265 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
266 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
266 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
267 # > <type 'dict'>
267 # > <type 'dict'>
268 # > >>> print type(__builtins__)
268 # > >>> print type(__builtins__)
269 # > <type 'module'>
269 # > <type 'module'>
270 # > Is this difference in return value intentional?
270 # > Is this difference in return value intentional?
271
271
272 # Well, it's documented that '__builtins__' can be either a dictionary
272 # Well, it's documented that '__builtins__' can be either a dictionary
273 # or a module, and it's been that way for a long time. Whether it's
273 # or a module, and it's been that way for a long time. Whether it's
274 # intentional (or sensible), I don't know. In any case, the idea is
274 # intentional (or sensible), I don't know. In any case, the idea is
275 # that if you need to access the built-in namespace directly, you
275 # that if you need to access the built-in namespace directly, you
276 # should start with "import __builtin__" (note, no 's') which will
276 # should start with "import __builtin__" (note, no 's') which will
277 # definitely give you a module. Yeah, it's somewhat confusing:-(.
277 # definitely give you a module. Yeah, it's somewhat confusing:-(.
278
278
279 if user_ns is None:
279 if user_ns is None:
280 # Set __name__ to __main__ to better match the behavior of the
280 # Set __name__ to __main__ to better match the behavior of the
281 # normal interpreter.
281 # normal interpreter.
282 user_ns = {'__name__' :'__main__',
282 user_ns = {'__name__' :'__main__',
283 '__builtins__' : __builtin__,
283 '__builtins__' : __builtin__,
284 }
284 }
285
285
286 if user_global_ns is None:
286 if user_global_ns is None:
287 user_global_ns = {}
287 user_global_ns = {}
288
288
289 # Assign namespaces
289 # Assign namespaces
290 # This is the namespace where all normal user variables live
290 # This is the namespace where all normal user variables live
291 self.user_ns = user_ns
291 self.user_ns = user_ns
292 # Embedded instances require a separate namespace for globals.
292 # Embedded instances require a separate namespace for globals.
293 # Normally this one is unused by non-embedded instances.
293 # Normally this one is unused by non-embedded instances.
294 self.user_global_ns = user_global_ns
294 self.user_global_ns = user_global_ns
295 # A namespace to keep track of internal data structures to prevent
295 # A namespace to keep track of internal data structures to prevent
296 # them from cluttering user-visible stuff. Will be updated later
296 # them from cluttering user-visible stuff. Will be updated later
297 self.internal_ns = {}
297 self.internal_ns = {}
298
298
299 # Namespace of system aliases. Each entry in the alias
299 # Namespace of system aliases. Each entry in the alias
300 # table must be a 2-tuple of the form (N,name), where N is the number
300 # table must be a 2-tuple of the form (N,name), where N is the number
301 # of positional arguments of the alias.
301 # of positional arguments of the alias.
302 self.alias_table = {}
302 self.alias_table = {}
303
303
304 # A table holding all the namespaces IPython deals with, so that
304 # A table holding all the namespaces IPython deals with, so that
305 # introspection facilities can search easily.
305 # introspection facilities can search easily.
306 self.ns_table = {'user':user_ns,
306 self.ns_table = {'user':user_ns,
307 'user_global':user_global_ns,
307 'user_global':user_global_ns,
308 'alias':self.alias_table,
308 'alias':self.alias_table,
309 'internal':self.internal_ns,
309 'internal':self.internal_ns,
310 'builtin':__builtin__.__dict__
310 'builtin':__builtin__.__dict__
311 }
311 }
312
312
313 # The user namespace MUST have a pointer to the shell itself.
313 # The user namespace MUST have a pointer to the shell itself.
314 self.user_ns[name] = self
314 self.user_ns[name] = self
315
315
316 # We need to insert into sys.modules something that looks like a
316 # We need to insert into sys.modules something that looks like a
317 # module but which accesses the IPython namespace, for shelve and
317 # module but which accesses the IPython namespace, for shelve and
318 # pickle to work interactively. Normally they rely on getting
318 # pickle to work interactively. Normally they rely on getting
319 # everything out of __main__, but for embedding purposes each IPython
319 # everything out of __main__, but for embedding purposes each IPython
320 # instance has its own private namespace, so we can't go shoving
320 # instance has its own private namespace, so we can't go shoving
321 # everything into __main__.
321 # everything into __main__.
322
322
323 # note, however, that we should only do this for non-embedded
323 # note, however, that we should only do this for non-embedded
324 # ipythons, which really mimic the __main__.__dict__ with their own
324 # ipythons, which really mimic the __main__.__dict__ with their own
325 # namespace. Embedded instances, on the other hand, should not do
325 # namespace. Embedded instances, on the other hand, should not do
326 # this because they need to manage the user local/global namespaces
326 # this because they need to manage the user local/global namespaces
327 # only, but they live within a 'normal' __main__ (meaning, they
327 # only, but they live within a 'normal' __main__ (meaning, they
328 # shouldn't overtake the execution environment of the script they're
328 # shouldn't overtake the execution environment of the script they're
329 # embedded in).
329 # embedded in).
330
330
331 if not embedded:
331 if not embedded:
332 try:
332 try:
333 main_name = self.user_ns['__name__']
333 main_name = self.user_ns['__name__']
334 except KeyError:
334 except KeyError:
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 else:
336 else:
337 #print "pickle hack in place" # dbg
337 #print "pickle hack in place" # dbg
338 #print 'main_name:',main_name # dbg
338 #print 'main_name:',main_name # dbg
339 sys.modules[main_name] = FakeModule(self.user_ns)
339 sys.modules[main_name] = FakeModule(self.user_ns)
340
340
341 # List of input with multi-line handling.
341 # List of input with multi-line handling.
342 # Fill its zero entry, user counter starts at 1
342 # Fill its zero entry, user counter starts at 1
343 self.input_hist = InputList(['\n'])
343 self.input_hist = InputList(['\n'])
344
344
345 # list of visited directories
345 # list of visited directories
346 try:
346 try:
347 self.dir_hist = [os.getcwd()]
347 self.dir_hist = [os.getcwd()]
348 except IOError, e:
348 except IOError, e:
349 self.dir_hist = []
349 self.dir_hist = []
350
350
351 # dict of output history
351 # dict of output history
352 self.output_hist = {}
352 self.output_hist = {}
353
353
354 # dict of things NOT to alias (keywords, builtins and some magics)
354 # dict of things NOT to alias (keywords, builtins and some magics)
355 no_alias = {}
355 no_alias = {}
356 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
356 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
357 for key in keyword.kwlist + no_alias_magics:
357 for key in keyword.kwlist + no_alias_magics:
358 no_alias[key] = 1
358 no_alias[key] = 1
359 no_alias.update(__builtin__.__dict__)
359 no_alias.update(__builtin__.__dict__)
360 self.no_alias = no_alias
360 self.no_alias = no_alias
361
361
362 # make global variables for user access to these
362 # make global variables for user access to these
363 self.user_ns['_ih'] = self.input_hist
363 self.user_ns['_ih'] = self.input_hist
364 self.user_ns['_oh'] = self.output_hist
364 self.user_ns['_oh'] = self.output_hist
365 self.user_ns['_dh'] = self.dir_hist
365 self.user_ns['_dh'] = self.dir_hist
366
366
367 # user aliases to input and output histories
367 # user aliases to input and output histories
368 self.user_ns['In'] = self.input_hist
368 self.user_ns['In'] = self.input_hist
369 self.user_ns['Out'] = self.output_hist
369 self.user_ns['Out'] = self.output_hist
370
370
371 # Object variable to store code object waiting execution. This is
371 # Object variable to store code object waiting execution. This is
372 # used mainly by the multithreaded shells, but it can come in handy in
372 # used mainly by the multithreaded shells, but it can come in handy in
373 # other situations. No need to use a Queue here, since it's a single
373 # other situations. No need to use a Queue here, since it's a single
374 # item which gets cleared once run.
374 # item which gets cleared once run.
375 self.code_to_run = None
375 self.code_to_run = None
376
376
377 # escapes for automatic behavior on the command line
377 # escapes for automatic behavior on the command line
378 self.ESC_SHELL = '!'
378 self.ESC_SHELL = '!'
379 self.ESC_HELP = '?'
379 self.ESC_HELP = '?'
380 self.ESC_MAGIC = '%'
380 self.ESC_MAGIC = '%'
381 self.ESC_QUOTE = ','
381 self.ESC_QUOTE = ','
382 self.ESC_QUOTE2 = ';'
382 self.ESC_QUOTE2 = ';'
383 self.ESC_PAREN = '/'
383 self.ESC_PAREN = '/'
384
384
385 # And their associated handlers
385 # And their associated handlers
386 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
386 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
387 self.ESC_QUOTE : self.handle_auto,
387 self.ESC_QUOTE : self.handle_auto,
388 self.ESC_QUOTE2 : self.handle_auto,
388 self.ESC_QUOTE2 : self.handle_auto,
389 self.ESC_MAGIC : self.handle_magic,
389 self.ESC_MAGIC : self.handle_magic,
390 self.ESC_HELP : self.handle_help,
390 self.ESC_HELP : self.handle_help,
391 self.ESC_SHELL : self.handle_shell_escape,
391 self.ESC_SHELL : self.handle_shell_escape,
392 }
392 }
393
393
394 # class initializations
394 # class initializations
395 Magic.__init__(self,self)
395 Magic.__init__(self,self)
396
396
397 # Python source parser/formatter for syntax highlighting
397 # Python source parser/formatter for syntax highlighting
398 pyformat = PyColorize.Parser().format
398 pyformat = PyColorize.Parser().format
399 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
399 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
400
400
401 # hooks holds pointers used for user-side customizations
401 # hooks holds pointers used for user-side customizations
402 self.hooks = Struct()
402 self.hooks = Struct()
403
403
404 # Set all default hooks, defined in the IPython.hooks module.
404 # Set all default hooks, defined in the IPython.hooks module.
405 hooks = IPython.hooks
405 hooks = IPython.hooks
406 for hook_name in hooks.__all__:
406 for hook_name in hooks.__all__:
407 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
407 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
408 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
408 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
409
409
410 # Flag to mark unconditional exit
410 # Flag to mark unconditional exit
411 self.exit_now = False
411 self.exit_now = False
412
412
413 self.usage_min = """\
413 self.usage_min = """\
414 An enhanced console for Python.
414 An enhanced console for Python.
415 Some of its features are:
415 Some of its features are:
416 - Readline support if the readline library is present.
416 - Readline support if the readline library is present.
417 - Tab completion in the local namespace.
417 - Tab completion in the local namespace.
418 - Logging of input, see command-line options.
418 - Logging of input, see command-line options.
419 - System shell escape via ! , eg !ls.
419 - System shell escape via ! , eg !ls.
420 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
420 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
421 - Keeps track of locally defined variables via %who, %whos.
421 - Keeps track of locally defined variables via %who, %whos.
422 - Show object information with a ? eg ?x or x? (use ?? for more info).
422 - Show object information with a ? eg ?x or x? (use ?? for more info).
423 """
423 """
424 if usage: self.usage = usage
424 if usage: self.usage = usage
425 else: self.usage = self.usage_min
425 else: self.usage = self.usage_min
426
426
427 # Storage
427 # Storage
428 self.rc = rc # This will hold all configuration information
428 self.rc = rc # This will hold all configuration information
429 self.pager = 'less'
429 self.pager = 'less'
430 # temporary files used for various purposes. Deleted at exit.
430 # temporary files used for various purposes. Deleted at exit.
431 self.tempfiles = []
431 self.tempfiles = []
432
432
433 # Keep track of readline usage (later set by init_readline)
433 # Keep track of readline usage (later set by init_readline)
434 self.has_readline = False
434 self.has_readline = False
435
435
436 # template for logfile headers. It gets resolved at runtime by the
436 # template for logfile headers. It gets resolved at runtime by the
437 # logstart method.
437 # logstart method.
438 self.loghead_tpl = \
438 self.loghead_tpl = \
439 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
439 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
440 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
440 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
441 #log# opts = %s
441 #log# opts = %s
442 #log# args = %s
442 #log# args = %s
443 #log# It is safe to make manual edits below here.
443 #log# It is safe to make manual edits below here.
444 #log#-----------------------------------------------------------------------
444 #log#-----------------------------------------------------------------------
445 """
445 """
446 # for pushd/popd management
446 # for pushd/popd management
447 try:
447 try:
448 self.home_dir = get_home_dir()
448 self.home_dir = get_home_dir()
449 except HomeDirError,msg:
449 except HomeDirError,msg:
450 fatal(msg)
450 fatal(msg)
451
451
452 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
452 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
453
453
454 # Functions to call the underlying shell.
454 # Functions to call the underlying shell.
455
455
456 # utility to expand user variables via Itpl
456 # utility to expand user variables via Itpl
457 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
457 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
458 self.user_ns))
458 self.user_ns))
459 # The first is similar to os.system, but it doesn't return a value,
459 # The first is similar to os.system, but it doesn't return a value,
460 # and it allows interpolation of variables in the user's namespace.
460 # and it allows interpolation of variables in the user's namespace.
461 self.system = lambda cmd: shell(self.var_expand(cmd),
461 self.system = lambda cmd: shell(self.var_expand(cmd),
462 header='IPython system call: ',
462 header='IPython system call: ',
463 verbose=self.rc.system_verbose)
463 verbose=self.rc.system_verbose)
464 # These are for getoutput and getoutputerror:
464 # These are for getoutput and getoutputerror:
465 self.getoutput = lambda cmd: \
465 self.getoutput = lambda cmd: \
466 getoutput(self.var_expand(cmd),
466 getoutput(self.var_expand(cmd),
467 header='IPython system call: ',
467 header='IPython system call: ',
468 verbose=self.rc.system_verbose)
468 verbose=self.rc.system_verbose)
469 self.getoutputerror = lambda cmd: \
469 self.getoutputerror = lambda cmd: \
470 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
470 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
471 self.user_ns)),
471 self.user_ns)),
472 header='IPython system call: ',
472 header='IPython system call: ',
473 verbose=self.rc.system_verbose)
473 verbose=self.rc.system_verbose)
474
474
475 # RegExp for splitting line contents into pre-char//first
475 # RegExp for splitting line contents into pre-char//first
476 # word-method//rest. For clarity, each group in on one line.
476 # word-method//rest. For clarity, each group in on one line.
477
477
478 # WARNING: update the regexp if the above escapes are changed, as they
478 # WARNING: update the regexp if the above escapes are changed, as they
479 # are hardwired in.
479 # are hardwired in.
480
480
481 # Don't get carried away with trying to make the autocalling catch too
481 # Don't get carried away with trying to make the autocalling catch too
482 # much: it's better to be conservative rather than to trigger hidden
482 # much: it's better to be conservative rather than to trigger hidden
483 # evals() somewhere and end up causing side effects.
483 # evals() somewhere and end up causing side effects.
484
484
485 self.line_split = re.compile(r'^([\s*,;/])'
485 self.line_split = re.compile(r'^([\s*,;/])'
486 r'([\?\w\.]+\w*\s*)'
486 r'([\?\w\.]+\w*\s*)'
487 r'(\(?.*$)')
487 r'(\(?.*$)')
488
488
489 # Original re, keep around for a while in case changes break something
489 # Original re, keep around for a while in case changes break something
490 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
490 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
491 # r'(\s*[\?\w\.]+\w*\s*)'
491 # r'(\s*[\?\w\.]+\w*\s*)'
492 # r'(\(?.*$)')
492 # r'(\(?.*$)')
493
493
494 # RegExp to identify potential function names
494 # RegExp to identify potential function names
495 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
495 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
496
496
497 # RegExp to exclude strings with this start from autocalling. In
497 # RegExp to exclude strings with this start from autocalling. In
498 # particular, all binary operators should be excluded, so that if foo
498 # particular, all binary operators should be excluded, so that if foo
499 # is callable, foo OP bar doesn't become foo(OP bar), which is
499 # is callable, foo OP bar doesn't become foo(OP bar), which is
500 # invalid. The characters '!=()' don't need to be checked for, as the
500 # invalid. The characters '!=()' don't need to be checked for, as the
501 # _prefilter routine explicitely does so, to catch direct calls and
501 # _prefilter routine explicitely does so, to catch direct calls and
502 # rebindings of existing names.
502 # rebindings of existing names.
503
503
504 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
504 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
505 # it affects the rest of the group in square brackets.
505 # it affects the rest of the group in square brackets.
506 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
506 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
507 '|^is |^not |^in |^and |^or ')
507 '|^is |^not |^in |^and |^or ')
508
508
509 # try to catch also methods for stuff in lists/tuples/dicts: off
509 # try to catch also methods for stuff in lists/tuples/dicts: off
510 # (experimental). For this to work, the line_split regexp would need
510 # (experimental). For this to work, the line_split regexp would need
511 # to be modified so it wouldn't break things at '['. That line is
511 # to be modified so it wouldn't break things at '['. That line is
512 # nasty enough that I shouldn't change it until I can test it _well_.
512 # nasty enough that I shouldn't change it until I can test it _well_.
513 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
513 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
514
514
515 # keep track of where we started running (mainly for crash post-mortem)
515 # keep track of where we started running (mainly for crash post-mortem)
516 self.starting_dir = os.getcwd()
516 self.starting_dir = os.getcwd()
517
517
518 # Various switches which can be set
518 # Various switches which can be set
519 self.CACHELENGTH = 5000 # this is cheap, it's just text
519 self.CACHELENGTH = 5000 # this is cheap, it's just text
520 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
520 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
521 self.banner2 = banner2
521 self.banner2 = banner2
522
522
523 # TraceBack handlers:
523 # TraceBack handlers:
524
524
525 # Syntax error handler.
525 # Syntax error handler.
526 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
526 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
527
527
528 # The interactive one is initialized with an offset, meaning we always
528 # The interactive one is initialized with an offset, meaning we always
529 # want to remove the topmost item in the traceback, which is our own
529 # want to remove the topmost item in the traceback, which is our own
530 # internal code. Valid modes: ['Plain','Context','Verbose']
530 # internal code. Valid modes: ['Plain','Context','Verbose']
531 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
531 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
532 color_scheme='NoColor',
532 color_scheme='NoColor',
533 tb_offset = 1)
533 tb_offset = 1)
534
534
535 # IPython itself shouldn't crash. This will produce a detailed
535 # IPython itself shouldn't crash. This will produce a detailed
536 # post-mortem if it does. But we only install the crash handler for
536 # post-mortem if it does. But we only install the crash handler for
537 # non-threaded shells, the threaded ones use a normal verbose reporter
537 # non-threaded shells, the threaded ones use a normal verbose reporter
538 # and lose the crash handler. This is because exceptions in the main
538 # and lose the crash handler. This is because exceptions in the main
539 # thread (such as in GUI code) propagate directly to sys.excepthook,
539 # thread (such as in GUI code) propagate directly to sys.excepthook,
540 # and there's no point in printing crash dumps for every user exception.
540 # and there's no point in printing crash dumps for every user exception.
541 if self.isthreaded:
541 if self.isthreaded:
542 sys.excepthook = ultraTB.FormattedTB()
542 sys.excepthook = ultraTB.FormattedTB()
543 else:
543 else:
544 from IPython import CrashHandler
544 from IPython import CrashHandler
545 sys.excepthook = CrashHandler.CrashHandler(self)
545 sys.excepthook = CrashHandler.CrashHandler(self)
546
546
547 # The instance will store a pointer to this, so that runtime code
547 # The instance will store a pointer to this, so that runtime code
548 # (such as magics) can access it. This is because during the
548 # (such as magics) can access it. This is because during the
549 # read-eval loop, it gets temporarily overwritten (to deal with GUI
549 # read-eval loop, it gets temporarily overwritten (to deal with GUI
550 # frameworks).
550 # frameworks).
551 self.sys_excepthook = sys.excepthook
551 self.sys_excepthook = sys.excepthook
552
552
553 # and add any custom exception handlers the user may have specified
553 # and add any custom exception handlers the user may have specified
554 self.set_custom_exc(*custom_exceptions)
554 self.set_custom_exc(*custom_exceptions)
555
555
556 # Object inspector
556 # Object inspector
557 self.inspector = OInspect.Inspector(OInspect.InspectColors,
557 self.inspector = OInspect.Inspector(OInspect.InspectColors,
558 PyColorize.ANSICodeColors,
558 PyColorize.ANSICodeColors,
559 'NoColor')
559 'NoColor')
560 # indentation management
560 # indentation management
561 self.autoindent = False
561 self.autoindent = False
562 self.indent_current_nsp = 0
562 self.indent_current_nsp = 0
563 self.indent_current = '' # actual indent string
564
563
565 # Make some aliases automatically
564 # Make some aliases automatically
566 # Prepare list of shell aliases to auto-define
565 # Prepare list of shell aliases to auto-define
567 if os.name == 'posix':
566 if os.name == 'posix':
568 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
567 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
569 'mv mv -i','rm rm -i','cp cp -i',
568 'mv mv -i','rm rm -i','cp cp -i',
570 'cat cat','less less','clear clear',
569 'cat cat','less less','clear clear',
571 # a better ls
570 # a better ls
572 'ls ls -F',
571 'ls ls -F',
573 # long ls
572 # long ls
574 'll ls -lF',
573 'll ls -lF',
575 # color ls
574 # color ls
576 'lc ls -F -o --color',
575 'lc ls -F -o --color',
577 # ls normal files only
576 # ls normal files only
578 'lf ls -F -o --color %l | grep ^-',
577 'lf ls -F -o --color %l | grep ^-',
579 # ls symbolic links
578 # ls symbolic links
580 'lk ls -F -o --color %l | grep ^l',
579 'lk ls -F -o --color %l | grep ^l',
581 # directories or links to directories,
580 # directories or links to directories,
582 'ldir ls -F -o --color %l | grep /$',
581 'ldir ls -F -o --color %l | grep /$',
583 # things which are executable
582 # things which are executable
584 'lx ls -F -o --color %l | grep ^-..x',
583 'lx ls -F -o --color %l | grep ^-..x',
585 )
584 )
586 elif os.name in ['nt','dos']:
585 elif os.name in ['nt','dos']:
587 auto_alias = ('dir dir /on', 'ls dir /on',
586 auto_alias = ('dir dir /on', 'ls dir /on',
588 'ddir dir /ad /on', 'ldir dir /ad /on',
587 'ddir dir /ad /on', 'ldir dir /ad /on',
589 'mkdir mkdir','rmdir rmdir','echo echo',
588 'mkdir mkdir','rmdir rmdir','echo echo',
590 'ren ren','cls cls','copy copy')
589 'ren ren','cls cls','copy copy')
591 else:
590 else:
592 auto_alias = ()
591 auto_alias = ()
593 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
592 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
594 # Call the actual (public) initializer
593 # Call the actual (public) initializer
595 self.init_auto_alias()
594 self.init_auto_alias()
596 # end __init__
595 # end __init__
597
596
598 def post_config_initialization(self):
597 def post_config_initialization(self):
599 """Post configuration init method
598 """Post configuration init method
600
599
601 This is called after the configuration files have been processed to
600 This is called after the configuration files have been processed to
602 'finalize' the initialization."""
601 'finalize' the initialization."""
603
602
604 rc = self.rc
603 rc = self.rc
605
604
606 # Load readline proper
605 # Load readline proper
607 if rc.readline:
606 if rc.readline:
608 self.init_readline()
607 self.init_readline()
609
608
610 # local shortcut, this is used a LOT
609 # local shortcut, this is used a LOT
611 self.log = self.logger.log
610 self.log = self.logger.log
612
611
613 # Initialize cache, set in/out prompts and printing system
612 # Initialize cache, set in/out prompts and printing system
614 self.outputcache = CachedOutput(self,
613 self.outputcache = CachedOutput(self,
615 rc.cache_size,
614 rc.cache_size,
616 rc.pprint,
615 rc.pprint,
617 input_sep = rc.separate_in,
616 input_sep = rc.separate_in,
618 output_sep = rc.separate_out,
617 output_sep = rc.separate_out,
619 output_sep2 = rc.separate_out2,
618 output_sep2 = rc.separate_out2,
620 ps1 = rc.prompt_in1,
619 ps1 = rc.prompt_in1,
621 ps2 = rc.prompt_in2,
620 ps2 = rc.prompt_in2,
622 ps_out = rc.prompt_out,
621 ps_out = rc.prompt_out,
623 pad_left = rc.prompts_pad_left)
622 pad_left = rc.prompts_pad_left)
624
623
625 # user may have over-ridden the default print hook:
624 # user may have over-ridden the default print hook:
626 try:
625 try:
627 self.outputcache.__class__.display = self.hooks.display
626 self.outputcache.__class__.display = self.hooks.display
628 except AttributeError:
627 except AttributeError:
629 pass
628 pass
630
629
631 # I don't like assigning globally to sys, because it means when embedding
630 # I don't like assigning globally to sys, because it means when embedding
632 # instances, each embedded instance overrides the previous choice. But
631 # instances, each embedded instance overrides the previous choice. But
633 # sys.displayhook seems to be called internally by exec, so I don't see a
632 # sys.displayhook seems to be called internally by exec, so I don't see a
634 # way around it.
633 # way around it.
635 sys.displayhook = self.outputcache
634 sys.displayhook = self.outputcache
636
635
637 # Set user colors (don't do it in the constructor above so that it
636 # Set user colors (don't do it in the constructor above so that it
638 # doesn't crash if colors option is invalid)
637 # doesn't crash if colors option is invalid)
639 self.magic_colors(rc.colors)
638 self.magic_colors(rc.colors)
640
639
641 # Set calling of pdb on exceptions
640 # Set calling of pdb on exceptions
642 self.call_pdb = rc.pdb
641 self.call_pdb = rc.pdb
643
642
644 # Load user aliases
643 # Load user aliases
645 for alias in rc.alias:
644 for alias in rc.alias:
646 self.magic_alias(alias)
645 self.magic_alias(alias)
647
646
648 # dynamic data that survives through sessions
647 # dynamic data that survives through sessions
649 # XXX make the filename a config option?
648 # XXX make the filename a config option?
650 persist_base = 'persist'
649 persist_base = 'persist'
651 if rc.profile:
650 if rc.profile:
652 persist_base += '_%s' % rc.profile
651 persist_base += '_%s' % rc.profile
653 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
652 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
654
653
655 try:
654 try:
656 self.persist = pickle.load(file(self.persist_fname))
655 self.persist = pickle.load(file(self.persist_fname))
657 except:
656 except:
658 self.persist = {}
657 self.persist = {}
659
658
660
659
661 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
660 for (key, value) in [(k[2:],v) for (k,v) in self.persist.items() if k.startswith('S:')]:
662 try:
661 try:
663 obj = pickle.loads(value)
662 obj = pickle.loads(value)
664 except:
663 except:
665
664
666 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
665 print "Unable to restore variable '%s', ignoring (use %%store -d to forget!)" % key
667 print "The error was:",sys.exc_info()[0]
666 print "The error was:",sys.exc_info()[0]
668 continue
667 continue
669
668
670
669
671 self.user_ns[key] = obj
670 self.user_ns[key] = obj
672
671
673 def add_builtins(self):
672 def add_builtins(self):
674 """Store ipython references into the builtin namespace.
673 """Store ipython references into the builtin namespace.
675
674
676 Some parts of ipython operate via builtins injected here, which hold a
675 Some parts of ipython operate via builtins injected here, which hold a
677 reference to IPython itself."""
676 reference to IPython itself."""
678
677
679 builtins_new = dict(__IPYTHON__ = self,
678 builtins_new = dict(__IPYTHON__ = self,
680 ip_set_hook = self.set_hook,
679 ip_set_hook = self.set_hook,
681 jobs = self.jobs,
680 jobs = self.jobs,
682 ipmagic = self.ipmagic,
681 ipmagic = self.ipmagic,
683 ipalias = self.ipalias,
682 ipalias = self.ipalias,
684 ipsystem = self.ipsystem,
683 ipsystem = self.ipsystem,
685 )
684 )
686 for biname,bival in builtins_new.items():
685 for biname,bival in builtins_new.items():
687 try:
686 try:
688 # store the orignal value so we can restore it
687 # store the orignal value so we can restore it
689 self.builtins_added[biname] = __builtin__.__dict__[biname]
688 self.builtins_added[biname] = __builtin__.__dict__[biname]
690 except KeyError:
689 except KeyError:
691 # or mark that it wasn't defined, and we'll just delete it at
690 # or mark that it wasn't defined, and we'll just delete it at
692 # cleanup
691 # cleanup
693 self.builtins_added[biname] = Undefined
692 self.builtins_added[biname] = Undefined
694 __builtin__.__dict__[biname] = bival
693 __builtin__.__dict__[biname] = bival
695
694
696 # Keep in the builtins a flag for when IPython is active. We set it
695 # Keep in the builtins a flag for when IPython is active. We set it
697 # with setdefault so that multiple nested IPythons don't clobber one
696 # with setdefault so that multiple nested IPythons don't clobber one
698 # another. Each will increase its value by one upon being activated,
697 # another. Each will increase its value by one upon being activated,
699 # which also gives us a way to determine the nesting level.
698 # which also gives us a way to determine the nesting level.
700 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
699 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
701
700
702 def clean_builtins(self):
701 def clean_builtins(self):
703 """Remove any builtins which might have been added by add_builtins, or
702 """Remove any builtins which might have been added by add_builtins, or
704 restore overwritten ones to their previous values."""
703 restore overwritten ones to their previous values."""
705 for biname,bival in self.builtins_added.items():
704 for biname,bival in self.builtins_added.items():
706 if bival is Undefined:
705 if bival is Undefined:
707 del __builtin__.__dict__[biname]
706 del __builtin__.__dict__[biname]
708 else:
707 else:
709 __builtin__.__dict__[biname] = bival
708 __builtin__.__dict__[biname] = bival
710 self.builtins_added.clear()
709 self.builtins_added.clear()
711
710
712 def set_hook(self,name,hook, priority = 50):
711 def set_hook(self,name,hook, priority = 50):
713 """set_hook(name,hook) -> sets an internal IPython hook.
712 """set_hook(name,hook) -> sets an internal IPython hook.
714
713
715 IPython exposes some of its internal API as user-modifiable hooks. By
714 IPython exposes some of its internal API as user-modifiable hooks. By
716 adding your function to one of these hooks, you can modify IPython's
715 adding your function to one of these hooks, you can modify IPython's
717 behavior to call at runtime your own routines."""
716 behavior to call at runtime your own routines."""
718
717
719 # At some point in the future, this should validate the hook before it
718 # At some point in the future, this should validate the hook before it
720 # accepts it. Probably at least check that the hook takes the number
719 # accepts it. Probably at least check that the hook takes the number
721 # of args it's supposed to.
720 # of args it's supposed to.
722 dp = getattr(self.hooks, name, None)
721 dp = getattr(self.hooks, name, None)
723 if not dp:
722 if not dp:
724 dp = IPython.hooks.CommandChainDispatcher()
723 dp = IPython.hooks.CommandChainDispatcher()
725
724
726 f = new.instancemethod(hook,self,self.__class__)
725 f = new.instancemethod(hook,self,self.__class__)
727 try:
726 try:
728 dp.add(f,priority)
727 dp.add(f,priority)
729 except AttributeError:
728 except AttributeError:
730 # it was not commandchain, plain old func - replace
729 # it was not commandchain, plain old func - replace
731 dp = f
730 dp = f
732
731
733 setattr(self.hooks,name, dp)
732 setattr(self.hooks,name, dp)
734
733
735
734
736 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
735 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
737
736
738 def set_custom_exc(self,exc_tuple,handler):
737 def set_custom_exc(self,exc_tuple,handler):
739 """set_custom_exc(exc_tuple,handler)
738 """set_custom_exc(exc_tuple,handler)
740
739
741 Set a custom exception handler, which will be called if any of the
740 Set a custom exception handler, which will be called if any of the
742 exceptions in exc_tuple occur in the mainloop (specifically, in the
741 exceptions in exc_tuple occur in the mainloop (specifically, in the
743 runcode() method.
742 runcode() method.
744
743
745 Inputs:
744 Inputs:
746
745
747 - exc_tuple: a *tuple* of valid exceptions to call the defined
746 - exc_tuple: a *tuple* of valid exceptions to call the defined
748 handler for. It is very important that you use a tuple, and NOT A
747 handler for. It is very important that you use a tuple, and NOT A
749 LIST here, because of the way Python's except statement works. If
748 LIST here, because of the way Python's except statement works. If
750 you only want to trap a single exception, use a singleton tuple:
749 you only want to trap a single exception, use a singleton tuple:
751
750
752 exc_tuple == (MyCustomException,)
751 exc_tuple == (MyCustomException,)
753
752
754 - handler: this must be defined as a function with the following
753 - handler: this must be defined as a function with the following
755 basic interface: def my_handler(self,etype,value,tb).
754 basic interface: def my_handler(self,etype,value,tb).
756
755
757 This will be made into an instance method (via new.instancemethod)
756 This will be made into an instance method (via new.instancemethod)
758 of IPython itself, and it will be called if any of the exceptions
757 of IPython itself, and it will be called if any of the exceptions
759 listed in the exc_tuple are caught. If the handler is None, an
758 listed in the exc_tuple are caught. If the handler is None, an
760 internal basic one is used, which just prints basic info.
759 internal basic one is used, which just prints basic info.
761
760
762 WARNING: by putting in your own exception handler into IPython's main
761 WARNING: by putting in your own exception handler into IPython's main
763 execution loop, you run a very good chance of nasty crashes. This
762 execution loop, you run a very good chance of nasty crashes. This
764 facility should only be used if you really know what you are doing."""
763 facility should only be used if you really know what you are doing."""
765
764
766 assert type(exc_tuple)==type(()) , \
765 assert type(exc_tuple)==type(()) , \
767 "The custom exceptions must be given AS A TUPLE."
766 "The custom exceptions must be given AS A TUPLE."
768
767
769 def dummy_handler(self,etype,value,tb):
768 def dummy_handler(self,etype,value,tb):
770 print '*** Simple custom exception handler ***'
769 print '*** Simple custom exception handler ***'
771 print 'Exception type :',etype
770 print 'Exception type :',etype
772 print 'Exception value:',value
771 print 'Exception value:',value
773 print 'Traceback :',tb
772 print 'Traceback :',tb
774 print 'Source code :','\n'.join(self.buffer)
773 print 'Source code :','\n'.join(self.buffer)
775
774
776 if handler is None: handler = dummy_handler
775 if handler is None: handler = dummy_handler
777
776
778 self.CustomTB = new.instancemethod(handler,self,self.__class__)
777 self.CustomTB = new.instancemethod(handler,self,self.__class__)
779 self.custom_exceptions = exc_tuple
778 self.custom_exceptions = exc_tuple
780
779
781 def set_custom_completer(self,completer,pos=0):
780 def set_custom_completer(self,completer,pos=0):
782 """set_custom_completer(completer,pos=0)
781 """set_custom_completer(completer,pos=0)
783
782
784 Adds a new custom completer function.
783 Adds a new custom completer function.
785
784
786 The position argument (defaults to 0) is the index in the completers
785 The position argument (defaults to 0) is the index in the completers
787 list where you want the completer to be inserted."""
786 list where you want the completer to be inserted."""
788
787
789 newcomp = new.instancemethod(completer,self.Completer,
788 newcomp = new.instancemethod(completer,self.Completer,
790 self.Completer.__class__)
789 self.Completer.__class__)
791 self.Completer.matchers.insert(pos,newcomp)
790 self.Completer.matchers.insert(pos,newcomp)
792
791
793 def _get_call_pdb(self):
792 def _get_call_pdb(self):
794 return self._call_pdb
793 return self._call_pdb
795
794
796 def _set_call_pdb(self,val):
795 def _set_call_pdb(self,val):
797
796
798 if val not in (0,1,False,True):
797 if val not in (0,1,False,True):
799 raise ValueError,'new call_pdb value must be boolean'
798 raise ValueError,'new call_pdb value must be boolean'
800
799
801 # store value in instance
800 # store value in instance
802 self._call_pdb = val
801 self._call_pdb = val
803
802
804 # notify the actual exception handlers
803 # notify the actual exception handlers
805 self.InteractiveTB.call_pdb = val
804 self.InteractiveTB.call_pdb = val
806 if self.isthreaded:
805 if self.isthreaded:
807 try:
806 try:
808 self.sys_excepthook.call_pdb = val
807 self.sys_excepthook.call_pdb = val
809 except:
808 except:
810 warn('Failed to activate pdb for threaded exception handler')
809 warn('Failed to activate pdb for threaded exception handler')
811
810
812 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
811 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
813 'Control auto-activation of pdb at exceptions')
812 'Control auto-activation of pdb at exceptions')
814
813
815
814
816 # These special functions get installed in the builtin namespace, to
815 # These special functions get installed in the builtin namespace, to
817 # provide programmatic (pure python) access to magics, aliases and system
816 # provide programmatic (pure python) access to magics, aliases and system
818 # calls. This is important for logging, user scripting, and more.
817 # calls. This is important for logging, user scripting, and more.
819
818
820 # We are basically exposing, via normal python functions, the three
819 # We are basically exposing, via normal python functions, the three
821 # mechanisms in which ipython offers special call modes (magics for
820 # mechanisms in which ipython offers special call modes (magics for
822 # internal control, aliases for direct system access via pre-selected
821 # internal control, aliases for direct system access via pre-selected
823 # names, and !cmd for calling arbitrary system commands).
822 # names, and !cmd for calling arbitrary system commands).
824
823
825 def ipmagic(self,arg_s):
824 def ipmagic(self,arg_s):
826 """Call a magic function by name.
825 """Call a magic function by name.
827
826
828 Input: a string containing the name of the magic function to call and any
827 Input: a string containing the name of the magic function to call and any
829 additional arguments to be passed to the magic.
828 additional arguments to be passed to the magic.
830
829
831 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
830 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
832 prompt:
831 prompt:
833
832
834 In[1]: %name -opt foo bar
833 In[1]: %name -opt foo bar
835
834
836 To call a magic without arguments, simply use ipmagic('name').
835 To call a magic without arguments, simply use ipmagic('name').
837
836
838 This provides a proper Python function to call IPython's magics in any
837 This provides a proper Python function to call IPython's magics in any
839 valid Python code you can type at the interpreter, including loops and
838 valid Python code you can type at the interpreter, including loops and
840 compound statements. It is added by IPython to the Python builtin
839 compound statements. It is added by IPython to the Python builtin
841 namespace upon initialization."""
840 namespace upon initialization."""
842
841
843 args = arg_s.split(' ',1)
842 args = arg_s.split(' ',1)
844 magic_name = args[0]
843 magic_name = args[0]
845 magic_name = magic_name.lstrip(self.ESC_MAGIC)
844 magic_name = magic_name.lstrip(self.ESC_MAGIC)
846
845
847 try:
846 try:
848 magic_args = args[1]
847 magic_args = args[1]
849 except IndexError:
848 except IndexError:
850 magic_args = ''
849 magic_args = ''
851 fn = getattr(self,'magic_'+magic_name,None)
850 fn = getattr(self,'magic_'+magic_name,None)
852 if fn is None:
851 if fn is None:
853 error("Magic function `%s` not found." % magic_name)
852 error("Magic function `%s` not found." % magic_name)
854 else:
853 else:
855 magic_args = self.var_expand(magic_args)
854 magic_args = self.var_expand(magic_args)
856 return fn(magic_args)
855 return fn(magic_args)
857
856
858 def ipalias(self,arg_s):
857 def ipalias(self,arg_s):
859 """Call an alias by name.
858 """Call an alias by name.
860
859
861 Input: a string containing the name of the alias to call and any
860 Input: a string containing the name of the alias to call and any
862 additional arguments to be passed to the magic.
861 additional arguments to be passed to the magic.
863
862
864 ipalias('name -opt foo bar') is equivalent to typing at the ipython
863 ipalias('name -opt foo bar') is equivalent to typing at the ipython
865 prompt:
864 prompt:
866
865
867 In[1]: name -opt foo bar
866 In[1]: name -opt foo bar
868
867
869 To call an alias without arguments, simply use ipalias('name').
868 To call an alias without arguments, simply use ipalias('name').
870
869
871 This provides a proper Python function to call IPython's aliases in any
870 This provides a proper Python function to call IPython's aliases in any
872 valid Python code you can type at the interpreter, including loops and
871 valid Python code you can type at the interpreter, including loops and
873 compound statements. It is added by IPython to the Python builtin
872 compound statements. It is added by IPython to the Python builtin
874 namespace upon initialization."""
873 namespace upon initialization."""
875
874
876 args = arg_s.split(' ',1)
875 args = arg_s.split(' ',1)
877 alias_name = args[0]
876 alias_name = args[0]
878 try:
877 try:
879 alias_args = args[1]
878 alias_args = args[1]
880 except IndexError:
879 except IndexError:
881 alias_args = ''
880 alias_args = ''
882 if alias_name in self.alias_table:
881 if alias_name in self.alias_table:
883 self.call_alias(alias_name,alias_args)
882 self.call_alias(alias_name,alias_args)
884 else:
883 else:
885 error("Alias `%s` not found." % alias_name)
884 error("Alias `%s` not found." % alias_name)
886
885
887 def ipsystem(self,arg_s):
886 def ipsystem(self,arg_s):
888 """Make a system call, using IPython."""
887 """Make a system call, using IPython."""
889
888
890 self.system(arg_s)
889 self.system(arg_s)
891
890
892 def complete(self,text):
891 def complete(self,text):
893 """Return a sorted list of all possible completions on text.
892 """Return a sorted list of all possible completions on text.
894
893
895 Inputs:
894 Inputs:
896
895
897 - text: a string of text to be completed on.
896 - text: a string of text to be completed on.
898
897
899 This is a wrapper around the completion mechanism, similar to what
898 This is a wrapper around the completion mechanism, similar to what
900 readline does at the command line when the TAB key is hit. By
899 readline does at the command line when the TAB key is hit. By
901 exposing it as a method, it can be used by other non-readline
900 exposing it as a method, it can be used by other non-readline
902 environments (such as GUIs) for text completion.
901 environments (such as GUIs) for text completion.
903
902
904 Simple usage example:
903 Simple usage example:
905
904
906 In [1]: x = 'hello'
905 In [1]: x = 'hello'
907
906
908 In [2]: __IP.complete('x.l')
907 In [2]: __IP.complete('x.l')
909 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
908 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
910
909
911 complete = self.Completer.complete
910 complete = self.Completer.complete
912 state = 0
911 state = 0
913 # use a dict so we get unique keys, since ipyhton's multiple
912 # use a dict so we get unique keys, since ipyhton's multiple
914 # completers can return duplicates.
913 # completers can return duplicates.
915 comps = {}
914 comps = {}
916 while True:
915 while True:
917 newcomp = complete(text,state)
916 newcomp = complete(text,state)
918 if newcomp is None:
917 if newcomp is None:
919 break
918 break
920 comps[newcomp] = 1
919 comps[newcomp] = 1
921 state += 1
920 state += 1
922 outcomps = comps.keys()
921 outcomps = comps.keys()
923 outcomps.sort()
922 outcomps.sort()
924 return outcomps
923 return outcomps
925
924
926 def set_completer_frame(self, frame=None):
925 def set_completer_frame(self, frame=None):
927 if frame:
926 if frame:
928 self.Completer.namespace = frame.f_locals
927 self.Completer.namespace = frame.f_locals
929 self.Completer.global_namespace = frame.f_globals
928 self.Completer.global_namespace = frame.f_globals
930 else:
929 else:
931 self.Completer.namespace = self.user_ns
930 self.Completer.namespace = self.user_ns
932 self.Completer.global_namespace = self.user_global_ns
931 self.Completer.global_namespace = self.user_global_ns
933
932
934 def init_auto_alias(self):
933 def init_auto_alias(self):
935 """Define some aliases automatically.
934 """Define some aliases automatically.
936
935
937 These are ALL parameter-less aliases"""
936 These are ALL parameter-less aliases"""
938
937
939 for alias,cmd in self.auto_alias:
938 for alias,cmd in self.auto_alias:
940 self.alias_table[alias] = (0,cmd)
939 self.alias_table[alias] = (0,cmd)
941
940
942 def alias_table_validate(self,verbose=0):
941 def alias_table_validate(self,verbose=0):
943 """Update information about the alias table.
942 """Update information about the alias table.
944
943
945 In particular, make sure no Python keywords/builtins are in it."""
944 In particular, make sure no Python keywords/builtins are in it."""
946
945
947 no_alias = self.no_alias
946 no_alias = self.no_alias
948 for k in self.alias_table.keys():
947 for k in self.alias_table.keys():
949 if k in no_alias:
948 if k in no_alias:
950 del self.alias_table[k]
949 del self.alias_table[k]
951 if verbose:
950 if verbose:
952 print ("Deleting alias <%s>, it's a Python "
951 print ("Deleting alias <%s>, it's a Python "
953 "keyword or builtin." % k)
952 "keyword or builtin." % k)
954
953
955 def set_autoindent(self,value=None):
954 def set_autoindent(self,value=None):
956 """Set the autoindent flag, checking for readline support.
955 """Set the autoindent flag, checking for readline support.
957
956
958 If called with no arguments, it acts as a toggle."""
957 If called with no arguments, it acts as a toggle."""
959
958
960 if not self.has_readline:
959 if not self.has_readline:
961 if os.name == 'posix':
960 if os.name == 'posix':
962 warn("The auto-indent feature requires the readline library")
961 warn("The auto-indent feature requires the readline library")
963 self.autoindent = 0
962 self.autoindent = 0
964 return
963 return
965 if value is None:
964 if value is None:
966 self.autoindent = not self.autoindent
965 self.autoindent = not self.autoindent
967 else:
966 else:
968 self.autoindent = value
967 self.autoindent = value
969
968
970 def rc_set_toggle(self,rc_field,value=None):
969 def rc_set_toggle(self,rc_field,value=None):
971 """Set or toggle a field in IPython's rc config. structure.
970 """Set or toggle a field in IPython's rc config. structure.
972
971
973 If called with no arguments, it acts as a toggle.
972 If called with no arguments, it acts as a toggle.
974
973
975 If called with a non-existent field, the resulting AttributeError
974 If called with a non-existent field, the resulting AttributeError
976 exception will propagate out."""
975 exception will propagate out."""
977
976
978 rc_val = getattr(self.rc,rc_field)
977 rc_val = getattr(self.rc,rc_field)
979 if value is None:
978 if value is None:
980 value = not rc_val
979 value = not rc_val
981 setattr(self.rc,rc_field,value)
980 setattr(self.rc,rc_field,value)
982
981
983 def user_setup(self,ipythondir,rc_suffix,mode='install'):
982 def user_setup(self,ipythondir,rc_suffix,mode='install'):
984 """Install the user configuration directory.
983 """Install the user configuration directory.
985
984
986 Can be called when running for the first time or to upgrade the user's
985 Can be called when running for the first time or to upgrade the user's
987 .ipython/ directory with the mode parameter. Valid modes are 'install'
986 .ipython/ directory with the mode parameter. Valid modes are 'install'
988 and 'upgrade'."""
987 and 'upgrade'."""
989
988
990 def wait():
989 def wait():
991 try:
990 try:
992 raw_input("Please press <RETURN> to start IPython.")
991 raw_input("Please press <RETURN> to start IPython.")
993 except EOFError:
992 except EOFError:
994 print >> Term.cout
993 print >> Term.cout
995 print '*'*70
994 print '*'*70
996
995
997 cwd = os.getcwd() # remember where we started
996 cwd = os.getcwd() # remember where we started
998 glb = glob.glob
997 glb = glob.glob
999 print '*'*70
998 print '*'*70
1000 if mode == 'install':
999 if mode == 'install':
1001 print \
1000 print \
1002 """Welcome to IPython. I will try to create a personal configuration directory
1001 """Welcome to IPython. I will try to create a personal configuration directory
1003 where you can customize many aspects of IPython's functionality in:\n"""
1002 where you can customize many aspects of IPython's functionality in:\n"""
1004 else:
1003 else:
1005 print 'I am going to upgrade your configuration in:'
1004 print 'I am going to upgrade your configuration in:'
1006
1005
1007 print ipythondir
1006 print ipythondir
1008
1007
1009 rcdirend = os.path.join('IPython','UserConfig')
1008 rcdirend = os.path.join('IPython','UserConfig')
1010 cfg = lambda d: os.path.join(d,rcdirend)
1009 cfg = lambda d: os.path.join(d,rcdirend)
1011 try:
1010 try:
1012 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1011 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1013 except IOError:
1012 except IOError:
1014 warning = """
1013 warning = """
1015 Installation error. IPython's directory was not found.
1014 Installation error. IPython's directory was not found.
1016
1015
1017 Check the following:
1016 Check the following:
1018
1017
1019 The ipython/IPython directory should be in a directory belonging to your
1018 The ipython/IPython directory should be in a directory belonging to your
1020 PYTHONPATH environment variable (that is, it should be in a directory
1019 PYTHONPATH environment variable (that is, it should be in a directory
1021 belonging to sys.path). You can copy it explicitly there or just link to it.
1020 belonging to sys.path). You can copy it explicitly there or just link to it.
1022
1021
1023 IPython will proceed with builtin defaults.
1022 IPython will proceed with builtin defaults.
1024 """
1023 """
1025 warn(warning)
1024 warn(warning)
1026 wait()
1025 wait()
1027 return
1026 return
1028
1027
1029 if mode == 'install':
1028 if mode == 'install':
1030 try:
1029 try:
1031 shutil.copytree(rcdir,ipythondir)
1030 shutil.copytree(rcdir,ipythondir)
1032 os.chdir(ipythondir)
1031 os.chdir(ipythondir)
1033 rc_files = glb("ipythonrc*")
1032 rc_files = glb("ipythonrc*")
1034 for rc_file in rc_files:
1033 for rc_file in rc_files:
1035 os.rename(rc_file,rc_file+rc_suffix)
1034 os.rename(rc_file,rc_file+rc_suffix)
1036 except:
1035 except:
1037 warning = """
1036 warning = """
1038
1037
1039 There was a problem with the installation:
1038 There was a problem with the installation:
1040 %s
1039 %s
1041 Try to correct it or contact the developers if you think it's a bug.
1040 Try to correct it or contact the developers if you think it's a bug.
1042 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1041 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1043 warn(warning)
1042 warn(warning)
1044 wait()
1043 wait()
1045 return
1044 return
1046
1045
1047 elif mode == 'upgrade':
1046 elif mode == 'upgrade':
1048 try:
1047 try:
1049 os.chdir(ipythondir)
1048 os.chdir(ipythondir)
1050 except:
1049 except:
1051 print """
1050 print """
1052 Can not upgrade: changing to directory %s failed. Details:
1051 Can not upgrade: changing to directory %s failed. Details:
1053 %s
1052 %s
1054 """ % (ipythondir,sys.exc_info()[1])
1053 """ % (ipythondir,sys.exc_info()[1])
1055 wait()
1054 wait()
1056 return
1055 return
1057 else:
1056 else:
1058 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1057 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1059 for new_full_path in sources:
1058 for new_full_path in sources:
1060 new_filename = os.path.basename(new_full_path)
1059 new_filename = os.path.basename(new_full_path)
1061 if new_filename.startswith('ipythonrc'):
1060 if new_filename.startswith('ipythonrc'):
1062 new_filename = new_filename + rc_suffix
1061 new_filename = new_filename + rc_suffix
1063 # The config directory should only contain files, skip any
1062 # The config directory should only contain files, skip any
1064 # directories which may be there (like CVS)
1063 # directories which may be there (like CVS)
1065 if os.path.isdir(new_full_path):
1064 if os.path.isdir(new_full_path):
1066 continue
1065 continue
1067 if os.path.exists(new_filename):
1066 if os.path.exists(new_filename):
1068 old_file = new_filename+'.old'
1067 old_file = new_filename+'.old'
1069 if os.path.exists(old_file):
1068 if os.path.exists(old_file):
1070 os.remove(old_file)
1069 os.remove(old_file)
1071 os.rename(new_filename,old_file)
1070 os.rename(new_filename,old_file)
1072 shutil.copy(new_full_path,new_filename)
1071 shutil.copy(new_full_path,new_filename)
1073 else:
1072 else:
1074 raise ValueError,'unrecognized mode for install:',`mode`
1073 raise ValueError,'unrecognized mode for install:',`mode`
1075
1074
1076 # Fix line-endings to those native to each platform in the config
1075 # Fix line-endings to those native to each platform in the config
1077 # directory.
1076 # directory.
1078 try:
1077 try:
1079 os.chdir(ipythondir)
1078 os.chdir(ipythondir)
1080 except:
1079 except:
1081 print """
1080 print """
1082 Problem: changing to directory %s failed.
1081 Problem: changing to directory %s failed.
1083 Details:
1082 Details:
1084 %s
1083 %s
1085
1084
1086 Some configuration files may have incorrect line endings. This should not
1085 Some configuration files may have incorrect line endings. This should not
1087 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1086 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1088 wait()
1087 wait()
1089 else:
1088 else:
1090 for fname in glb('ipythonrc*'):
1089 for fname in glb('ipythonrc*'):
1091 try:
1090 try:
1092 native_line_ends(fname,backup=0)
1091 native_line_ends(fname,backup=0)
1093 except IOError:
1092 except IOError:
1094 pass
1093 pass
1095
1094
1096 if mode == 'install':
1095 if mode == 'install':
1097 print """
1096 print """
1098 Successful installation!
1097 Successful installation!
1099
1098
1100 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1099 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1101 IPython manual (there are both HTML and PDF versions supplied with the
1100 IPython manual (there are both HTML and PDF versions supplied with the
1102 distribution) to make sure that your system environment is properly configured
1101 distribution) to make sure that your system environment is properly configured
1103 to take advantage of IPython's features."""
1102 to take advantage of IPython's features."""
1104 else:
1103 else:
1105 print """
1104 print """
1106 Successful upgrade!
1105 Successful upgrade!
1107
1106
1108 All files in your directory:
1107 All files in your directory:
1109 %(ipythondir)s
1108 %(ipythondir)s
1110 which would have been overwritten by the upgrade were backed up with a .old
1109 which would have been overwritten by the upgrade were backed up with a .old
1111 extension. If you had made particular customizations in those files you may
1110 extension. If you had made particular customizations in those files you may
1112 want to merge them back into the new files.""" % locals()
1111 want to merge them back into the new files.""" % locals()
1113 wait()
1112 wait()
1114 os.chdir(cwd)
1113 os.chdir(cwd)
1115 # end user_setup()
1114 # end user_setup()
1116
1115
1117 def atexit_operations(self):
1116 def atexit_operations(self):
1118 """This will be executed at the time of exit.
1117 """This will be executed at the time of exit.
1119
1118
1120 Saving of persistent data should be performed here. """
1119 Saving of persistent data should be performed here. """
1121
1120
1122 #print '*** IPython exit cleanup ***' # dbg
1121 #print '*** IPython exit cleanup ***' # dbg
1123 # input history
1122 # input history
1124 self.savehist()
1123 self.savehist()
1125
1124
1126 # Cleanup all tempfiles left around
1125 # Cleanup all tempfiles left around
1127 for tfile in self.tempfiles:
1126 for tfile in self.tempfiles:
1128 try:
1127 try:
1129 os.unlink(tfile)
1128 os.unlink(tfile)
1130 except OSError:
1129 except OSError:
1131 pass
1130 pass
1132
1131
1133 # save the "persistent data" catch-all dictionary
1132 # save the "persistent data" catch-all dictionary
1134 try:
1133 try:
1135 pickle.dump(self.persist, open(self.persist_fname,"w"))
1134 pickle.dump(self.persist, open(self.persist_fname,"w"))
1136 except:
1135 except:
1137 print "*** ERROR *** persistent data saving failed."
1136 print "*** ERROR *** persistent data saving failed."
1138
1137
1139 def savehist(self):
1138 def savehist(self):
1140 """Save input history to a file (via readline library)."""
1139 """Save input history to a file (via readline library)."""
1141 try:
1140 try:
1142 self.readline.write_history_file(self.histfile)
1141 self.readline.write_history_file(self.histfile)
1143 except:
1142 except:
1144 print 'Unable to save IPython command history to file: ' + \
1143 print 'Unable to save IPython command history to file: ' + \
1145 `self.histfile`
1144 `self.histfile`
1146
1145
1147 def pre_readline(self):
1146 def pre_readline(self):
1148 """readline hook to be used at the start of each line.
1147 """readline hook to be used at the start of each line.
1149
1148
1150 Currently it handles auto-indent only."""
1149 Currently it handles auto-indent only."""
1151
1150
1152 self.readline.insert_text(self.indent_current)
1151 #debugp('self.indent_current_nsp','pre_readline:')
1152 self.readline.insert_text(self.indent_current_str())
1153
1153
1154 def init_readline(self):
1154 def init_readline(self):
1155 """Command history completion/saving/reloading."""
1155 """Command history completion/saving/reloading."""
1156 try:
1156 try:
1157 import readline
1157 import readline
1158 except ImportError:
1158 except ImportError:
1159 self.has_readline = 0
1159 self.has_readline = 0
1160 self.readline = None
1160 self.readline = None
1161 # no point in bugging windows users with this every time:
1161 # no point in bugging windows users with this every time:
1162 if os.name == 'posix':
1162 if os.name == 'posix':
1163 warn('Readline services not available on this platform.')
1163 warn('Readline services not available on this platform.')
1164 else:
1164 else:
1165 import atexit
1165 import atexit
1166 from IPython.completer import IPCompleter
1166 from IPython.completer import IPCompleter
1167 self.Completer = IPCompleter(self,
1167 self.Completer = IPCompleter(self,
1168 self.user_ns,
1168 self.user_ns,
1169 self.user_global_ns,
1169 self.user_global_ns,
1170 self.rc.readline_omit__names,
1170 self.rc.readline_omit__names,
1171 self.alias_table)
1171 self.alias_table)
1172
1172
1173 # Platform-specific configuration
1173 # Platform-specific configuration
1174 if os.name == 'nt':
1174 if os.name == 'nt':
1175 self.readline_startup_hook = readline.set_pre_input_hook
1175 self.readline_startup_hook = readline.set_pre_input_hook
1176 else:
1176 else:
1177 self.readline_startup_hook = readline.set_startup_hook
1177 self.readline_startup_hook = readline.set_startup_hook
1178
1178
1179 # Load user's initrc file (readline config)
1179 # Load user's initrc file (readline config)
1180 inputrc_name = os.environ.get('INPUTRC')
1180 inputrc_name = os.environ.get('INPUTRC')
1181 if inputrc_name is None:
1181 if inputrc_name is None:
1182 home_dir = get_home_dir()
1182 home_dir = get_home_dir()
1183 if home_dir is not None:
1183 if home_dir is not None:
1184 inputrc_name = os.path.join(home_dir,'.inputrc')
1184 inputrc_name = os.path.join(home_dir,'.inputrc')
1185 if os.path.isfile(inputrc_name):
1185 if os.path.isfile(inputrc_name):
1186 try:
1186 try:
1187 readline.read_init_file(inputrc_name)
1187 readline.read_init_file(inputrc_name)
1188 except:
1188 except:
1189 warn('Problems reading readline initialization file <%s>'
1189 warn('Problems reading readline initialization file <%s>'
1190 % inputrc_name)
1190 % inputrc_name)
1191
1191
1192 self.has_readline = 1
1192 self.has_readline = 1
1193 self.readline = readline
1193 self.readline = readline
1194 # save this in sys so embedded copies can restore it properly
1194 # save this in sys so embedded copies can restore it properly
1195 sys.ipcompleter = self.Completer.complete
1195 sys.ipcompleter = self.Completer.complete
1196 readline.set_completer(self.Completer.complete)
1196 readline.set_completer(self.Completer.complete)
1197
1197
1198 # Configure readline according to user's prefs
1198 # Configure readline according to user's prefs
1199 for rlcommand in self.rc.readline_parse_and_bind:
1199 for rlcommand in self.rc.readline_parse_and_bind:
1200 readline.parse_and_bind(rlcommand)
1200 readline.parse_and_bind(rlcommand)
1201
1201
1202 # remove some chars from the delimiters list
1202 # remove some chars from the delimiters list
1203 delims = readline.get_completer_delims()
1203 delims = readline.get_completer_delims()
1204 delims = delims.translate(string._idmap,
1204 delims = delims.translate(string._idmap,
1205 self.rc.readline_remove_delims)
1205 self.rc.readline_remove_delims)
1206 readline.set_completer_delims(delims)
1206 readline.set_completer_delims(delims)
1207 # otherwise we end up with a monster history after a while:
1207 # otherwise we end up with a monster history after a while:
1208 readline.set_history_length(1000)
1208 readline.set_history_length(1000)
1209 try:
1209 try:
1210 #print '*** Reading readline history' # dbg
1210 #print '*** Reading readline history' # dbg
1211 readline.read_history_file(self.histfile)
1211 readline.read_history_file(self.histfile)
1212 except IOError:
1212 except IOError:
1213 pass # It doesn't exist yet.
1213 pass # It doesn't exist yet.
1214
1214
1215 atexit.register(self.atexit_operations)
1215 atexit.register(self.atexit_operations)
1216 del atexit
1216 del atexit
1217
1217
1218 # Configure auto-indent for all platforms
1218 # Configure auto-indent for all platforms
1219 self.set_autoindent(self.rc.autoindent)
1219 self.set_autoindent(self.rc.autoindent)
1220
1220
1221 def _should_recompile(self,e):
1221 def _should_recompile(self,e):
1222 """Utility routine for edit_syntax_error"""
1222 """Utility routine for edit_syntax_error"""
1223
1223
1224 if e.filename in ('<ipython console>','<input>','<string>',
1224 if e.filename in ('<ipython console>','<input>','<string>',
1225 '<console>',None):
1225 '<console>',None):
1226
1226
1227 return False
1227 return False
1228 try:
1228 try:
1229 if not ask_yes_no('Return to editor to correct syntax error? '
1229 if not ask_yes_no('Return to editor to correct syntax error? '
1230 '[Y/n] ','y'):
1230 '[Y/n] ','y'):
1231 return False
1231 return False
1232 except EOFError:
1232 except EOFError:
1233 return False
1233 return False
1234
1234
1235 def int0(x):
1235 def int0(x):
1236 try:
1236 try:
1237 return int(x)
1237 return int(x)
1238 except TypeError:
1238 except TypeError:
1239 return 0
1239 return 0
1240 # always pass integer line and offset values to editor hook
1240 # always pass integer line and offset values to editor hook
1241 self.hooks.fix_error_editor(e.filename,
1241 self.hooks.fix_error_editor(e.filename,
1242 int0(e.lineno),int0(e.offset),e.msg)
1242 int0(e.lineno),int0(e.offset),e.msg)
1243 return True
1243 return True
1244
1244
1245 def edit_syntax_error(self):
1245 def edit_syntax_error(self):
1246 """The bottom half of the syntax error handler called in the main loop.
1246 """The bottom half of the syntax error handler called in the main loop.
1247
1247
1248 Loop until syntax error is fixed or user cancels.
1248 Loop until syntax error is fixed or user cancels.
1249 """
1249 """
1250
1250
1251 while self.SyntaxTB.last_syntax_error:
1251 while self.SyntaxTB.last_syntax_error:
1252 # copy and clear last_syntax_error
1252 # copy and clear last_syntax_error
1253 err = self.SyntaxTB.clear_err_state()
1253 err = self.SyntaxTB.clear_err_state()
1254 if not self._should_recompile(err):
1254 if not self._should_recompile(err):
1255 return
1255 return
1256 try:
1256 try:
1257 # may set last_syntax_error again if a SyntaxError is raised
1257 # may set last_syntax_error again if a SyntaxError is raised
1258 self.safe_execfile(err.filename,self.shell.user_ns)
1258 self.safe_execfile(err.filename,self.shell.user_ns)
1259 except:
1259 except:
1260 self.showtraceback()
1260 self.showtraceback()
1261 else:
1261 else:
1262 f = file(err.filename)
1262 f = file(err.filename)
1263 try:
1263 try:
1264 sys.displayhook(f.read())
1264 sys.displayhook(f.read())
1265 finally:
1265 finally:
1266 f.close()
1266 f.close()
1267
1267
1268 def showsyntaxerror(self, filename=None):
1268 def showsyntaxerror(self, filename=None):
1269 """Display the syntax error that just occurred.
1269 """Display the syntax error that just occurred.
1270
1270
1271 This doesn't display a stack trace because there isn't one.
1271 This doesn't display a stack trace because there isn't one.
1272
1272
1273 If a filename is given, it is stuffed in the exception instead
1273 If a filename is given, it is stuffed in the exception instead
1274 of what was there before (because Python's parser always uses
1274 of what was there before (because Python's parser always uses
1275 "<string>" when reading from a string).
1275 "<string>" when reading from a string).
1276 """
1276 """
1277 etype, value, last_traceback = sys.exc_info()
1277 etype, value, last_traceback = sys.exc_info()
1278 if filename and etype is SyntaxError:
1278 if filename and etype is SyntaxError:
1279 # Work hard to stuff the correct filename in the exception
1279 # Work hard to stuff the correct filename in the exception
1280 try:
1280 try:
1281 msg, (dummy_filename, lineno, offset, line) = value
1281 msg, (dummy_filename, lineno, offset, line) = value
1282 except:
1282 except:
1283 # Not the format we expect; leave it alone
1283 # Not the format we expect; leave it alone
1284 pass
1284 pass
1285 else:
1285 else:
1286 # Stuff in the right filename
1286 # Stuff in the right filename
1287 try:
1287 try:
1288 # Assume SyntaxError is a class exception
1288 # Assume SyntaxError is a class exception
1289 value = SyntaxError(msg, (filename, lineno, offset, line))
1289 value = SyntaxError(msg, (filename, lineno, offset, line))
1290 except:
1290 except:
1291 # If that failed, assume SyntaxError is a string
1291 # If that failed, assume SyntaxError is a string
1292 value = msg, (filename, lineno, offset, line)
1292 value = msg, (filename, lineno, offset, line)
1293 self.SyntaxTB(etype,value,[])
1293 self.SyntaxTB(etype,value,[])
1294
1294
1295 def debugger(self):
1295 def debugger(self):
1296 """Call the pdb debugger."""
1296 """Call the pdb debugger."""
1297
1297
1298 if not self.rc.pdb:
1298 if not self.rc.pdb:
1299 return
1299 return
1300 pdb.pm()
1300 pdb.pm()
1301
1301
1302 def showtraceback(self,exc_tuple = None,filename=None):
1302 def showtraceback(self,exc_tuple = None,filename=None):
1303 """Display the exception that just occurred."""
1303 """Display the exception that just occurred."""
1304
1304
1305 # Though this won't be called by syntax errors in the input line,
1305 # Though this won't be called by syntax errors in the input line,
1306 # there may be SyntaxError cases whith imported code.
1306 # there may be SyntaxError cases whith imported code.
1307 if exc_tuple is None:
1307 if exc_tuple is None:
1308 type, value, tb = sys.exc_info()
1308 type, value, tb = sys.exc_info()
1309 else:
1309 else:
1310 type, value, tb = exc_tuple
1310 type, value, tb = exc_tuple
1311 if type is SyntaxError:
1311 if type is SyntaxError:
1312 self.showsyntaxerror(filename)
1312 self.showsyntaxerror(filename)
1313 else:
1313 else:
1314 self.InteractiveTB()
1314 self.InteractiveTB()
1315 if self.InteractiveTB.call_pdb and self.has_readline:
1315 if self.InteractiveTB.call_pdb and self.has_readline:
1316 # pdb mucks up readline, fix it back
1316 # pdb mucks up readline, fix it back
1317 self.readline.set_completer(self.Completer.complete)
1317 self.readline.set_completer(self.Completer.complete)
1318
1318
1319 def mainloop(self,banner=None):
1319 def mainloop(self,banner=None):
1320 """Creates the local namespace and starts the mainloop.
1320 """Creates the local namespace and starts the mainloop.
1321
1321
1322 If an optional banner argument is given, it will override the
1322 If an optional banner argument is given, it will override the
1323 internally created default banner."""
1323 internally created default banner."""
1324
1324
1325 if self.rc.c: # Emulate Python's -c option
1325 if self.rc.c: # Emulate Python's -c option
1326 self.exec_init_cmd()
1326 self.exec_init_cmd()
1327 if banner is None:
1327 if banner is None:
1328 if self.rc.banner:
1328 if self.rc.banner:
1329 banner = self.BANNER+self.banner2
1329 banner = self.BANNER+self.banner2
1330 else:
1330 else:
1331 banner = ''
1331 banner = ''
1332 self.interact(banner)
1332 self.interact(banner)
1333
1333
1334 def exec_init_cmd(self):
1334 def exec_init_cmd(self):
1335 """Execute a command given at the command line.
1335 """Execute a command given at the command line.
1336
1336
1337 This emulates Python's -c option."""
1337 This emulates Python's -c option."""
1338
1338
1339 sys.argv = ['-c']
1339 sys.argv = ['-c']
1340 self.push(self.rc.c)
1340 self.push(self.rc.c)
1341
1341
1342 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1342 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1343 """Embeds IPython into a running python program.
1343 """Embeds IPython into a running python program.
1344
1344
1345 Input:
1345 Input:
1346
1346
1347 - header: An optional header message can be specified.
1347 - header: An optional header message can be specified.
1348
1348
1349 - local_ns, global_ns: working namespaces. If given as None, the
1349 - local_ns, global_ns: working namespaces. If given as None, the
1350 IPython-initialized one is updated with __main__.__dict__, so that
1350 IPython-initialized one is updated with __main__.__dict__, so that
1351 program variables become visible but user-specific configuration
1351 program variables become visible but user-specific configuration
1352 remains possible.
1352 remains possible.
1353
1353
1354 - stack_depth: specifies how many levels in the stack to go to
1354 - stack_depth: specifies how many levels in the stack to go to
1355 looking for namespaces (when local_ns and global_ns are None). This
1355 looking for namespaces (when local_ns and global_ns are None). This
1356 allows an intermediate caller to make sure that this function gets
1356 allows an intermediate caller to make sure that this function gets
1357 the namespace from the intended level in the stack. By default (0)
1357 the namespace from the intended level in the stack. By default (0)
1358 it will get its locals and globals from the immediate caller.
1358 it will get its locals and globals from the immediate caller.
1359
1359
1360 Warning: it's possible to use this in a program which is being run by
1360 Warning: it's possible to use this in a program which is being run by
1361 IPython itself (via %run), but some funny things will happen (a few
1361 IPython itself (via %run), but some funny things will happen (a few
1362 globals get overwritten). In the future this will be cleaned up, as
1362 globals get overwritten). In the future this will be cleaned up, as
1363 there is no fundamental reason why it can't work perfectly."""
1363 there is no fundamental reason why it can't work perfectly."""
1364
1364
1365 # Get locals and globals from caller
1365 # Get locals and globals from caller
1366 if local_ns is None or global_ns is None:
1366 if local_ns is None or global_ns is None:
1367 call_frame = sys._getframe(stack_depth).f_back
1367 call_frame = sys._getframe(stack_depth).f_back
1368
1368
1369 if local_ns is None:
1369 if local_ns is None:
1370 local_ns = call_frame.f_locals
1370 local_ns = call_frame.f_locals
1371 if global_ns is None:
1371 if global_ns is None:
1372 global_ns = call_frame.f_globals
1372 global_ns = call_frame.f_globals
1373
1373
1374 # Update namespaces and fire up interpreter
1374 # Update namespaces and fire up interpreter
1375
1375
1376 # The global one is easy, we can just throw it in
1376 # The global one is easy, we can just throw it in
1377 self.user_global_ns = global_ns
1377 self.user_global_ns = global_ns
1378
1378
1379 # but the user/local one is tricky: ipython needs it to store internal
1379 # but the user/local one is tricky: ipython needs it to store internal
1380 # data, but we also need the locals. We'll copy locals in the user
1380 # data, but we also need the locals. We'll copy locals in the user
1381 # one, but will track what got copied so we can delete them at exit.
1381 # one, but will track what got copied so we can delete them at exit.
1382 # This is so that a later embedded call doesn't see locals from a
1382 # This is so that a later embedded call doesn't see locals from a
1383 # previous call (which most likely existed in a separate scope).
1383 # previous call (which most likely existed in a separate scope).
1384 local_varnames = local_ns.keys()
1384 local_varnames = local_ns.keys()
1385 self.user_ns.update(local_ns)
1385 self.user_ns.update(local_ns)
1386
1386
1387 # Patch for global embedding to make sure that things don't overwrite
1387 # Patch for global embedding to make sure that things don't overwrite
1388 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1388 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1389 # FIXME. Test this a bit more carefully (the if.. is new)
1389 # FIXME. Test this a bit more carefully (the if.. is new)
1390 if local_ns is None and global_ns is None:
1390 if local_ns is None and global_ns is None:
1391 self.user_global_ns.update(__main__.__dict__)
1391 self.user_global_ns.update(__main__.__dict__)
1392
1392
1393 # make sure the tab-completer has the correct frame information, so it
1393 # make sure the tab-completer has the correct frame information, so it
1394 # actually completes using the frame's locals/globals
1394 # actually completes using the frame's locals/globals
1395 self.set_completer_frame()
1395 self.set_completer_frame()
1396
1396
1397 # before activating the interactive mode, we need to make sure that
1397 # before activating the interactive mode, we need to make sure that
1398 # all names in the builtin namespace needed by ipython point to
1398 # all names in the builtin namespace needed by ipython point to
1399 # ourselves, and not to other instances.
1399 # ourselves, and not to other instances.
1400 self.add_builtins()
1400 self.add_builtins()
1401
1401
1402 self.interact(header)
1402 self.interact(header)
1403
1403
1404 # now, purge out the user namespace from anything we might have added
1404 # now, purge out the user namespace from anything we might have added
1405 # from the caller's local namespace
1405 # from the caller's local namespace
1406 delvar = self.user_ns.pop
1406 delvar = self.user_ns.pop
1407 for var in local_varnames:
1407 for var in local_varnames:
1408 delvar(var,None)
1408 delvar(var,None)
1409 # and clean builtins we may have overridden
1409 # and clean builtins we may have overridden
1410 self.clean_builtins()
1410 self.clean_builtins()
1411
1411
1412 def interact(self, banner=None):
1412 def interact(self, banner=None):
1413 """Closely emulate the interactive Python console.
1413 """Closely emulate the interactive Python console.
1414
1414
1415 The optional banner argument specify the banner to print
1415 The optional banner argument specify the banner to print
1416 before the first interaction; by default it prints a banner
1416 before the first interaction; by default it prints a banner
1417 similar to the one printed by the real Python interpreter,
1417 similar to the one printed by the real Python interpreter,
1418 followed by the current class name in parentheses (so as not
1418 followed by the current class name in parentheses (so as not
1419 to confuse this with the real interpreter -- since it's so
1419 to confuse this with the real interpreter -- since it's so
1420 close!).
1420 close!).
1421
1421
1422 """
1422 """
1423 cprt = 'Type "copyright", "credits" or "license" for more information.'
1423 cprt = 'Type "copyright", "credits" or "license" for more information.'
1424 if banner is None:
1424 if banner is None:
1425 self.write("Python %s on %s\n%s\n(%s)\n" %
1425 self.write("Python %s on %s\n%s\n(%s)\n" %
1426 (sys.version, sys.platform, cprt,
1426 (sys.version, sys.platform, cprt,
1427 self.__class__.__name__))
1427 self.__class__.__name__))
1428 else:
1428 else:
1429 self.write(banner)
1429 self.write(banner)
1430
1430
1431 more = 0
1431 more = 0
1432
1432
1433 # Mark activity in the builtins
1433 # Mark activity in the builtins
1434 __builtin__.__dict__['__IPYTHON__active'] += 1
1434 __builtin__.__dict__['__IPYTHON__active'] += 1
1435
1435
1436 # exit_now is set by a call to %Exit or %Quit
1436 # exit_now is set by a call to %Exit or %Quit
1437 self.exit_now = False
1437 self.exit_now = False
1438 while not self.exit_now:
1438 while not self.exit_now:
1439
1439
1440 try:
1440 try:
1441 if more:
1441 if more:
1442 prompt = self.outputcache.prompt2
1442 prompt = self.outputcache.prompt2
1443 if self.autoindent:
1443 if self.autoindent:
1444 self.readline_startup_hook(self.pre_readline)
1444 self.readline_startup_hook(self.pre_readline)
1445 else:
1445 else:
1446 prompt = self.outputcache.prompt1
1446 prompt = self.outputcache.prompt1
1447 try:
1447 try:
1448 line = self.raw_input(prompt,more)
1448 line = self.raw_input(prompt,more)
1449 if self.autoindent:
1449 if self.autoindent:
1450 self.readline_startup_hook(None)
1450 self.readline_startup_hook(None)
1451 except EOFError:
1451 except EOFError:
1452 if self.autoindent:
1452 if self.autoindent:
1453 self.readline_startup_hook(None)
1453 self.readline_startup_hook(None)
1454 self.write("\n")
1454 self.write("\n")
1455 self.exit()
1455 self.exit()
1456 else:
1456 else:
1457 more = self.push(line)
1457 more = self.push(line)
1458
1458
1459 if (self.SyntaxTB.last_syntax_error and
1459 if (self.SyntaxTB.last_syntax_error and
1460 self.rc.autoedit_syntax):
1460 self.rc.autoedit_syntax):
1461 self.edit_syntax_error()
1461 self.edit_syntax_error()
1462
1462
1463 except KeyboardInterrupt:
1463 except KeyboardInterrupt:
1464 self.write("\nKeyboardInterrupt\n")
1464 self.write("\nKeyboardInterrupt\n")
1465 self.resetbuffer()
1465 self.resetbuffer()
1466 more = 0
1466 more = 0
1467 # keep cache in sync with the prompt counter:
1467 # keep cache in sync with the prompt counter:
1468 self.outputcache.prompt_count -= 1
1468 self.outputcache.prompt_count -= 1
1469
1469
1470 if self.autoindent:
1470 if self.autoindent:
1471 self.indent_current_nsp = 0
1471 self.indent_current_nsp = 0
1472 self.indent_current = ' '* self.indent_current_nsp
1473
1472
1474 except bdb.BdbQuit:
1473 except bdb.BdbQuit:
1475 warn("The Python debugger has exited with a BdbQuit exception.\n"
1474 warn("The Python debugger has exited with a BdbQuit exception.\n"
1476 "Because of how pdb handles the stack, it is impossible\n"
1475 "Because of how pdb handles the stack, it is impossible\n"
1477 "for IPython to properly format this particular exception.\n"
1476 "for IPython to properly format this particular exception.\n"
1478 "IPython will resume normal operation.")
1477 "IPython will resume normal operation.")
1479
1478
1480 # We are off again...
1479 # We are off again...
1481 __builtin__.__dict__['__IPYTHON__active'] -= 1
1480 __builtin__.__dict__['__IPYTHON__active'] -= 1
1482
1481
1483 def excepthook(self, type, value, tb):
1482 def excepthook(self, type, value, tb):
1484 """One more defense for GUI apps that call sys.excepthook.
1483 """One more defense for GUI apps that call sys.excepthook.
1485
1484
1486 GUI frameworks like wxPython trap exceptions and call
1485 GUI frameworks like wxPython trap exceptions and call
1487 sys.excepthook themselves. I guess this is a feature that
1486 sys.excepthook themselves. I guess this is a feature that
1488 enables them to keep running after exceptions that would
1487 enables them to keep running after exceptions that would
1489 otherwise kill their mainloop. This is a bother for IPython
1488 otherwise kill their mainloop. This is a bother for IPython
1490 which excepts to catch all of the program exceptions with a try:
1489 which excepts to catch all of the program exceptions with a try:
1491 except: statement.
1490 except: statement.
1492
1491
1493 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1492 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1494 any app directly invokes sys.excepthook, it will look to the user like
1493 any app directly invokes sys.excepthook, it will look to the user like
1495 IPython crashed. In order to work around this, we can disable the
1494 IPython crashed. In order to work around this, we can disable the
1496 CrashHandler and replace it with this excepthook instead, which prints a
1495 CrashHandler and replace it with this excepthook instead, which prints a
1497 regular traceback using our InteractiveTB. In this fashion, apps which
1496 regular traceback using our InteractiveTB. In this fashion, apps which
1498 call sys.excepthook will generate a regular-looking exception from
1497 call sys.excepthook will generate a regular-looking exception from
1499 IPython, and the CrashHandler will only be triggered by real IPython
1498 IPython, and the CrashHandler will only be triggered by real IPython
1500 crashes.
1499 crashes.
1501
1500
1502 This hook should be used sparingly, only in places which are not likely
1501 This hook should be used sparingly, only in places which are not likely
1503 to be true IPython errors.
1502 to be true IPython errors.
1504 """
1503 """
1505
1504
1506 self.InteractiveTB(type, value, tb, tb_offset=0)
1505 self.InteractiveTB(type, value, tb, tb_offset=0)
1507 if self.InteractiveTB.call_pdb and self.has_readline:
1506 if self.InteractiveTB.call_pdb and self.has_readline:
1508 self.readline.set_completer(self.Completer.complete)
1507 self.readline.set_completer(self.Completer.complete)
1509
1508
1510 def call_alias(self,alias,rest=''):
1509 def call_alias(self,alias,rest=''):
1511 """Call an alias given its name and the rest of the line.
1510 """Call an alias given its name and the rest of the line.
1512
1511
1513 This function MUST be given a proper alias, because it doesn't make
1512 This function MUST be given a proper alias, because it doesn't make
1514 any checks when looking up into the alias table. The caller is
1513 any checks when looking up into the alias table. The caller is
1515 responsible for invoking it only with a valid alias."""
1514 responsible for invoking it only with a valid alias."""
1516
1515
1517 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1516 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1518 nargs,cmd = self.alias_table[alias]
1517 nargs,cmd = self.alias_table[alias]
1519 # Expand the %l special to be the user's input line
1518 # Expand the %l special to be the user's input line
1520 if cmd.find('%l') >= 0:
1519 if cmd.find('%l') >= 0:
1521 cmd = cmd.replace('%l',rest)
1520 cmd = cmd.replace('%l',rest)
1522 rest = ''
1521 rest = ''
1523 if nargs==0:
1522 if nargs==0:
1524 # Simple, argument-less aliases
1523 # Simple, argument-less aliases
1525 cmd = '%s %s' % (cmd,rest)
1524 cmd = '%s %s' % (cmd,rest)
1526 else:
1525 else:
1527 # Handle aliases with positional arguments
1526 # Handle aliases with positional arguments
1528 args = rest.split(None,nargs)
1527 args = rest.split(None,nargs)
1529 if len(args)< nargs:
1528 if len(args)< nargs:
1530 error('Alias <%s> requires %s arguments, %s given.' %
1529 error('Alias <%s> requires %s arguments, %s given.' %
1531 (alias,nargs,len(args)))
1530 (alias,nargs,len(args)))
1532 return
1531 return
1533 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1532 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1534 # Now call the macro, evaluating in the user's namespace
1533 # Now call the macro, evaluating in the user's namespace
1535 try:
1534 try:
1536 self.system(cmd)
1535 self.system(cmd)
1537 except:
1536 except:
1538 self.showtraceback()
1537 self.showtraceback()
1539
1538
1539 def indent_current_str(self):
1540 """return the current level of indentation as a string"""
1541 return self.indent_current_nsp * ' '
1542
1540 def autoindent_update(self,line):
1543 def autoindent_update(self,line):
1541 """Keep track of the indent level."""
1544 """Keep track of the indent level."""
1542
1545
1546 debugp('line','autoindent_update:')
1547 debugp('self.indent_current_nsp')
1543 if self.autoindent:
1548 if self.autoindent:
1544 if line:
1549 if line:
1545 self.indent_current_nsp = num_ini_spaces(line)
1550 inisp = num_ini_spaces(line)
1551 if inisp < self.indent_current_nsp:
1552 self.indent_current_nsp = inisp
1546
1553
1547 if line[-1] == ':':
1554 if line[-1] == ':':
1548 self.indent_current_nsp += 4
1555 self.indent_current_nsp += 4
1549 elif dedent_re.match(line):
1556 elif dedent_re.match(line):
1550 self.indent_current_nsp -= 4
1557 self.indent_current_nsp -= 4
1551 else:
1558 else:
1552 self.indent_current_nsp = 0
1559 self.indent_current_nsp = 0
1553
1560
1554 # indent_current is the actual string to be inserted
1555 # by the readline hooks for indentation
1556 self.indent_current = ' '* self.indent_current_nsp
1557
1558 def runlines(self,lines):
1561 def runlines(self,lines):
1559 """Run a string of one or more lines of source.
1562 """Run a string of one or more lines of source.
1560
1563
1561 This method is capable of running a string containing multiple source
1564 This method is capable of running a string containing multiple source
1562 lines, as if they had been entered at the IPython prompt. Since it
1565 lines, as if they had been entered at the IPython prompt. Since it
1563 exposes IPython's processing machinery, the given strings can contain
1566 exposes IPython's processing machinery, the given strings can contain
1564 magic calls (%magic), special shell access (!cmd), etc."""
1567 magic calls (%magic), special shell access (!cmd), etc."""
1565
1568
1566 # We must start with a clean buffer, in case this is run from an
1569 # We must start with a clean buffer, in case this is run from an
1567 # interactive IPython session (via a magic, for example).
1570 # interactive IPython session (via a magic, for example).
1568 self.resetbuffer()
1571 self.resetbuffer()
1569 lines = lines.split('\n')
1572 lines = lines.split('\n')
1570 more = 0
1573 more = 0
1571 for line in lines:
1574 for line in lines:
1572 # skip blank lines so we don't mess up the prompt counter, but do
1575 # skip blank lines so we don't mess up the prompt counter, but do
1573 # NOT skip even a blank line if we are in a code block (more is
1576 # NOT skip even a blank line if we are in a code block (more is
1574 # true)
1577 # true)
1575 if line or more:
1578 if line or more:
1576 more = self.push(self.prefilter(line,more))
1579 more = self.push(self.prefilter(line,more))
1577 # IPython's runsource returns None if there was an error
1580 # IPython's runsource returns None if there was an error
1578 # compiling the code. This allows us to stop processing right
1581 # compiling the code. This allows us to stop processing right
1579 # away, so the user gets the error message at the right place.
1582 # away, so the user gets the error message at the right place.
1580 if more is None:
1583 if more is None:
1581 break
1584 break
1582 # final newline in case the input didn't have it, so that the code
1585 # final newline in case the input didn't have it, so that the code
1583 # actually does get executed
1586 # actually does get executed
1584 if more:
1587 if more:
1585 self.push('\n')
1588 self.push('\n')
1586
1589
1587 def runsource(self, source, filename='<input>', symbol='single'):
1590 def runsource(self, source, filename='<input>', symbol='single'):
1588 """Compile and run some source in the interpreter.
1591 """Compile and run some source in the interpreter.
1589
1592
1590 Arguments are as for compile_command().
1593 Arguments are as for compile_command().
1591
1594
1592 One several things can happen:
1595 One several things can happen:
1593
1596
1594 1) The input is incorrect; compile_command() raised an
1597 1) The input is incorrect; compile_command() raised an
1595 exception (SyntaxError or OverflowError). A syntax traceback
1598 exception (SyntaxError or OverflowError). A syntax traceback
1596 will be printed by calling the showsyntaxerror() method.
1599 will be printed by calling the showsyntaxerror() method.
1597
1600
1598 2) The input is incomplete, and more input is required;
1601 2) The input is incomplete, and more input is required;
1599 compile_command() returned None. Nothing happens.
1602 compile_command() returned None. Nothing happens.
1600
1603
1601 3) The input is complete; compile_command() returned a code
1604 3) The input is complete; compile_command() returned a code
1602 object. The code is executed by calling self.runcode() (which
1605 object. The code is executed by calling self.runcode() (which
1603 also handles run-time exceptions, except for SystemExit).
1606 also handles run-time exceptions, except for SystemExit).
1604
1607
1605 The return value is:
1608 The return value is:
1606
1609
1607 - True in case 2
1610 - True in case 2
1608
1611
1609 - False in the other cases, unless an exception is raised, where
1612 - False in the other cases, unless an exception is raised, where
1610 None is returned instead. This can be used by external callers to
1613 None is returned instead. This can be used by external callers to
1611 know whether to continue feeding input or not.
1614 know whether to continue feeding input or not.
1612
1615
1613 The return value can be used to decide whether to use sys.ps1 or
1616 The return value can be used to decide whether to use sys.ps1 or
1614 sys.ps2 to prompt the next line."""
1617 sys.ps2 to prompt the next line."""
1615
1618
1616 try:
1619 try:
1617 code = self.compile(source,filename,symbol)
1620 code = self.compile(source,filename,symbol)
1618 except (OverflowError, SyntaxError, ValueError):
1621 except (OverflowError, SyntaxError, ValueError):
1619 # Case 1
1622 # Case 1
1620 self.showsyntaxerror(filename)
1623 self.showsyntaxerror(filename)
1621 return None
1624 return None
1622
1625
1623 if code is None:
1626 if code is None:
1624 # Case 2
1627 # Case 2
1625 return True
1628 return True
1626
1629
1627 # Case 3
1630 # Case 3
1628 # We store the code object so that threaded shells and
1631 # We store the code object so that threaded shells and
1629 # custom exception handlers can access all this info if needed.
1632 # custom exception handlers can access all this info if needed.
1630 # The source corresponding to this can be obtained from the
1633 # The source corresponding to this can be obtained from the
1631 # buffer attribute as '\n'.join(self.buffer).
1634 # buffer attribute as '\n'.join(self.buffer).
1632 self.code_to_run = code
1635 self.code_to_run = code
1633 # now actually execute the code object
1636 # now actually execute the code object
1634 if self.runcode(code) == 0:
1637 if self.runcode(code) == 0:
1635 return False
1638 return False
1636 else:
1639 else:
1637 return None
1640 return None
1638
1641
1639 def runcode(self,code_obj):
1642 def runcode(self,code_obj):
1640 """Execute a code object.
1643 """Execute a code object.
1641
1644
1642 When an exception occurs, self.showtraceback() is called to display a
1645 When an exception occurs, self.showtraceback() is called to display a
1643 traceback.
1646 traceback.
1644
1647
1645 Return value: a flag indicating whether the code to be run completed
1648 Return value: a flag indicating whether the code to be run completed
1646 successfully:
1649 successfully:
1647
1650
1648 - 0: successful execution.
1651 - 0: successful execution.
1649 - 1: an error occurred.
1652 - 1: an error occurred.
1650 """
1653 """
1651
1654
1652 # Set our own excepthook in case the user code tries to call it
1655 # Set our own excepthook in case the user code tries to call it
1653 # directly, so that the IPython crash handler doesn't get triggered
1656 # directly, so that the IPython crash handler doesn't get triggered
1654 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1657 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1655
1658
1656 # we save the original sys.excepthook in the instance, in case config
1659 # we save the original sys.excepthook in the instance, in case config
1657 # code (such as magics) needs access to it.
1660 # code (such as magics) needs access to it.
1658 self.sys_excepthook = old_excepthook
1661 self.sys_excepthook = old_excepthook
1659 outflag = 1 # happens in more places, so it's easier as default
1662 outflag = 1 # happens in more places, so it's easier as default
1660 try:
1663 try:
1661 try:
1664 try:
1662 # Embedded instances require separate global/local namespaces
1665 # Embedded instances require separate global/local namespaces
1663 # so they can see both the surrounding (local) namespace and
1666 # so they can see both the surrounding (local) namespace and
1664 # the module-level globals when called inside another function.
1667 # the module-level globals when called inside another function.
1665 if self.embedded:
1668 if self.embedded:
1666 exec code_obj in self.user_global_ns, self.user_ns
1669 exec code_obj in self.user_global_ns, self.user_ns
1667 # Normal (non-embedded) instances should only have a single
1670 # Normal (non-embedded) instances should only have a single
1668 # namespace for user code execution, otherwise functions won't
1671 # namespace for user code execution, otherwise functions won't
1669 # see interactive top-level globals.
1672 # see interactive top-level globals.
1670 else:
1673 else:
1671 exec code_obj in self.user_ns
1674 exec code_obj in self.user_ns
1672 finally:
1675 finally:
1673 # Reset our crash handler in place
1676 # Reset our crash handler in place
1674 sys.excepthook = old_excepthook
1677 sys.excepthook = old_excepthook
1675 except SystemExit:
1678 except SystemExit:
1676 self.resetbuffer()
1679 self.resetbuffer()
1677 self.showtraceback()
1680 self.showtraceback()
1678 warn("Type exit or quit to exit IPython "
1681 warn("Type exit or quit to exit IPython "
1679 "(%Exit or %Quit do so unconditionally).",level=1)
1682 "(%Exit or %Quit do so unconditionally).",level=1)
1680 except self.custom_exceptions:
1683 except self.custom_exceptions:
1681 etype,value,tb = sys.exc_info()
1684 etype,value,tb = sys.exc_info()
1682 self.CustomTB(etype,value,tb)
1685 self.CustomTB(etype,value,tb)
1683 except:
1686 except:
1684 self.showtraceback()
1687 self.showtraceback()
1685 else:
1688 else:
1686 outflag = 0
1689 outflag = 0
1687 if softspace(sys.stdout, 0):
1690 if softspace(sys.stdout, 0):
1688 print
1691 print
1689 # Flush out code object which has been run (and source)
1692 # Flush out code object which has been run (and source)
1690 self.code_to_run = None
1693 self.code_to_run = None
1691 return outflag
1694 return outflag
1692
1695
1693 def push(self, line):
1696 def push(self, line):
1694 """Push a line to the interpreter.
1697 """Push a line to the interpreter.
1695
1698
1696 The line should not have a trailing newline; it may have
1699 The line should not have a trailing newline; it may have
1697 internal newlines. The line is appended to a buffer and the
1700 internal newlines. The line is appended to a buffer and the
1698 interpreter's runsource() method is called with the
1701 interpreter's runsource() method is called with the
1699 concatenated contents of the buffer as source. If this
1702 concatenated contents of the buffer as source. If this
1700 indicates that the command was executed or invalid, the buffer
1703 indicates that the command was executed or invalid, the buffer
1701 is reset; otherwise, the command is incomplete, and the buffer
1704 is reset; otherwise, the command is incomplete, and the buffer
1702 is left as it was after the line was appended. The return
1705 is left as it was after the line was appended. The return
1703 value is 1 if more input is required, 0 if the line was dealt
1706 value is 1 if more input is required, 0 if the line was dealt
1704 with in some way (this is the same as runsource()).
1707 with in some way (this is the same as runsource()).
1705 """
1708 """
1706
1709
1707 # autoindent management should be done here, and not in the
1710 # autoindent management should be done here, and not in the
1708 # interactive loop, since that one is only seen by keyboard input. We
1711 # interactive loop, since that one is only seen by keyboard input. We
1709 # need this done correctly even for code run via runlines (which uses
1712 # need this done correctly even for code run via runlines (which uses
1710 # push).
1713 # push).
1711
1714
1712 #print 'push line: <%s>' % line # dbg
1715 #print 'push line: <%s>' % line # dbg
1713 self.autoindent_update(line)
1716 self.autoindent_update(line)
1714
1717
1715 self.buffer.append(line)
1718 self.buffer.append(line)
1716 more = self.runsource('\n'.join(self.buffer), self.filename)
1719 more = self.runsource('\n'.join(self.buffer), self.filename)
1717 if not more:
1720 if not more:
1718 self.resetbuffer()
1721 self.resetbuffer()
1719 return more
1722 return more
1720
1723
1721 def resetbuffer(self):
1724 def resetbuffer(self):
1722 """Reset the input buffer."""
1725 """Reset the input buffer."""
1723 self.buffer[:] = []
1726 self.buffer[:] = []
1724
1727
1725 def raw_input(self,prompt='',continue_prompt=False):
1728 def raw_input(self,prompt='',continue_prompt=False):
1726 """Write a prompt and read a line.
1729 """Write a prompt and read a line.
1727
1730
1728 The returned line does not include the trailing newline.
1731 The returned line does not include the trailing newline.
1729 When the user enters the EOF key sequence, EOFError is raised.
1732 When the user enters the EOF key sequence, EOFError is raised.
1730
1733
1731 Optional inputs:
1734 Optional inputs:
1732
1735
1733 - prompt(''): a string to be printed to prompt the user.
1736 - prompt(''): a string to be printed to prompt the user.
1734
1737
1735 - continue_prompt(False): whether this line is the first one or a
1738 - continue_prompt(False): whether this line is the first one or a
1736 continuation in a sequence of inputs.
1739 continuation in a sequence of inputs.
1737 """
1740 """
1738
1741
1739 line = raw_input_original(prompt)
1742 line = raw_input_original(prompt)
1740 # Try to be reasonably smart about not re-indenting pasted input more
1743 # Try to be reasonably smart about not re-indenting pasted input more
1741 # than necessary. We do this by trimming out the auto-indent initial
1744 # than necessary. We do this by trimming out the auto-indent initial
1742 # spaces, if the user's actual input started itself with whitespace.
1745 # spaces, if the user's actual input started itself with whitespace.
1743 #debugp('self.buffer[-1]')
1746 #debugp('self.buffer[-1]')
1744 ## if self.autoindent:
1747
1745 ## try:
1748 debugp('line')
1746 ## prev_line = self.buffer[-1]
1749 debugp('self.indent_current_nsp')
1747 ## except IndexError:
1750 if self.autoindent:
1748 ## prev_line = ''
1751 if num_ini_spaces(line) > self.indent_current_nsp:
1749 ## prev_indent = num_ini_spaces(prev_line)
1752 line = line[self.indent_current_nsp:]
1750 ## debugp('prev_indent')
1753 self.indent_current_nsp = 0
1751 ## # Split the user's input
1754 debugp('self.indent_current_nsp')
1752 ## line1 = line[:self.indent_current_nsp]
1755
1753 ## line2 = line[self.indent_current_nsp:]
1756 debugp('line')
1754 ## if line1.isspace() and line2 and \
1755 ## num_ini_spaces(line2)==prev_indent:
1756 ## line = line2
1757 #debugp('line')
1758 #debugp('line1')
1759 #debugp('line2')
1760 ## if line1.isspace() and line2 and line2[0:1] in (' ','\t'):
1761 ## line = line2
1762 ## debugp('line')
1763 return self.prefilter(line,continue_prompt)
1757 return self.prefilter(line,continue_prompt)
1764
1758
1765 def split_user_input(self,line):
1759 def split_user_input(self,line):
1766 """Split user input into pre-char, function part and rest."""
1760 """Split user input into pre-char, function part and rest."""
1767
1761
1768 lsplit = self.line_split.match(line)
1762 lsplit = self.line_split.match(line)
1769 if lsplit is None: # no regexp match returns None
1763 if lsplit is None: # no regexp match returns None
1770 try:
1764 try:
1771 iFun,theRest = line.split(None,1)
1765 iFun,theRest = line.split(None,1)
1772 except ValueError:
1766 except ValueError:
1773 iFun,theRest = line,''
1767 iFun,theRest = line,''
1774 pre = re.match('^(\s*)(.*)',line).groups()[0]
1768 pre = re.match('^(\s*)(.*)',line).groups()[0]
1775 else:
1769 else:
1776 pre,iFun,theRest = lsplit.groups()
1770 pre,iFun,theRest = lsplit.groups()
1777
1771
1778 #print 'line:<%s>' % line # dbg
1772 #print 'line:<%s>' % line # dbg
1779 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1773 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1780 return pre,iFun.strip(),theRest
1774 return pre,iFun.strip(),theRest
1781
1775
1782 def _prefilter(self, line, continue_prompt):
1776 def _prefilter(self, line, continue_prompt):
1783 """Calls different preprocessors, depending on the form of line."""
1777 """Calls different preprocessors, depending on the form of line."""
1784
1778
1785 # All handlers *must* return a value, even if it's blank ('').
1779 # All handlers *must* return a value, even if it's blank ('').
1786
1780
1787 # Lines are NOT logged here. Handlers should process the line as
1781 # Lines are NOT logged here. Handlers should process the line as
1788 # needed, update the cache AND log it (so that the input cache array
1782 # needed, update the cache AND log it (so that the input cache array
1789 # stays synced).
1783 # stays synced).
1790
1784
1791 # This function is _very_ delicate, and since it's also the one which
1785 # This function is _very_ delicate, and since it's also the one which
1792 # determines IPython's response to user input, it must be as efficient
1786 # determines IPython's response to user input, it must be as efficient
1793 # as possible. For this reason it has _many_ returns in it, trying
1787 # as possible. For this reason it has _many_ returns in it, trying
1794 # always to exit as quickly as it can figure out what it needs to do.
1788 # always to exit as quickly as it can figure out what it needs to do.
1795
1789
1796 # This function is the main responsible for maintaining IPython's
1790 # This function is the main responsible for maintaining IPython's
1797 # behavior respectful of Python's semantics. So be _very_ careful if
1791 # behavior respectful of Python's semantics. So be _very_ careful if
1798 # making changes to anything here.
1792 # making changes to anything here.
1799
1793
1800 #.....................................................................
1794 #.....................................................................
1801 # Code begins
1795 # Code begins
1802
1796
1803 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1797 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1804
1798
1805 # save the line away in case we crash, so the post-mortem handler can
1799 # save the line away in case we crash, so the post-mortem handler can
1806 # record it
1800 # record it
1807 self._last_input_line = line
1801 self._last_input_line = line
1808
1802
1809 #print '***line: <%s>' % line # dbg
1803 #print '***line: <%s>' % line # dbg
1810
1804
1811 # the input history needs to track even empty lines
1805 # the input history needs to track even empty lines
1812 if not line.strip():
1806 if not line.strip():
1813 if not continue_prompt:
1807 if not continue_prompt:
1814 self.outputcache.prompt_count -= 1
1808 self.outputcache.prompt_count -= 1
1815 return self.handle_normal(line,continue_prompt)
1809 return self.handle_normal(line,continue_prompt)
1816 #return self.handle_normal('',continue_prompt)
1810 #return self.handle_normal('',continue_prompt)
1817
1811
1818 # print '***cont',continue_prompt # dbg
1812 # print '***cont',continue_prompt # dbg
1819 # special handlers are only allowed for single line statements
1813 # special handlers are only allowed for single line statements
1820 if continue_prompt and not self.rc.multi_line_specials:
1814 if continue_prompt and not self.rc.multi_line_specials:
1821 return self.handle_normal(line,continue_prompt)
1815 return self.handle_normal(line,continue_prompt)
1822
1816
1823 # For the rest, we need the structure of the input
1817 # For the rest, we need the structure of the input
1824 pre,iFun,theRest = self.split_user_input(line)
1818 pre,iFun,theRest = self.split_user_input(line)
1825 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1819 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1826
1820
1827 # First check for explicit escapes in the last/first character
1821 # First check for explicit escapes in the last/first character
1828 handler = None
1822 handler = None
1829 if line[-1] == self.ESC_HELP:
1823 if line[-1] == self.ESC_HELP:
1830 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1824 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1831 if handler is None:
1825 if handler is None:
1832 # look at the first character of iFun, NOT of line, so we skip
1826 # look at the first character of iFun, NOT of line, so we skip
1833 # leading whitespace in multiline input
1827 # leading whitespace in multiline input
1834 handler = self.esc_handlers.get(iFun[0:1])
1828 handler = self.esc_handlers.get(iFun[0:1])
1835 if handler is not None:
1829 if handler is not None:
1836 return handler(line,continue_prompt,pre,iFun,theRest)
1830 return handler(line,continue_prompt,pre,iFun,theRest)
1837 # Emacs ipython-mode tags certain input lines
1831 # Emacs ipython-mode tags certain input lines
1838 if line.endswith('# PYTHON-MODE'):
1832 if line.endswith('# PYTHON-MODE'):
1839 return self.handle_emacs(line,continue_prompt)
1833 return self.handle_emacs(line,continue_prompt)
1840
1834
1841 # Next, check if we can automatically execute this thing
1835 # Next, check if we can automatically execute this thing
1842
1836
1843 # Allow ! in multi-line statements if multi_line_specials is on:
1837 # Allow ! in multi-line statements if multi_line_specials is on:
1844 if continue_prompt and self.rc.multi_line_specials and \
1838 if continue_prompt and self.rc.multi_line_specials and \
1845 iFun.startswith(self.ESC_SHELL):
1839 iFun.startswith(self.ESC_SHELL):
1846 return self.handle_shell_escape(line,continue_prompt,
1840 return self.handle_shell_escape(line,continue_prompt,
1847 pre=pre,iFun=iFun,
1841 pre=pre,iFun=iFun,
1848 theRest=theRest)
1842 theRest=theRest)
1849
1843
1850 # Let's try to find if the input line is a magic fn
1844 # Let's try to find if the input line is a magic fn
1851 oinfo = None
1845 oinfo = None
1852 if hasattr(self,'magic_'+iFun):
1846 if hasattr(self,'magic_'+iFun):
1853 # WARNING: _ofind uses getattr(), so it can consume generators and
1847 # WARNING: _ofind uses getattr(), so it can consume generators and
1854 # cause other side effects.
1848 # cause other side effects.
1855 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1849 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1856 if oinfo['ismagic']:
1850 if oinfo['ismagic']:
1857 # Be careful not to call magics when a variable assignment is
1851 # Be careful not to call magics when a variable assignment is
1858 # being made (ls='hi', for example)
1852 # being made (ls='hi', for example)
1859 if self.rc.automagic and \
1853 if self.rc.automagic and \
1860 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1854 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1861 (self.rc.multi_line_specials or not continue_prompt):
1855 (self.rc.multi_line_specials or not continue_prompt):
1862 return self.handle_magic(line,continue_prompt,
1856 return self.handle_magic(line,continue_prompt,
1863 pre,iFun,theRest)
1857 pre,iFun,theRest)
1864 else:
1858 else:
1865 return self.handle_normal(line,continue_prompt)
1859 return self.handle_normal(line,continue_prompt)
1866
1860
1867 # If the rest of the line begins with an (in)equality, assginment or
1861 # If the rest of the line begins with an (in)equality, assginment or
1868 # function call, we should not call _ofind but simply execute it.
1862 # function call, we should not call _ofind but simply execute it.
1869 # This avoids spurious geattr() accesses on objects upon assignment.
1863 # This avoids spurious geattr() accesses on objects upon assignment.
1870 #
1864 #
1871 # It also allows users to assign to either alias or magic names true
1865 # It also allows users to assign to either alias or magic names true
1872 # python variables (the magic/alias systems always take second seat to
1866 # python variables (the magic/alias systems always take second seat to
1873 # true python code).
1867 # true python code).
1874 if theRest and theRest[0] in '!=()':
1868 if theRest and theRest[0] in '!=()':
1875 return self.handle_normal(line,continue_prompt)
1869 return self.handle_normal(line,continue_prompt)
1876
1870
1877 if oinfo is None:
1871 if oinfo is None:
1878 # let's try to ensure that _oinfo is ONLY called when autocall is
1872 # let's try to ensure that _oinfo is ONLY called when autocall is
1879 # on. Since it has inevitable potential side effects, at least
1873 # on. Since it has inevitable potential side effects, at least
1880 # having autocall off should be a guarantee to the user that no
1874 # having autocall off should be a guarantee to the user that no
1881 # weird things will happen.
1875 # weird things will happen.
1882
1876
1883 if self.rc.autocall:
1877 if self.rc.autocall:
1884 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1878 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1885 else:
1879 else:
1886 # in this case, all that's left is either an alias or
1880 # in this case, all that's left is either an alias or
1887 # processing the line normally.
1881 # processing the line normally.
1888 if iFun in self.alias_table:
1882 if iFun in self.alias_table:
1889 return self.handle_alias(line,continue_prompt,
1883 return self.handle_alias(line,continue_prompt,
1890 pre,iFun,theRest)
1884 pre,iFun,theRest)
1891
1885
1892 else:
1886 else:
1893 return self.handle_normal(line,continue_prompt)
1887 return self.handle_normal(line,continue_prompt)
1894
1888
1895 if not oinfo['found']:
1889 if not oinfo['found']:
1896 return self.handle_normal(line,continue_prompt)
1890 return self.handle_normal(line,continue_prompt)
1897 else:
1891 else:
1898 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1892 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1899 if oinfo['isalias']:
1893 if oinfo['isalias']:
1900 return self.handle_alias(line,continue_prompt,
1894 return self.handle_alias(line,continue_prompt,
1901 pre,iFun,theRest)
1895 pre,iFun,theRest)
1902
1896
1903 if (self.rc.autocall
1897 if (self.rc.autocall
1904 and
1898 and
1905 (
1899 (
1906 #only consider exclusion re if not "," or ";" autoquoting
1900 #only consider exclusion re if not "," or ";" autoquoting
1907 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2) or
1901 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2) or
1908 (not self.re_exclude_auto.match(theRest)))
1902 (not self.re_exclude_auto.match(theRest)))
1909 and
1903 and
1910 self.re_fun_name.match(iFun) and
1904 self.re_fun_name.match(iFun) and
1911 callable(oinfo['obj'])) :
1905 callable(oinfo['obj'])) :
1912 #print 'going auto' # dbg
1906 #print 'going auto' # dbg
1913 return self.handle_auto(line,continue_prompt,
1907 return self.handle_auto(line,continue_prompt,
1914 pre,iFun,theRest,oinfo['obj'])
1908 pre,iFun,theRest,oinfo['obj'])
1915 else:
1909 else:
1916 #print 'was callable?', callable(oinfo['obj']) # dbg
1910 #print 'was callable?', callable(oinfo['obj']) # dbg
1917 return self.handle_normal(line,continue_prompt)
1911 return self.handle_normal(line,continue_prompt)
1918
1912
1919 # If we get here, we have a normal Python line. Log and return.
1913 # If we get here, we have a normal Python line. Log and return.
1920 return self.handle_normal(line,continue_prompt)
1914 return self.handle_normal(line,continue_prompt)
1921
1915
1922 def _prefilter_dumb(self, line, continue_prompt):
1916 def _prefilter_dumb(self, line, continue_prompt):
1923 """simple prefilter function, for debugging"""
1917 """simple prefilter function, for debugging"""
1924 return self.handle_normal(line,continue_prompt)
1918 return self.handle_normal(line,continue_prompt)
1925
1919
1926 # Set the default prefilter() function (this can be user-overridden)
1920 # Set the default prefilter() function (this can be user-overridden)
1927 prefilter = _prefilter
1921 prefilter = _prefilter
1928
1922
1929 def handle_normal(self,line,continue_prompt=None,
1923 def handle_normal(self,line,continue_prompt=None,
1930 pre=None,iFun=None,theRest=None):
1924 pre=None,iFun=None,theRest=None):
1931 """Handle normal input lines. Use as a template for handlers."""
1925 """Handle normal input lines. Use as a template for handlers."""
1932
1926
1933 # With autoindent on, we need some way to exit the input loop, and I
1927 # With autoindent on, we need some way to exit the input loop, and I
1934 # don't want to force the user to have to backspace all the way to
1928 # don't want to force the user to have to backspace all the way to
1935 # clear the line. The rule will be in this case, that either two
1929 # clear the line. The rule will be in this case, that either two
1936 # lines of pure whitespace in a row, or a line of pure whitespace but
1930 # lines of pure whitespace in a row, or a line of pure whitespace but
1937 # of a size different to the indent level, will exit the input loop.
1931 # of a size different to the indent level, will exit the input loop.
1938
1932
1939 if (continue_prompt and self.autoindent and line.isspace() and
1933 if (continue_prompt and self.autoindent and line.isspace() and
1940 (line != self.indent_current or (self.buffer[-1]).isspace() )):
1934 (line != self.indent_current_str() or
1935 (self.buffer[-1]).isspace() )):
1941 line = ''
1936 line = ''
1942
1937
1943 self.log(line,continue_prompt)
1938 self.log(line,continue_prompt)
1944 return line
1939 return line
1945
1940
1946 def handle_alias(self,line,continue_prompt=None,
1941 def handle_alias(self,line,continue_prompt=None,
1947 pre=None,iFun=None,theRest=None):
1942 pre=None,iFun=None,theRest=None):
1948 """Handle alias input lines. """
1943 """Handle alias input lines. """
1949
1944
1950 # pre is needed, because it carries the leading whitespace. Otherwise
1945 # pre is needed, because it carries the leading whitespace. Otherwise
1951 # aliases won't work in indented sections.
1946 # aliases won't work in indented sections.
1952 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1947 line_out = '%sipalias(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1953 self.log(line_out,continue_prompt)
1948 self.log(line_out,continue_prompt)
1954 return line_out
1949 return line_out
1955
1950
1956 def handle_shell_escape(self, line, continue_prompt=None,
1951 def handle_shell_escape(self, line, continue_prompt=None,
1957 pre=None,iFun=None,theRest=None):
1952 pre=None,iFun=None,theRest=None):
1958 """Execute the line in a shell, empty return value"""
1953 """Execute the line in a shell, empty return value"""
1959
1954
1960 #print 'line in :', `line` # dbg
1955 #print 'line in :', `line` # dbg
1961 # Example of a special handler. Others follow a similar pattern.
1956 # Example of a special handler. Others follow a similar pattern.
1962 if line.lstrip().startswith('!!'):
1957 if line.lstrip().startswith('!!'):
1963 # rewrite iFun/theRest to properly hold the call to %sx and
1958 # rewrite iFun/theRest to properly hold the call to %sx and
1964 # the actual command to be executed, so handle_magic can work
1959 # the actual command to be executed, so handle_magic can work
1965 # correctly
1960 # correctly
1966 theRest = '%s %s' % (iFun[2:],theRest)
1961 theRest = '%s %s' % (iFun[2:],theRest)
1967 iFun = 'sx'
1962 iFun = 'sx'
1968 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1963 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
1969 line.lstrip()[2:]),
1964 line.lstrip()[2:]),
1970 continue_prompt,pre,iFun,theRest)
1965 continue_prompt,pre,iFun,theRest)
1971 else:
1966 else:
1972 cmd=line.lstrip().lstrip('!')
1967 cmd=line.lstrip().lstrip('!')
1973 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1968 line_out = '%sipsystem(%s)' % (pre,make_quoted_expr(cmd))
1974 # update cache/log and return
1969 # update cache/log and return
1975 self.log(line_out,continue_prompt)
1970 self.log(line_out,continue_prompt)
1976 return line_out
1971 return line_out
1977
1972
1978 def handle_magic(self, line, continue_prompt=None,
1973 def handle_magic(self, line, continue_prompt=None,
1979 pre=None,iFun=None,theRest=None):
1974 pre=None,iFun=None,theRest=None):
1980 """Execute magic functions."""
1975 """Execute magic functions."""
1981
1976
1982
1977
1983 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1978 cmd = '%sipmagic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
1984 self.log(cmd,continue_prompt)
1979 self.log(cmd,continue_prompt)
1985 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1980 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1986 return cmd
1981 return cmd
1987
1982
1988 def handle_auto(self, line, continue_prompt=None,
1983 def handle_auto(self, line, continue_prompt=None,
1989 pre=None,iFun=None,theRest=None,obj=None):
1984 pre=None,iFun=None,theRest=None,obj=None):
1990 """Hande lines which can be auto-executed, quoting if requested."""
1985 """Hande lines which can be auto-executed, quoting if requested."""
1991
1986
1992 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1987 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1993
1988
1994 # This should only be active for single-line input!
1989 # This should only be active for single-line input!
1995 if continue_prompt:
1990 if continue_prompt:
1996 self.log(line,continue_prompt)
1991 self.log(line,continue_prompt)
1997 return line
1992 return line
1998
1993
1999 auto_rewrite = True
1994 auto_rewrite = True
2000 if pre == self.ESC_QUOTE:
1995 if pre == self.ESC_QUOTE:
2001 # Auto-quote splitting on whitespace
1996 # Auto-quote splitting on whitespace
2002 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1997 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2003 elif pre == self.ESC_QUOTE2:
1998 elif pre == self.ESC_QUOTE2:
2004 # Auto-quote whole string
1999 # Auto-quote whole string
2005 newcmd = '%s("%s")' % (iFun,theRest)
2000 newcmd = '%s("%s")' % (iFun,theRest)
2006 else:
2001 else:
2007 # Auto-paren.
2002 # Auto-paren.
2008 # We only apply it to argument-less calls if the autocall
2003 # We only apply it to argument-less calls if the autocall
2009 # parameter is set to 2. We only need to check that autocall is <
2004 # parameter is set to 2. We only need to check that autocall is <
2010 # 2, since this function isn't called unless it's at least 1.
2005 # 2, since this function isn't called unless it's at least 1.
2011 if not theRest and (self.rc.autocall < 2):
2006 if not theRest and (self.rc.autocall < 2):
2012 newcmd = '%s %s' % (iFun,theRest)
2007 newcmd = '%s %s' % (iFun,theRest)
2013 auto_rewrite = False
2008 auto_rewrite = False
2014 else:
2009 else:
2015 if theRest.startswith('['):
2010 if theRest.startswith('['):
2016 if hasattr(obj,'__getitem__'):
2011 if hasattr(obj,'__getitem__'):
2017 # Don't autocall in this case: item access for an object
2012 # Don't autocall in this case: item access for an object
2018 # which is BOTH callable and implements __getitem__.
2013 # which is BOTH callable and implements __getitem__.
2019 newcmd = '%s %s' % (iFun,theRest)
2014 newcmd = '%s %s' % (iFun,theRest)
2020 auto_rewrite = False
2015 auto_rewrite = False
2021 else:
2016 else:
2022 # if the object doesn't support [] access, go ahead and
2017 # if the object doesn't support [] access, go ahead and
2023 # autocall
2018 # autocall
2024 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2019 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2025 elif theRest.endswith(';'):
2020 elif theRest.endswith(';'):
2026 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2021 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2027 else:
2022 else:
2028 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2023 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2029
2024
2030 if auto_rewrite:
2025 if auto_rewrite:
2031 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2026 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2032 # log what is now valid Python, not the actual user input (without the
2027 # log what is now valid Python, not the actual user input (without the
2033 # final newline)
2028 # final newline)
2034 self.log(newcmd,continue_prompt)
2029 self.log(newcmd,continue_prompt)
2035 return newcmd
2030 return newcmd
2036
2031
2037 def handle_help(self, line, continue_prompt=None,
2032 def handle_help(self, line, continue_prompt=None,
2038 pre=None,iFun=None,theRest=None):
2033 pre=None,iFun=None,theRest=None):
2039 """Try to get some help for the object.
2034 """Try to get some help for the object.
2040
2035
2041 obj? or ?obj -> basic information.
2036 obj? or ?obj -> basic information.
2042 obj?? or ??obj -> more details.
2037 obj?? or ??obj -> more details.
2043 """
2038 """
2044
2039
2045 # We need to make sure that we don't process lines which would be
2040 # We need to make sure that we don't process lines which would be
2046 # otherwise valid python, such as "x=1 # what?"
2041 # otherwise valid python, such as "x=1 # what?"
2047 try:
2042 try:
2048 codeop.compile_command(line)
2043 codeop.compile_command(line)
2049 except SyntaxError:
2044 except SyntaxError:
2050 # We should only handle as help stuff which is NOT valid syntax
2045 # We should only handle as help stuff which is NOT valid syntax
2051 if line[0]==self.ESC_HELP:
2046 if line[0]==self.ESC_HELP:
2052 line = line[1:]
2047 line = line[1:]
2053 elif line[-1]==self.ESC_HELP:
2048 elif line[-1]==self.ESC_HELP:
2054 line = line[:-1]
2049 line = line[:-1]
2055 self.log('#?'+line)
2050 self.log('#?'+line)
2056 if line:
2051 if line:
2057 self.magic_pinfo(line)
2052 self.magic_pinfo(line)
2058 else:
2053 else:
2059 page(self.usage,screen_lines=self.rc.screen_length)
2054 page(self.usage,screen_lines=self.rc.screen_length)
2060 return '' # Empty string is needed here!
2055 return '' # Empty string is needed here!
2061 except:
2056 except:
2062 # Pass any other exceptions through to the normal handler
2057 # Pass any other exceptions through to the normal handler
2063 return self.handle_normal(line,continue_prompt)
2058 return self.handle_normal(line,continue_prompt)
2064 else:
2059 else:
2065 # If the code compiles ok, we should handle it normally
2060 # If the code compiles ok, we should handle it normally
2066 return self.handle_normal(line,continue_prompt)
2061 return self.handle_normal(line,continue_prompt)
2067
2062
2068 def handle_emacs(self,line,continue_prompt=None,
2063 def handle_emacs(self,line,continue_prompt=None,
2069 pre=None,iFun=None,theRest=None):
2064 pre=None,iFun=None,theRest=None):
2070 """Handle input lines marked by python-mode."""
2065 """Handle input lines marked by python-mode."""
2071
2066
2072 # Currently, nothing is done. Later more functionality can be added
2067 # Currently, nothing is done. Later more functionality can be added
2073 # here if needed.
2068 # here if needed.
2074
2069
2075 # The input cache shouldn't be updated
2070 # The input cache shouldn't be updated
2076
2071
2077 return line
2072 return line
2078
2073
2079 def mktempfile(self,data=None):
2074 def mktempfile(self,data=None):
2080 """Make a new tempfile and return its filename.
2075 """Make a new tempfile and return its filename.
2081
2076
2082 This makes a call to tempfile.mktemp, but it registers the created
2077 This makes a call to tempfile.mktemp, but it registers the created
2083 filename internally so ipython cleans it up at exit time.
2078 filename internally so ipython cleans it up at exit time.
2084
2079
2085 Optional inputs:
2080 Optional inputs:
2086
2081
2087 - data(None): if data is given, it gets written out to the temp file
2082 - data(None): if data is given, it gets written out to the temp file
2088 immediately, and the file is closed again."""
2083 immediately, and the file is closed again."""
2089
2084
2090 filename = tempfile.mktemp('.py','ipython_edit_')
2085 filename = tempfile.mktemp('.py','ipython_edit_')
2091 self.tempfiles.append(filename)
2086 self.tempfiles.append(filename)
2092
2087
2093 if data:
2088 if data:
2094 tmp_file = open(filename,'w')
2089 tmp_file = open(filename,'w')
2095 tmp_file.write(data)
2090 tmp_file.write(data)
2096 tmp_file.close()
2091 tmp_file.close()
2097 return filename
2092 return filename
2098
2093
2099 def write(self,data):
2094 def write(self,data):
2100 """Write a string to the default output"""
2095 """Write a string to the default output"""
2101 Term.cout.write(data)
2096 Term.cout.write(data)
2102
2097
2103 def write_err(self,data):
2098 def write_err(self,data):
2104 """Write a string to the default error output"""
2099 """Write a string to the default error output"""
2105 Term.cerr.write(data)
2100 Term.cerr.write(data)
2106
2101
2107 def exit(self):
2102 def exit(self):
2108 """Handle interactive exit.
2103 """Handle interactive exit.
2109
2104
2110 This method sets the exit_now attribute."""
2105 This method sets the exit_now attribute."""
2111
2106
2112 if self.rc.confirm_exit:
2107 if self.rc.confirm_exit:
2113 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2108 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2114 self.exit_now = True
2109 self.exit_now = True
2115 else:
2110 else:
2116 self.exit_now = True
2111 self.exit_now = True
2117 return self.exit_now
2112 return self.exit_now
2118
2113
2119 def safe_execfile(self,fname,*where,**kw):
2114 def safe_execfile(self,fname,*where,**kw):
2120 fname = os.path.expanduser(fname)
2115 fname = os.path.expanduser(fname)
2121
2116
2122 # find things also in current directory
2117 # find things also in current directory
2123 dname = os.path.dirname(fname)
2118 dname = os.path.dirname(fname)
2124 if not sys.path.count(dname):
2119 if not sys.path.count(dname):
2125 sys.path.append(dname)
2120 sys.path.append(dname)
2126
2121
2127 try:
2122 try:
2128 xfile = open(fname)
2123 xfile = open(fname)
2129 except:
2124 except:
2130 print >> Term.cerr, \
2125 print >> Term.cerr, \
2131 'Could not open file <%s> for safe execution.' % fname
2126 'Could not open file <%s> for safe execution.' % fname
2132 return None
2127 return None
2133
2128
2134 kw.setdefault('islog',0)
2129 kw.setdefault('islog',0)
2135 kw.setdefault('quiet',1)
2130 kw.setdefault('quiet',1)
2136 kw.setdefault('exit_ignore',0)
2131 kw.setdefault('exit_ignore',0)
2137 first = xfile.readline()
2132 first = xfile.readline()
2138 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2133 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2139 xfile.close()
2134 xfile.close()
2140 # line by line execution
2135 # line by line execution
2141 if first.startswith(loghead) or kw['islog']:
2136 if first.startswith(loghead) or kw['islog']:
2142 print 'Loading log file <%s> one line at a time...' % fname
2137 print 'Loading log file <%s> one line at a time...' % fname
2143 if kw['quiet']:
2138 if kw['quiet']:
2144 stdout_save = sys.stdout
2139 stdout_save = sys.stdout
2145 sys.stdout = StringIO.StringIO()
2140 sys.stdout = StringIO.StringIO()
2146 try:
2141 try:
2147 globs,locs = where[0:2]
2142 globs,locs = where[0:2]
2148 except:
2143 except:
2149 try:
2144 try:
2150 globs = locs = where[0]
2145 globs = locs = where[0]
2151 except:
2146 except:
2152 globs = locs = globals()
2147 globs = locs = globals()
2153 badblocks = []
2148 badblocks = []
2154
2149
2155 # we also need to identify indented blocks of code when replaying
2150 # we also need to identify indented blocks of code when replaying
2156 # logs and put them together before passing them to an exec
2151 # logs and put them together before passing them to an exec
2157 # statement. This takes a bit of regexp and look-ahead work in the
2152 # statement. This takes a bit of regexp and look-ahead work in the
2158 # file. It's easiest if we swallow the whole thing in memory
2153 # file. It's easiest if we swallow the whole thing in memory
2159 # first, and manually walk through the lines list moving the
2154 # first, and manually walk through the lines list moving the
2160 # counter ourselves.
2155 # counter ourselves.
2161 indent_re = re.compile('\s+\S')
2156 indent_re = re.compile('\s+\S')
2162 xfile = open(fname)
2157 xfile = open(fname)
2163 filelines = xfile.readlines()
2158 filelines = xfile.readlines()
2164 xfile.close()
2159 xfile.close()
2165 nlines = len(filelines)
2160 nlines = len(filelines)
2166 lnum = 0
2161 lnum = 0
2167 while lnum < nlines:
2162 while lnum < nlines:
2168 line = filelines[lnum]
2163 line = filelines[lnum]
2169 lnum += 1
2164 lnum += 1
2170 # don't re-insert logger status info into cache
2165 # don't re-insert logger status info into cache
2171 if line.startswith('#log#'):
2166 if line.startswith('#log#'):
2172 continue
2167 continue
2173 else:
2168 else:
2174 # build a block of code (maybe a single line) for execution
2169 # build a block of code (maybe a single line) for execution
2175 block = line
2170 block = line
2176 try:
2171 try:
2177 next = filelines[lnum] # lnum has already incremented
2172 next = filelines[lnum] # lnum has already incremented
2178 except:
2173 except:
2179 next = None
2174 next = None
2180 while next and indent_re.match(next):
2175 while next and indent_re.match(next):
2181 block += next
2176 block += next
2182 lnum += 1
2177 lnum += 1
2183 try:
2178 try:
2184 next = filelines[lnum]
2179 next = filelines[lnum]
2185 except:
2180 except:
2186 next = None
2181 next = None
2187 # now execute the block of one or more lines
2182 # now execute the block of one or more lines
2188 try:
2183 try:
2189 exec block in globs,locs
2184 exec block in globs,locs
2190 except SystemExit:
2185 except SystemExit:
2191 pass
2186 pass
2192 except:
2187 except:
2193 badblocks.append(block.rstrip())
2188 badblocks.append(block.rstrip())
2194 if kw['quiet']: # restore stdout
2189 if kw['quiet']: # restore stdout
2195 sys.stdout.close()
2190 sys.stdout.close()
2196 sys.stdout = stdout_save
2191 sys.stdout = stdout_save
2197 print 'Finished replaying log file <%s>' % fname
2192 print 'Finished replaying log file <%s>' % fname
2198 if badblocks:
2193 if badblocks:
2199 print >> sys.stderr, ('\nThe following lines/blocks in file '
2194 print >> sys.stderr, ('\nThe following lines/blocks in file '
2200 '<%s> reported errors:' % fname)
2195 '<%s> reported errors:' % fname)
2201
2196
2202 for badline in badblocks:
2197 for badline in badblocks:
2203 print >> sys.stderr, badline
2198 print >> sys.stderr, badline
2204 else: # regular file execution
2199 else: # regular file execution
2205 try:
2200 try:
2206 execfile(fname,*where)
2201 execfile(fname,*where)
2207 except SyntaxError:
2202 except SyntaxError:
2208 etype,evalue = sys.exc_info()[:2]
2203 etype,evalue = sys.exc_info()[:2]
2209 self.SyntaxTB(etype,evalue,[])
2204 self.SyntaxTB(etype,evalue,[])
2210 warn('Failure executing file: <%s>' % fname)
2205 warn('Failure executing file: <%s>' % fname)
2211 except SystemExit,status:
2206 except SystemExit,status:
2212 if not kw['exit_ignore']:
2207 if not kw['exit_ignore']:
2213 self.InteractiveTB()
2208 self.InteractiveTB()
2214 warn('Failure executing file: <%s>' % fname)
2209 warn('Failure executing file: <%s>' % fname)
2215 except:
2210 except:
2216 self.InteractiveTB()
2211 self.InteractiveTB()
2217 warn('Failure executing file: <%s>' % fname)
2212 warn('Failure executing file: <%s>' % fname)
2218
2213
2219 #************************* end of file <iplib.py> *****************************
2214 #************************* end of file <iplib.py> *****************************
@@ -1,4953 +1,4965 b''
1 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
4 multiline code with autoindent on working. But I am really not
5 sure, so this needs more testing. Will commit a debug-enabled
6 version for now, while I test it some more, so that Ville and
7 others may also catch any problems. Also made
8 self.indent_current_str() a method, to ensure that there's no
9 chance of the indent space count and the corresponding string
10 falling out of sync. All code needing the string should just call
11 the method.
12
1 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
13 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2
14
3 * IPython/Magic.py (magic_edit): fix check for when users don't
15 * IPython/Magic.py (magic_edit): fix check for when users don't
4 save their output files, the try/except was in the wrong section.
16 save their output files, the try/except was in the wrong section.
5
17
6 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
18 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
7
19
8 * IPython/Magic.py (magic_run): fix __file__ global missing from
20 * IPython/Magic.py (magic_run): fix __file__ global missing from
9 script's namespace when executed via %run. After a report by
21 script's namespace when executed via %run. After a report by
10 Vivian.
22 Vivian.
11
23
12 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
24 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
13 when using python 2.4. The parent constructor changed in 2.4, and
25 when using python 2.4. The parent constructor changed in 2.4, and
14 we need to track it directly (we can't call it, as it messes up
26 we need to track it directly (we can't call it, as it messes up
15 readline and tab-completion inside our pdb would stop working).
27 readline and tab-completion inside our pdb would stop working).
16 After a bug report by R. Bernstein <rocky-AT-panix.com>.
28 After a bug report by R. Bernstein <rocky-AT-panix.com>.
17
29
18 2006-01-16 Ville Vainio <vivainio@gmail.com>
30 2006-01-16 Ville Vainio <vivainio@gmail.com>
19
31
20 * Ipython/magic.py:Reverted back to old %edit functionality
32 * Ipython/magic.py:Reverted back to old %edit functionality
21 that returns file contents on exit.
33 that returns file contents on exit.
22
34
23 * IPython/path.py: Added Jason Orendorff's "path" module to
35 * IPython/path.py: Added Jason Orendorff's "path" module to
24 IPython tree, http://www.jorendorff.com/articles/python/path/.
36 IPython tree, http://www.jorendorff.com/articles/python/path/.
25 You can get path objects conveniently through %sc, and !!, e.g.:
37 You can get path objects conveniently through %sc, and !!, e.g.:
26 sc files=ls
38 sc files=ls
27 for p in files.paths: # or files.p
39 for p in files.paths: # or files.p
28 print p,p.mtime
40 print p,p.mtime
29
41
30 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
42 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
31 now work again without considering the exclusion regexp -
43 now work again without considering the exclusion regexp -
32 hence, things like ',foo my/path' turn to 'foo("my/path")'
44 hence, things like ',foo my/path' turn to 'foo("my/path")'
33 instead of syntax error.
45 instead of syntax error.
34
46
35
47
36 2006-01-14 Ville Vainio <vivainio@gmail.com>
48 2006-01-14 Ville Vainio <vivainio@gmail.com>
37
49
38 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
50 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
39 ipapi decorators for python 2.4 users, options() provides access to rc
51 ipapi decorators for python 2.4 users, options() provides access to rc
40 data.
52 data.
41
53
42 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
54 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
43 as path separators (even on Linux ;-). Space character after
55 as path separators (even on Linux ;-). Space character after
44 backslash (as yielded by tab completer) is still space;
56 backslash (as yielded by tab completer) is still space;
45 "%cd long\ name" works as expected.
57 "%cd long\ name" works as expected.
46
58
47 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
59 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
48 as "chain of command", with priority. API stays the same,
60 as "chain of command", with priority. API stays the same,
49 TryNext exception raised by a hook function signals that
61 TryNext exception raised by a hook function signals that
50 current hook failed and next hook should try handling it, as
62 current hook failed and next hook should try handling it, as
51 suggested by Walter Dörwald <walter@livinglogic.de>. Walter also
63 suggested by Walter Dörwald <walter@livinglogic.de>. Walter also
52 requested configurable display hook, which is now implemented.
64 requested configurable display hook, which is now implemented.
53
65
54 2006-01-13 Ville Vainio <vivainio@gmail.com>
66 2006-01-13 Ville Vainio <vivainio@gmail.com>
55
67
56 * IPython/platutils*.py: platform specific utility functions,
68 * IPython/platutils*.py: platform specific utility functions,
57 so far only set_term_title is implemented (change terminal
69 so far only set_term_title is implemented (change terminal
58 label in windowing systems). %cd now changes the title to
70 label in windowing systems). %cd now changes the title to
59 current dir.
71 current dir.
60
72
61 * IPython/Release.py: Added myself to "authors" list,
73 * IPython/Release.py: Added myself to "authors" list,
62 had to create new files.
74 had to create new files.
63
75
64 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
76 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
65 shell escape; not a known bug but had potential to be one in the
77 shell escape; not a known bug but had potential to be one in the
66 future.
78 future.
67
79
68 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
80 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
69 extension API for IPython! See the module for usage example. Fix
81 extension API for IPython! See the module for usage example. Fix
70 OInspect for docstring-less magic functions.
82 OInspect for docstring-less magic functions.
71
83
72
84
73 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
85 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
74
86
75 * IPython/iplib.py (raw_input): temporarily deactivate all
87 * IPython/iplib.py (raw_input): temporarily deactivate all
76 attempts at allowing pasting of code with autoindent on. It
88 attempts at allowing pasting of code with autoindent on. It
77 introduced bugs (reported by Prabhu) and I can't seem to find a
89 introduced bugs (reported by Prabhu) and I can't seem to find a
78 robust combination which works in all cases. Will have to revisit
90 robust combination which works in all cases. Will have to revisit
79 later.
91 later.
80
92
81 * IPython/genutils.py: remove isspace() function. We've dropped
93 * IPython/genutils.py: remove isspace() function. We've dropped
82 2.2 compatibility, so it's OK to use the string method.
94 2.2 compatibility, so it's OK to use the string method.
83
95
84 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
96 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
85
97
86 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
98 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
87 matching what NOT to autocall on, to include all python binary
99 matching what NOT to autocall on, to include all python binary
88 operators (including things like 'and', 'or', 'is' and 'in').
100 operators (including things like 'and', 'or', 'is' and 'in').
89 Prompted by a bug report on 'foo & bar', but I realized we had
101 Prompted by a bug report on 'foo & bar', but I realized we had
90 many more potential bug cases with other operators. The regexp is
102 many more potential bug cases with other operators. The regexp is
91 self.re_exclude_auto, it's fairly commented.
103 self.re_exclude_auto, it's fairly commented.
92
104
93 2006-01-12 Ville Vainio <vivainio@gmail.com>
105 2006-01-12 Ville Vainio <vivainio@gmail.com>
94
106
95 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
107 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
96 Prettified and hardened string/backslash quoting with ipsystem(),
108 Prettified and hardened string/backslash quoting with ipsystem(),
97 ipalias() and ipmagic(). Now even \ characters are passed to
109 ipalias() and ipmagic(). Now even \ characters are passed to
98 %magics, !shell escapes and aliases exactly as they are in the
110 %magics, !shell escapes and aliases exactly as they are in the
99 ipython command line. Should improve backslash experience,
111 ipython command line. Should improve backslash experience,
100 particularly in Windows (path delimiter for some commands that
112 particularly in Windows (path delimiter for some commands that
101 won't understand '/'), but Unix benefits as well (regexps). %cd
113 won't understand '/'), but Unix benefits as well (regexps). %cd
102 magic still doesn't support backslash path delimiters, though. Also
114 magic still doesn't support backslash path delimiters, though. Also
103 deleted all pretense of supporting multiline command strings in
115 deleted all pretense of supporting multiline command strings in
104 !system or %magic commands. Thanks to Jerry McRae for suggestions.
116 !system or %magic commands. Thanks to Jerry McRae for suggestions.
105
117
106 * doc/build_doc_instructions.txt added. Documentation on how to
118 * doc/build_doc_instructions.txt added. Documentation on how to
107 use doc/update_manual.py, added yesterday. Both files contributed
119 use doc/update_manual.py, added yesterday. Both files contributed
108 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
120 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
109 doc/*.sh for deprecation at a later date.
121 doc/*.sh for deprecation at a later date.
110
122
111 * /ipython.py Added ipython.py to root directory for
123 * /ipython.py Added ipython.py to root directory for
112 zero-installation (tar xzvf ipython.tgz; cd ipython; python
124 zero-installation (tar xzvf ipython.tgz; cd ipython; python
113 ipython.py) and development convenience (no need to kee doing
125 ipython.py) and development convenience (no need to kee doing
114 "setup.py install" between changes).
126 "setup.py install" between changes).
115
127
116 * Made ! and !! shell escapes work (again) in multiline expressions:
128 * Made ! and !! shell escapes work (again) in multiline expressions:
117 if 1:
129 if 1:
118 !ls
130 !ls
119 !!ls
131 !!ls
120
132
121 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
133 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
122
134
123 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
135 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
124 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
136 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
125 module in case-insensitive installation. Was causing crashes
137 module in case-insensitive installation. Was causing crashes
126 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
138 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
127
139
128 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
140 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
129 <marienz-AT-gentoo.org>, closes
141 <marienz-AT-gentoo.org>, closes
130 http://www.scipy.net/roundup/ipython/issue51.
142 http://www.scipy.net/roundup/ipython/issue51.
131
143
132 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
144 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
133
145
134 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
146 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the the
135 problem of excessive CPU usage under *nix and keyboard lag under
147 problem of excessive CPU usage under *nix and keyboard lag under
136 win32.
148 win32.
137
149
138 2006-01-10 *** Released version 0.7.0
150 2006-01-10 *** Released version 0.7.0
139
151
140 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
152 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
141
153
142 * IPython/Release.py (revision): tag version number to 0.7.0,
154 * IPython/Release.py (revision): tag version number to 0.7.0,
143 ready for release.
155 ready for release.
144
156
145 * IPython/Magic.py (magic_edit): Add print statement to %edit so
157 * IPython/Magic.py (magic_edit): Add print statement to %edit so
146 it informs the user of the name of the temp. file used. This can
158 it informs the user of the name of the temp. file used. This can
147 help if you decide later to reuse that same file, so you know
159 help if you decide later to reuse that same file, so you know
148 where to copy the info from.
160 where to copy the info from.
149
161
150 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
162 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
151
163
152 * setup_bdist_egg.py: little script to build an egg. Added
164 * setup_bdist_egg.py: little script to build an egg. Added
153 support in the release tools as well.
165 support in the release tools as well.
154
166
155 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
167 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
156
168
157 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
169 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
158 version selection (new -wxversion command line and ipythonrc
170 version selection (new -wxversion command line and ipythonrc
159 parameter). Patch contributed by Arnd Baecker
171 parameter). Patch contributed by Arnd Baecker
160 <arnd.baecker-AT-web.de>.
172 <arnd.baecker-AT-web.de>.
161
173
162 * IPython/iplib.py (embed_mainloop): fix tab-completion in
174 * IPython/iplib.py (embed_mainloop): fix tab-completion in
163 embedded instances, for variables defined at the interactive
175 embedded instances, for variables defined at the interactive
164 prompt of the embedded ipython. Reported by Arnd.
176 prompt of the embedded ipython. Reported by Arnd.
165
177
166 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
178 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
167 it can be used as a (stateful) toggle, or with a direct parameter.
179 it can be used as a (stateful) toggle, or with a direct parameter.
168
180
169 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
181 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
170 could be triggered in certain cases and cause the traceback
182 could be triggered in certain cases and cause the traceback
171 printer not to work.
183 printer not to work.
172
184
173 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
185 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
174
186
175 * IPython/iplib.py (_should_recompile): Small fix, closes
187 * IPython/iplib.py (_should_recompile): Small fix, closes
176 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
188 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
177
189
178 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
190 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
179
191
180 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
192 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
181 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
193 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
182 Moad for help with tracking it down.
194 Moad for help with tracking it down.
183
195
184 * IPython/iplib.py (handle_auto): fix autocall handling for
196 * IPython/iplib.py (handle_auto): fix autocall handling for
185 objects which support BOTH __getitem__ and __call__ (so that f [x]
197 objects which support BOTH __getitem__ and __call__ (so that f [x]
186 is left alone, instead of becoming f([x]) automatically).
198 is left alone, instead of becoming f([x]) automatically).
187
199
188 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
200 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
189 Ville's patch.
201 Ville's patch.
190
202
191 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
203 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
192
204
193 * IPython/iplib.py (handle_auto): changed autocall semantics to
205 * IPython/iplib.py (handle_auto): changed autocall semantics to
194 include 'smart' mode, where the autocall transformation is NOT
206 include 'smart' mode, where the autocall transformation is NOT
195 applied if there are no arguments on the line. This allows you to
207 applied if there are no arguments on the line. This allows you to
196 just type 'foo' if foo is a callable to see its internal form,
208 just type 'foo' if foo is a callable to see its internal form,
197 instead of having it called with no arguments (typically a
209 instead of having it called with no arguments (typically a
198 mistake). The old 'full' autocall still exists: for that, you
210 mistake). The old 'full' autocall still exists: for that, you
199 need to set the 'autocall' parameter to 2 in your ipythonrc file.
211 need to set the 'autocall' parameter to 2 in your ipythonrc file.
200
212
201 * IPython/completer.py (Completer.attr_matches): add
213 * IPython/completer.py (Completer.attr_matches): add
202 tab-completion support for Enthoughts' traits. After a report by
214 tab-completion support for Enthoughts' traits. After a report by
203 Arnd and a patch by Prabhu.
215 Arnd and a patch by Prabhu.
204
216
205 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
217 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
206
218
207 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
219 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
208 Schmolck's patch to fix inspect.getinnerframes().
220 Schmolck's patch to fix inspect.getinnerframes().
209
221
210 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
222 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
211 for embedded instances, regarding handling of namespaces and items
223 for embedded instances, regarding handling of namespaces and items
212 added to the __builtin__ one. Multiple embedded instances and
224 added to the __builtin__ one. Multiple embedded instances and
213 recursive embeddings should work better now (though I'm not sure
225 recursive embeddings should work better now (though I'm not sure
214 I've got all the corner cases fixed, that code is a bit of a brain
226 I've got all the corner cases fixed, that code is a bit of a brain
215 twister).
227 twister).
216
228
217 * IPython/Magic.py (magic_edit): added support to edit in-memory
229 * IPython/Magic.py (magic_edit): added support to edit in-memory
218 macros (automatically creates the necessary temp files). %edit
230 macros (automatically creates the necessary temp files). %edit
219 also doesn't return the file contents anymore, it's just noise.
231 also doesn't return the file contents anymore, it's just noise.
220
232
221 * IPython/completer.py (Completer.attr_matches): revert change to
233 * IPython/completer.py (Completer.attr_matches): revert change to
222 complete only on attributes listed in __all__. I realized it
234 complete only on attributes listed in __all__. I realized it
223 cripples the tab-completion system as a tool for exploring the
235 cripples the tab-completion system as a tool for exploring the
224 internals of unknown libraries (it renders any non-__all__
236 internals of unknown libraries (it renders any non-__all__
225 attribute off-limits). I got bit by this when trying to see
237 attribute off-limits). I got bit by this when trying to see
226 something inside the dis module.
238 something inside the dis module.
227
239
228 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
240 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
229
241
230 * IPython/iplib.py (InteractiveShell.__init__): add .meta
242 * IPython/iplib.py (InteractiveShell.__init__): add .meta
231 namespace for users and extension writers to hold data in. This
243 namespace for users and extension writers to hold data in. This
232 follows the discussion in
244 follows the discussion in
233 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
245 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
234
246
235 * IPython/completer.py (IPCompleter.complete): small patch to help
247 * IPython/completer.py (IPCompleter.complete): small patch to help
236 tab-completion under Emacs, after a suggestion by John Barnard
248 tab-completion under Emacs, after a suggestion by John Barnard
237 <barnarj-AT-ccf.org>.
249 <barnarj-AT-ccf.org>.
238
250
239 * IPython/Magic.py (Magic.extract_input_slices): added support for
251 * IPython/Magic.py (Magic.extract_input_slices): added support for
240 the slice notation in magics to use N-M to represent numbers N...M
252 the slice notation in magics to use N-M to represent numbers N...M
241 (closed endpoints). This is used by %macro and %save.
253 (closed endpoints). This is used by %macro and %save.
242
254
243 * IPython/completer.py (Completer.attr_matches): for modules which
255 * IPython/completer.py (Completer.attr_matches): for modules which
244 define __all__, complete only on those. After a patch by Jeffrey
256 define __all__, complete only on those. After a patch by Jeffrey
245 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
257 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
246 speed up this routine.
258 speed up this routine.
247
259
248 * IPython/Logger.py (Logger.log): fix a history handling bug. I
260 * IPython/Logger.py (Logger.log): fix a history handling bug. I
249 don't know if this is the end of it, but the behavior now is
261 don't know if this is the end of it, but the behavior now is
250 certainly much more correct. Note that coupled with macros,
262 certainly much more correct. Note that coupled with macros,
251 slightly surprising (at first) behavior may occur: a macro will in
263 slightly surprising (at first) behavior may occur: a macro will in
252 general expand to multiple lines of input, so upon exiting, the
264 general expand to multiple lines of input, so upon exiting, the
253 in/out counters will both be bumped by the corresponding amount
265 in/out counters will both be bumped by the corresponding amount
254 (as if the macro's contents had been typed interactively). Typing
266 (as if the macro's contents had been typed interactively). Typing
255 %hist will reveal the intermediate (silently processed) lines.
267 %hist will reveal the intermediate (silently processed) lines.
256
268
257 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
269 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
258 pickle to fail (%run was overwriting __main__ and not restoring
270 pickle to fail (%run was overwriting __main__ and not restoring
259 it, but pickle relies on __main__ to operate).
271 it, but pickle relies on __main__ to operate).
260
272
261 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
273 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
262 using properties, but forgot to make the main InteractiveShell
274 using properties, but forgot to make the main InteractiveShell
263 class a new-style class. Properties fail silently, and
275 class a new-style class. Properties fail silently, and
264 misteriously, with old-style class (getters work, but
276 misteriously, with old-style class (getters work, but
265 setters don't do anything).
277 setters don't do anything).
266
278
267 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
279 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
268
280
269 * IPython/Magic.py (magic_history): fix history reporting bug (I
281 * IPython/Magic.py (magic_history): fix history reporting bug (I
270 know some nasties are still there, I just can't seem to find a
282 know some nasties are still there, I just can't seem to find a
271 reproducible test case to track them down; the input history is
283 reproducible test case to track them down; the input history is
272 falling out of sync...)
284 falling out of sync...)
273
285
274 * IPython/iplib.py (handle_shell_escape): fix bug where both
286 * IPython/iplib.py (handle_shell_escape): fix bug where both
275 aliases and system accesses where broken for indented code (such
287 aliases and system accesses where broken for indented code (such
276 as loops).
288 as loops).
277
289
278 * IPython/genutils.py (shell): fix small but critical bug for
290 * IPython/genutils.py (shell): fix small but critical bug for
279 win32 system access.
291 win32 system access.
280
292
281 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
293 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
282
294
283 * IPython/iplib.py (showtraceback): remove use of the
295 * IPython/iplib.py (showtraceback): remove use of the
284 sys.last_{type/value/traceback} structures, which are non
296 sys.last_{type/value/traceback} structures, which are non
285 thread-safe.
297 thread-safe.
286 (_prefilter): change control flow to ensure that we NEVER
298 (_prefilter): change control flow to ensure that we NEVER
287 introspect objects when autocall is off. This will guarantee that
299 introspect objects when autocall is off. This will guarantee that
288 having an input line of the form 'x.y', where access to attribute
300 having an input line of the form 'x.y', where access to attribute
289 'y' has side effects, doesn't trigger the side effect TWICE. It
301 'y' has side effects, doesn't trigger the side effect TWICE. It
290 is important to note that, with autocall on, these side effects
302 is important to note that, with autocall on, these side effects
291 can still happen.
303 can still happen.
292 (ipsystem): new builtin, to complete the ip{magic/alias/system}
304 (ipsystem): new builtin, to complete the ip{magic/alias/system}
293 trio. IPython offers these three kinds of special calls which are
305 trio. IPython offers these three kinds of special calls which are
294 not python code, and it's a good thing to have their call method
306 not python code, and it's a good thing to have their call method
295 be accessible as pure python functions (not just special syntax at
307 be accessible as pure python functions (not just special syntax at
296 the command line). It gives us a better internal implementation
308 the command line). It gives us a better internal implementation
297 structure, as well as exposing these for user scripting more
309 structure, as well as exposing these for user scripting more
298 cleanly.
310 cleanly.
299
311
300 * IPython/macro.py (Macro.__init__): moved macros to a standalone
312 * IPython/macro.py (Macro.__init__): moved macros to a standalone
301 file. Now that they'll be more likely to be used with the
313 file. Now that they'll be more likely to be used with the
302 persistance system (%store), I want to make sure their module path
314 persistance system (%store), I want to make sure their module path
303 doesn't change in the future, so that we don't break things for
315 doesn't change in the future, so that we don't break things for
304 users' persisted data.
316 users' persisted data.
305
317
306 * IPython/iplib.py (autoindent_update): move indentation
318 * IPython/iplib.py (autoindent_update): move indentation
307 management into the _text_ processing loop, not the keyboard
319 management into the _text_ processing loop, not the keyboard
308 interactive one. This is necessary to correctly process non-typed
320 interactive one. This is necessary to correctly process non-typed
309 multiline input (such as macros).
321 multiline input (such as macros).
310
322
311 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
323 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
312 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
324 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
313 which was producing problems in the resulting manual.
325 which was producing problems in the resulting manual.
314 (magic_whos): improve reporting of instances (show their class,
326 (magic_whos): improve reporting of instances (show their class,
315 instead of simply printing 'instance' which isn't terribly
327 instead of simply printing 'instance' which isn't terribly
316 informative).
328 informative).
317
329
318 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
330 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
319 (minor mods) to support network shares under win32.
331 (minor mods) to support network shares under win32.
320
332
321 * IPython/winconsole.py (get_console_size): add new winconsole
333 * IPython/winconsole.py (get_console_size): add new winconsole
322 module and fixes to page_dumb() to improve its behavior under
334 module and fixes to page_dumb() to improve its behavior under
323 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
335 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
324
336
325 * IPython/Magic.py (Macro): simplified Macro class to just
337 * IPython/Magic.py (Macro): simplified Macro class to just
326 subclass list. We've had only 2.2 compatibility for a very long
338 subclass list. We've had only 2.2 compatibility for a very long
327 time, yet I was still avoiding subclassing the builtin types. No
339 time, yet I was still avoiding subclassing the builtin types. No
328 more (I'm also starting to use properties, though I won't shift to
340 more (I'm also starting to use properties, though I won't shift to
329 2.3-specific features quite yet).
341 2.3-specific features quite yet).
330 (magic_store): added Ville's patch for lightweight variable
342 (magic_store): added Ville's patch for lightweight variable
331 persistence, after a request on the user list by Matt Wilkie
343 persistence, after a request on the user list by Matt Wilkie
332 <maphew-AT-gmail.com>. The new %store magic's docstring has full
344 <maphew-AT-gmail.com>. The new %store magic's docstring has full
333 details.
345 details.
334
346
335 * IPython/iplib.py (InteractiveShell.post_config_initialization):
347 * IPython/iplib.py (InteractiveShell.post_config_initialization):
336 changed the default logfile name from 'ipython.log' to
348 changed the default logfile name from 'ipython.log' to
337 'ipython_log.py'. These logs are real python files, and now that
349 'ipython_log.py'. These logs are real python files, and now that
338 we have much better multiline support, people are more likely to
350 we have much better multiline support, people are more likely to
339 want to use them as such. Might as well name them correctly.
351 want to use them as such. Might as well name them correctly.
340
352
341 * IPython/Magic.py: substantial cleanup. While we can't stop
353 * IPython/Magic.py: substantial cleanup. While we can't stop
342 using magics as mixins, due to the existing customizations 'out
354 using magics as mixins, due to the existing customizations 'out
343 there' which rely on the mixin naming conventions, at least I
355 there' which rely on the mixin naming conventions, at least I
344 cleaned out all cross-class name usage. So once we are OK with
356 cleaned out all cross-class name usage. So once we are OK with
345 breaking compatibility, the two systems can be separated.
357 breaking compatibility, the two systems can be separated.
346
358
347 * IPython/Logger.py: major cleanup. This one is NOT a mixin
359 * IPython/Logger.py: major cleanup. This one is NOT a mixin
348 anymore, and the class is a fair bit less hideous as well. New
360 anymore, and the class is a fair bit less hideous as well. New
349 features were also introduced: timestamping of input, and logging
361 features were also introduced: timestamping of input, and logging
350 of output results. These are user-visible with the -t and -o
362 of output results. These are user-visible with the -t and -o
351 options to %logstart. Closes
363 options to %logstart. Closes
352 http://www.scipy.net/roundup/ipython/issue11 and a request by
364 http://www.scipy.net/roundup/ipython/issue11 and a request by
353 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
365 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
354
366
355 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
367 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
356
368
357 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
369 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
358 better hadnle backslashes in paths. See the thread 'More Windows
370 better hadnle backslashes in paths. See the thread 'More Windows
359 questions part 2 - \/ characters revisited' on the iypthon user
371 questions part 2 - \/ characters revisited' on the iypthon user
360 list:
372 list:
361 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
373 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
362
374
363 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
375 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
364
376
365 (InteractiveShell.__init__): change threaded shells to not use the
377 (InteractiveShell.__init__): change threaded shells to not use the
366 ipython crash handler. This was causing more problems than not,
378 ipython crash handler. This was causing more problems than not,
367 as exceptions in the main thread (GUI code, typically) would
379 as exceptions in the main thread (GUI code, typically) would
368 always show up as a 'crash', when they really weren't.
380 always show up as a 'crash', when they really weren't.
369
381
370 The colors and exception mode commands (%colors/%xmode) have been
382 The colors and exception mode commands (%colors/%xmode) have been
371 synchronized to also take this into account, so users can get
383 synchronized to also take this into account, so users can get
372 verbose exceptions for their threaded code as well. I also added
384 verbose exceptions for their threaded code as well. I also added
373 support for activating pdb inside this exception handler as well,
385 support for activating pdb inside this exception handler as well,
374 so now GUI authors can use IPython's enhanced pdb at runtime.
386 so now GUI authors can use IPython's enhanced pdb at runtime.
375
387
376 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
388 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
377 true by default, and add it to the shipped ipythonrc file. Since
389 true by default, and add it to the shipped ipythonrc file. Since
378 this asks the user before proceeding, I think it's OK to make it
390 this asks the user before proceeding, I think it's OK to make it
379 true by default.
391 true by default.
380
392
381 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
393 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
382 of the previous special-casing of input in the eval loop. I think
394 of the previous special-casing of input in the eval loop. I think
383 this is cleaner, as they really are commands and shouldn't have
395 this is cleaner, as they really are commands and shouldn't have
384 a special role in the middle of the core code.
396 a special role in the middle of the core code.
385
397
386 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
398 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
387
399
388 * IPython/iplib.py (edit_syntax_error): added support for
400 * IPython/iplib.py (edit_syntax_error): added support for
389 automatically reopening the editor if the file had a syntax error
401 automatically reopening the editor if the file had a syntax error
390 in it. Thanks to scottt who provided the patch at:
402 in it. Thanks to scottt who provided the patch at:
391 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
403 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
392 version committed).
404 version committed).
393
405
394 * IPython/iplib.py (handle_normal): add suport for multi-line
406 * IPython/iplib.py (handle_normal): add suport for multi-line
395 input with emtpy lines. This fixes
407 input with emtpy lines. This fixes
396 http://www.scipy.net/roundup/ipython/issue43 and a similar
408 http://www.scipy.net/roundup/ipython/issue43 and a similar
397 discussion on the user list.
409 discussion on the user list.
398
410
399 WARNING: a behavior change is necessarily introduced to support
411 WARNING: a behavior change is necessarily introduced to support
400 blank lines: now a single blank line with whitespace does NOT
412 blank lines: now a single blank line with whitespace does NOT
401 break the input loop, which means that when autoindent is on, by
413 break the input loop, which means that when autoindent is on, by
402 default hitting return on the next (indented) line does NOT exit.
414 default hitting return on the next (indented) line does NOT exit.
403
415
404 Instead, to exit a multiline input you can either have:
416 Instead, to exit a multiline input you can either have:
405
417
406 - TWO whitespace lines (just hit return again), or
418 - TWO whitespace lines (just hit return again), or
407 - a single whitespace line of a different length than provided
419 - a single whitespace line of a different length than provided
408 by the autoindent (add or remove a space).
420 by the autoindent (add or remove a space).
409
421
410 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
422 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
411 module to better organize all readline-related functionality.
423 module to better organize all readline-related functionality.
412 I've deleted FlexCompleter and put all completion clases here.
424 I've deleted FlexCompleter and put all completion clases here.
413
425
414 * IPython/iplib.py (raw_input): improve indentation management.
426 * IPython/iplib.py (raw_input): improve indentation management.
415 It is now possible to paste indented code with autoindent on, and
427 It is now possible to paste indented code with autoindent on, and
416 the code is interpreted correctly (though it still looks bad on
428 the code is interpreted correctly (though it still looks bad on
417 screen, due to the line-oriented nature of ipython).
429 screen, due to the line-oriented nature of ipython).
418 (MagicCompleter.complete): change behavior so that a TAB key on an
430 (MagicCompleter.complete): change behavior so that a TAB key on an
419 otherwise empty line actually inserts a tab, instead of completing
431 otherwise empty line actually inserts a tab, instead of completing
420 on the entire global namespace. This makes it easier to use the
432 on the entire global namespace. This makes it easier to use the
421 TAB key for indentation. After a request by Hans Meine
433 TAB key for indentation. After a request by Hans Meine
422 <hans_meine-AT-gmx.net>
434 <hans_meine-AT-gmx.net>
423 (_prefilter): add support so that typing plain 'exit' or 'quit'
435 (_prefilter): add support so that typing plain 'exit' or 'quit'
424 does a sensible thing. Originally I tried to deviate as little as
436 does a sensible thing. Originally I tried to deviate as little as
425 possible from the default python behavior, but even that one may
437 possible from the default python behavior, but even that one may
426 change in this direction (thread on python-dev to that effect).
438 change in this direction (thread on python-dev to that effect).
427 Regardless, ipython should do the right thing even if CPython's
439 Regardless, ipython should do the right thing even if CPython's
428 '>>>' prompt doesn't.
440 '>>>' prompt doesn't.
429 (InteractiveShell): removed subclassing code.InteractiveConsole
441 (InteractiveShell): removed subclassing code.InteractiveConsole
430 class. By now we'd overridden just about all of its methods: I've
442 class. By now we'd overridden just about all of its methods: I've
431 copied the remaining two over, and now ipython is a standalone
443 copied the remaining two over, and now ipython is a standalone
432 class. This will provide a clearer picture for the chainsaw
444 class. This will provide a clearer picture for the chainsaw
433 branch refactoring.
445 branch refactoring.
434
446
435 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
447 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
436
448
437 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
449 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
438 failures for objects which break when dir() is called on them.
450 failures for objects which break when dir() is called on them.
439
451
440 * IPython/FlexCompleter.py (Completer.__init__): Added support for
452 * IPython/FlexCompleter.py (Completer.__init__): Added support for
441 distinct local and global namespaces in the completer API. This
453 distinct local and global namespaces in the completer API. This
442 change allows us top properly handle completion with distinct
454 change allows us top properly handle completion with distinct
443 scopes, including in embedded instances (this had never really
455 scopes, including in embedded instances (this had never really
444 worked correctly).
456 worked correctly).
445
457
446 Note: this introduces a change in the constructor for
458 Note: this introduces a change in the constructor for
447 MagicCompleter, as a new global_namespace parameter is now the
459 MagicCompleter, as a new global_namespace parameter is now the
448 second argument (the others were bumped one position).
460 second argument (the others were bumped one position).
449
461
450 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
462 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
451
463
452 * IPython/iplib.py (embed_mainloop): fix tab-completion in
464 * IPython/iplib.py (embed_mainloop): fix tab-completion in
453 embedded instances (which can be done now thanks to Vivian's
465 embedded instances (which can be done now thanks to Vivian's
454 frame-handling fixes for pdb).
466 frame-handling fixes for pdb).
455 (InteractiveShell.__init__): Fix namespace handling problem in
467 (InteractiveShell.__init__): Fix namespace handling problem in
456 embedded instances. We were overwriting __main__ unconditionally,
468 embedded instances. We were overwriting __main__ unconditionally,
457 and this should only be done for 'full' (non-embedded) IPython;
469 and this should only be done for 'full' (non-embedded) IPython;
458 embedded instances must respect the caller's __main__. Thanks to
470 embedded instances must respect the caller's __main__. Thanks to
459 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
471 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
460
472
461 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
473 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
462
474
463 * setup.py: added download_url to setup(). This registers the
475 * setup.py: added download_url to setup(). This registers the
464 download address at PyPI, which is not only useful to humans
476 download address at PyPI, which is not only useful to humans
465 browsing the site, but is also picked up by setuptools (the Eggs
477 browsing the site, but is also picked up by setuptools (the Eggs
466 machinery). Thanks to Ville and R. Kern for the info/discussion
478 machinery). Thanks to Ville and R. Kern for the info/discussion
467 on this.
479 on this.
468
480
469 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
481 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
470
482
471 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
483 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
472 This brings a lot of nice functionality to the pdb mode, which now
484 This brings a lot of nice functionality to the pdb mode, which now
473 has tab-completion, syntax highlighting, and better stack handling
485 has tab-completion, syntax highlighting, and better stack handling
474 than before. Many thanks to Vivian De Smedt
486 than before. Many thanks to Vivian De Smedt
475 <vivian-AT-vdesmedt.com> for the original patches.
487 <vivian-AT-vdesmedt.com> for the original patches.
476
488
477 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
489 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
478
490
479 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
491 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
480 sequence to consistently accept the banner argument. The
492 sequence to consistently accept the banner argument. The
481 inconsistency was tripping SAGE, thanks to Gary Zablackis
493 inconsistency was tripping SAGE, thanks to Gary Zablackis
482 <gzabl-AT-yahoo.com> for the report.
494 <gzabl-AT-yahoo.com> for the report.
483
495
484 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
496 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
485
497
486 * IPython/iplib.py (InteractiveShell.post_config_initialization):
498 * IPython/iplib.py (InteractiveShell.post_config_initialization):
487 Fix bug where a naked 'alias' call in the ipythonrc file would
499 Fix bug where a naked 'alias' call in the ipythonrc file would
488 cause a crash. Bug reported by Jorgen Stenarson.
500 cause a crash. Bug reported by Jorgen Stenarson.
489
501
490 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
502 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
491
503
492 * IPython/ipmaker.py (make_IPython): cleanups which should improve
504 * IPython/ipmaker.py (make_IPython): cleanups which should improve
493 startup time.
505 startup time.
494
506
495 * IPython/iplib.py (runcode): my globals 'fix' for embedded
507 * IPython/iplib.py (runcode): my globals 'fix' for embedded
496 instances had introduced a bug with globals in normal code. Now
508 instances had introduced a bug with globals in normal code. Now
497 it's working in all cases.
509 it's working in all cases.
498
510
499 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
511 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
500 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
512 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
501 has been introduced to set the default case sensitivity of the
513 has been introduced to set the default case sensitivity of the
502 searches. Users can still select either mode at runtime on a
514 searches. Users can still select either mode at runtime on a
503 per-search basis.
515 per-search basis.
504
516
505 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
517 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
506
518
507 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
519 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
508 attributes in wildcard searches for subclasses. Modified version
520 attributes in wildcard searches for subclasses. Modified version
509 of a patch by Jorgen.
521 of a patch by Jorgen.
510
522
511 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
523 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
512
524
513 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
525 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
514 embedded instances. I added a user_global_ns attribute to the
526 embedded instances. I added a user_global_ns attribute to the
515 InteractiveShell class to handle this.
527 InteractiveShell class to handle this.
516
528
517 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
529 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
518
530
519 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
531 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
520 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
532 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
521 (reported under win32, but may happen also in other platforms).
533 (reported under win32, but may happen also in other platforms).
522 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
534 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
523
535
524 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
536 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
525
537
526 * IPython/Magic.py (magic_psearch): new support for wildcard
538 * IPython/Magic.py (magic_psearch): new support for wildcard
527 patterns. Now, typing ?a*b will list all names which begin with a
539 patterns. Now, typing ?a*b will list all names which begin with a
528 and end in b, for example. The %psearch magic has full
540 and end in b, for example. The %psearch magic has full
529 docstrings. Many thanks to Jörgen Stenarson
541 docstrings. Many thanks to Jörgen Stenarson
530 <jorgen.stenarson-AT-bostream.nu>, author of the patches
542 <jorgen.stenarson-AT-bostream.nu>, author of the patches
531 implementing this functionality.
543 implementing this functionality.
532
544
533 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
545 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
534
546
535 * Manual: fixed long-standing annoyance of double-dashes (as in
547 * Manual: fixed long-standing annoyance of double-dashes (as in
536 --prefix=~, for example) being stripped in the HTML version. This
548 --prefix=~, for example) being stripped in the HTML version. This
537 is a latex2html bug, but a workaround was provided. Many thanks
549 is a latex2html bug, but a workaround was provided. Many thanks
538 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
550 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
539 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
551 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
540 rolling. This seemingly small issue had tripped a number of users
552 rolling. This seemingly small issue had tripped a number of users
541 when first installing, so I'm glad to see it gone.
553 when first installing, so I'm glad to see it gone.
542
554
543 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
555 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
544
556
545 * IPython/Extensions/numeric_formats.py: fix missing import,
557 * IPython/Extensions/numeric_formats.py: fix missing import,
546 reported by Stephen Walton.
558 reported by Stephen Walton.
547
559
548 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
560 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
549
561
550 * IPython/demo.py: finish demo module, fully documented now.
562 * IPython/demo.py: finish demo module, fully documented now.
551
563
552 * IPython/genutils.py (file_read): simple little utility to read a
564 * IPython/genutils.py (file_read): simple little utility to read a
553 file and ensure it's closed afterwards.
565 file and ensure it's closed afterwards.
554
566
555 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
567 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
556
568
557 * IPython/demo.py (Demo.__init__): added support for individually
569 * IPython/demo.py (Demo.__init__): added support for individually
558 tagging blocks for automatic execution.
570 tagging blocks for automatic execution.
559
571
560 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
572 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
561 syntax-highlighted python sources, requested by John.
573 syntax-highlighted python sources, requested by John.
562
574
563 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
575 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
564
576
565 * IPython/demo.py (Demo.again): fix bug where again() blocks after
577 * IPython/demo.py (Demo.again): fix bug where again() blocks after
566 finishing.
578 finishing.
567
579
568 * IPython/genutils.py (shlex_split): moved from Magic to here,
580 * IPython/genutils.py (shlex_split): moved from Magic to here,
569 where all 2.2 compatibility stuff lives. I needed it for demo.py.
581 where all 2.2 compatibility stuff lives. I needed it for demo.py.
570
582
571 * IPython/demo.py (Demo.__init__): added support for silent
583 * IPython/demo.py (Demo.__init__): added support for silent
572 blocks, improved marks as regexps, docstrings written.
584 blocks, improved marks as regexps, docstrings written.
573 (Demo.__init__): better docstring, added support for sys.argv.
585 (Demo.__init__): better docstring, added support for sys.argv.
574
586
575 * IPython/genutils.py (marquee): little utility used by the demo
587 * IPython/genutils.py (marquee): little utility used by the demo
576 code, handy in general.
588 code, handy in general.
577
589
578 * IPython/demo.py (Demo.__init__): new class for interactive
590 * IPython/demo.py (Demo.__init__): new class for interactive
579 demos. Not documented yet, I just wrote it in a hurry for
591 demos. Not documented yet, I just wrote it in a hurry for
580 scipy'05. Will docstring later.
592 scipy'05. Will docstring later.
581
593
582 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
594 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
583
595
584 * IPython/Shell.py (sigint_handler): Drastic simplification which
596 * IPython/Shell.py (sigint_handler): Drastic simplification which
585 also seems to make Ctrl-C work correctly across threads! This is
597 also seems to make Ctrl-C work correctly across threads! This is
586 so simple, that I can't beleive I'd missed it before. Needs more
598 so simple, that I can't beleive I'd missed it before. Needs more
587 testing, though.
599 testing, though.
588 (KBINT): Never mind, revert changes. I'm sure I'd tried something
600 (KBINT): Never mind, revert changes. I'm sure I'd tried something
589 like this before...
601 like this before...
590
602
591 * IPython/genutils.py (get_home_dir): add protection against
603 * IPython/genutils.py (get_home_dir): add protection against
592 non-dirs in win32 registry.
604 non-dirs in win32 registry.
593
605
594 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
606 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
595 bug where dict was mutated while iterating (pysh crash).
607 bug where dict was mutated while iterating (pysh crash).
596
608
597 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
609 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
598
610
599 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
611 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
600 spurious newlines added by this routine. After a report by
612 spurious newlines added by this routine. After a report by
601 F. Mantegazza.
613 F. Mantegazza.
602
614
603 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
615 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
604
616
605 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
617 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
606 calls. These were a leftover from the GTK 1.x days, and can cause
618 calls. These were a leftover from the GTK 1.x days, and can cause
607 problems in certain cases (after a report by John Hunter).
619 problems in certain cases (after a report by John Hunter).
608
620
609 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
621 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
610 os.getcwd() fails at init time. Thanks to patch from David Remahl
622 os.getcwd() fails at init time. Thanks to patch from David Remahl
611 <chmod007-AT-mac.com>.
623 <chmod007-AT-mac.com>.
612 (InteractiveShell.__init__): prevent certain special magics from
624 (InteractiveShell.__init__): prevent certain special magics from
613 being shadowed by aliases. Closes
625 being shadowed by aliases. Closes
614 http://www.scipy.net/roundup/ipython/issue41.
626 http://www.scipy.net/roundup/ipython/issue41.
615
627
616 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
628 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
617
629
618 * IPython/iplib.py (InteractiveShell.complete): Added new
630 * IPython/iplib.py (InteractiveShell.complete): Added new
619 top-level completion method to expose the completion mechanism
631 top-level completion method to expose the completion mechanism
620 beyond readline-based environments.
632 beyond readline-based environments.
621
633
622 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
634 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
623
635
624 * tools/ipsvnc (svnversion): fix svnversion capture.
636 * tools/ipsvnc (svnversion): fix svnversion capture.
625
637
626 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
638 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
627 attribute to self, which was missing. Before, it was set by a
639 attribute to self, which was missing. Before, it was set by a
628 routine which in certain cases wasn't being called, so the
640 routine which in certain cases wasn't being called, so the
629 instance could end up missing the attribute. This caused a crash.
641 instance could end up missing the attribute. This caused a crash.
630 Closes http://www.scipy.net/roundup/ipython/issue40.
642 Closes http://www.scipy.net/roundup/ipython/issue40.
631
643
632 2005-08-16 Fernando Perez <fperez@colorado.edu>
644 2005-08-16 Fernando Perez <fperez@colorado.edu>
633
645
634 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
646 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
635 contains non-string attribute. Closes
647 contains non-string attribute. Closes
636 http://www.scipy.net/roundup/ipython/issue38.
648 http://www.scipy.net/roundup/ipython/issue38.
637
649
638 2005-08-14 Fernando Perez <fperez@colorado.edu>
650 2005-08-14 Fernando Perez <fperez@colorado.edu>
639
651
640 * tools/ipsvnc: Minor improvements, to add changeset info.
652 * tools/ipsvnc: Minor improvements, to add changeset info.
641
653
642 2005-08-12 Fernando Perez <fperez@colorado.edu>
654 2005-08-12 Fernando Perez <fperez@colorado.edu>
643
655
644 * IPython/iplib.py (runsource): remove self.code_to_run_src
656 * IPython/iplib.py (runsource): remove self.code_to_run_src
645 attribute. I realized this is nothing more than
657 attribute. I realized this is nothing more than
646 '\n'.join(self.buffer), and having the same data in two different
658 '\n'.join(self.buffer), and having the same data in two different
647 places is just asking for synchronization bugs. This may impact
659 places is just asking for synchronization bugs. This may impact
648 people who have custom exception handlers, so I need to warn
660 people who have custom exception handlers, so I need to warn
649 ipython-dev about it (F. Mantegazza may use them).
661 ipython-dev about it (F. Mantegazza may use them).
650
662
651 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
663 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
652
664
653 * IPython/genutils.py: fix 2.2 compatibility (generators)
665 * IPython/genutils.py: fix 2.2 compatibility (generators)
654
666
655 2005-07-18 Fernando Perez <fperez@colorado.edu>
667 2005-07-18 Fernando Perez <fperez@colorado.edu>
656
668
657 * IPython/genutils.py (get_home_dir): fix to help users with
669 * IPython/genutils.py (get_home_dir): fix to help users with
658 invalid $HOME under win32.
670 invalid $HOME under win32.
659
671
660 2005-07-17 Fernando Perez <fperez@colorado.edu>
672 2005-07-17 Fernando Perez <fperez@colorado.edu>
661
673
662 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
674 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
663 some old hacks and clean up a bit other routines; code should be
675 some old hacks and clean up a bit other routines; code should be
664 simpler and a bit faster.
676 simpler and a bit faster.
665
677
666 * IPython/iplib.py (interact): removed some last-resort attempts
678 * IPython/iplib.py (interact): removed some last-resort attempts
667 to survive broken stdout/stderr. That code was only making it
679 to survive broken stdout/stderr. That code was only making it
668 harder to abstract out the i/o (necessary for gui integration),
680 harder to abstract out the i/o (necessary for gui integration),
669 and the crashes it could prevent were extremely rare in practice
681 and the crashes it could prevent were extremely rare in practice
670 (besides being fully user-induced in a pretty violent manner).
682 (besides being fully user-induced in a pretty violent manner).
671
683
672 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
684 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
673 Nothing major yet, but the code is simpler to read; this should
685 Nothing major yet, but the code is simpler to read; this should
674 make it easier to do more serious modifications in the future.
686 make it easier to do more serious modifications in the future.
675
687
676 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
688 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
677 which broke in .15 (thanks to a report by Ville).
689 which broke in .15 (thanks to a report by Ville).
678
690
679 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
691 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
680 be quite correct, I know next to nothing about unicode). This
692 be quite correct, I know next to nothing about unicode). This
681 will allow unicode strings to be used in prompts, amongst other
693 will allow unicode strings to be used in prompts, amongst other
682 cases. It also will prevent ipython from crashing when unicode
694 cases. It also will prevent ipython from crashing when unicode
683 shows up unexpectedly in many places. If ascii encoding fails, we
695 shows up unexpectedly in many places. If ascii encoding fails, we
684 assume utf_8. Currently the encoding is not a user-visible
696 assume utf_8. Currently the encoding is not a user-visible
685 setting, though it could be made so if there is demand for it.
697 setting, though it could be made so if there is demand for it.
686
698
687 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
699 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
688
700
689 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
701 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
690
702
691 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
703 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
692
704
693 * IPython/genutils.py: Add 2.2 compatibility here, so all other
705 * IPython/genutils.py: Add 2.2 compatibility here, so all other
694 code can work transparently for 2.2/2.3.
706 code can work transparently for 2.2/2.3.
695
707
696 2005-07-16 Fernando Perez <fperez@colorado.edu>
708 2005-07-16 Fernando Perez <fperez@colorado.edu>
697
709
698 * IPython/ultraTB.py (ExceptionColors): Make a global variable
710 * IPython/ultraTB.py (ExceptionColors): Make a global variable
699 out of the color scheme table used for coloring exception
711 out of the color scheme table used for coloring exception
700 tracebacks. This allows user code to add new schemes at runtime.
712 tracebacks. This allows user code to add new schemes at runtime.
701 This is a minimally modified version of the patch at
713 This is a minimally modified version of the patch at
702 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
714 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
703 for the contribution.
715 for the contribution.
704
716
705 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
717 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
706 slightly modified version of the patch in
718 slightly modified version of the patch in
707 http://www.scipy.net/roundup/ipython/issue34, which also allows me
719 http://www.scipy.net/roundup/ipython/issue34, which also allows me
708 to remove the previous try/except solution (which was costlier).
720 to remove the previous try/except solution (which was costlier).
709 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
721 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
710
722
711 2005-06-08 Fernando Perez <fperez@colorado.edu>
723 2005-06-08 Fernando Perez <fperez@colorado.edu>
712
724
713 * IPython/iplib.py (write/write_err): Add methods to abstract all
725 * IPython/iplib.py (write/write_err): Add methods to abstract all
714 I/O a bit more.
726 I/O a bit more.
715
727
716 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
728 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
717 warning, reported by Aric Hagberg, fix by JD Hunter.
729 warning, reported by Aric Hagberg, fix by JD Hunter.
718
730
719 2005-06-02 *** Released version 0.6.15
731 2005-06-02 *** Released version 0.6.15
720
732
721 2005-06-01 Fernando Perez <fperez@colorado.edu>
733 2005-06-01 Fernando Perez <fperez@colorado.edu>
722
734
723 * IPython/iplib.py (MagicCompleter.file_matches): Fix
735 * IPython/iplib.py (MagicCompleter.file_matches): Fix
724 tab-completion of filenames within open-quoted strings. Note that
736 tab-completion of filenames within open-quoted strings. Note that
725 this requires that in ~/.ipython/ipythonrc, users change the
737 this requires that in ~/.ipython/ipythonrc, users change the
726 readline delimiters configuration to read:
738 readline delimiters configuration to read:
727
739
728 readline_remove_delims -/~
740 readline_remove_delims -/~
729
741
730
742
731 2005-05-31 *** Released version 0.6.14
743 2005-05-31 *** Released version 0.6.14
732
744
733 2005-05-29 Fernando Perez <fperez@colorado.edu>
745 2005-05-29 Fernando Perez <fperez@colorado.edu>
734
746
735 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
747 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
736 with files not on the filesystem. Reported by Eliyahu Sandler
748 with files not on the filesystem. Reported by Eliyahu Sandler
737 <eli@gondolin.net>
749 <eli@gondolin.net>
738
750
739 2005-05-22 Fernando Perez <fperez@colorado.edu>
751 2005-05-22 Fernando Perez <fperez@colorado.edu>
740
752
741 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
753 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
742 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
754 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
743
755
744 2005-05-19 Fernando Perez <fperez@colorado.edu>
756 2005-05-19 Fernando Perez <fperez@colorado.edu>
745
757
746 * IPython/iplib.py (safe_execfile): close a file which could be
758 * IPython/iplib.py (safe_execfile): close a file which could be
747 left open (causing problems in win32, which locks open files).
759 left open (causing problems in win32, which locks open files).
748 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
760 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
749
761
750 2005-05-18 Fernando Perez <fperez@colorado.edu>
762 2005-05-18 Fernando Perez <fperez@colorado.edu>
751
763
752 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
764 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
753 keyword arguments correctly to safe_execfile().
765 keyword arguments correctly to safe_execfile().
754
766
755 2005-05-13 Fernando Perez <fperez@colorado.edu>
767 2005-05-13 Fernando Perez <fperez@colorado.edu>
756
768
757 * ipython.1: Added info about Qt to manpage, and threads warning
769 * ipython.1: Added info about Qt to manpage, and threads warning
758 to usage page (invoked with --help).
770 to usage page (invoked with --help).
759
771
760 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
772 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
761 new matcher (it goes at the end of the priority list) to do
773 new matcher (it goes at the end of the priority list) to do
762 tab-completion on named function arguments. Submitted by George
774 tab-completion on named function arguments. Submitted by George
763 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
775 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
764 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
776 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
765 for more details.
777 for more details.
766
778
767 * IPython/Magic.py (magic_run): Added new -e flag to ignore
779 * IPython/Magic.py (magic_run): Added new -e flag to ignore
768 SystemExit exceptions in the script being run. Thanks to a report
780 SystemExit exceptions in the script being run. Thanks to a report
769 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
781 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
770 producing very annoying behavior when running unit tests.
782 producing very annoying behavior when running unit tests.
771
783
772 2005-05-12 Fernando Perez <fperez@colorado.edu>
784 2005-05-12 Fernando Perez <fperez@colorado.edu>
773
785
774 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
786 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
775 which I'd broken (again) due to a changed regexp. In the process,
787 which I'd broken (again) due to a changed regexp. In the process,
776 added ';' as an escape to auto-quote the whole line without
788 added ';' as an escape to auto-quote the whole line without
777 splitting its arguments. Thanks to a report by Jerry McRae
789 splitting its arguments. Thanks to a report by Jerry McRae
778 <qrs0xyc02-AT-sneakemail.com>.
790 <qrs0xyc02-AT-sneakemail.com>.
779
791
780 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
792 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
781 possible crashes caused by a TokenError. Reported by Ed Schofield
793 possible crashes caused by a TokenError. Reported by Ed Schofield
782 <schofield-AT-ftw.at>.
794 <schofield-AT-ftw.at>.
783
795
784 2005-05-06 Fernando Perez <fperez@colorado.edu>
796 2005-05-06 Fernando Perez <fperez@colorado.edu>
785
797
786 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
798 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
787
799
788 2005-04-29 Fernando Perez <fperez@colorado.edu>
800 2005-04-29 Fernando Perez <fperez@colorado.edu>
789
801
790 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
802 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
791 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
803 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
792 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
804 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
793 which provides support for Qt interactive usage (similar to the
805 which provides support for Qt interactive usage (similar to the
794 existing one for WX and GTK). This had been often requested.
806 existing one for WX and GTK). This had been often requested.
795
807
796 2005-04-14 *** Released version 0.6.13
808 2005-04-14 *** Released version 0.6.13
797
809
798 2005-04-08 Fernando Perez <fperez@colorado.edu>
810 2005-04-08 Fernando Perez <fperez@colorado.edu>
799
811
800 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
812 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
801 from _ofind, which gets called on almost every input line. Now,
813 from _ofind, which gets called on almost every input line. Now,
802 we only try to get docstrings if they are actually going to be
814 we only try to get docstrings if they are actually going to be
803 used (the overhead of fetching unnecessary docstrings can be
815 used (the overhead of fetching unnecessary docstrings can be
804 noticeable for certain objects, such as Pyro proxies).
816 noticeable for certain objects, such as Pyro proxies).
805
817
806 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
818 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
807 for completers. For some reason I had been passing them the state
819 for completers. For some reason I had been passing them the state
808 variable, which completers never actually need, and was in
820 variable, which completers never actually need, and was in
809 conflict with the rlcompleter API. Custom completers ONLY need to
821 conflict with the rlcompleter API. Custom completers ONLY need to
810 take the text parameter.
822 take the text parameter.
811
823
812 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
824 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
813 work correctly in pysh. I've also moved all the logic which used
825 work correctly in pysh. I've also moved all the logic which used
814 to be in pysh.py here, which will prevent problems with future
826 to be in pysh.py here, which will prevent problems with future
815 upgrades. However, this time I must warn users to update their
827 upgrades. However, this time I must warn users to update their
816 pysh profile to include the line
828 pysh profile to include the line
817
829
818 import_all IPython.Extensions.InterpreterExec
830 import_all IPython.Extensions.InterpreterExec
819
831
820 because otherwise things won't work for them. They MUST also
832 because otherwise things won't work for them. They MUST also
821 delete pysh.py and the line
833 delete pysh.py and the line
822
834
823 execfile pysh.py
835 execfile pysh.py
824
836
825 from their ipythonrc-pysh.
837 from their ipythonrc-pysh.
826
838
827 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
839 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
828 robust in the face of objects whose dir() returns non-strings
840 robust in the face of objects whose dir() returns non-strings
829 (which it shouldn't, but some broken libs like ITK do). Thanks to
841 (which it shouldn't, but some broken libs like ITK do). Thanks to
830 a patch by John Hunter (implemented differently, though). Also
842 a patch by John Hunter (implemented differently, though). Also
831 minor improvements by using .extend instead of + on lists.
843 minor improvements by using .extend instead of + on lists.
832
844
833 * pysh.py:
845 * pysh.py:
834
846
835 2005-04-06 Fernando Perez <fperez@colorado.edu>
847 2005-04-06 Fernando Perez <fperez@colorado.edu>
836
848
837 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
849 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
838 by default, so that all users benefit from it. Those who don't
850 by default, so that all users benefit from it. Those who don't
839 want it can still turn it off.
851 want it can still turn it off.
840
852
841 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
853 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
842 config file, I'd forgotten about this, so users were getting it
854 config file, I'd forgotten about this, so users were getting it
843 off by default.
855 off by default.
844
856
845 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
857 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
846 consistency. Now magics can be called in multiline statements,
858 consistency. Now magics can be called in multiline statements,
847 and python variables can be expanded in magic calls via $var.
859 and python variables can be expanded in magic calls via $var.
848 This makes the magic system behave just like aliases or !system
860 This makes the magic system behave just like aliases or !system
849 calls.
861 calls.
850
862
851 2005-03-28 Fernando Perez <fperez@colorado.edu>
863 2005-03-28 Fernando Perez <fperez@colorado.edu>
852
864
853 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
865 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
854 expensive string additions for building command. Add support for
866 expensive string additions for building command. Add support for
855 trailing ';' when autocall is used.
867 trailing ';' when autocall is used.
856
868
857 2005-03-26 Fernando Perez <fperez@colorado.edu>
869 2005-03-26 Fernando Perez <fperez@colorado.edu>
858
870
859 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
871 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
860 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
872 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
861 ipython.el robust against prompts with any number of spaces
873 ipython.el robust against prompts with any number of spaces
862 (including 0) after the ':' character.
874 (including 0) after the ':' character.
863
875
864 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
876 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
865 continuation prompt, which misled users to think the line was
877 continuation prompt, which misled users to think the line was
866 already indented. Closes debian Bug#300847, reported to me by
878 already indented. Closes debian Bug#300847, reported to me by
867 Norbert Tretkowski <tretkowski-AT-inittab.de>.
879 Norbert Tretkowski <tretkowski-AT-inittab.de>.
868
880
869 2005-03-23 Fernando Perez <fperez@colorado.edu>
881 2005-03-23 Fernando Perez <fperez@colorado.edu>
870
882
871 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
883 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
872 properly aligned if they have embedded newlines.
884 properly aligned if they have embedded newlines.
873
885
874 * IPython/iplib.py (runlines): Add a public method to expose
886 * IPython/iplib.py (runlines): Add a public method to expose
875 IPython's code execution machinery, so that users can run strings
887 IPython's code execution machinery, so that users can run strings
876 as if they had been typed at the prompt interactively.
888 as if they had been typed at the prompt interactively.
877 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
889 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
878 methods which can call the system shell, but with python variable
890 methods which can call the system shell, but with python variable
879 expansion. The three such methods are: __IPYTHON__.system,
891 expansion. The three such methods are: __IPYTHON__.system,
880 .getoutput and .getoutputerror. These need to be documented in a
892 .getoutput and .getoutputerror. These need to be documented in a
881 'public API' section (to be written) of the manual.
893 'public API' section (to be written) of the manual.
882
894
883 2005-03-20 Fernando Perez <fperez@colorado.edu>
895 2005-03-20 Fernando Perez <fperez@colorado.edu>
884
896
885 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
897 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
886 for custom exception handling. This is quite powerful, and it
898 for custom exception handling. This is quite powerful, and it
887 allows for user-installable exception handlers which can trap
899 allows for user-installable exception handlers which can trap
888 custom exceptions at runtime and treat them separately from
900 custom exceptions at runtime and treat them separately from
889 IPython's default mechanisms. At the request of Frédéric
901 IPython's default mechanisms. At the request of Frédéric
890 Mantegazza <mantegazza-AT-ill.fr>.
902 Mantegazza <mantegazza-AT-ill.fr>.
891 (InteractiveShell.set_custom_completer): public API function to
903 (InteractiveShell.set_custom_completer): public API function to
892 add new completers at runtime.
904 add new completers at runtime.
893
905
894 2005-03-19 Fernando Perez <fperez@colorado.edu>
906 2005-03-19 Fernando Perez <fperez@colorado.edu>
895
907
896 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
908 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
897 allow objects which provide their docstrings via non-standard
909 allow objects which provide their docstrings via non-standard
898 mechanisms (like Pyro proxies) to still be inspected by ipython's
910 mechanisms (like Pyro proxies) to still be inspected by ipython's
899 ? system.
911 ? system.
900
912
901 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
913 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
902 automatic capture system. I tried quite hard to make it work
914 automatic capture system. I tried quite hard to make it work
903 reliably, and simply failed. I tried many combinations with the
915 reliably, and simply failed. I tried many combinations with the
904 subprocess module, but eventually nothing worked in all needed
916 subprocess module, but eventually nothing worked in all needed
905 cases (not blocking stdin for the child, duplicating stdout
917 cases (not blocking stdin for the child, duplicating stdout
906 without blocking, etc). The new %sc/%sx still do capture to these
918 without blocking, etc). The new %sc/%sx still do capture to these
907 magical list/string objects which make shell use much more
919 magical list/string objects which make shell use much more
908 conveninent, so not all is lost.
920 conveninent, so not all is lost.
909
921
910 XXX - FIX MANUAL for the change above!
922 XXX - FIX MANUAL for the change above!
911
923
912 (runsource): I copied code.py's runsource() into ipython to modify
924 (runsource): I copied code.py's runsource() into ipython to modify
913 it a bit. Now the code object and source to be executed are
925 it a bit. Now the code object and source to be executed are
914 stored in ipython. This makes this info accessible to third-party
926 stored in ipython. This makes this info accessible to third-party
915 tools, like custom exception handlers. After a request by Frédéric
927 tools, like custom exception handlers. After a request by Frédéric
916 Mantegazza <mantegazza-AT-ill.fr>.
928 Mantegazza <mantegazza-AT-ill.fr>.
917
929
918 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
930 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
919 history-search via readline (like C-p/C-n). I'd wanted this for a
931 history-search via readline (like C-p/C-n). I'd wanted this for a
920 long time, but only recently found out how to do it. For users
932 long time, but only recently found out how to do it. For users
921 who already have their ipythonrc files made and want this, just
933 who already have their ipythonrc files made and want this, just
922 add:
934 add:
923
935
924 readline_parse_and_bind "\e[A": history-search-backward
936 readline_parse_and_bind "\e[A": history-search-backward
925 readline_parse_and_bind "\e[B": history-search-forward
937 readline_parse_and_bind "\e[B": history-search-forward
926
938
927 2005-03-18 Fernando Perez <fperez@colorado.edu>
939 2005-03-18 Fernando Perez <fperez@colorado.edu>
928
940
929 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
941 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
930 LSString and SList classes which allow transparent conversions
942 LSString and SList classes which allow transparent conversions
931 between list mode and whitespace-separated string.
943 between list mode and whitespace-separated string.
932 (magic_r): Fix recursion problem in %r.
944 (magic_r): Fix recursion problem in %r.
933
945
934 * IPython/genutils.py (LSString): New class to be used for
946 * IPython/genutils.py (LSString): New class to be used for
935 automatic storage of the results of all alias/system calls in _o
947 automatic storage of the results of all alias/system calls in _o
936 and _e (stdout/err). These provide a .l/.list attribute which
948 and _e (stdout/err). These provide a .l/.list attribute which
937 does automatic splitting on newlines. This means that for most
949 does automatic splitting on newlines. This means that for most
938 uses, you'll never need to do capturing of output with %sc/%sx
950 uses, you'll never need to do capturing of output with %sc/%sx
939 anymore, since ipython keeps this always done for you. Note that
951 anymore, since ipython keeps this always done for you. Note that
940 only the LAST results are stored, the _o/e variables are
952 only the LAST results are stored, the _o/e variables are
941 overwritten on each call. If you need to save their contents
953 overwritten on each call. If you need to save their contents
942 further, simply bind them to any other name.
954 further, simply bind them to any other name.
943
955
944 2005-03-17 Fernando Perez <fperez@colorado.edu>
956 2005-03-17 Fernando Perez <fperez@colorado.edu>
945
957
946 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
958 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
947 prompt namespace handling.
959 prompt namespace handling.
948
960
949 2005-03-16 Fernando Perez <fperez@colorado.edu>
961 2005-03-16 Fernando Perez <fperez@colorado.edu>
950
962
951 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
963 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
952 classic prompts to be '>>> ' (final space was missing, and it
964 classic prompts to be '>>> ' (final space was missing, and it
953 trips the emacs python mode).
965 trips the emacs python mode).
954 (BasePrompt.__str__): Added safe support for dynamic prompt
966 (BasePrompt.__str__): Added safe support for dynamic prompt
955 strings. Now you can set your prompt string to be '$x', and the
967 strings. Now you can set your prompt string to be '$x', and the
956 value of x will be printed from your interactive namespace. The
968 value of x will be printed from your interactive namespace. The
957 interpolation syntax includes the full Itpl support, so
969 interpolation syntax includes the full Itpl support, so
958 ${foo()+x+bar()} is a valid prompt string now, and the function
970 ${foo()+x+bar()} is a valid prompt string now, and the function
959 calls will be made at runtime.
971 calls will be made at runtime.
960
972
961 2005-03-15 Fernando Perez <fperez@colorado.edu>
973 2005-03-15 Fernando Perez <fperez@colorado.edu>
962
974
963 * IPython/Magic.py (magic_history): renamed %hist to %history, to
975 * IPython/Magic.py (magic_history): renamed %hist to %history, to
964 avoid name clashes in pylab. %hist still works, it just forwards
976 avoid name clashes in pylab. %hist still works, it just forwards
965 the call to %history.
977 the call to %history.
966
978
967 2005-03-02 *** Released version 0.6.12
979 2005-03-02 *** Released version 0.6.12
968
980
969 2005-03-02 Fernando Perez <fperez@colorado.edu>
981 2005-03-02 Fernando Perez <fperez@colorado.edu>
970
982
971 * IPython/iplib.py (handle_magic): log magic calls properly as
983 * IPython/iplib.py (handle_magic): log magic calls properly as
972 ipmagic() function calls.
984 ipmagic() function calls.
973
985
974 * IPython/Magic.py (magic_time): Improved %time to support
986 * IPython/Magic.py (magic_time): Improved %time to support
975 statements and provide wall-clock as well as CPU time.
987 statements and provide wall-clock as well as CPU time.
976
988
977 2005-02-27 Fernando Perez <fperez@colorado.edu>
989 2005-02-27 Fernando Perez <fperez@colorado.edu>
978
990
979 * IPython/hooks.py: New hooks module, to expose user-modifiable
991 * IPython/hooks.py: New hooks module, to expose user-modifiable
980 IPython functionality in a clean manner. For now only the editor
992 IPython functionality in a clean manner. For now only the editor
981 hook is actually written, and other thigns which I intend to turn
993 hook is actually written, and other thigns which I intend to turn
982 into proper hooks aren't yet there. The display and prefilter
994 into proper hooks aren't yet there. The display and prefilter
983 stuff, for example, should be hooks. But at least now the
995 stuff, for example, should be hooks. But at least now the
984 framework is in place, and the rest can be moved here with more
996 framework is in place, and the rest can be moved here with more
985 time later. IPython had had a .hooks variable for a long time for
997 time later. IPython had had a .hooks variable for a long time for
986 this purpose, but I'd never actually used it for anything.
998 this purpose, but I'd never actually used it for anything.
987
999
988 2005-02-26 Fernando Perez <fperez@colorado.edu>
1000 2005-02-26 Fernando Perez <fperez@colorado.edu>
989
1001
990 * IPython/ipmaker.py (make_IPython): make the default ipython
1002 * IPython/ipmaker.py (make_IPython): make the default ipython
991 directory be called _ipython under win32, to follow more the
1003 directory be called _ipython under win32, to follow more the
992 naming peculiarities of that platform (where buggy software like
1004 naming peculiarities of that platform (where buggy software like
993 Visual Sourcesafe breaks with .named directories). Reported by
1005 Visual Sourcesafe breaks with .named directories). Reported by
994 Ville Vainio.
1006 Ville Vainio.
995
1007
996 2005-02-23 Fernando Perez <fperez@colorado.edu>
1008 2005-02-23 Fernando Perez <fperez@colorado.edu>
997
1009
998 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1010 * IPython/iplib.py (InteractiveShell.__init__): removed a few
999 auto_aliases for win32 which were causing problems. Users can
1011 auto_aliases for win32 which were causing problems. Users can
1000 define the ones they personally like.
1012 define the ones they personally like.
1001
1013
1002 2005-02-21 Fernando Perez <fperez@colorado.edu>
1014 2005-02-21 Fernando Perez <fperez@colorado.edu>
1003
1015
1004 * IPython/Magic.py (magic_time): new magic to time execution of
1016 * IPython/Magic.py (magic_time): new magic to time execution of
1005 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1017 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1006
1018
1007 2005-02-19 Fernando Perez <fperez@colorado.edu>
1019 2005-02-19 Fernando Perez <fperez@colorado.edu>
1008
1020
1009 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1021 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1010 into keys (for prompts, for example).
1022 into keys (for prompts, for example).
1011
1023
1012 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1024 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1013 prompts in case users want them. This introduces a small behavior
1025 prompts in case users want them. This introduces a small behavior
1014 change: ipython does not automatically add a space to all prompts
1026 change: ipython does not automatically add a space to all prompts
1015 anymore. To get the old prompts with a space, users should add it
1027 anymore. To get the old prompts with a space, users should add it
1016 manually to their ipythonrc file, so for example prompt_in1 should
1028 manually to their ipythonrc file, so for example prompt_in1 should
1017 now read 'In [\#]: ' instead of 'In [\#]:'.
1029 now read 'In [\#]: ' instead of 'In [\#]:'.
1018 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1030 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1019 file) to control left-padding of secondary prompts.
1031 file) to control left-padding of secondary prompts.
1020
1032
1021 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1033 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1022 the profiler can't be imported. Fix for Debian, which removed
1034 the profiler can't be imported. Fix for Debian, which removed
1023 profile.py because of License issues. I applied a slightly
1035 profile.py because of License issues. I applied a slightly
1024 modified version of the original Debian patch at
1036 modified version of the original Debian patch at
1025 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1037 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1026
1038
1027 2005-02-17 Fernando Perez <fperez@colorado.edu>
1039 2005-02-17 Fernando Perez <fperez@colorado.edu>
1028
1040
1029 * IPython/genutils.py (native_line_ends): Fix bug which would
1041 * IPython/genutils.py (native_line_ends): Fix bug which would
1030 cause improper line-ends under win32 b/c I was not opening files
1042 cause improper line-ends under win32 b/c I was not opening files
1031 in binary mode. Bug report and fix thanks to Ville.
1043 in binary mode. Bug report and fix thanks to Ville.
1032
1044
1033 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1045 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1034 trying to catch spurious foo[1] autocalls. My fix actually broke
1046 trying to catch spurious foo[1] autocalls. My fix actually broke
1035 ',/' autoquote/call with explicit escape (bad regexp).
1047 ',/' autoquote/call with explicit escape (bad regexp).
1036
1048
1037 2005-02-15 *** Released version 0.6.11
1049 2005-02-15 *** Released version 0.6.11
1038
1050
1039 2005-02-14 Fernando Perez <fperez@colorado.edu>
1051 2005-02-14 Fernando Perez <fperez@colorado.edu>
1040
1052
1041 * IPython/background_jobs.py: New background job management
1053 * IPython/background_jobs.py: New background job management
1042 subsystem. This is implemented via a new set of classes, and
1054 subsystem. This is implemented via a new set of classes, and
1043 IPython now provides a builtin 'jobs' object for background job
1055 IPython now provides a builtin 'jobs' object for background job
1044 execution. A convenience %bg magic serves as a lightweight
1056 execution. A convenience %bg magic serves as a lightweight
1045 frontend for starting the more common type of calls. This was
1057 frontend for starting the more common type of calls. This was
1046 inspired by discussions with B. Granger and the BackgroundCommand
1058 inspired by discussions with B. Granger and the BackgroundCommand
1047 class described in the book Python Scripting for Computational
1059 class described in the book Python Scripting for Computational
1048 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1060 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1049 (although ultimately no code from this text was used, as IPython's
1061 (although ultimately no code from this text was used, as IPython's
1050 system is a separate implementation).
1062 system is a separate implementation).
1051
1063
1052 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1064 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1053 to control the completion of single/double underscore names
1065 to control the completion of single/double underscore names
1054 separately. As documented in the example ipytonrc file, the
1066 separately. As documented in the example ipytonrc file, the
1055 readline_omit__names variable can now be set to 2, to omit even
1067 readline_omit__names variable can now be set to 2, to omit even
1056 single underscore names. Thanks to a patch by Brian Wong
1068 single underscore names. Thanks to a patch by Brian Wong
1057 <BrianWong-AT-AirgoNetworks.Com>.
1069 <BrianWong-AT-AirgoNetworks.Com>.
1058 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1070 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1059 be autocalled as foo([1]) if foo were callable. A problem for
1071 be autocalled as foo([1]) if foo were callable. A problem for
1060 things which are both callable and implement __getitem__.
1072 things which are both callable and implement __getitem__.
1061 (init_readline): Fix autoindentation for win32. Thanks to a patch
1073 (init_readline): Fix autoindentation for win32. Thanks to a patch
1062 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1074 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1063
1075
1064 2005-02-12 Fernando Perez <fperez@colorado.edu>
1076 2005-02-12 Fernando Perez <fperez@colorado.edu>
1065
1077
1066 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1078 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1067 which I had written long ago to sort out user error messages which
1079 which I had written long ago to sort out user error messages which
1068 may occur during startup. This seemed like a good idea initially,
1080 may occur during startup. This seemed like a good idea initially,
1069 but it has proven a disaster in retrospect. I don't want to
1081 but it has proven a disaster in retrospect. I don't want to
1070 change much code for now, so my fix is to set the internal 'debug'
1082 change much code for now, so my fix is to set the internal 'debug'
1071 flag to true everywhere, whose only job was precisely to control
1083 flag to true everywhere, whose only job was precisely to control
1072 this subsystem. This closes issue 28 (as well as avoiding all
1084 this subsystem. This closes issue 28 (as well as avoiding all
1073 sorts of strange hangups which occur from time to time).
1085 sorts of strange hangups which occur from time to time).
1074
1086
1075 2005-02-07 Fernando Perez <fperez@colorado.edu>
1087 2005-02-07 Fernando Perez <fperez@colorado.edu>
1076
1088
1077 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1089 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1078 previous call produced a syntax error.
1090 previous call produced a syntax error.
1079
1091
1080 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1092 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1081 classes without constructor.
1093 classes without constructor.
1082
1094
1083 2005-02-06 Fernando Perez <fperez@colorado.edu>
1095 2005-02-06 Fernando Perez <fperez@colorado.edu>
1084
1096
1085 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1097 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1086 completions with the results of each matcher, so we return results
1098 completions with the results of each matcher, so we return results
1087 to the user from all namespaces. This breaks with ipython
1099 to the user from all namespaces. This breaks with ipython
1088 tradition, but I think it's a nicer behavior. Now you get all
1100 tradition, but I think it's a nicer behavior. Now you get all
1089 possible completions listed, from all possible namespaces (python,
1101 possible completions listed, from all possible namespaces (python,
1090 filesystem, magics...) After a request by John Hunter
1102 filesystem, magics...) After a request by John Hunter
1091 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1103 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1092
1104
1093 2005-02-05 Fernando Perez <fperez@colorado.edu>
1105 2005-02-05 Fernando Perez <fperez@colorado.edu>
1094
1106
1095 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1107 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1096 the call had quote characters in it (the quotes were stripped).
1108 the call had quote characters in it (the quotes were stripped).
1097
1109
1098 2005-01-31 Fernando Perez <fperez@colorado.edu>
1110 2005-01-31 Fernando Perez <fperez@colorado.edu>
1099
1111
1100 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1112 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1101 Itpl.itpl() to make the code more robust against psyco
1113 Itpl.itpl() to make the code more robust against psyco
1102 optimizations.
1114 optimizations.
1103
1115
1104 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1116 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1105 of causing an exception. Quicker, cleaner.
1117 of causing an exception. Quicker, cleaner.
1106
1118
1107 2005-01-28 Fernando Perez <fperez@colorado.edu>
1119 2005-01-28 Fernando Perez <fperez@colorado.edu>
1108
1120
1109 * scripts/ipython_win_post_install.py (install): hardcode
1121 * scripts/ipython_win_post_install.py (install): hardcode
1110 sys.prefix+'python.exe' as the executable path. It turns out that
1122 sys.prefix+'python.exe' as the executable path. It turns out that
1111 during the post-installation run, sys.executable resolves to the
1123 during the post-installation run, sys.executable resolves to the
1112 name of the binary installer! I should report this as a distutils
1124 name of the binary installer! I should report this as a distutils
1113 bug, I think. I updated the .10 release with this tiny fix, to
1125 bug, I think. I updated the .10 release with this tiny fix, to
1114 avoid annoying the lists further.
1126 avoid annoying the lists further.
1115
1127
1116 2005-01-27 *** Released version 0.6.10
1128 2005-01-27 *** Released version 0.6.10
1117
1129
1118 2005-01-27 Fernando Perez <fperez@colorado.edu>
1130 2005-01-27 Fernando Perez <fperez@colorado.edu>
1119
1131
1120 * IPython/numutils.py (norm): Added 'inf' as optional name for
1132 * IPython/numutils.py (norm): Added 'inf' as optional name for
1121 L-infinity norm, included references to mathworld.com for vector
1133 L-infinity norm, included references to mathworld.com for vector
1122 norm definitions.
1134 norm definitions.
1123 (amin/amax): added amin/amax for array min/max. Similar to what
1135 (amin/amax): added amin/amax for array min/max. Similar to what
1124 pylab ships with after the recent reorganization of names.
1136 pylab ships with after the recent reorganization of names.
1125 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1137 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1126
1138
1127 * ipython.el: committed Alex's recent fixes and improvements.
1139 * ipython.el: committed Alex's recent fixes and improvements.
1128 Tested with python-mode from CVS, and it looks excellent. Since
1140 Tested with python-mode from CVS, and it looks excellent. Since
1129 python-mode hasn't released anything in a while, I'm temporarily
1141 python-mode hasn't released anything in a while, I'm temporarily
1130 putting a copy of today's CVS (v 4.70) of python-mode in:
1142 putting a copy of today's CVS (v 4.70) of python-mode in:
1131 http://ipython.scipy.org/tmp/python-mode.el
1143 http://ipython.scipy.org/tmp/python-mode.el
1132
1144
1133 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1145 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1134 sys.executable for the executable name, instead of assuming it's
1146 sys.executable for the executable name, instead of assuming it's
1135 called 'python.exe' (the post-installer would have produced broken
1147 called 'python.exe' (the post-installer would have produced broken
1136 setups on systems with a differently named python binary).
1148 setups on systems with a differently named python binary).
1137
1149
1138 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1150 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1139 references to os.linesep, to make the code more
1151 references to os.linesep, to make the code more
1140 platform-independent. This is also part of the win32 coloring
1152 platform-independent. This is also part of the win32 coloring
1141 fixes.
1153 fixes.
1142
1154
1143 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1155 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1144 lines, which actually cause coloring bugs because the length of
1156 lines, which actually cause coloring bugs because the length of
1145 the line is very difficult to correctly compute with embedded
1157 the line is very difficult to correctly compute with embedded
1146 escapes. This was the source of all the coloring problems under
1158 escapes. This was the source of all the coloring problems under
1147 Win32. I think that _finally_, Win32 users have a properly
1159 Win32. I think that _finally_, Win32 users have a properly
1148 working ipython in all respects. This would never have happened
1160 working ipython in all respects. This would never have happened
1149 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1161 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1150
1162
1151 2005-01-26 *** Released version 0.6.9
1163 2005-01-26 *** Released version 0.6.9
1152
1164
1153 2005-01-25 Fernando Perez <fperez@colorado.edu>
1165 2005-01-25 Fernando Perez <fperez@colorado.edu>
1154
1166
1155 * setup.py: finally, we have a true Windows installer, thanks to
1167 * setup.py: finally, we have a true Windows installer, thanks to
1156 the excellent work of Viktor Ransmayr
1168 the excellent work of Viktor Ransmayr
1157 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1169 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1158 Windows users. The setup routine is quite a bit cleaner thanks to
1170 Windows users. The setup routine is quite a bit cleaner thanks to
1159 this, and the post-install script uses the proper functions to
1171 this, and the post-install script uses the proper functions to
1160 allow a clean de-installation using the standard Windows Control
1172 allow a clean de-installation using the standard Windows Control
1161 Panel.
1173 Panel.
1162
1174
1163 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1175 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1164 environment variable under all OSes (including win32) if
1176 environment variable under all OSes (including win32) if
1165 available. This will give consistency to win32 users who have set
1177 available. This will give consistency to win32 users who have set
1166 this variable for any reason. If os.environ['HOME'] fails, the
1178 this variable for any reason. If os.environ['HOME'] fails, the
1167 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1179 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1168
1180
1169 2005-01-24 Fernando Perez <fperez@colorado.edu>
1181 2005-01-24 Fernando Perez <fperez@colorado.edu>
1170
1182
1171 * IPython/numutils.py (empty_like): add empty_like(), similar to
1183 * IPython/numutils.py (empty_like): add empty_like(), similar to
1172 zeros_like() but taking advantage of the new empty() Numeric routine.
1184 zeros_like() but taking advantage of the new empty() Numeric routine.
1173
1185
1174 2005-01-23 *** Released version 0.6.8
1186 2005-01-23 *** Released version 0.6.8
1175
1187
1176 2005-01-22 Fernando Perez <fperez@colorado.edu>
1188 2005-01-22 Fernando Perez <fperez@colorado.edu>
1177
1189
1178 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1190 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1179 automatic show() calls. After discussing things with JDH, it
1191 automatic show() calls. After discussing things with JDH, it
1180 turns out there are too many corner cases where this can go wrong.
1192 turns out there are too many corner cases where this can go wrong.
1181 It's best not to try to be 'too smart', and simply have ipython
1193 It's best not to try to be 'too smart', and simply have ipython
1182 reproduce as much as possible the default behavior of a normal
1194 reproduce as much as possible the default behavior of a normal
1183 python shell.
1195 python shell.
1184
1196
1185 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1197 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1186 line-splitting regexp and _prefilter() to avoid calling getattr()
1198 line-splitting regexp and _prefilter() to avoid calling getattr()
1187 on assignments. This closes
1199 on assignments. This closes
1188 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1200 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1189 readline uses getattr(), so a simple <TAB> keypress is still
1201 readline uses getattr(), so a simple <TAB> keypress is still
1190 enough to trigger getattr() calls on an object.
1202 enough to trigger getattr() calls on an object.
1191
1203
1192 2005-01-21 Fernando Perez <fperez@colorado.edu>
1204 2005-01-21 Fernando Perez <fperez@colorado.edu>
1193
1205
1194 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1206 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1195 docstring under pylab so it doesn't mask the original.
1207 docstring under pylab so it doesn't mask the original.
1196
1208
1197 2005-01-21 *** Released version 0.6.7
1209 2005-01-21 *** Released version 0.6.7
1198
1210
1199 2005-01-21 Fernando Perez <fperez@colorado.edu>
1211 2005-01-21 Fernando Perez <fperez@colorado.edu>
1200
1212
1201 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1213 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1202 signal handling for win32 users in multithreaded mode.
1214 signal handling for win32 users in multithreaded mode.
1203
1215
1204 2005-01-17 Fernando Perez <fperez@colorado.edu>
1216 2005-01-17 Fernando Perez <fperez@colorado.edu>
1205
1217
1206 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1218 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1207 instances with no __init__. After a crash report by Norbert Nemec
1219 instances with no __init__. After a crash report by Norbert Nemec
1208 <Norbert-AT-nemec-online.de>.
1220 <Norbert-AT-nemec-online.de>.
1209
1221
1210 2005-01-14 Fernando Perez <fperez@colorado.edu>
1222 2005-01-14 Fernando Perez <fperez@colorado.edu>
1211
1223
1212 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1224 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1213 names for verbose exceptions, when multiple dotted names and the
1225 names for verbose exceptions, when multiple dotted names and the
1214 'parent' object were present on the same line.
1226 'parent' object were present on the same line.
1215
1227
1216 2005-01-11 Fernando Perez <fperez@colorado.edu>
1228 2005-01-11 Fernando Perez <fperez@colorado.edu>
1217
1229
1218 * IPython/genutils.py (flag_calls): new utility to trap and flag
1230 * IPython/genutils.py (flag_calls): new utility to trap and flag
1219 calls in functions. I need it to clean up matplotlib support.
1231 calls in functions. I need it to clean up matplotlib support.
1220 Also removed some deprecated code in genutils.
1232 Also removed some deprecated code in genutils.
1221
1233
1222 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1234 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1223 that matplotlib scripts called with %run, which don't call show()
1235 that matplotlib scripts called with %run, which don't call show()
1224 themselves, still have their plotting windows open.
1236 themselves, still have their plotting windows open.
1225
1237
1226 2005-01-05 Fernando Perez <fperez@colorado.edu>
1238 2005-01-05 Fernando Perez <fperez@colorado.edu>
1227
1239
1228 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1240 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1229 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1241 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1230
1242
1231 2004-12-19 Fernando Perez <fperez@colorado.edu>
1243 2004-12-19 Fernando Perez <fperez@colorado.edu>
1232
1244
1233 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1245 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1234 parent_runcode, which was an eyesore. The same result can be
1246 parent_runcode, which was an eyesore. The same result can be
1235 obtained with Python's regular superclass mechanisms.
1247 obtained with Python's regular superclass mechanisms.
1236
1248
1237 2004-12-17 Fernando Perez <fperez@colorado.edu>
1249 2004-12-17 Fernando Perez <fperez@colorado.edu>
1238
1250
1239 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1251 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1240 reported by Prabhu.
1252 reported by Prabhu.
1241 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1253 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1242 sys.stderr) instead of explicitly calling sys.stderr. This helps
1254 sys.stderr) instead of explicitly calling sys.stderr. This helps
1243 maintain our I/O abstractions clean, for future GUI embeddings.
1255 maintain our I/O abstractions clean, for future GUI embeddings.
1244
1256
1245 * IPython/genutils.py (info): added new utility for sys.stderr
1257 * IPython/genutils.py (info): added new utility for sys.stderr
1246 unified info message handling (thin wrapper around warn()).
1258 unified info message handling (thin wrapper around warn()).
1247
1259
1248 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1260 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1249 composite (dotted) names on verbose exceptions.
1261 composite (dotted) names on verbose exceptions.
1250 (VerboseTB.nullrepr): harden against another kind of errors which
1262 (VerboseTB.nullrepr): harden against another kind of errors which
1251 Python's inspect module can trigger, and which were crashing
1263 Python's inspect module can trigger, and which were crashing
1252 IPython. Thanks to a report by Marco Lombardi
1264 IPython. Thanks to a report by Marco Lombardi
1253 <mlombard-AT-ma010192.hq.eso.org>.
1265 <mlombard-AT-ma010192.hq.eso.org>.
1254
1266
1255 2004-12-13 *** Released version 0.6.6
1267 2004-12-13 *** Released version 0.6.6
1256
1268
1257 2004-12-12 Fernando Perez <fperez@colorado.edu>
1269 2004-12-12 Fernando Perez <fperez@colorado.edu>
1258
1270
1259 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1271 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1260 generated by pygtk upon initialization if it was built without
1272 generated by pygtk upon initialization if it was built without
1261 threads (for matplotlib users). After a crash reported by
1273 threads (for matplotlib users). After a crash reported by
1262 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1274 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1263
1275
1264 * IPython/ipmaker.py (make_IPython): fix small bug in the
1276 * IPython/ipmaker.py (make_IPython): fix small bug in the
1265 import_some parameter for multiple imports.
1277 import_some parameter for multiple imports.
1266
1278
1267 * IPython/iplib.py (ipmagic): simplified the interface of
1279 * IPython/iplib.py (ipmagic): simplified the interface of
1268 ipmagic() to take a single string argument, just as it would be
1280 ipmagic() to take a single string argument, just as it would be
1269 typed at the IPython cmd line.
1281 typed at the IPython cmd line.
1270 (ipalias): Added new ipalias() with an interface identical to
1282 (ipalias): Added new ipalias() with an interface identical to
1271 ipmagic(). This completes exposing a pure python interface to the
1283 ipmagic(). This completes exposing a pure python interface to the
1272 alias and magic system, which can be used in loops or more complex
1284 alias and magic system, which can be used in loops or more complex
1273 code where IPython's automatic line mangling is not active.
1285 code where IPython's automatic line mangling is not active.
1274
1286
1275 * IPython/genutils.py (timing): changed interface of timing to
1287 * IPython/genutils.py (timing): changed interface of timing to
1276 simply run code once, which is the most common case. timings()
1288 simply run code once, which is the most common case. timings()
1277 remains unchanged, for the cases where you want multiple runs.
1289 remains unchanged, for the cases where you want multiple runs.
1278
1290
1279 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1291 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1280 bug where Python2.2 crashes with exec'ing code which does not end
1292 bug where Python2.2 crashes with exec'ing code which does not end
1281 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1293 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1282 before.
1294 before.
1283
1295
1284 2004-12-10 Fernando Perez <fperez@colorado.edu>
1296 2004-12-10 Fernando Perez <fperez@colorado.edu>
1285
1297
1286 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1298 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1287 -t to -T, to accomodate the new -t flag in %run (the %run and
1299 -t to -T, to accomodate the new -t flag in %run (the %run and
1288 %prun options are kind of intermixed, and it's not easy to change
1300 %prun options are kind of intermixed, and it's not easy to change
1289 this with the limitations of python's getopt).
1301 this with the limitations of python's getopt).
1290
1302
1291 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1303 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1292 the execution of scripts. It's not as fine-tuned as timeit.py,
1304 the execution of scripts. It's not as fine-tuned as timeit.py,
1293 but it works from inside ipython (and under 2.2, which lacks
1305 but it works from inside ipython (and under 2.2, which lacks
1294 timeit.py). Optionally a number of runs > 1 can be given for
1306 timeit.py). Optionally a number of runs > 1 can be given for
1295 timing very short-running code.
1307 timing very short-running code.
1296
1308
1297 * IPython/genutils.py (uniq_stable): new routine which returns a
1309 * IPython/genutils.py (uniq_stable): new routine which returns a
1298 list of unique elements in any iterable, but in stable order of
1310 list of unique elements in any iterable, but in stable order of
1299 appearance. I needed this for the ultraTB fixes, and it's a handy
1311 appearance. I needed this for the ultraTB fixes, and it's a handy
1300 utility.
1312 utility.
1301
1313
1302 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1314 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1303 dotted names in Verbose exceptions. This had been broken since
1315 dotted names in Verbose exceptions. This had been broken since
1304 the very start, now x.y will properly be printed in a Verbose
1316 the very start, now x.y will properly be printed in a Verbose
1305 traceback, instead of x being shown and y appearing always as an
1317 traceback, instead of x being shown and y appearing always as an
1306 'undefined global'. Getting this to work was a bit tricky,
1318 'undefined global'. Getting this to work was a bit tricky,
1307 because by default python tokenizers are stateless. Saved by
1319 because by default python tokenizers are stateless. Saved by
1308 python's ability to easily add a bit of state to an arbitrary
1320 python's ability to easily add a bit of state to an arbitrary
1309 function (without needing to build a full-blown callable object).
1321 function (without needing to build a full-blown callable object).
1310
1322
1311 Also big cleanup of this code, which had horrendous runtime
1323 Also big cleanup of this code, which had horrendous runtime
1312 lookups of zillions of attributes for colorization. Moved all
1324 lookups of zillions of attributes for colorization. Moved all
1313 this code into a few templates, which make it cleaner and quicker.
1325 this code into a few templates, which make it cleaner and quicker.
1314
1326
1315 Printout quality was also improved for Verbose exceptions: one
1327 Printout quality was also improved for Verbose exceptions: one
1316 variable per line, and memory addresses are printed (this can be
1328 variable per line, and memory addresses are printed (this can be
1317 quite handy in nasty debugging situations, which is what Verbose
1329 quite handy in nasty debugging situations, which is what Verbose
1318 is for).
1330 is for).
1319
1331
1320 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1332 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1321 the command line as scripts to be loaded by embedded instances.
1333 the command line as scripts to be loaded by embedded instances.
1322 Doing so has the potential for an infinite recursion if there are
1334 Doing so has the potential for an infinite recursion if there are
1323 exceptions thrown in the process. This fixes a strange crash
1335 exceptions thrown in the process. This fixes a strange crash
1324 reported by Philippe MULLER <muller-AT-irit.fr>.
1336 reported by Philippe MULLER <muller-AT-irit.fr>.
1325
1337
1326 2004-12-09 Fernando Perez <fperez@colorado.edu>
1338 2004-12-09 Fernando Perez <fperez@colorado.edu>
1327
1339
1328 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1340 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1329 to reflect new names in matplotlib, which now expose the
1341 to reflect new names in matplotlib, which now expose the
1330 matlab-compatible interface via a pylab module instead of the
1342 matlab-compatible interface via a pylab module instead of the
1331 'matlab' name. The new code is backwards compatible, so users of
1343 'matlab' name. The new code is backwards compatible, so users of
1332 all matplotlib versions are OK. Patch by J. Hunter.
1344 all matplotlib versions are OK. Patch by J. Hunter.
1333
1345
1334 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1346 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1335 of __init__ docstrings for instances (class docstrings are already
1347 of __init__ docstrings for instances (class docstrings are already
1336 automatically printed). Instances with customized docstrings
1348 automatically printed). Instances with customized docstrings
1337 (indep. of the class) are also recognized and all 3 separate
1349 (indep. of the class) are also recognized and all 3 separate
1338 docstrings are printed (instance, class, constructor). After some
1350 docstrings are printed (instance, class, constructor). After some
1339 comments/suggestions by J. Hunter.
1351 comments/suggestions by J. Hunter.
1340
1352
1341 2004-12-05 Fernando Perez <fperez@colorado.edu>
1353 2004-12-05 Fernando Perez <fperez@colorado.edu>
1342
1354
1343 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1355 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1344 warnings when tab-completion fails and triggers an exception.
1356 warnings when tab-completion fails and triggers an exception.
1345
1357
1346 2004-12-03 Fernando Perez <fperez@colorado.edu>
1358 2004-12-03 Fernando Perez <fperez@colorado.edu>
1347
1359
1348 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1360 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1349 be triggered when using 'run -p'. An incorrect option flag was
1361 be triggered when using 'run -p'. An incorrect option flag was
1350 being set ('d' instead of 'D').
1362 being set ('d' instead of 'D').
1351 (manpage): fix missing escaped \- sign.
1363 (manpage): fix missing escaped \- sign.
1352
1364
1353 2004-11-30 *** Released version 0.6.5
1365 2004-11-30 *** Released version 0.6.5
1354
1366
1355 2004-11-30 Fernando Perez <fperez@colorado.edu>
1367 2004-11-30 Fernando Perez <fperez@colorado.edu>
1356
1368
1357 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1369 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1358 setting with -d option.
1370 setting with -d option.
1359
1371
1360 * setup.py (docfiles): Fix problem where the doc glob I was using
1372 * setup.py (docfiles): Fix problem where the doc glob I was using
1361 was COMPLETELY BROKEN. It was giving the right files by pure
1373 was COMPLETELY BROKEN. It was giving the right files by pure
1362 accident, but failed once I tried to include ipython.el. Note:
1374 accident, but failed once I tried to include ipython.el. Note:
1363 glob() does NOT allow you to do exclusion on multiple endings!
1375 glob() does NOT allow you to do exclusion on multiple endings!
1364
1376
1365 2004-11-29 Fernando Perez <fperez@colorado.edu>
1377 2004-11-29 Fernando Perez <fperez@colorado.edu>
1366
1378
1367 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1379 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1368 the manpage as the source. Better formatting & consistency.
1380 the manpage as the source. Better formatting & consistency.
1369
1381
1370 * IPython/Magic.py (magic_run): Added new -d option, to run
1382 * IPython/Magic.py (magic_run): Added new -d option, to run
1371 scripts under the control of the python pdb debugger. Note that
1383 scripts under the control of the python pdb debugger. Note that
1372 this required changing the %prun option -d to -D, to avoid a clash
1384 this required changing the %prun option -d to -D, to avoid a clash
1373 (since %run must pass options to %prun, and getopt is too dumb to
1385 (since %run must pass options to %prun, and getopt is too dumb to
1374 handle options with string values with embedded spaces). Thanks
1386 handle options with string values with embedded spaces). Thanks
1375 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1387 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1376 (magic_who_ls): added type matching to %who and %whos, so that one
1388 (magic_who_ls): added type matching to %who and %whos, so that one
1377 can filter their output to only include variables of certain
1389 can filter their output to only include variables of certain
1378 types. Another suggestion by Matthew.
1390 types. Another suggestion by Matthew.
1379 (magic_whos): Added memory summaries in kb and Mb for arrays.
1391 (magic_whos): Added memory summaries in kb and Mb for arrays.
1380 (magic_who): Improve formatting (break lines every 9 vars).
1392 (magic_who): Improve formatting (break lines every 9 vars).
1381
1393
1382 2004-11-28 Fernando Perez <fperez@colorado.edu>
1394 2004-11-28 Fernando Perez <fperez@colorado.edu>
1383
1395
1384 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1396 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1385 cache when empty lines were present.
1397 cache when empty lines were present.
1386
1398
1387 2004-11-24 Fernando Perez <fperez@colorado.edu>
1399 2004-11-24 Fernando Perez <fperez@colorado.edu>
1388
1400
1389 * IPython/usage.py (__doc__): document the re-activated threading
1401 * IPython/usage.py (__doc__): document the re-activated threading
1390 options for WX and GTK.
1402 options for WX and GTK.
1391
1403
1392 2004-11-23 Fernando Perez <fperez@colorado.edu>
1404 2004-11-23 Fernando Perez <fperez@colorado.edu>
1393
1405
1394 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1406 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1395 the -wthread and -gthread options, along with a new -tk one to try
1407 the -wthread and -gthread options, along with a new -tk one to try
1396 and coordinate Tk threading with wx/gtk. The tk support is very
1408 and coordinate Tk threading with wx/gtk. The tk support is very
1397 platform dependent, since it seems to require Tcl and Tk to be
1409 platform dependent, since it seems to require Tcl and Tk to be
1398 built with threads (Fedora1/2 appears NOT to have it, but in
1410 built with threads (Fedora1/2 appears NOT to have it, but in
1399 Prabhu's Debian boxes it works OK). But even with some Tk
1411 Prabhu's Debian boxes it works OK). But even with some Tk
1400 limitations, this is a great improvement.
1412 limitations, this is a great improvement.
1401
1413
1402 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1414 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1403 info in user prompts. Patch by Prabhu.
1415 info in user prompts. Patch by Prabhu.
1404
1416
1405 2004-11-18 Fernando Perez <fperez@colorado.edu>
1417 2004-11-18 Fernando Perez <fperez@colorado.edu>
1406
1418
1407 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1419 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1408 EOFErrors and bail, to avoid infinite loops if a non-terminating
1420 EOFErrors and bail, to avoid infinite loops if a non-terminating
1409 file is fed into ipython. Patch submitted in issue 19 by user,
1421 file is fed into ipython. Patch submitted in issue 19 by user,
1410 many thanks.
1422 many thanks.
1411
1423
1412 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1424 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1413 autoquote/parens in continuation prompts, which can cause lots of
1425 autoquote/parens in continuation prompts, which can cause lots of
1414 problems. Closes roundup issue 20.
1426 problems. Closes roundup issue 20.
1415
1427
1416 2004-11-17 Fernando Perez <fperez@colorado.edu>
1428 2004-11-17 Fernando Perez <fperez@colorado.edu>
1417
1429
1418 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1430 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1419 reported as debian bug #280505. I'm not sure my local changelog
1431 reported as debian bug #280505. I'm not sure my local changelog
1420 entry has the proper debian format (Jack?).
1432 entry has the proper debian format (Jack?).
1421
1433
1422 2004-11-08 *** Released version 0.6.4
1434 2004-11-08 *** Released version 0.6.4
1423
1435
1424 2004-11-08 Fernando Perez <fperez@colorado.edu>
1436 2004-11-08 Fernando Perez <fperez@colorado.edu>
1425
1437
1426 * IPython/iplib.py (init_readline): Fix exit message for Windows
1438 * IPython/iplib.py (init_readline): Fix exit message for Windows
1427 when readline is active. Thanks to a report by Eric Jones
1439 when readline is active. Thanks to a report by Eric Jones
1428 <eric-AT-enthought.com>.
1440 <eric-AT-enthought.com>.
1429
1441
1430 2004-11-07 Fernando Perez <fperez@colorado.edu>
1442 2004-11-07 Fernando Perez <fperez@colorado.edu>
1431
1443
1432 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1444 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1433 sometimes seen by win2k/cygwin users.
1445 sometimes seen by win2k/cygwin users.
1434
1446
1435 2004-11-06 Fernando Perez <fperez@colorado.edu>
1447 2004-11-06 Fernando Perez <fperez@colorado.edu>
1436
1448
1437 * IPython/iplib.py (interact): Change the handling of %Exit from
1449 * IPython/iplib.py (interact): Change the handling of %Exit from
1438 trying to propagate a SystemExit to an internal ipython flag.
1450 trying to propagate a SystemExit to an internal ipython flag.
1439 This is less elegant than using Python's exception mechanism, but
1451 This is less elegant than using Python's exception mechanism, but
1440 I can't get that to work reliably with threads, so under -pylab
1452 I can't get that to work reliably with threads, so under -pylab
1441 %Exit was hanging IPython. Cross-thread exception handling is
1453 %Exit was hanging IPython. Cross-thread exception handling is
1442 really a bitch. Thaks to a bug report by Stephen Walton
1454 really a bitch. Thaks to a bug report by Stephen Walton
1443 <stephen.walton-AT-csun.edu>.
1455 <stephen.walton-AT-csun.edu>.
1444
1456
1445 2004-11-04 Fernando Perez <fperez@colorado.edu>
1457 2004-11-04 Fernando Perez <fperez@colorado.edu>
1446
1458
1447 * IPython/iplib.py (raw_input_original): store a pointer to the
1459 * IPython/iplib.py (raw_input_original): store a pointer to the
1448 true raw_input to harden against code which can modify it
1460 true raw_input to harden against code which can modify it
1449 (wx.py.PyShell does this and would otherwise crash ipython).
1461 (wx.py.PyShell does this and would otherwise crash ipython).
1450 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1462 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1451
1463
1452 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1464 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1453 Ctrl-C problem, which does not mess up the input line.
1465 Ctrl-C problem, which does not mess up the input line.
1454
1466
1455 2004-11-03 Fernando Perez <fperez@colorado.edu>
1467 2004-11-03 Fernando Perez <fperez@colorado.edu>
1456
1468
1457 * IPython/Release.py: Changed licensing to BSD, in all files.
1469 * IPython/Release.py: Changed licensing to BSD, in all files.
1458 (name): lowercase name for tarball/RPM release.
1470 (name): lowercase name for tarball/RPM release.
1459
1471
1460 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1472 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1461 use throughout ipython.
1473 use throughout ipython.
1462
1474
1463 * IPython/Magic.py (Magic._ofind): Switch to using the new
1475 * IPython/Magic.py (Magic._ofind): Switch to using the new
1464 OInspect.getdoc() function.
1476 OInspect.getdoc() function.
1465
1477
1466 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1478 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1467 of the line currently being canceled via Ctrl-C. It's extremely
1479 of the line currently being canceled via Ctrl-C. It's extremely
1468 ugly, but I don't know how to do it better (the problem is one of
1480 ugly, but I don't know how to do it better (the problem is one of
1469 handling cross-thread exceptions).
1481 handling cross-thread exceptions).
1470
1482
1471 2004-10-28 Fernando Perez <fperez@colorado.edu>
1483 2004-10-28 Fernando Perez <fperez@colorado.edu>
1472
1484
1473 * IPython/Shell.py (signal_handler): add signal handlers to trap
1485 * IPython/Shell.py (signal_handler): add signal handlers to trap
1474 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1486 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1475 report by Francesc Alted.
1487 report by Francesc Alted.
1476
1488
1477 2004-10-21 Fernando Perez <fperez@colorado.edu>
1489 2004-10-21 Fernando Perez <fperez@colorado.edu>
1478
1490
1479 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1491 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1480 to % for pysh syntax extensions.
1492 to % for pysh syntax extensions.
1481
1493
1482 2004-10-09 Fernando Perez <fperez@colorado.edu>
1494 2004-10-09 Fernando Perez <fperez@colorado.edu>
1483
1495
1484 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1496 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1485 arrays to print a more useful summary, without calling str(arr).
1497 arrays to print a more useful summary, without calling str(arr).
1486 This avoids the problem of extremely lengthy computations which
1498 This avoids the problem of extremely lengthy computations which
1487 occur if arr is large, and appear to the user as a system lockup
1499 occur if arr is large, and appear to the user as a system lockup
1488 with 100% cpu activity. After a suggestion by Kristian Sandberg
1500 with 100% cpu activity. After a suggestion by Kristian Sandberg
1489 <Kristian.Sandberg@colorado.edu>.
1501 <Kristian.Sandberg@colorado.edu>.
1490 (Magic.__init__): fix bug in global magic escapes not being
1502 (Magic.__init__): fix bug in global magic escapes not being
1491 correctly set.
1503 correctly set.
1492
1504
1493 2004-10-08 Fernando Perez <fperez@colorado.edu>
1505 2004-10-08 Fernando Perez <fperez@colorado.edu>
1494
1506
1495 * IPython/Magic.py (__license__): change to absolute imports of
1507 * IPython/Magic.py (__license__): change to absolute imports of
1496 ipython's own internal packages, to start adapting to the absolute
1508 ipython's own internal packages, to start adapting to the absolute
1497 import requirement of PEP-328.
1509 import requirement of PEP-328.
1498
1510
1499 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1511 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1500 files, and standardize author/license marks through the Release
1512 files, and standardize author/license marks through the Release
1501 module instead of having per/file stuff (except for files with
1513 module instead of having per/file stuff (except for files with
1502 particular licenses, like the MIT/PSF-licensed codes).
1514 particular licenses, like the MIT/PSF-licensed codes).
1503
1515
1504 * IPython/Debugger.py: remove dead code for python 2.1
1516 * IPython/Debugger.py: remove dead code for python 2.1
1505
1517
1506 2004-10-04 Fernando Perez <fperez@colorado.edu>
1518 2004-10-04 Fernando Perez <fperez@colorado.edu>
1507
1519
1508 * IPython/iplib.py (ipmagic): New function for accessing magics
1520 * IPython/iplib.py (ipmagic): New function for accessing magics
1509 via a normal python function call.
1521 via a normal python function call.
1510
1522
1511 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1523 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1512 from '@' to '%', to accomodate the new @decorator syntax of python
1524 from '@' to '%', to accomodate the new @decorator syntax of python
1513 2.4.
1525 2.4.
1514
1526
1515 2004-09-29 Fernando Perez <fperez@colorado.edu>
1527 2004-09-29 Fernando Perez <fperez@colorado.edu>
1516
1528
1517 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1529 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1518 matplotlib.use to prevent running scripts which try to switch
1530 matplotlib.use to prevent running scripts which try to switch
1519 interactive backends from within ipython. This will just crash
1531 interactive backends from within ipython. This will just crash
1520 the python interpreter, so we can't allow it (but a detailed error
1532 the python interpreter, so we can't allow it (but a detailed error
1521 is given to the user).
1533 is given to the user).
1522
1534
1523 2004-09-28 Fernando Perez <fperez@colorado.edu>
1535 2004-09-28 Fernando Perez <fperez@colorado.edu>
1524
1536
1525 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1537 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1526 matplotlib-related fixes so that using @run with non-matplotlib
1538 matplotlib-related fixes so that using @run with non-matplotlib
1527 scripts doesn't pop up spurious plot windows. This requires
1539 scripts doesn't pop up spurious plot windows. This requires
1528 matplotlib >= 0.63, where I had to make some changes as well.
1540 matplotlib >= 0.63, where I had to make some changes as well.
1529
1541
1530 * IPython/ipmaker.py (make_IPython): update version requirement to
1542 * IPython/ipmaker.py (make_IPython): update version requirement to
1531 python 2.2.
1543 python 2.2.
1532
1544
1533 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1545 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1534 banner arg for embedded customization.
1546 banner arg for embedded customization.
1535
1547
1536 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1548 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1537 explicit uses of __IP as the IPython's instance name. Now things
1549 explicit uses of __IP as the IPython's instance name. Now things
1538 are properly handled via the shell.name value. The actual code
1550 are properly handled via the shell.name value. The actual code
1539 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1551 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1540 is much better than before. I'll clean things completely when the
1552 is much better than before. I'll clean things completely when the
1541 magic stuff gets a real overhaul.
1553 magic stuff gets a real overhaul.
1542
1554
1543 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1555 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1544 minor changes to debian dir.
1556 minor changes to debian dir.
1545
1557
1546 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1558 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1547 pointer to the shell itself in the interactive namespace even when
1559 pointer to the shell itself in the interactive namespace even when
1548 a user-supplied dict is provided. This is needed for embedding
1560 a user-supplied dict is provided. This is needed for embedding
1549 purposes (found by tests with Michel Sanner).
1561 purposes (found by tests with Michel Sanner).
1550
1562
1551 2004-09-27 Fernando Perez <fperez@colorado.edu>
1563 2004-09-27 Fernando Perez <fperez@colorado.edu>
1552
1564
1553 * IPython/UserConfig/ipythonrc: remove []{} from
1565 * IPython/UserConfig/ipythonrc: remove []{} from
1554 readline_remove_delims, so that things like [modname.<TAB> do
1566 readline_remove_delims, so that things like [modname.<TAB> do
1555 proper completion. This disables [].TAB, but that's a less common
1567 proper completion. This disables [].TAB, but that's a less common
1556 case than module names in list comprehensions, for example.
1568 case than module names in list comprehensions, for example.
1557 Thanks to a report by Andrea Riciputi.
1569 Thanks to a report by Andrea Riciputi.
1558
1570
1559 2004-09-09 Fernando Perez <fperez@colorado.edu>
1571 2004-09-09 Fernando Perez <fperez@colorado.edu>
1560
1572
1561 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1573 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1562 blocking problems in win32 and osx. Fix by John.
1574 blocking problems in win32 and osx. Fix by John.
1563
1575
1564 2004-09-08 Fernando Perez <fperez@colorado.edu>
1576 2004-09-08 Fernando Perez <fperez@colorado.edu>
1565
1577
1566 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1578 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1567 for Win32 and OSX. Fix by John Hunter.
1579 for Win32 and OSX. Fix by John Hunter.
1568
1580
1569 2004-08-30 *** Released version 0.6.3
1581 2004-08-30 *** Released version 0.6.3
1570
1582
1571 2004-08-30 Fernando Perez <fperez@colorado.edu>
1583 2004-08-30 Fernando Perez <fperez@colorado.edu>
1572
1584
1573 * setup.py (isfile): Add manpages to list of dependent files to be
1585 * setup.py (isfile): Add manpages to list of dependent files to be
1574 updated.
1586 updated.
1575
1587
1576 2004-08-27 Fernando Perez <fperez@colorado.edu>
1588 2004-08-27 Fernando Perez <fperez@colorado.edu>
1577
1589
1578 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1590 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1579 for now. They don't really work with standalone WX/GTK code
1591 for now. They don't really work with standalone WX/GTK code
1580 (though matplotlib IS working fine with both of those backends).
1592 (though matplotlib IS working fine with both of those backends).
1581 This will neeed much more testing. I disabled most things with
1593 This will neeed much more testing. I disabled most things with
1582 comments, so turning it back on later should be pretty easy.
1594 comments, so turning it back on later should be pretty easy.
1583
1595
1584 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1596 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1585 autocalling of expressions like r'foo', by modifying the line
1597 autocalling of expressions like r'foo', by modifying the line
1586 split regexp. Closes
1598 split regexp. Closes
1587 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1599 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1588 Riley <ipythonbugs-AT-sabi.net>.
1600 Riley <ipythonbugs-AT-sabi.net>.
1589 (InteractiveShell.mainloop): honor --nobanner with banner
1601 (InteractiveShell.mainloop): honor --nobanner with banner
1590 extensions.
1602 extensions.
1591
1603
1592 * IPython/Shell.py: Significant refactoring of all classes, so
1604 * IPython/Shell.py: Significant refactoring of all classes, so
1593 that we can really support ALL matplotlib backends and threading
1605 that we can really support ALL matplotlib backends and threading
1594 models (John spotted a bug with Tk which required this). Now we
1606 models (John spotted a bug with Tk which required this). Now we
1595 should support single-threaded, WX-threads and GTK-threads, both
1607 should support single-threaded, WX-threads and GTK-threads, both
1596 for generic code and for matplotlib.
1608 for generic code and for matplotlib.
1597
1609
1598 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1610 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1599 -pylab, to simplify things for users. Will also remove the pylab
1611 -pylab, to simplify things for users. Will also remove the pylab
1600 profile, since now all of matplotlib configuration is directly
1612 profile, since now all of matplotlib configuration is directly
1601 handled here. This also reduces startup time.
1613 handled here. This also reduces startup time.
1602
1614
1603 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1615 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1604 shell wasn't being correctly called. Also in IPShellWX.
1616 shell wasn't being correctly called. Also in IPShellWX.
1605
1617
1606 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1618 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1607 fine-tune banner.
1619 fine-tune banner.
1608
1620
1609 * IPython/numutils.py (spike): Deprecate these spike functions,
1621 * IPython/numutils.py (spike): Deprecate these spike functions,
1610 delete (long deprecated) gnuplot_exec handler.
1622 delete (long deprecated) gnuplot_exec handler.
1611
1623
1612 2004-08-26 Fernando Perez <fperez@colorado.edu>
1624 2004-08-26 Fernando Perez <fperez@colorado.edu>
1613
1625
1614 * ipython.1: Update for threading options, plus some others which
1626 * ipython.1: Update for threading options, plus some others which
1615 were missing.
1627 were missing.
1616
1628
1617 * IPython/ipmaker.py (__call__): Added -wthread option for
1629 * IPython/ipmaker.py (__call__): Added -wthread option for
1618 wxpython thread handling. Make sure threading options are only
1630 wxpython thread handling. Make sure threading options are only
1619 valid at the command line.
1631 valid at the command line.
1620
1632
1621 * scripts/ipython: moved shell selection into a factory function
1633 * scripts/ipython: moved shell selection into a factory function
1622 in Shell.py, to keep the starter script to a minimum.
1634 in Shell.py, to keep the starter script to a minimum.
1623
1635
1624 2004-08-25 Fernando Perez <fperez@colorado.edu>
1636 2004-08-25 Fernando Perez <fperez@colorado.edu>
1625
1637
1626 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1638 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1627 John. Along with some recent changes he made to matplotlib, the
1639 John. Along with some recent changes he made to matplotlib, the
1628 next versions of both systems should work very well together.
1640 next versions of both systems should work very well together.
1629
1641
1630 2004-08-24 Fernando Perez <fperez@colorado.edu>
1642 2004-08-24 Fernando Perez <fperez@colorado.edu>
1631
1643
1632 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1644 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1633 tried to switch the profiling to using hotshot, but I'm getting
1645 tried to switch the profiling to using hotshot, but I'm getting
1634 strange errors from prof.runctx() there. I may be misreading the
1646 strange errors from prof.runctx() there. I may be misreading the
1635 docs, but it looks weird. For now the profiling code will
1647 docs, but it looks weird. For now the profiling code will
1636 continue to use the standard profiler.
1648 continue to use the standard profiler.
1637
1649
1638 2004-08-23 Fernando Perez <fperez@colorado.edu>
1650 2004-08-23 Fernando Perez <fperez@colorado.edu>
1639
1651
1640 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1652 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1641 threaded shell, by John Hunter. It's not quite ready yet, but
1653 threaded shell, by John Hunter. It's not quite ready yet, but
1642 close.
1654 close.
1643
1655
1644 2004-08-22 Fernando Perez <fperez@colorado.edu>
1656 2004-08-22 Fernando Perez <fperez@colorado.edu>
1645
1657
1646 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1658 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1647 in Magic and ultraTB.
1659 in Magic and ultraTB.
1648
1660
1649 * ipython.1: document threading options in manpage.
1661 * ipython.1: document threading options in manpage.
1650
1662
1651 * scripts/ipython: Changed name of -thread option to -gthread,
1663 * scripts/ipython: Changed name of -thread option to -gthread,
1652 since this is GTK specific. I want to leave the door open for a
1664 since this is GTK specific. I want to leave the door open for a
1653 -wthread option for WX, which will most likely be necessary. This
1665 -wthread option for WX, which will most likely be necessary. This
1654 change affects usage and ipmaker as well.
1666 change affects usage and ipmaker as well.
1655
1667
1656 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1668 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1657 handle the matplotlib shell issues. Code by John Hunter
1669 handle the matplotlib shell issues. Code by John Hunter
1658 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1670 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1659 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1671 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1660 broken (and disabled for end users) for now, but it puts the
1672 broken (and disabled for end users) for now, but it puts the
1661 infrastructure in place.
1673 infrastructure in place.
1662
1674
1663 2004-08-21 Fernando Perez <fperez@colorado.edu>
1675 2004-08-21 Fernando Perez <fperez@colorado.edu>
1664
1676
1665 * ipythonrc-pylab: Add matplotlib support.
1677 * ipythonrc-pylab: Add matplotlib support.
1666
1678
1667 * matplotlib_config.py: new files for matplotlib support, part of
1679 * matplotlib_config.py: new files for matplotlib support, part of
1668 the pylab profile.
1680 the pylab profile.
1669
1681
1670 * IPython/usage.py (__doc__): documented the threading options.
1682 * IPython/usage.py (__doc__): documented the threading options.
1671
1683
1672 2004-08-20 Fernando Perez <fperez@colorado.edu>
1684 2004-08-20 Fernando Perez <fperez@colorado.edu>
1673
1685
1674 * ipython: Modified the main calling routine to handle the -thread
1686 * ipython: Modified the main calling routine to handle the -thread
1675 and -mpthread options. This needs to be done as a top-level hack,
1687 and -mpthread options. This needs to be done as a top-level hack,
1676 because it determines which class to instantiate for IPython
1688 because it determines which class to instantiate for IPython
1677 itself.
1689 itself.
1678
1690
1679 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1691 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1680 classes to support multithreaded GTK operation without blocking,
1692 classes to support multithreaded GTK operation without blocking,
1681 and matplotlib with all backends. This is a lot of still very
1693 and matplotlib with all backends. This is a lot of still very
1682 experimental code, and threads are tricky. So it may still have a
1694 experimental code, and threads are tricky. So it may still have a
1683 few rough edges... This code owes a lot to
1695 few rough edges... This code owes a lot to
1684 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1696 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1685 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1697 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1686 to John Hunter for all the matplotlib work.
1698 to John Hunter for all the matplotlib work.
1687
1699
1688 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1700 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1689 options for gtk thread and matplotlib support.
1701 options for gtk thread and matplotlib support.
1690
1702
1691 2004-08-16 Fernando Perez <fperez@colorado.edu>
1703 2004-08-16 Fernando Perez <fperez@colorado.edu>
1692
1704
1693 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1705 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1694 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1706 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1695 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1707 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1696
1708
1697 2004-08-11 Fernando Perez <fperez@colorado.edu>
1709 2004-08-11 Fernando Perez <fperez@colorado.edu>
1698
1710
1699 * setup.py (isfile): Fix build so documentation gets updated for
1711 * setup.py (isfile): Fix build so documentation gets updated for
1700 rpms (it was only done for .tgz builds).
1712 rpms (it was only done for .tgz builds).
1701
1713
1702 2004-08-10 Fernando Perez <fperez@colorado.edu>
1714 2004-08-10 Fernando Perez <fperez@colorado.edu>
1703
1715
1704 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1716 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1705
1717
1706 * iplib.py : Silence syntax error exceptions in tab-completion.
1718 * iplib.py : Silence syntax error exceptions in tab-completion.
1707
1719
1708 2004-08-05 Fernando Perez <fperez@colorado.edu>
1720 2004-08-05 Fernando Perez <fperez@colorado.edu>
1709
1721
1710 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1722 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1711 'color off' mark for continuation prompts. This was causing long
1723 'color off' mark for continuation prompts. This was causing long
1712 continuation lines to mis-wrap.
1724 continuation lines to mis-wrap.
1713
1725
1714 2004-08-01 Fernando Perez <fperez@colorado.edu>
1726 2004-08-01 Fernando Perez <fperez@colorado.edu>
1715
1727
1716 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1728 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1717 for building ipython to be a parameter. All this is necessary
1729 for building ipython to be a parameter. All this is necessary
1718 right now to have a multithreaded version, but this insane
1730 right now to have a multithreaded version, but this insane
1719 non-design will be cleaned up soon. For now, it's a hack that
1731 non-design will be cleaned up soon. For now, it's a hack that
1720 works.
1732 works.
1721
1733
1722 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1734 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1723 args in various places. No bugs so far, but it's a dangerous
1735 args in various places. No bugs so far, but it's a dangerous
1724 practice.
1736 practice.
1725
1737
1726 2004-07-31 Fernando Perez <fperez@colorado.edu>
1738 2004-07-31 Fernando Perez <fperez@colorado.edu>
1727
1739
1728 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1740 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1729 fix completion of files with dots in their names under most
1741 fix completion of files with dots in their names under most
1730 profiles (pysh was OK because the completion order is different).
1742 profiles (pysh was OK because the completion order is different).
1731
1743
1732 2004-07-27 Fernando Perez <fperez@colorado.edu>
1744 2004-07-27 Fernando Perez <fperez@colorado.edu>
1733
1745
1734 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1746 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1735 keywords manually, b/c the one in keyword.py was removed in python
1747 keywords manually, b/c the one in keyword.py was removed in python
1736 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1748 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1737 This is NOT a bug under python 2.3 and earlier.
1749 This is NOT a bug under python 2.3 and earlier.
1738
1750
1739 2004-07-26 Fernando Perez <fperez@colorado.edu>
1751 2004-07-26 Fernando Perez <fperez@colorado.edu>
1740
1752
1741 * IPython/ultraTB.py (VerboseTB.text): Add another
1753 * IPython/ultraTB.py (VerboseTB.text): Add another
1742 linecache.checkcache() call to try to prevent inspect.py from
1754 linecache.checkcache() call to try to prevent inspect.py from
1743 crashing under python 2.3. I think this fixes
1755 crashing under python 2.3. I think this fixes
1744 http://www.scipy.net/roundup/ipython/issue17.
1756 http://www.scipy.net/roundup/ipython/issue17.
1745
1757
1746 2004-07-26 *** Released version 0.6.2
1758 2004-07-26 *** Released version 0.6.2
1747
1759
1748 2004-07-26 Fernando Perez <fperez@colorado.edu>
1760 2004-07-26 Fernando Perez <fperez@colorado.edu>
1749
1761
1750 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1762 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1751 fail for any number.
1763 fail for any number.
1752 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1764 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1753 empty bookmarks.
1765 empty bookmarks.
1754
1766
1755 2004-07-26 *** Released version 0.6.1
1767 2004-07-26 *** Released version 0.6.1
1756
1768
1757 2004-07-26 Fernando Perez <fperez@colorado.edu>
1769 2004-07-26 Fernando Perez <fperez@colorado.edu>
1758
1770
1759 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1771 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1760
1772
1761 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1773 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1762 escaping '()[]{}' in filenames.
1774 escaping '()[]{}' in filenames.
1763
1775
1764 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1776 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1765 Python 2.2 users who lack a proper shlex.split.
1777 Python 2.2 users who lack a proper shlex.split.
1766
1778
1767 2004-07-19 Fernando Perez <fperez@colorado.edu>
1779 2004-07-19 Fernando Perez <fperez@colorado.edu>
1768
1780
1769 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1781 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1770 for reading readline's init file. I follow the normal chain:
1782 for reading readline's init file. I follow the normal chain:
1771 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1783 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1772 report by Mike Heeter. This closes
1784 report by Mike Heeter. This closes
1773 http://www.scipy.net/roundup/ipython/issue16.
1785 http://www.scipy.net/roundup/ipython/issue16.
1774
1786
1775 2004-07-18 Fernando Perez <fperez@colorado.edu>
1787 2004-07-18 Fernando Perez <fperez@colorado.edu>
1776
1788
1777 * IPython/iplib.py (__init__): Add better handling of '\' under
1789 * IPython/iplib.py (__init__): Add better handling of '\' under
1778 Win32 for filenames. After a patch by Ville.
1790 Win32 for filenames. After a patch by Ville.
1779
1791
1780 2004-07-17 Fernando Perez <fperez@colorado.edu>
1792 2004-07-17 Fernando Perez <fperez@colorado.edu>
1781
1793
1782 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1794 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1783 autocalling would be triggered for 'foo is bar' if foo is
1795 autocalling would be triggered for 'foo is bar' if foo is
1784 callable. I also cleaned up the autocall detection code to use a
1796 callable. I also cleaned up the autocall detection code to use a
1785 regexp, which is faster. Bug reported by Alexander Schmolck.
1797 regexp, which is faster. Bug reported by Alexander Schmolck.
1786
1798
1787 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1799 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1788 '?' in them would confuse the help system. Reported by Alex
1800 '?' in them would confuse the help system. Reported by Alex
1789 Schmolck.
1801 Schmolck.
1790
1802
1791 2004-07-16 Fernando Perez <fperez@colorado.edu>
1803 2004-07-16 Fernando Perez <fperez@colorado.edu>
1792
1804
1793 * IPython/GnuplotInteractive.py (__all__): added plot2.
1805 * IPython/GnuplotInteractive.py (__all__): added plot2.
1794
1806
1795 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1807 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1796 plotting dictionaries, lists or tuples of 1d arrays.
1808 plotting dictionaries, lists or tuples of 1d arrays.
1797
1809
1798 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1810 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1799 optimizations.
1811 optimizations.
1800
1812
1801 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1813 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1802 the information which was there from Janko's original IPP code:
1814 the information which was there from Janko's original IPP code:
1803
1815
1804 03.05.99 20:53 porto.ifm.uni-kiel.de
1816 03.05.99 20:53 porto.ifm.uni-kiel.de
1805 --Started changelog.
1817 --Started changelog.
1806 --make clear do what it say it does
1818 --make clear do what it say it does
1807 --added pretty output of lines from inputcache
1819 --added pretty output of lines from inputcache
1808 --Made Logger a mixin class, simplifies handling of switches
1820 --Made Logger a mixin class, simplifies handling of switches
1809 --Added own completer class. .string<TAB> expands to last history
1821 --Added own completer class. .string<TAB> expands to last history
1810 line which starts with string. The new expansion is also present
1822 line which starts with string. The new expansion is also present
1811 with Ctrl-r from the readline library. But this shows, who this
1823 with Ctrl-r from the readline library. But this shows, who this
1812 can be done for other cases.
1824 can be done for other cases.
1813 --Added convention that all shell functions should accept a
1825 --Added convention that all shell functions should accept a
1814 parameter_string This opens the door for different behaviour for
1826 parameter_string This opens the door for different behaviour for
1815 each function. @cd is a good example of this.
1827 each function. @cd is a good example of this.
1816
1828
1817 04.05.99 12:12 porto.ifm.uni-kiel.de
1829 04.05.99 12:12 porto.ifm.uni-kiel.de
1818 --added logfile rotation
1830 --added logfile rotation
1819 --added new mainloop method which freezes first the namespace
1831 --added new mainloop method which freezes first the namespace
1820
1832
1821 07.05.99 21:24 porto.ifm.uni-kiel.de
1833 07.05.99 21:24 porto.ifm.uni-kiel.de
1822 --added the docreader classes. Now there is a help system.
1834 --added the docreader classes. Now there is a help system.
1823 -This is only a first try. Currently it's not easy to put new
1835 -This is only a first try. Currently it's not easy to put new
1824 stuff in the indices. But this is the way to go. Info would be
1836 stuff in the indices. But this is the way to go. Info would be
1825 better, but HTML is every where and not everybody has an info
1837 better, but HTML is every where and not everybody has an info
1826 system installed and it's not so easy to change html-docs to info.
1838 system installed and it's not so easy to change html-docs to info.
1827 --added global logfile option
1839 --added global logfile option
1828 --there is now a hook for object inspection method pinfo needs to
1840 --there is now a hook for object inspection method pinfo needs to
1829 be provided for this. Can be reached by two '??'.
1841 be provided for this. Can be reached by two '??'.
1830
1842
1831 08.05.99 20:51 porto.ifm.uni-kiel.de
1843 08.05.99 20:51 porto.ifm.uni-kiel.de
1832 --added a README
1844 --added a README
1833 --bug in rc file. Something has changed so functions in the rc
1845 --bug in rc file. Something has changed so functions in the rc
1834 file need to reference the shell and not self. Not clear if it's a
1846 file need to reference the shell and not self. Not clear if it's a
1835 bug or feature.
1847 bug or feature.
1836 --changed rc file for new behavior
1848 --changed rc file for new behavior
1837
1849
1838 2004-07-15 Fernando Perez <fperez@colorado.edu>
1850 2004-07-15 Fernando Perez <fperez@colorado.edu>
1839
1851
1840 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1852 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1841 cache was falling out of sync in bizarre manners when multi-line
1853 cache was falling out of sync in bizarre manners when multi-line
1842 input was present. Minor optimizations and cleanup.
1854 input was present. Minor optimizations and cleanup.
1843
1855
1844 (Logger): Remove old Changelog info for cleanup. This is the
1856 (Logger): Remove old Changelog info for cleanup. This is the
1845 information which was there from Janko's original code:
1857 information which was there from Janko's original code:
1846
1858
1847 Changes to Logger: - made the default log filename a parameter
1859 Changes to Logger: - made the default log filename a parameter
1848
1860
1849 - put a check for lines beginning with !@? in log(). Needed
1861 - put a check for lines beginning with !@? in log(). Needed
1850 (even if the handlers properly log their lines) for mid-session
1862 (even if the handlers properly log their lines) for mid-session
1851 logging activation to work properly. Without this, lines logged
1863 logging activation to work properly. Without this, lines logged
1852 in mid session, which get read from the cache, would end up
1864 in mid session, which get read from the cache, would end up
1853 'bare' (with !@? in the open) in the log. Now they are caught
1865 'bare' (with !@? in the open) in the log. Now they are caught
1854 and prepended with a #.
1866 and prepended with a #.
1855
1867
1856 * IPython/iplib.py (InteractiveShell.init_readline): added check
1868 * IPython/iplib.py (InteractiveShell.init_readline): added check
1857 in case MagicCompleter fails to be defined, so we don't crash.
1869 in case MagicCompleter fails to be defined, so we don't crash.
1858
1870
1859 2004-07-13 Fernando Perez <fperez@colorado.edu>
1871 2004-07-13 Fernando Perez <fperez@colorado.edu>
1860
1872
1861 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1873 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1862 of EPS if the requested filename ends in '.eps'.
1874 of EPS if the requested filename ends in '.eps'.
1863
1875
1864 2004-07-04 Fernando Perez <fperez@colorado.edu>
1876 2004-07-04 Fernando Perez <fperez@colorado.edu>
1865
1877
1866 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1878 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1867 escaping of quotes when calling the shell.
1879 escaping of quotes when calling the shell.
1868
1880
1869 2004-07-02 Fernando Perez <fperez@colorado.edu>
1881 2004-07-02 Fernando Perez <fperez@colorado.edu>
1870
1882
1871 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1883 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1872 gettext not working because we were clobbering '_'. Fixes
1884 gettext not working because we were clobbering '_'. Fixes
1873 http://www.scipy.net/roundup/ipython/issue6.
1885 http://www.scipy.net/roundup/ipython/issue6.
1874
1886
1875 2004-07-01 Fernando Perez <fperez@colorado.edu>
1887 2004-07-01 Fernando Perez <fperez@colorado.edu>
1876
1888
1877 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1889 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1878 into @cd. Patch by Ville.
1890 into @cd. Patch by Ville.
1879
1891
1880 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1892 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1881 new function to store things after ipmaker runs. Patch by Ville.
1893 new function to store things after ipmaker runs. Patch by Ville.
1882 Eventually this will go away once ipmaker is removed and the class
1894 Eventually this will go away once ipmaker is removed and the class
1883 gets cleaned up, but for now it's ok. Key functionality here is
1895 gets cleaned up, but for now it's ok. Key functionality here is
1884 the addition of the persistent storage mechanism, a dict for
1896 the addition of the persistent storage mechanism, a dict for
1885 keeping data across sessions (for now just bookmarks, but more can
1897 keeping data across sessions (for now just bookmarks, but more can
1886 be implemented later).
1898 be implemented later).
1887
1899
1888 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1900 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1889 persistent across sections. Patch by Ville, I modified it
1901 persistent across sections. Patch by Ville, I modified it
1890 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1902 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1891 added a '-l' option to list all bookmarks.
1903 added a '-l' option to list all bookmarks.
1892
1904
1893 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1905 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1894 center for cleanup. Registered with atexit.register(). I moved
1906 center for cleanup. Registered with atexit.register(). I moved
1895 here the old exit_cleanup(). After a patch by Ville.
1907 here the old exit_cleanup(). After a patch by Ville.
1896
1908
1897 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1909 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1898 characters in the hacked shlex_split for python 2.2.
1910 characters in the hacked shlex_split for python 2.2.
1899
1911
1900 * IPython/iplib.py (file_matches): more fixes to filenames with
1912 * IPython/iplib.py (file_matches): more fixes to filenames with
1901 whitespace in them. It's not perfect, but limitations in python's
1913 whitespace in them. It's not perfect, but limitations in python's
1902 readline make it impossible to go further.
1914 readline make it impossible to go further.
1903
1915
1904 2004-06-29 Fernando Perez <fperez@colorado.edu>
1916 2004-06-29 Fernando Perez <fperez@colorado.edu>
1905
1917
1906 * IPython/iplib.py (file_matches): escape whitespace correctly in
1918 * IPython/iplib.py (file_matches): escape whitespace correctly in
1907 filename completions. Bug reported by Ville.
1919 filename completions. Bug reported by Ville.
1908
1920
1909 2004-06-28 Fernando Perez <fperez@colorado.edu>
1921 2004-06-28 Fernando Perez <fperez@colorado.edu>
1910
1922
1911 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1923 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1912 the history file will be called 'history-PROFNAME' (or just
1924 the history file will be called 'history-PROFNAME' (or just
1913 'history' if no profile is loaded). I was getting annoyed at
1925 'history' if no profile is loaded). I was getting annoyed at
1914 getting my Numerical work history clobbered by pysh sessions.
1926 getting my Numerical work history clobbered by pysh sessions.
1915
1927
1916 * IPython/iplib.py (InteractiveShell.__init__): Internal
1928 * IPython/iplib.py (InteractiveShell.__init__): Internal
1917 getoutputerror() function so that we can honor the system_verbose
1929 getoutputerror() function so that we can honor the system_verbose
1918 flag for _all_ system calls. I also added escaping of #
1930 flag for _all_ system calls. I also added escaping of #
1919 characters here to avoid confusing Itpl.
1931 characters here to avoid confusing Itpl.
1920
1932
1921 * IPython/Magic.py (shlex_split): removed call to shell in
1933 * IPython/Magic.py (shlex_split): removed call to shell in
1922 parse_options and replaced it with shlex.split(). The annoying
1934 parse_options and replaced it with shlex.split(). The annoying
1923 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1935 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1924 to backport it from 2.3, with several frail hacks (the shlex
1936 to backport it from 2.3, with several frail hacks (the shlex
1925 module is rather limited in 2.2). Thanks to a suggestion by Ville
1937 module is rather limited in 2.2). Thanks to a suggestion by Ville
1926 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1938 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1927 problem.
1939 problem.
1928
1940
1929 (Magic.magic_system_verbose): new toggle to print the actual
1941 (Magic.magic_system_verbose): new toggle to print the actual
1930 system calls made by ipython. Mainly for debugging purposes.
1942 system calls made by ipython. Mainly for debugging purposes.
1931
1943
1932 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1944 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1933 doesn't support persistence. Reported (and fix suggested) by
1945 doesn't support persistence. Reported (and fix suggested) by
1934 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1946 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1935
1947
1936 2004-06-26 Fernando Perez <fperez@colorado.edu>
1948 2004-06-26 Fernando Perez <fperez@colorado.edu>
1937
1949
1938 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1950 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1939 continue prompts.
1951 continue prompts.
1940
1952
1941 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1953 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1942 function (basically a big docstring) and a few more things here to
1954 function (basically a big docstring) and a few more things here to
1943 speedup startup. pysh.py is now very lightweight. We want because
1955 speedup startup. pysh.py is now very lightweight. We want because
1944 it gets execfile'd, while InterpreterExec gets imported, so
1956 it gets execfile'd, while InterpreterExec gets imported, so
1945 byte-compilation saves time.
1957 byte-compilation saves time.
1946
1958
1947 2004-06-25 Fernando Perez <fperez@colorado.edu>
1959 2004-06-25 Fernando Perez <fperez@colorado.edu>
1948
1960
1949 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1961 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1950 -NUM', which was recently broken.
1962 -NUM', which was recently broken.
1951
1963
1952 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1964 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1953 in multi-line input (but not !!, which doesn't make sense there).
1965 in multi-line input (but not !!, which doesn't make sense there).
1954
1966
1955 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1967 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1956 It's just too useful, and people can turn it off in the less
1968 It's just too useful, and people can turn it off in the less
1957 common cases where it's a problem.
1969 common cases where it's a problem.
1958
1970
1959 2004-06-24 Fernando Perez <fperez@colorado.edu>
1971 2004-06-24 Fernando Perez <fperez@colorado.edu>
1960
1972
1961 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1973 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1962 special syntaxes (like alias calling) is now allied in multi-line
1974 special syntaxes (like alias calling) is now allied in multi-line
1963 input. This is still _very_ experimental, but it's necessary for
1975 input. This is still _very_ experimental, but it's necessary for
1964 efficient shell usage combining python looping syntax with system
1976 efficient shell usage combining python looping syntax with system
1965 calls. For now it's restricted to aliases, I don't think it
1977 calls. For now it's restricted to aliases, I don't think it
1966 really even makes sense to have this for magics.
1978 really even makes sense to have this for magics.
1967
1979
1968 2004-06-23 Fernando Perez <fperez@colorado.edu>
1980 2004-06-23 Fernando Perez <fperez@colorado.edu>
1969
1981
1970 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1982 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1971 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1983 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1972
1984
1973 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1985 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1974 extensions under Windows (after code sent by Gary Bishop). The
1986 extensions under Windows (after code sent by Gary Bishop). The
1975 extensions considered 'executable' are stored in IPython's rc
1987 extensions considered 'executable' are stored in IPython's rc
1976 structure as win_exec_ext.
1988 structure as win_exec_ext.
1977
1989
1978 * IPython/genutils.py (shell): new function, like system() but
1990 * IPython/genutils.py (shell): new function, like system() but
1979 without return value. Very useful for interactive shell work.
1991 without return value. Very useful for interactive shell work.
1980
1992
1981 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1993 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1982 delete aliases.
1994 delete aliases.
1983
1995
1984 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1996 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1985 sure that the alias table doesn't contain python keywords.
1997 sure that the alias table doesn't contain python keywords.
1986
1998
1987 2004-06-21 Fernando Perez <fperez@colorado.edu>
1999 2004-06-21 Fernando Perez <fperez@colorado.edu>
1988
2000
1989 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2001 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1990 non-existent items are found in $PATH. Reported by Thorsten.
2002 non-existent items are found in $PATH. Reported by Thorsten.
1991
2003
1992 2004-06-20 Fernando Perez <fperez@colorado.edu>
2004 2004-06-20 Fernando Perez <fperez@colorado.edu>
1993
2005
1994 * IPython/iplib.py (complete): modified the completer so that the
2006 * IPython/iplib.py (complete): modified the completer so that the
1995 order of priorities can be easily changed at runtime.
2007 order of priorities can be easily changed at runtime.
1996
2008
1997 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2009 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1998 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2010 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1999
2011
2000 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2012 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2001 expand Python variables prepended with $ in all system calls. The
2013 expand Python variables prepended with $ in all system calls. The
2002 same was done to InteractiveShell.handle_shell_escape. Now all
2014 same was done to InteractiveShell.handle_shell_escape. Now all
2003 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2015 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2004 expansion of python variables and expressions according to the
2016 expansion of python variables and expressions according to the
2005 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2017 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2006
2018
2007 Though PEP-215 has been rejected, a similar (but simpler) one
2019 Though PEP-215 has been rejected, a similar (but simpler) one
2008 seems like it will go into Python 2.4, PEP-292 -
2020 seems like it will go into Python 2.4, PEP-292 -
2009 http://www.python.org/peps/pep-0292.html.
2021 http://www.python.org/peps/pep-0292.html.
2010
2022
2011 I'll keep the full syntax of PEP-215, since IPython has since the
2023 I'll keep the full syntax of PEP-215, since IPython has since the
2012 start used Ka-Ping Yee's reference implementation discussed there
2024 start used Ka-Ping Yee's reference implementation discussed there
2013 (Itpl), and I actually like the powerful semantics it offers.
2025 (Itpl), and I actually like the powerful semantics it offers.
2014
2026
2015 In order to access normal shell variables, the $ has to be escaped
2027 In order to access normal shell variables, the $ has to be escaped
2016 via an extra $. For example:
2028 via an extra $. For example:
2017
2029
2018 In [7]: PATH='a python variable'
2030 In [7]: PATH='a python variable'
2019
2031
2020 In [8]: !echo $PATH
2032 In [8]: !echo $PATH
2021 a python variable
2033 a python variable
2022
2034
2023 In [9]: !echo $$PATH
2035 In [9]: !echo $$PATH
2024 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2036 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2025
2037
2026 (Magic.parse_options): escape $ so the shell doesn't evaluate
2038 (Magic.parse_options): escape $ so the shell doesn't evaluate
2027 things prematurely.
2039 things prematurely.
2028
2040
2029 * IPython/iplib.py (InteractiveShell.call_alias): added the
2041 * IPython/iplib.py (InteractiveShell.call_alias): added the
2030 ability for aliases to expand python variables via $.
2042 ability for aliases to expand python variables via $.
2031
2043
2032 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2044 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2033 system, now there's a @rehash/@rehashx pair of magics. These work
2045 system, now there's a @rehash/@rehashx pair of magics. These work
2034 like the csh rehash command, and can be invoked at any time. They
2046 like the csh rehash command, and can be invoked at any time. They
2035 build a table of aliases to everything in the user's $PATH
2047 build a table of aliases to everything in the user's $PATH
2036 (@rehash uses everything, @rehashx is slower but only adds
2048 (@rehash uses everything, @rehashx is slower but only adds
2037 executable files). With this, the pysh.py-based shell profile can
2049 executable files). With this, the pysh.py-based shell profile can
2038 now simply call rehash upon startup, and full access to all
2050 now simply call rehash upon startup, and full access to all
2039 programs in the user's path is obtained.
2051 programs in the user's path is obtained.
2040
2052
2041 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2053 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2042 functionality is now fully in place. I removed the old dynamic
2054 functionality is now fully in place. I removed the old dynamic
2043 code generation based approach, in favor of a much lighter one
2055 code generation based approach, in favor of a much lighter one
2044 based on a simple dict. The advantage is that this allows me to
2056 based on a simple dict. The advantage is that this allows me to
2045 now have thousands of aliases with negligible cost (unthinkable
2057 now have thousands of aliases with negligible cost (unthinkable
2046 with the old system).
2058 with the old system).
2047
2059
2048 2004-06-19 Fernando Perez <fperez@colorado.edu>
2060 2004-06-19 Fernando Perez <fperez@colorado.edu>
2049
2061
2050 * IPython/iplib.py (__init__): extended MagicCompleter class to
2062 * IPython/iplib.py (__init__): extended MagicCompleter class to
2051 also complete (last in priority) on user aliases.
2063 also complete (last in priority) on user aliases.
2052
2064
2053 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2065 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2054 call to eval.
2066 call to eval.
2055 (ItplNS.__init__): Added a new class which functions like Itpl,
2067 (ItplNS.__init__): Added a new class which functions like Itpl,
2056 but allows configuring the namespace for the evaluation to occur
2068 but allows configuring the namespace for the evaluation to occur
2057 in.
2069 in.
2058
2070
2059 2004-06-18 Fernando Perez <fperez@colorado.edu>
2071 2004-06-18 Fernando Perez <fperez@colorado.edu>
2060
2072
2061 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2073 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2062 better message when 'exit' or 'quit' are typed (a common newbie
2074 better message when 'exit' or 'quit' are typed (a common newbie
2063 confusion).
2075 confusion).
2064
2076
2065 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2077 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2066 check for Windows users.
2078 check for Windows users.
2067
2079
2068 * IPython/iplib.py (InteractiveShell.user_setup): removed
2080 * IPython/iplib.py (InteractiveShell.user_setup): removed
2069 disabling of colors for Windows. I'll test at runtime and issue a
2081 disabling of colors for Windows. I'll test at runtime and issue a
2070 warning if Gary's readline isn't found, as to nudge users to
2082 warning if Gary's readline isn't found, as to nudge users to
2071 download it.
2083 download it.
2072
2084
2073 2004-06-16 Fernando Perez <fperez@colorado.edu>
2085 2004-06-16 Fernando Perez <fperez@colorado.edu>
2074
2086
2075 * IPython/genutils.py (Stream.__init__): changed to print errors
2087 * IPython/genutils.py (Stream.__init__): changed to print errors
2076 to sys.stderr. I had a circular dependency here. Now it's
2088 to sys.stderr. I had a circular dependency here. Now it's
2077 possible to run ipython as IDLE's shell (consider this pre-alpha,
2089 possible to run ipython as IDLE's shell (consider this pre-alpha,
2078 since true stdout things end up in the starting terminal instead
2090 since true stdout things end up in the starting terminal instead
2079 of IDLE's out).
2091 of IDLE's out).
2080
2092
2081 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2093 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2082 users who haven't # updated their prompt_in2 definitions. Remove
2094 users who haven't # updated their prompt_in2 definitions. Remove
2083 eventually.
2095 eventually.
2084 (multiple_replace): added credit to original ASPN recipe.
2096 (multiple_replace): added credit to original ASPN recipe.
2085
2097
2086 2004-06-15 Fernando Perez <fperez@colorado.edu>
2098 2004-06-15 Fernando Perez <fperez@colorado.edu>
2087
2099
2088 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2100 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2089 list of auto-defined aliases.
2101 list of auto-defined aliases.
2090
2102
2091 2004-06-13 Fernando Perez <fperez@colorado.edu>
2103 2004-06-13 Fernando Perez <fperez@colorado.edu>
2092
2104
2093 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2105 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2094 install was really requested (so setup.py can be used for other
2106 install was really requested (so setup.py can be used for other
2095 things under Windows).
2107 things under Windows).
2096
2108
2097 2004-06-10 Fernando Perez <fperez@colorado.edu>
2109 2004-06-10 Fernando Perez <fperez@colorado.edu>
2098
2110
2099 * IPython/Logger.py (Logger.create_log): Manually remove any old
2111 * IPython/Logger.py (Logger.create_log): Manually remove any old
2100 backup, since os.remove may fail under Windows. Fixes bug
2112 backup, since os.remove may fail under Windows. Fixes bug
2101 reported by Thorsten.
2113 reported by Thorsten.
2102
2114
2103 2004-06-09 Fernando Perez <fperez@colorado.edu>
2115 2004-06-09 Fernando Perez <fperez@colorado.edu>
2104
2116
2105 * examples/example-embed.py: fixed all references to %n (replaced
2117 * examples/example-embed.py: fixed all references to %n (replaced
2106 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2118 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2107 for all examples and the manual as well.
2119 for all examples and the manual as well.
2108
2120
2109 2004-06-08 Fernando Perez <fperez@colorado.edu>
2121 2004-06-08 Fernando Perez <fperez@colorado.edu>
2110
2122
2111 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2123 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2112 alignment and color management. All 3 prompt subsystems now
2124 alignment and color management. All 3 prompt subsystems now
2113 inherit from BasePrompt.
2125 inherit from BasePrompt.
2114
2126
2115 * tools/release: updates for windows installer build and tag rpms
2127 * tools/release: updates for windows installer build and tag rpms
2116 with python version (since paths are fixed).
2128 with python version (since paths are fixed).
2117
2129
2118 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2130 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2119 which will become eventually obsolete. Also fixed the default
2131 which will become eventually obsolete. Also fixed the default
2120 prompt_in2 to use \D, so at least new users start with the correct
2132 prompt_in2 to use \D, so at least new users start with the correct
2121 defaults.
2133 defaults.
2122 WARNING: Users with existing ipythonrc files will need to apply
2134 WARNING: Users with existing ipythonrc files will need to apply
2123 this fix manually!
2135 this fix manually!
2124
2136
2125 * setup.py: make windows installer (.exe). This is finally the
2137 * setup.py: make windows installer (.exe). This is finally the
2126 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2138 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2127 which I hadn't included because it required Python 2.3 (or recent
2139 which I hadn't included because it required Python 2.3 (or recent
2128 distutils).
2140 distutils).
2129
2141
2130 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2142 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2131 usage of new '\D' escape.
2143 usage of new '\D' escape.
2132
2144
2133 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2145 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2134 lacks os.getuid())
2146 lacks os.getuid())
2135 (CachedOutput.set_colors): Added the ability to turn coloring
2147 (CachedOutput.set_colors): Added the ability to turn coloring
2136 on/off with @colors even for manually defined prompt colors. It
2148 on/off with @colors even for manually defined prompt colors. It
2137 uses a nasty global, but it works safely and via the generic color
2149 uses a nasty global, but it works safely and via the generic color
2138 handling mechanism.
2150 handling mechanism.
2139 (Prompt2.__init__): Introduced new escape '\D' for continuation
2151 (Prompt2.__init__): Introduced new escape '\D' for continuation
2140 prompts. It represents the counter ('\#') as dots.
2152 prompts. It represents the counter ('\#') as dots.
2141 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2153 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2142 need to update their ipythonrc files and replace '%n' with '\D' in
2154 need to update their ipythonrc files and replace '%n' with '\D' in
2143 their prompt_in2 settings everywhere. Sorry, but there's
2155 their prompt_in2 settings everywhere. Sorry, but there's
2144 otherwise no clean way to get all prompts to properly align. The
2156 otherwise no clean way to get all prompts to properly align. The
2145 ipythonrc shipped with IPython has been updated.
2157 ipythonrc shipped with IPython has been updated.
2146
2158
2147 2004-06-07 Fernando Perez <fperez@colorado.edu>
2159 2004-06-07 Fernando Perez <fperez@colorado.edu>
2148
2160
2149 * setup.py (isfile): Pass local_icons option to latex2html, so the
2161 * setup.py (isfile): Pass local_icons option to latex2html, so the
2150 resulting HTML file is self-contained. Thanks to
2162 resulting HTML file is self-contained. Thanks to
2151 dryice-AT-liu.com.cn for the tip.
2163 dryice-AT-liu.com.cn for the tip.
2152
2164
2153 * pysh.py: I created a new profile 'shell', which implements a
2165 * pysh.py: I created a new profile 'shell', which implements a
2154 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2166 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2155 system shell, nor will it become one anytime soon. It's mainly
2167 system shell, nor will it become one anytime soon. It's mainly
2156 meant to illustrate the use of the new flexible bash-like prompts.
2168 meant to illustrate the use of the new flexible bash-like prompts.
2157 I guess it could be used by hardy souls for true shell management,
2169 I guess it could be used by hardy souls for true shell management,
2158 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2170 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2159 profile. This uses the InterpreterExec extension provided by
2171 profile. This uses the InterpreterExec extension provided by
2160 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2172 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2161
2173
2162 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2174 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2163 auto-align itself with the length of the previous input prompt
2175 auto-align itself with the length of the previous input prompt
2164 (taking into account the invisible color escapes).
2176 (taking into account the invisible color escapes).
2165 (CachedOutput.__init__): Large restructuring of this class. Now
2177 (CachedOutput.__init__): Large restructuring of this class. Now
2166 all three prompts (primary1, primary2, output) are proper objects,
2178 all three prompts (primary1, primary2, output) are proper objects,
2167 managed by the 'parent' CachedOutput class. The code is still a
2179 managed by the 'parent' CachedOutput class. The code is still a
2168 bit hackish (all prompts share state via a pointer to the cache),
2180 bit hackish (all prompts share state via a pointer to the cache),
2169 but it's overall far cleaner than before.
2181 but it's overall far cleaner than before.
2170
2182
2171 * IPython/genutils.py (getoutputerror): modified to add verbose,
2183 * IPython/genutils.py (getoutputerror): modified to add verbose,
2172 debug and header options. This makes the interface of all getout*
2184 debug and header options. This makes the interface of all getout*
2173 functions uniform.
2185 functions uniform.
2174 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2186 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2175
2187
2176 * IPython/Magic.py (Magic.default_option): added a function to
2188 * IPython/Magic.py (Magic.default_option): added a function to
2177 allow registering default options for any magic command. This
2189 allow registering default options for any magic command. This
2178 makes it easy to have profiles which customize the magics globally
2190 makes it easy to have profiles which customize the magics globally
2179 for a certain use. The values set through this function are
2191 for a certain use. The values set through this function are
2180 picked up by the parse_options() method, which all magics should
2192 picked up by the parse_options() method, which all magics should
2181 use to parse their options.
2193 use to parse their options.
2182
2194
2183 * IPython/genutils.py (warn): modified the warnings framework to
2195 * IPython/genutils.py (warn): modified the warnings framework to
2184 use the Term I/O class. I'm trying to slowly unify all of
2196 use the Term I/O class. I'm trying to slowly unify all of
2185 IPython's I/O operations to pass through Term.
2197 IPython's I/O operations to pass through Term.
2186
2198
2187 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2199 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2188 the secondary prompt to correctly match the length of the primary
2200 the secondary prompt to correctly match the length of the primary
2189 one for any prompt. Now multi-line code will properly line up
2201 one for any prompt. Now multi-line code will properly line up
2190 even for path dependent prompts, such as the new ones available
2202 even for path dependent prompts, such as the new ones available
2191 via the prompt_specials.
2203 via the prompt_specials.
2192
2204
2193 2004-06-06 Fernando Perez <fperez@colorado.edu>
2205 2004-06-06 Fernando Perez <fperez@colorado.edu>
2194
2206
2195 * IPython/Prompts.py (prompt_specials): Added the ability to have
2207 * IPython/Prompts.py (prompt_specials): Added the ability to have
2196 bash-like special sequences in the prompts, which get
2208 bash-like special sequences in the prompts, which get
2197 automatically expanded. Things like hostname, current working
2209 automatically expanded. Things like hostname, current working
2198 directory and username are implemented already, but it's easy to
2210 directory and username are implemented already, but it's easy to
2199 add more in the future. Thanks to a patch by W.J. van der Laan
2211 add more in the future. Thanks to a patch by W.J. van der Laan
2200 <gnufnork-AT-hetdigitalegat.nl>
2212 <gnufnork-AT-hetdigitalegat.nl>
2201 (prompt_specials): Added color support for prompt strings, so
2213 (prompt_specials): Added color support for prompt strings, so
2202 users can define arbitrary color setups for their prompts.
2214 users can define arbitrary color setups for their prompts.
2203
2215
2204 2004-06-05 Fernando Perez <fperez@colorado.edu>
2216 2004-06-05 Fernando Perez <fperez@colorado.edu>
2205
2217
2206 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2218 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2207 code to load Gary Bishop's readline and configure it
2219 code to load Gary Bishop's readline and configure it
2208 automatically. Thanks to Gary for help on this.
2220 automatically. Thanks to Gary for help on this.
2209
2221
2210 2004-06-01 Fernando Perez <fperez@colorado.edu>
2222 2004-06-01 Fernando Perez <fperez@colorado.edu>
2211
2223
2212 * IPython/Logger.py (Logger.create_log): fix bug for logging
2224 * IPython/Logger.py (Logger.create_log): fix bug for logging
2213 with no filename (previous fix was incomplete).
2225 with no filename (previous fix was incomplete).
2214
2226
2215 2004-05-25 Fernando Perez <fperez@colorado.edu>
2227 2004-05-25 Fernando Perez <fperez@colorado.edu>
2216
2228
2217 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2229 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2218 parens would get passed to the shell.
2230 parens would get passed to the shell.
2219
2231
2220 2004-05-20 Fernando Perez <fperez@colorado.edu>
2232 2004-05-20 Fernando Perez <fperez@colorado.edu>
2221
2233
2222 * IPython/Magic.py (Magic.magic_prun): changed default profile
2234 * IPython/Magic.py (Magic.magic_prun): changed default profile
2223 sort order to 'time' (the more common profiling need).
2235 sort order to 'time' (the more common profiling need).
2224
2236
2225 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2237 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2226 so that source code shown is guaranteed in sync with the file on
2238 so that source code shown is guaranteed in sync with the file on
2227 disk (also changed in psource). Similar fix to the one for
2239 disk (also changed in psource). Similar fix to the one for
2228 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2240 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2229 <yann.ledu-AT-noos.fr>.
2241 <yann.ledu-AT-noos.fr>.
2230
2242
2231 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2243 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2232 with a single option would not be correctly parsed. Closes
2244 with a single option would not be correctly parsed. Closes
2233 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2245 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2234 introduced in 0.6.0 (on 2004-05-06).
2246 introduced in 0.6.0 (on 2004-05-06).
2235
2247
2236 2004-05-13 *** Released version 0.6.0
2248 2004-05-13 *** Released version 0.6.0
2237
2249
2238 2004-05-13 Fernando Perez <fperez@colorado.edu>
2250 2004-05-13 Fernando Perez <fperez@colorado.edu>
2239
2251
2240 * debian/: Added debian/ directory to CVS, so that debian support
2252 * debian/: Added debian/ directory to CVS, so that debian support
2241 is publicly accessible. The debian package is maintained by Jack
2253 is publicly accessible. The debian package is maintained by Jack
2242 Moffit <jack-AT-xiph.org>.
2254 Moffit <jack-AT-xiph.org>.
2243
2255
2244 * Documentation: included the notes about an ipython-based system
2256 * Documentation: included the notes about an ipython-based system
2245 shell (the hypothetical 'pysh') into the new_design.pdf document,
2257 shell (the hypothetical 'pysh') into the new_design.pdf document,
2246 so that these ideas get distributed to users along with the
2258 so that these ideas get distributed to users along with the
2247 official documentation.
2259 official documentation.
2248
2260
2249 2004-05-10 Fernando Perez <fperez@colorado.edu>
2261 2004-05-10 Fernando Perez <fperez@colorado.edu>
2250
2262
2251 * IPython/Logger.py (Logger.create_log): fix recently introduced
2263 * IPython/Logger.py (Logger.create_log): fix recently introduced
2252 bug (misindented line) where logstart would fail when not given an
2264 bug (misindented line) where logstart would fail when not given an
2253 explicit filename.
2265 explicit filename.
2254
2266
2255 2004-05-09 Fernando Perez <fperez@colorado.edu>
2267 2004-05-09 Fernando Perez <fperez@colorado.edu>
2256
2268
2257 * IPython/Magic.py (Magic.parse_options): skip system call when
2269 * IPython/Magic.py (Magic.parse_options): skip system call when
2258 there are no options to look for. Faster, cleaner for the common
2270 there are no options to look for. Faster, cleaner for the common
2259 case.
2271 case.
2260
2272
2261 * Documentation: many updates to the manual: describing Windows
2273 * Documentation: many updates to the manual: describing Windows
2262 support better, Gnuplot updates, credits, misc small stuff. Also
2274 support better, Gnuplot updates, credits, misc small stuff. Also
2263 updated the new_design doc a bit.
2275 updated the new_design doc a bit.
2264
2276
2265 2004-05-06 *** Released version 0.6.0.rc1
2277 2004-05-06 *** Released version 0.6.0.rc1
2266
2278
2267 2004-05-06 Fernando Perez <fperez@colorado.edu>
2279 2004-05-06 Fernando Perez <fperez@colorado.edu>
2268
2280
2269 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2281 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2270 operations to use the vastly more efficient list/''.join() method.
2282 operations to use the vastly more efficient list/''.join() method.
2271 (FormattedTB.text): Fix
2283 (FormattedTB.text): Fix
2272 http://www.scipy.net/roundup/ipython/issue12 - exception source
2284 http://www.scipy.net/roundup/ipython/issue12 - exception source
2273 extract not updated after reload. Thanks to Mike Salib
2285 extract not updated after reload. Thanks to Mike Salib
2274 <msalib-AT-mit.edu> for pinning the source of the problem.
2286 <msalib-AT-mit.edu> for pinning the source of the problem.
2275 Fortunately, the solution works inside ipython and doesn't require
2287 Fortunately, the solution works inside ipython and doesn't require
2276 any changes to python proper.
2288 any changes to python proper.
2277
2289
2278 * IPython/Magic.py (Magic.parse_options): Improved to process the
2290 * IPython/Magic.py (Magic.parse_options): Improved to process the
2279 argument list as a true shell would (by actually using the
2291 argument list as a true shell would (by actually using the
2280 underlying system shell). This way, all @magics automatically get
2292 underlying system shell). This way, all @magics automatically get
2281 shell expansion for variables. Thanks to a comment by Alex
2293 shell expansion for variables. Thanks to a comment by Alex
2282 Schmolck.
2294 Schmolck.
2283
2295
2284 2004-04-04 Fernando Perez <fperez@colorado.edu>
2296 2004-04-04 Fernando Perez <fperez@colorado.edu>
2285
2297
2286 * IPython/iplib.py (InteractiveShell.interact): Added a special
2298 * IPython/iplib.py (InteractiveShell.interact): Added a special
2287 trap for a debugger quit exception, which is basically impossible
2299 trap for a debugger quit exception, which is basically impossible
2288 to handle by normal mechanisms, given what pdb does to the stack.
2300 to handle by normal mechanisms, given what pdb does to the stack.
2289 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2301 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2290
2302
2291 2004-04-03 Fernando Perez <fperez@colorado.edu>
2303 2004-04-03 Fernando Perez <fperez@colorado.edu>
2292
2304
2293 * IPython/genutils.py (Term): Standardized the names of the Term
2305 * IPython/genutils.py (Term): Standardized the names of the Term
2294 class streams to cin/cout/cerr, following C++ naming conventions
2306 class streams to cin/cout/cerr, following C++ naming conventions
2295 (I can't use in/out/err because 'in' is not a valid attribute
2307 (I can't use in/out/err because 'in' is not a valid attribute
2296 name).
2308 name).
2297
2309
2298 * IPython/iplib.py (InteractiveShell.interact): don't increment
2310 * IPython/iplib.py (InteractiveShell.interact): don't increment
2299 the prompt if there's no user input. By Daniel 'Dang' Griffith
2311 the prompt if there's no user input. By Daniel 'Dang' Griffith
2300 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2312 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2301 Francois Pinard.
2313 Francois Pinard.
2302
2314
2303 2004-04-02 Fernando Perez <fperez@colorado.edu>
2315 2004-04-02 Fernando Perez <fperez@colorado.edu>
2304
2316
2305 * IPython/genutils.py (Stream.__init__): Modified to survive at
2317 * IPython/genutils.py (Stream.__init__): Modified to survive at
2306 least importing in contexts where stdin/out/err aren't true file
2318 least importing in contexts where stdin/out/err aren't true file
2307 objects, such as PyCrust (they lack fileno() and mode). However,
2319 objects, such as PyCrust (they lack fileno() and mode). However,
2308 the recovery facilities which rely on these things existing will
2320 the recovery facilities which rely on these things existing will
2309 not work.
2321 not work.
2310
2322
2311 2004-04-01 Fernando Perez <fperez@colorado.edu>
2323 2004-04-01 Fernando Perez <fperez@colorado.edu>
2312
2324
2313 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2325 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2314 use the new getoutputerror() function, so it properly
2326 use the new getoutputerror() function, so it properly
2315 distinguishes stdout/err.
2327 distinguishes stdout/err.
2316
2328
2317 * IPython/genutils.py (getoutputerror): added a function to
2329 * IPython/genutils.py (getoutputerror): added a function to
2318 capture separately the standard output and error of a command.
2330 capture separately the standard output and error of a command.
2319 After a comment from dang on the mailing lists. This code is
2331 After a comment from dang on the mailing lists. This code is
2320 basically a modified version of commands.getstatusoutput(), from
2332 basically a modified version of commands.getstatusoutput(), from
2321 the standard library.
2333 the standard library.
2322
2334
2323 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2335 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2324 '!!' as a special syntax (shorthand) to access @sx.
2336 '!!' as a special syntax (shorthand) to access @sx.
2325
2337
2326 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2338 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2327 command and return its output as a list split on '\n'.
2339 command and return its output as a list split on '\n'.
2328
2340
2329 2004-03-31 Fernando Perez <fperez@colorado.edu>
2341 2004-03-31 Fernando Perez <fperez@colorado.edu>
2330
2342
2331 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2343 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2332 method to dictionaries used as FakeModule instances if they lack
2344 method to dictionaries used as FakeModule instances if they lack
2333 it. At least pydoc in python2.3 breaks for runtime-defined
2345 it. At least pydoc in python2.3 breaks for runtime-defined
2334 functions without this hack. At some point I need to _really_
2346 functions without this hack. At some point I need to _really_
2335 understand what FakeModule is doing, because it's a gross hack.
2347 understand what FakeModule is doing, because it's a gross hack.
2336 But it solves Arnd's problem for now...
2348 But it solves Arnd's problem for now...
2337
2349
2338 2004-02-27 Fernando Perez <fperez@colorado.edu>
2350 2004-02-27 Fernando Perez <fperez@colorado.edu>
2339
2351
2340 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2352 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2341 mode would behave erratically. Also increased the number of
2353 mode would behave erratically. Also increased the number of
2342 possible logs in rotate mod to 999. Thanks to Rod Holland
2354 possible logs in rotate mod to 999. Thanks to Rod Holland
2343 <rhh@StructureLABS.com> for the report and fixes.
2355 <rhh@StructureLABS.com> for the report and fixes.
2344
2356
2345 2004-02-26 Fernando Perez <fperez@colorado.edu>
2357 2004-02-26 Fernando Perez <fperez@colorado.edu>
2346
2358
2347 * IPython/genutils.py (page): Check that the curses module really
2359 * IPython/genutils.py (page): Check that the curses module really
2348 has the initscr attribute before trying to use it. For some
2360 has the initscr attribute before trying to use it. For some
2349 reason, the Solaris curses module is missing this. I think this
2361 reason, the Solaris curses module is missing this. I think this
2350 should be considered a Solaris python bug, but I'm not sure.
2362 should be considered a Solaris python bug, but I'm not sure.
2351
2363
2352 2004-01-17 Fernando Perez <fperez@colorado.edu>
2364 2004-01-17 Fernando Perez <fperez@colorado.edu>
2353
2365
2354 * IPython/genutils.py (Stream.__init__): Changes to try to make
2366 * IPython/genutils.py (Stream.__init__): Changes to try to make
2355 ipython robust against stdin/out/err being closed by the user.
2367 ipython robust against stdin/out/err being closed by the user.
2356 This is 'user error' (and blocks a normal python session, at least
2368 This is 'user error' (and blocks a normal python session, at least
2357 the stdout case). However, Ipython should be able to survive such
2369 the stdout case). However, Ipython should be able to survive such
2358 instances of abuse as gracefully as possible. To simplify the
2370 instances of abuse as gracefully as possible. To simplify the
2359 coding and maintain compatibility with Gary Bishop's Term
2371 coding and maintain compatibility with Gary Bishop's Term
2360 contributions, I've made use of classmethods for this. I think
2372 contributions, I've made use of classmethods for this. I think
2361 this introduces a dependency on python 2.2.
2373 this introduces a dependency on python 2.2.
2362
2374
2363 2004-01-13 Fernando Perez <fperez@colorado.edu>
2375 2004-01-13 Fernando Perez <fperez@colorado.edu>
2364
2376
2365 * IPython/numutils.py (exp_safe): simplified the code a bit and
2377 * IPython/numutils.py (exp_safe): simplified the code a bit and
2366 removed the need for importing the kinds module altogether.
2378 removed the need for importing the kinds module altogether.
2367
2379
2368 2004-01-06 Fernando Perez <fperez@colorado.edu>
2380 2004-01-06 Fernando Perez <fperez@colorado.edu>
2369
2381
2370 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2382 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2371 a magic function instead, after some community feedback. No
2383 a magic function instead, after some community feedback. No
2372 special syntax will exist for it, but its name is deliberately
2384 special syntax will exist for it, but its name is deliberately
2373 very short.
2385 very short.
2374
2386
2375 2003-12-20 Fernando Perez <fperez@colorado.edu>
2387 2003-12-20 Fernando Perez <fperez@colorado.edu>
2376
2388
2377 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2389 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2378 new functionality, to automagically assign the result of a shell
2390 new functionality, to automagically assign the result of a shell
2379 command to a variable. I'll solicit some community feedback on
2391 command to a variable. I'll solicit some community feedback on
2380 this before making it permanent.
2392 this before making it permanent.
2381
2393
2382 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2394 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2383 requested about callables for which inspect couldn't obtain a
2395 requested about callables for which inspect couldn't obtain a
2384 proper argspec. Thanks to a crash report sent by Etienne
2396 proper argspec. Thanks to a crash report sent by Etienne
2385 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2397 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2386
2398
2387 2003-12-09 Fernando Perez <fperez@colorado.edu>
2399 2003-12-09 Fernando Perez <fperez@colorado.edu>
2388
2400
2389 * IPython/genutils.py (page): patch for the pager to work across
2401 * IPython/genutils.py (page): patch for the pager to work across
2390 various versions of Windows. By Gary Bishop.
2402 various versions of Windows. By Gary Bishop.
2391
2403
2392 2003-12-04 Fernando Perez <fperez@colorado.edu>
2404 2003-12-04 Fernando Perez <fperez@colorado.edu>
2393
2405
2394 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2406 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2395 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2407 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2396 While I tested this and it looks ok, there may still be corner
2408 While I tested this and it looks ok, there may still be corner
2397 cases I've missed.
2409 cases I've missed.
2398
2410
2399 2003-12-01 Fernando Perez <fperez@colorado.edu>
2411 2003-12-01 Fernando Perez <fperez@colorado.edu>
2400
2412
2401 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2413 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2402 where a line like 'p,q=1,2' would fail because the automagic
2414 where a line like 'p,q=1,2' would fail because the automagic
2403 system would be triggered for @p.
2415 system would be triggered for @p.
2404
2416
2405 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2417 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2406 cleanups, code unmodified.
2418 cleanups, code unmodified.
2407
2419
2408 * IPython/genutils.py (Term): added a class for IPython to handle
2420 * IPython/genutils.py (Term): added a class for IPython to handle
2409 output. In most cases it will just be a proxy for stdout/err, but
2421 output. In most cases it will just be a proxy for stdout/err, but
2410 having this allows modifications to be made for some platforms,
2422 having this allows modifications to be made for some platforms,
2411 such as handling color escapes under Windows. All of this code
2423 such as handling color escapes under Windows. All of this code
2412 was contributed by Gary Bishop, with minor modifications by me.
2424 was contributed by Gary Bishop, with minor modifications by me.
2413 The actual changes affect many files.
2425 The actual changes affect many files.
2414
2426
2415 2003-11-30 Fernando Perez <fperez@colorado.edu>
2427 2003-11-30 Fernando Perez <fperez@colorado.edu>
2416
2428
2417 * IPython/iplib.py (file_matches): new completion code, courtesy
2429 * IPython/iplib.py (file_matches): new completion code, courtesy
2418 of Jeff Collins. This enables filename completion again under
2430 of Jeff Collins. This enables filename completion again under
2419 python 2.3, which disabled it at the C level.
2431 python 2.3, which disabled it at the C level.
2420
2432
2421 2003-11-11 Fernando Perez <fperez@colorado.edu>
2433 2003-11-11 Fernando Perez <fperez@colorado.edu>
2422
2434
2423 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2435 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2424 for Numeric.array(map(...)), but often convenient.
2436 for Numeric.array(map(...)), but often convenient.
2425
2437
2426 2003-11-05 Fernando Perez <fperez@colorado.edu>
2438 2003-11-05 Fernando Perez <fperez@colorado.edu>
2427
2439
2428 * IPython/numutils.py (frange): Changed a call from int() to
2440 * IPython/numutils.py (frange): Changed a call from int() to
2429 int(round()) to prevent a problem reported with arange() in the
2441 int(round()) to prevent a problem reported with arange() in the
2430 numpy list.
2442 numpy list.
2431
2443
2432 2003-10-06 Fernando Perez <fperez@colorado.edu>
2444 2003-10-06 Fernando Perez <fperez@colorado.edu>
2433
2445
2434 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2446 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2435 prevent crashes if sys lacks an argv attribute (it happens with
2447 prevent crashes if sys lacks an argv attribute (it happens with
2436 embedded interpreters which build a bare-bones sys module).
2448 embedded interpreters which build a bare-bones sys module).
2437 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2449 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2438
2450
2439 2003-09-24 Fernando Perez <fperez@colorado.edu>
2451 2003-09-24 Fernando Perez <fperez@colorado.edu>
2440
2452
2441 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2453 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2442 to protect against poorly written user objects where __getattr__
2454 to protect against poorly written user objects where __getattr__
2443 raises exceptions other than AttributeError. Thanks to a bug
2455 raises exceptions other than AttributeError. Thanks to a bug
2444 report by Oliver Sander <osander-AT-gmx.de>.
2456 report by Oliver Sander <osander-AT-gmx.de>.
2445
2457
2446 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2458 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2447 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2459 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2448
2460
2449 2003-09-09 Fernando Perez <fperez@colorado.edu>
2461 2003-09-09 Fernando Perez <fperez@colorado.edu>
2450
2462
2451 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2463 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2452 unpacking a list whith a callable as first element would
2464 unpacking a list whith a callable as first element would
2453 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2465 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2454 Collins.
2466 Collins.
2455
2467
2456 2003-08-25 *** Released version 0.5.0
2468 2003-08-25 *** Released version 0.5.0
2457
2469
2458 2003-08-22 Fernando Perez <fperez@colorado.edu>
2470 2003-08-22 Fernando Perez <fperez@colorado.edu>
2459
2471
2460 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2472 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2461 improperly defined user exceptions. Thanks to feedback from Mark
2473 improperly defined user exceptions. Thanks to feedback from Mark
2462 Russell <mrussell-AT-verio.net>.
2474 Russell <mrussell-AT-verio.net>.
2463
2475
2464 2003-08-20 Fernando Perez <fperez@colorado.edu>
2476 2003-08-20 Fernando Perez <fperez@colorado.edu>
2465
2477
2466 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2478 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2467 printing so that it would print multi-line string forms starting
2479 printing so that it would print multi-line string forms starting
2468 with a new line. This way the formatting is better respected for
2480 with a new line. This way the formatting is better respected for
2469 objects which work hard to make nice string forms.
2481 objects which work hard to make nice string forms.
2470
2482
2471 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2483 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2472 autocall would overtake data access for objects with both
2484 autocall would overtake data access for objects with both
2473 __getitem__ and __call__.
2485 __getitem__ and __call__.
2474
2486
2475 2003-08-19 *** Released version 0.5.0-rc1
2487 2003-08-19 *** Released version 0.5.0-rc1
2476
2488
2477 2003-08-19 Fernando Perez <fperez@colorado.edu>
2489 2003-08-19 Fernando Perez <fperez@colorado.edu>
2478
2490
2479 * IPython/deep_reload.py (load_tail): single tiny change here
2491 * IPython/deep_reload.py (load_tail): single tiny change here
2480 seems to fix the long-standing bug of dreload() failing to work
2492 seems to fix the long-standing bug of dreload() failing to work
2481 for dotted names. But this module is pretty tricky, so I may have
2493 for dotted names. But this module is pretty tricky, so I may have
2482 missed some subtlety. Needs more testing!.
2494 missed some subtlety. Needs more testing!.
2483
2495
2484 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2496 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2485 exceptions which have badly implemented __str__ methods.
2497 exceptions which have badly implemented __str__ methods.
2486 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2498 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2487 which I've been getting reports about from Python 2.3 users. I
2499 which I've been getting reports about from Python 2.3 users. I
2488 wish I had a simple test case to reproduce the problem, so I could
2500 wish I had a simple test case to reproduce the problem, so I could
2489 either write a cleaner workaround or file a bug report if
2501 either write a cleaner workaround or file a bug report if
2490 necessary.
2502 necessary.
2491
2503
2492 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2504 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2493 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2505 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2494 a bug report by Tjabo Kloppenburg.
2506 a bug report by Tjabo Kloppenburg.
2495
2507
2496 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2508 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2497 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2509 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2498 seems rather unstable. Thanks to a bug report by Tjabo
2510 seems rather unstable. Thanks to a bug report by Tjabo
2499 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2511 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2500
2512
2501 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2513 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2502 this out soon because of the critical fixes in the inner loop for
2514 this out soon because of the critical fixes in the inner loop for
2503 generators.
2515 generators.
2504
2516
2505 * IPython/Magic.py (Magic.getargspec): removed. This (and
2517 * IPython/Magic.py (Magic.getargspec): removed. This (and
2506 _get_def) have been obsoleted by OInspect for a long time, I
2518 _get_def) have been obsoleted by OInspect for a long time, I
2507 hadn't noticed that they were dead code.
2519 hadn't noticed that they were dead code.
2508 (Magic._ofind): restored _ofind functionality for a few literals
2520 (Magic._ofind): restored _ofind functionality for a few literals
2509 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2521 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2510 for things like "hello".capitalize?, since that would require a
2522 for things like "hello".capitalize?, since that would require a
2511 potentially dangerous eval() again.
2523 potentially dangerous eval() again.
2512
2524
2513 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2525 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2514 logic a bit more to clean up the escapes handling and minimize the
2526 logic a bit more to clean up the escapes handling and minimize the
2515 use of _ofind to only necessary cases. The interactive 'feel' of
2527 use of _ofind to only necessary cases. The interactive 'feel' of
2516 IPython should have improved quite a bit with the changes in
2528 IPython should have improved quite a bit with the changes in
2517 _prefilter and _ofind (besides being far safer than before).
2529 _prefilter and _ofind (besides being far safer than before).
2518
2530
2519 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2531 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2520 obscure, never reported). Edit would fail to find the object to
2532 obscure, never reported). Edit would fail to find the object to
2521 edit under some circumstances.
2533 edit under some circumstances.
2522 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2534 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2523 which were causing double-calling of generators. Those eval calls
2535 which were causing double-calling of generators. Those eval calls
2524 were _very_ dangerous, since code with side effects could be
2536 were _very_ dangerous, since code with side effects could be
2525 triggered. As they say, 'eval is evil'... These were the
2537 triggered. As they say, 'eval is evil'... These were the
2526 nastiest evals in IPython. Besides, _ofind is now far simpler,
2538 nastiest evals in IPython. Besides, _ofind is now far simpler,
2527 and it should also be quite a bit faster. Its use of inspect is
2539 and it should also be quite a bit faster. Its use of inspect is
2528 also safer, so perhaps some of the inspect-related crashes I've
2540 also safer, so perhaps some of the inspect-related crashes I've
2529 seen lately with Python 2.3 might be taken care of. That will
2541 seen lately with Python 2.3 might be taken care of. That will
2530 need more testing.
2542 need more testing.
2531
2543
2532 2003-08-17 Fernando Perez <fperez@colorado.edu>
2544 2003-08-17 Fernando Perez <fperez@colorado.edu>
2533
2545
2534 * IPython/iplib.py (InteractiveShell._prefilter): significant
2546 * IPython/iplib.py (InteractiveShell._prefilter): significant
2535 simplifications to the logic for handling user escapes. Faster
2547 simplifications to the logic for handling user escapes. Faster
2536 and simpler code.
2548 and simpler code.
2537
2549
2538 2003-08-14 Fernando Perez <fperez@colorado.edu>
2550 2003-08-14 Fernando Perez <fperez@colorado.edu>
2539
2551
2540 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2552 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2541 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2553 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2542 but it should be quite a bit faster. And the recursive version
2554 but it should be quite a bit faster. And the recursive version
2543 generated O(log N) intermediate storage for all rank>1 arrays,
2555 generated O(log N) intermediate storage for all rank>1 arrays,
2544 even if they were contiguous.
2556 even if they were contiguous.
2545 (l1norm): Added this function.
2557 (l1norm): Added this function.
2546 (norm): Added this function for arbitrary norms (including
2558 (norm): Added this function for arbitrary norms (including
2547 l-infinity). l1 and l2 are still special cases for convenience
2559 l-infinity). l1 and l2 are still special cases for convenience
2548 and speed.
2560 and speed.
2549
2561
2550 2003-08-03 Fernando Perez <fperez@colorado.edu>
2562 2003-08-03 Fernando Perez <fperez@colorado.edu>
2551
2563
2552 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2564 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2553 exceptions, which now raise PendingDeprecationWarnings in Python
2565 exceptions, which now raise PendingDeprecationWarnings in Python
2554 2.3. There were some in Magic and some in Gnuplot2.
2566 2.3. There were some in Magic and some in Gnuplot2.
2555
2567
2556 2003-06-30 Fernando Perez <fperez@colorado.edu>
2568 2003-06-30 Fernando Perez <fperez@colorado.edu>
2557
2569
2558 * IPython/genutils.py (page): modified to call curses only for
2570 * IPython/genutils.py (page): modified to call curses only for
2559 terminals where TERM=='xterm'. After problems under many other
2571 terminals where TERM=='xterm'. After problems under many other
2560 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2572 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2561
2573
2562 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2574 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2563 would be triggered when readline was absent. This was just an old
2575 would be triggered when readline was absent. This was just an old
2564 debugging statement I'd forgotten to take out.
2576 debugging statement I'd forgotten to take out.
2565
2577
2566 2003-06-20 Fernando Perez <fperez@colorado.edu>
2578 2003-06-20 Fernando Perez <fperez@colorado.edu>
2567
2579
2568 * IPython/genutils.py (clock): modified to return only user time
2580 * IPython/genutils.py (clock): modified to return only user time
2569 (not counting system time), after a discussion on scipy. While
2581 (not counting system time), after a discussion on scipy. While
2570 system time may be a useful quantity occasionally, it may much
2582 system time may be a useful quantity occasionally, it may much
2571 more easily be skewed by occasional swapping or other similar
2583 more easily be skewed by occasional swapping or other similar
2572 activity.
2584 activity.
2573
2585
2574 2003-06-05 Fernando Perez <fperez@colorado.edu>
2586 2003-06-05 Fernando Perez <fperez@colorado.edu>
2575
2587
2576 * IPython/numutils.py (identity): new function, for building
2588 * IPython/numutils.py (identity): new function, for building
2577 arbitrary rank Kronecker deltas (mostly backwards compatible with
2589 arbitrary rank Kronecker deltas (mostly backwards compatible with
2578 Numeric.identity)
2590 Numeric.identity)
2579
2591
2580 2003-06-03 Fernando Perez <fperez@colorado.edu>
2592 2003-06-03 Fernando Perez <fperez@colorado.edu>
2581
2593
2582 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2594 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2583 arguments passed to magics with spaces, to allow trailing '\' to
2595 arguments passed to magics with spaces, to allow trailing '\' to
2584 work normally (mainly for Windows users).
2596 work normally (mainly for Windows users).
2585
2597
2586 2003-05-29 Fernando Perez <fperez@colorado.edu>
2598 2003-05-29 Fernando Perez <fperez@colorado.edu>
2587
2599
2588 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2600 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2589 instead of pydoc.help. This fixes a bizarre behavior where
2601 instead of pydoc.help. This fixes a bizarre behavior where
2590 printing '%s' % locals() would trigger the help system. Now
2602 printing '%s' % locals() would trigger the help system. Now
2591 ipython behaves like normal python does.
2603 ipython behaves like normal python does.
2592
2604
2593 Note that if one does 'from pydoc import help', the bizarre
2605 Note that if one does 'from pydoc import help', the bizarre
2594 behavior returns, but this will also happen in normal python, so
2606 behavior returns, but this will also happen in normal python, so
2595 it's not an ipython bug anymore (it has to do with how pydoc.help
2607 it's not an ipython bug anymore (it has to do with how pydoc.help
2596 is implemented).
2608 is implemented).
2597
2609
2598 2003-05-22 Fernando Perez <fperez@colorado.edu>
2610 2003-05-22 Fernando Perez <fperez@colorado.edu>
2599
2611
2600 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2612 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2601 return [] instead of None when nothing matches, also match to end
2613 return [] instead of None when nothing matches, also match to end
2602 of line. Patch by Gary Bishop.
2614 of line. Patch by Gary Bishop.
2603
2615
2604 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2616 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2605 protection as before, for files passed on the command line. This
2617 protection as before, for files passed on the command line. This
2606 prevents the CrashHandler from kicking in if user files call into
2618 prevents the CrashHandler from kicking in if user files call into
2607 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2619 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2608 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2620 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2609
2621
2610 2003-05-20 *** Released version 0.4.0
2622 2003-05-20 *** Released version 0.4.0
2611
2623
2612 2003-05-20 Fernando Perez <fperez@colorado.edu>
2624 2003-05-20 Fernando Perez <fperez@colorado.edu>
2613
2625
2614 * setup.py: added support for manpages. It's a bit hackish b/c of
2626 * setup.py: added support for manpages. It's a bit hackish b/c of
2615 a bug in the way the bdist_rpm distutils target handles gzipped
2627 a bug in the way the bdist_rpm distutils target handles gzipped
2616 manpages, but it works. After a patch by Jack.
2628 manpages, but it works. After a patch by Jack.
2617
2629
2618 2003-05-19 Fernando Perez <fperez@colorado.edu>
2630 2003-05-19 Fernando Perez <fperez@colorado.edu>
2619
2631
2620 * IPython/numutils.py: added a mockup of the kinds module, since
2632 * IPython/numutils.py: added a mockup of the kinds module, since
2621 it was recently removed from Numeric. This way, numutils will
2633 it was recently removed from Numeric. This way, numutils will
2622 work for all users even if they are missing kinds.
2634 work for all users even if they are missing kinds.
2623
2635
2624 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2636 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2625 failure, which can occur with SWIG-wrapped extensions. After a
2637 failure, which can occur with SWIG-wrapped extensions. After a
2626 crash report from Prabhu.
2638 crash report from Prabhu.
2627
2639
2628 2003-05-16 Fernando Perez <fperez@colorado.edu>
2640 2003-05-16 Fernando Perez <fperez@colorado.edu>
2629
2641
2630 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2642 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2631 protect ipython from user code which may call directly
2643 protect ipython from user code which may call directly
2632 sys.excepthook (this looks like an ipython crash to the user, even
2644 sys.excepthook (this looks like an ipython crash to the user, even
2633 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2645 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2634 This is especially important to help users of WxWindows, but may
2646 This is especially important to help users of WxWindows, but may
2635 also be useful in other cases.
2647 also be useful in other cases.
2636
2648
2637 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2649 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2638 an optional tb_offset to be specified, and to preserve exception
2650 an optional tb_offset to be specified, and to preserve exception
2639 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2651 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2640
2652
2641 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2653 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2642
2654
2643 2003-05-15 Fernando Perez <fperez@colorado.edu>
2655 2003-05-15 Fernando Perez <fperez@colorado.edu>
2644
2656
2645 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2657 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2646 installing for a new user under Windows.
2658 installing for a new user under Windows.
2647
2659
2648 2003-05-12 Fernando Perez <fperez@colorado.edu>
2660 2003-05-12 Fernando Perez <fperez@colorado.edu>
2649
2661
2650 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2662 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2651 handler for Emacs comint-based lines. Currently it doesn't do
2663 handler for Emacs comint-based lines. Currently it doesn't do
2652 much (but importantly, it doesn't update the history cache). In
2664 much (but importantly, it doesn't update the history cache). In
2653 the future it may be expanded if Alex needs more functionality
2665 the future it may be expanded if Alex needs more functionality
2654 there.
2666 there.
2655
2667
2656 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2668 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2657 info to crash reports.
2669 info to crash reports.
2658
2670
2659 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2671 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2660 just like Python's -c. Also fixed crash with invalid -color
2672 just like Python's -c. Also fixed crash with invalid -color
2661 option value at startup. Thanks to Will French
2673 option value at startup. Thanks to Will French
2662 <wfrench-AT-bestweb.net> for the bug report.
2674 <wfrench-AT-bestweb.net> for the bug report.
2663
2675
2664 2003-05-09 Fernando Perez <fperez@colorado.edu>
2676 2003-05-09 Fernando Perez <fperez@colorado.edu>
2665
2677
2666 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2678 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2667 to EvalDict (it's a mapping, after all) and simplified its code
2679 to EvalDict (it's a mapping, after all) and simplified its code
2668 quite a bit, after a nice discussion on c.l.py where Gustavo
2680 quite a bit, after a nice discussion on c.l.py where Gustavo
2669 Córdova <gcordova-AT-sismex.com> suggested the new version.
2681 Córdova <gcordova-AT-sismex.com> suggested the new version.
2670
2682
2671 2003-04-30 Fernando Perez <fperez@colorado.edu>
2683 2003-04-30 Fernando Perez <fperez@colorado.edu>
2672
2684
2673 * IPython/genutils.py (timings_out): modified it to reduce its
2685 * IPython/genutils.py (timings_out): modified it to reduce its
2674 overhead in the common reps==1 case.
2686 overhead in the common reps==1 case.
2675
2687
2676 2003-04-29 Fernando Perez <fperez@colorado.edu>
2688 2003-04-29 Fernando Perez <fperez@colorado.edu>
2677
2689
2678 * IPython/genutils.py (timings_out): Modified to use the resource
2690 * IPython/genutils.py (timings_out): Modified to use the resource
2679 module, which avoids the wraparound problems of time.clock().
2691 module, which avoids the wraparound problems of time.clock().
2680
2692
2681 2003-04-17 *** Released version 0.2.15pre4
2693 2003-04-17 *** Released version 0.2.15pre4
2682
2694
2683 2003-04-17 Fernando Perez <fperez@colorado.edu>
2695 2003-04-17 Fernando Perez <fperez@colorado.edu>
2684
2696
2685 * setup.py (scriptfiles): Split windows-specific stuff over to a
2697 * setup.py (scriptfiles): Split windows-specific stuff over to a
2686 separate file, in an attempt to have a Windows GUI installer.
2698 separate file, in an attempt to have a Windows GUI installer.
2687 That didn't work, but part of the groundwork is done.
2699 That didn't work, but part of the groundwork is done.
2688
2700
2689 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2701 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2690 indent/unindent with 4 spaces. Particularly useful in combination
2702 indent/unindent with 4 spaces. Particularly useful in combination
2691 with the new auto-indent option.
2703 with the new auto-indent option.
2692
2704
2693 2003-04-16 Fernando Perez <fperez@colorado.edu>
2705 2003-04-16 Fernando Perez <fperez@colorado.edu>
2694
2706
2695 * IPython/Magic.py: various replacements of self.rc for
2707 * IPython/Magic.py: various replacements of self.rc for
2696 self.shell.rc. A lot more remains to be done to fully disentangle
2708 self.shell.rc. A lot more remains to be done to fully disentangle
2697 this class from the main Shell class.
2709 this class from the main Shell class.
2698
2710
2699 * IPython/GnuplotRuntime.py: added checks for mouse support so
2711 * IPython/GnuplotRuntime.py: added checks for mouse support so
2700 that we don't try to enable it if the current gnuplot doesn't
2712 that we don't try to enable it if the current gnuplot doesn't
2701 really support it. Also added checks so that we don't try to
2713 really support it. Also added checks so that we don't try to
2702 enable persist under Windows (where Gnuplot doesn't recognize the
2714 enable persist under Windows (where Gnuplot doesn't recognize the
2703 option).
2715 option).
2704
2716
2705 * IPython/iplib.py (InteractiveShell.interact): Added optional
2717 * IPython/iplib.py (InteractiveShell.interact): Added optional
2706 auto-indenting code, after a patch by King C. Shu
2718 auto-indenting code, after a patch by King C. Shu
2707 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2719 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2708 get along well with pasting indented code. If I ever figure out
2720 get along well with pasting indented code. If I ever figure out
2709 how to make that part go well, it will become on by default.
2721 how to make that part go well, it will become on by default.
2710
2722
2711 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2723 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2712 crash ipython if there was an unmatched '%' in the user's prompt
2724 crash ipython if there was an unmatched '%' in the user's prompt
2713 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2725 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2714
2726
2715 * IPython/iplib.py (InteractiveShell.interact): removed the
2727 * IPython/iplib.py (InteractiveShell.interact): removed the
2716 ability to ask the user whether he wants to crash or not at the
2728 ability to ask the user whether he wants to crash or not at the
2717 'last line' exception handler. Calling functions at that point
2729 'last line' exception handler. Calling functions at that point
2718 changes the stack, and the error reports would have incorrect
2730 changes the stack, and the error reports would have incorrect
2719 tracebacks.
2731 tracebacks.
2720
2732
2721 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2733 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2722 pass through a peger a pretty-printed form of any object. After a
2734 pass through a peger a pretty-printed form of any object. After a
2723 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2735 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2724
2736
2725 2003-04-14 Fernando Perez <fperez@colorado.edu>
2737 2003-04-14 Fernando Perez <fperez@colorado.edu>
2726
2738
2727 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2739 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2728 all files in ~ would be modified at first install (instead of
2740 all files in ~ would be modified at first install (instead of
2729 ~/.ipython). This could be potentially disastrous, as the
2741 ~/.ipython). This could be potentially disastrous, as the
2730 modification (make line-endings native) could damage binary files.
2742 modification (make line-endings native) could damage binary files.
2731
2743
2732 2003-04-10 Fernando Perez <fperez@colorado.edu>
2744 2003-04-10 Fernando Perez <fperez@colorado.edu>
2733
2745
2734 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2746 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2735 handle only lines which are invalid python. This now means that
2747 handle only lines which are invalid python. This now means that
2736 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2748 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2737 for the bug report.
2749 for the bug report.
2738
2750
2739 2003-04-01 Fernando Perez <fperez@colorado.edu>
2751 2003-04-01 Fernando Perez <fperez@colorado.edu>
2740
2752
2741 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2753 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2742 where failing to set sys.last_traceback would crash pdb.pm().
2754 where failing to set sys.last_traceback would crash pdb.pm().
2743 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2755 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2744 report.
2756 report.
2745
2757
2746 2003-03-25 Fernando Perez <fperez@colorado.edu>
2758 2003-03-25 Fernando Perez <fperez@colorado.edu>
2747
2759
2748 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2760 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2749 before printing it (it had a lot of spurious blank lines at the
2761 before printing it (it had a lot of spurious blank lines at the
2750 end).
2762 end).
2751
2763
2752 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2764 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2753 output would be sent 21 times! Obviously people don't use this
2765 output would be sent 21 times! Obviously people don't use this
2754 too often, or I would have heard about it.
2766 too often, or I would have heard about it.
2755
2767
2756 2003-03-24 Fernando Perez <fperez@colorado.edu>
2768 2003-03-24 Fernando Perez <fperez@colorado.edu>
2757
2769
2758 * setup.py (scriptfiles): renamed the data_files parameter from
2770 * setup.py (scriptfiles): renamed the data_files parameter from
2759 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2771 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2760 for the patch.
2772 for the patch.
2761
2773
2762 2003-03-20 Fernando Perez <fperez@colorado.edu>
2774 2003-03-20 Fernando Perez <fperez@colorado.edu>
2763
2775
2764 * IPython/genutils.py (error): added error() and fatal()
2776 * IPython/genutils.py (error): added error() and fatal()
2765 functions.
2777 functions.
2766
2778
2767 2003-03-18 *** Released version 0.2.15pre3
2779 2003-03-18 *** Released version 0.2.15pre3
2768
2780
2769 2003-03-18 Fernando Perez <fperez@colorado.edu>
2781 2003-03-18 Fernando Perez <fperez@colorado.edu>
2770
2782
2771 * setupext/install_data_ext.py
2783 * setupext/install_data_ext.py
2772 (install_data_ext.initialize_options): Class contributed by Jack
2784 (install_data_ext.initialize_options): Class contributed by Jack
2773 Moffit for fixing the old distutils hack. He is sending this to
2785 Moffit for fixing the old distutils hack. He is sending this to
2774 the distutils folks so in the future we may not need it as a
2786 the distutils folks so in the future we may not need it as a
2775 private fix.
2787 private fix.
2776
2788
2777 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2789 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2778 changes for Debian packaging. See his patch for full details.
2790 changes for Debian packaging. See his patch for full details.
2779 The old distutils hack of making the ipythonrc* files carry a
2791 The old distutils hack of making the ipythonrc* files carry a
2780 bogus .py extension is gone, at last. Examples were moved to a
2792 bogus .py extension is gone, at last. Examples were moved to a
2781 separate subdir under doc/, and the separate executable scripts
2793 separate subdir under doc/, and the separate executable scripts
2782 now live in their own directory. Overall a great cleanup. The
2794 now live in their own directory. Overall a great cleanup. The
2783 manual was updated to use the new files, and setup.py has been
2795 manual was updated to use the new files, and setup.py has been
2784 fixed for this setup.
2796 fixed for this setup.
2785
2797
2786 * IPython/PyColorize.py (Parser.usage): made non-executable and
2798 * IPython/PyColorize.py (Parser.usage): made non-executable and
2787 created a pycolor wrapper around it to be included as a script.
2799 created a pycolor wrapper around it to be included as a script.
2788
2800
2789 2003-03-12 *** Released version 0.2.15pre2
2801 2003-03-12 *** Released version 0.2.15pre2
2790
2802
2791 2003-03-12 Fernando Perez <fperez@colorado.edu>
2803 2003-03-12 Fernando Perez <fperez@colorado.edu>
2792
2804
2793 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2805 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2794 long-standing problem with garbage characters in some terminals.
2806 long-standing problem with garbage characters in some terminals.
2795 The issue was really that the \001 and \002 escapes must _only_ be
2807 The issue was really that the \001 and \002 escapes must _only_ be
2796 passed to input prompts (which call readline), but _never_ to
2808 passed to input prompts (which call readline), but _never_ to
2797 normal text to be printed on screen. I changed ColorANSI to have
2809 normal text to be printed on screen. I changed ColorANSI to have
2798 two classes: TermColors and InputTermColors, each with the
2810 two classes: TermColors and InputTermColors, each with the
2799 appropriate escapes for input prompts or normal text. The code in
2811 appropriate escapes for input prompts or normal text. The code in
2800 Prompts.py got slightly more complicated, but this very old and
2812 Prompts.py got slightly more complicated, but this very old and
2801 annoying bug is finally fixed.
2813 annoying bug is finally fixed.
2802
2814
2803 All the credit for nailing down the real origin of this problem
2815 All the credit for nailing down the real origin of this problem
2804 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2816 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2805 *Many* thanks to him for spending quite a bit of effort on this.
2817 *Many* thanks to him for spending quite a bit of effort on this.
2806
2818
2807 2003-03-05 *** Released version 0.2.15pre1
2819 2003-03-05 *** Released version 0.2.15pre1
2808
2820
2809 2003-03-03 Fernando Perez <fperez@colorado.edu>
2821 2003-03-03 Fernando Perez <fperez@colorado.edu>
2810
2822
2811 * IPython/FakeModule.py: Moved the former _FakeModule to a
2823 * IPython/FakeModule.py: Moved the former _FakeModule to a
2812 separate file, because it's also needed by Magic (to fix a similar
2824 separate file, because it's also needed by Magic (to fix a similar
2813 pickle-related issue in @run).
2825 pickle-related issue in @run).
2814
2826
2815 2003-03-02 Fernando Perez <fperez@colorado.edu>
2827 2003-03-02 Fernando Perez <fperez@colorado.edu>
2816
2828
2817 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2829 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2818 the autocall option at runtime.
2830 the autocall option at runtime.
2819 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2831 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2820 across Magic.py to start separating Magic from InteractiveShell.
2832 across Magic.py to start separating Magic from InteractiveShell.
2821 (Magic._ofind): Fixed to return proper namespace for dotted
2833 (Magic._ofind): Fixed to return proper namespace for dotted
2822 names. Before, a dotted name would always return 'not currently
2834 names. Before, a dotted name would always return 'not currently
2823 defined', because it would find the 'parent'. s.x would be found,
2835 defined', because it would find the 'parent'. s.x would be found,
2824 but since 'x' isn't defined by itself, it would get confused.
2836 but since 'x' isn't defined by itself, it would get confused.
2825 (Magic.magic_run): Fixed pickling problems reported by Ralf
2837 (Magic.magic_run): Fixed pickling problems reported by Ralf
2826 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2838 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2827 that I'd used when Mike Heeter reported similar issues at the
2839 that I'd used when Mike Heeter reported similar issues at the
2828 top-level, but now for @run. It boils down to injecting the
2840 top-level, but now for @run. It boils down to injecting the
2829 namespace where code is being executed with something that looks
2841 namespace where code is being executed with something that looks
2830 enough like a module to fool pickle.dump(). Since a pickle stores
2842 enough like a module to fool pickle.dump(). Since a pickle stores
2831 a named reference to the importing module, we need this for
2843 a named reference to the importing module, we need this for
2832 pickles to save something sensible.
2844 pickles to save something sensible.
2833
2845
2834 * IPython/ipmaker.py (make_IPython): added an autocall option.
2846 * IPython/ipmaker.py (make_IPython): added an autocall option.
2835
2847
2836 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2848 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2837 the auto-eval code. Now autocalling is an option, and the code is
2849 the auto-eval code. Now autocalling is an option, and the code is
2838 also vastly safer. There is no more eval() involved at all.
2850 also vastly safer. There is no more eval() involved at all.
2839
2851
2840 2003-03-01 Fernando Perez <fperez@colorado.edu>
2852 2003-03-01 Fernando Perez <fperez@colorado.edu>
2841
2853
2842 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2854 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2843 dict with named keys instead of a tuple.
2855 dict with named keys instead of a tuple.
2844
2856
2845 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2857 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2846
2858
2847 * setup.py (make_shortcut): Fixed message about directories
2859 * setup.py (make_shortcut): Fixed message about directories
2848 created during Windows installation (the directories were ok, just
2860 created during Windows installation (the directories were ok, just
2849 the printed message was misleading). Thanks to Chris Liechti
2861 the printed message was misleading). Thanks to Chris Liechti
2850 <cliechti-AT-gmx.net> for the heads up.
2862 <cliechti-AT-gmx.net> for the heads up.
2851
2863
2852 2003-02-21 Fernando Perez <fperez@colorado.edu>
2864 2003-02-21 Fernando Perez <fperez@colorado.edu>
2853
2865
2854 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2866 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2855 of ValueError exception when checking for auto-execution. This
2867 of ValueError exception when checking for auto-execution. This
2856 one is raised by things like Numeric arrays arr.flat when the
2868 one is raised by things like Numeric arrays arr.flat when the
2857 array is non-contiguous.
2869 array is non-contiguous.
2858
2870
2859 2003-01-31 Fernando Perez <fperez@colorado.edu>
2871 2003-01-31 Fernando Perez <fperez@colorado.edu>
2860
2872
2861 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2873 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2862 not return any value at all (even though the command would get
2874 not return any value at all (even though the command would get
2863 executed).
2875 executed).
2864 (xsys): Flush stdout right after printing the command to ensure
2876 (xsys): Flush stdout right after printing the command to ensure
2865 proper ordering of commands and command output in the total
2877 proper ordering of commands and command output in the total
2866 output.
2878 output.
2867 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2879 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2868 system/getoutput as defaults. The old ones are kept for
2880 system/getoutput as defaults. The old ones are kept for
2869 compatibility reasons, so no code which uses this library needs
2881 compatibility reasons, so no code which uses this library needs
2870 changing.
2882 changing.
2871
2883
2872 2003-01-27 *** Released version 0.2.14
2884 2003-01-27 *** Released version 0.2.14
2873
2885
2874 2003-01-25 Fernando Perez <fperez@colorado.edu>
2886 2003-01-25 Fernando Perez <fperez@colorado.edu>
2875
2887
2876 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2888 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2877 functions defined in previous edit sessions could not be re-edited
2889 functions defined in previous edit sessions could not be re-edited
2878 (because the temp files were immediately removed). Now temp files
2890 (because the temp files were immediately removed). Now temp files
2879 are removed only at IPython's exit.
2891 are removed only at IPython's exit.
2880 (Magic.magic_run): Improved @run to perform shell-like expansions
2892 (Magic.magic_run): Improved @run to perform shell-like expansions
2881 on its arguments (~users and $VARS). With this, @run becomes more
2893 on its arguments (~users and $VARS). With this, @run becomes more
2882 like a normal command-line.
2894 like a normal command-line.
2883
2895
2884 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2896 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2885 bugs related to embedding and cleaned up that code. A fairly
2897 bugs related to embedding and cleaned up that code. A fairly
2886 important one was the impossibility to access the global namespace
2898 important one was the impossibility to access the global namespace
2887 through the embedded IPython (only local variables were visible).
2899 through the embedded IPython (only local variables were visible).
2888
2900
2889 2003-01-14 Fernando Perez <fperez@colorado.edu>
2901 2003-01-14 Fernando Perez <fperez@colorado.edu>
2890
2902
2891 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2903 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2892 auto-calling to be a bit more conservative. Now it doesn't get
2904 auto-calling to be a bit more conservative. Now it doesn't get
2893 triggered if any of '!=()<>' are in the rest of the input line, to
2905 triggered if any of '!=()<>' are in the rest of the input line, to
2894 allow comparing callables. Thanks to Alex for the heads up.
2906 allow comparing callables. Thanks to Alex for the heads up.
2895
2907
2896 2003-01-07 Fernando Perez <fperez@colorado.edu>
2908 2003-01-07 Fernando Perez <fperez@colorado.edu>
2897
2909
2898 * IPython/genutils.py (page): fixed estimation of the number of
2910 * IPython/genutils.py (page): fixed estimation of the number of
2899 lines in a string to be paged to simply count newlines. This
2911 lines in a string to be paged to simply count newlines. This
2900 prevents over-guessing due to embedded escape sequences. A better
2912 prevents over-guessing due to embedded escape sequences. A better
2901 long-term solution would involve stripping out the control chars
2913 long-term solution would involve stripping out the control chars
2902 for the count, but it's potentially so expensive I just don't
2914 for the count, but it's potentially so expensive I just don't
2903 think it's worth doing.
2915 think it's worth doing.
2904
2916
2905 2002-12-19 *** Released version 0.2.14pre50
2917 2002-12-19 *** Released version 0.2.14pre50
2906
2918
2907 2002-12-19 Fernando Perez <fperez@colorado.edu>
2919 2002-12-19 Fernando Perez <fperez@colorado.edu>
2908
2920
2909 * tools/release (version): Changed release scripts to inform
2921 * tools/release (version): Changed release scripts to inform
2910 Andrea and build a NEWS file with a list of recent changes.
2922 Andrea and build a NEWS file with a list of recent changes.
2911
2923
2912 * IPython/ColorANSI.py (__all__): changed terminal detection
2924 * IPython/ColorANSI.py (__all__): changed terminal detection
2913 code. Seems to work better for xterms without breaking
2925 code. Seems to work better for xterms without breaking
2914 konsole. Will need more testing to determine if WinXP and Mac OSX
2926 konsole. Will need more testing to determine if WinXP and Mac OSX
2915 also work ok.
2927 also work ok.
2916
2928
2917 2002-12-18 *** Released version 0.2.14pre49
2929 2002-12-18 *** Released version 0.2.14pre49
2918
2930
2919 2002-12-18 Fernando Perez <fperez@colorado.edu>
2931 2002-12-18 Fernando Perez <fperez@colorado.edu>
2920
2932
2921 * Docs: added new info about Mac OSX, from Andrea.
2933 * Docs: added new info about Mac OSX, from Andrea.
2922
2934
2923 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2935 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2924 allow direct plotting of python strings whose format is the same
2936 allow direct plotting of python strings whose format is the same
2925 of gnuplot data files.
2937 of gnuplot data files.
2926
2938
2927 2002-12-16 Fernando Perez <fperez@colorado.edu>
2939 2002-12-16 Fernando Perez <fperez@colorado.edu>
2928
2940
2929 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2941 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2930 value of exit question to be acknowledged.
2942 value of exit question to be acknowledged.
2931
2943
2932 2002-12-03 Fernando Perez <fperez@colorado.edu>
2944 2002-12-03 Fernando Perez <fperez@colorado.edu>
2933
2945
2934 * IPython/ipmaker.py: removed generators, which had been added
2946 * IPython/ipmaker.py: removed generators, which had been added
2935 by mistake in an earlier debugging run. This was causing trouble
2947 by mistake in an earlier debugging run. This was causing trouble
2936 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2948 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2937 for pointing this out.
2949 for pointing this out.
2938
2950
2939 2002-11-17 Fernando Perez <fperez@colorado.edu>
2951 2002-11-17 Fernando Perez <fperez@colorado.edu>
2940
2952
2941 * Manual: updated the Gnuplot section.
2953 * Manual: updated the Gnuplot section.
2942
2954
2943 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2955 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2944 a much better split of what goes in Runtime and what goes in
2956 a much better split of what goes in Runtime and what goes in
2945 Interactive.
2957 Interactive.
2946
2958
2947 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2959 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2948 being imported from iplib.
2960 being imported from iplib.
2949
2961
2950 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2962 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2951 for command-passing. Now the global Gnuplot instance is called
2963 for command-passing. Now the global Gnuplot instance is called
2952 'gp' instead of 'g', which was really a far too fragile and
2964 'gp' instead of 'g', which was really a far too fragile and
2953 common name.
2965 common name.
2954
2966
2955 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2967 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2956 bounding boxes generated by Gnuplot for square plots.
2968 bounding boxes generated by Gnuplot for square plots.
2957
2969
2958 * IPython/genutils.py (popkey): new function added. I should
2970 * IPython/genutils.py (popkey): new function added. I should
2959 suggest this on c.l.py as a dict method, it seems useful.
2971 suggest this on c.l.py as a dict method, it seems useful.
2960
2972
2961 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2973 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2962 to transparently handle PostScript generation. MUCH better than
2974 to transparently handle PostScript generation. MUCH better than
2963 the previous plot_eps/replot_eps (which I removed now). The code
2975 the previous plot_eps/replot_eps (which I removed now). The code
2964 is also fairly clean and well documented now (including
2976 is also fairly clean and well documented now (including
2965 docstrings).
2977 docstrings).
2966
2978
2967 2002-11-13 Fernando Perez <fperez@colorado.edu>
2979 2002-11-13 Fernando Perez <fperez@colorado.edu>
2968
2980
2969 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2981 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2970 (inconsistent with options).
2982 (inconsistent with options).
2971
2983
2972 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2984 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2973 manually disabled, I don't know why. Fixed it.
2985 manually disabled, I don't know why. Fixed it.
2974 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2986 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2975 eps output.
2987 eps output.
2976
2988
2977 2002-11-12 Fernando Perez <fperez@colorado.edu>
2989 2002-11-12 Fernando Perez <fperez@colorado.edu>
2978
2990
2979 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2991 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2980 don't propagate up to caller. Fixes crash reported by François
2992 don't propagate up to caller. Fixes crash reported by François
2981 Pinard.
2993 Pinard.
2982
2994
2983 2002-11-09 Fernando Perez <fperez@colorado.edu>
2995 2002-11-09 Fernando Perez <fperez@colorado.edu>
2984
2996
2985 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2997 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2986 history file for new users.
2998 history file for new users.
2987 (make_IPython): fixed bug where initial install would leave the
2999 (make_IPython): fixed bug where initial install would leave the
2988 user running in the .ipython dir.
3000 user running in the .ipython dir.
2989 (make_IPython): fixed bug where config dir .ipython would be
3001 (make_IPython): fixed bug where config dir .ipython would be
2990 created regardless of the given -ipythondir option. Thanks to Cory
3002 created regardless of the given -ipythondir option. Thanks to Cory
2991 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3003 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2992
3004
2993 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3005 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2994 type confirmations. Will need to use it in all of IPython's code
3006 type confirmations. Will need to use it in all of IPython's code
2995 consistently.
3007 consistently.
2996
3008
2997 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3009 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2998 context to print 31 lines instead of the default 5. This will make
3010 context to print 31 lines instead of the default 5. This will make
2999 the crash reports extremely detailed in case the problem is in
3011 the crash reports extremely detailed in case the problem is in
3000 libraries I don't have access to.
3012 libraries I don't have access to.
3001
3013
3002 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3014 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3003 line of defense' code to still crash, but giving users fair
3015 line of defense' code to still crash, but giving users fair
3004 warning. I don't want internal errors to go unreported: if there's
3016 warning. I don't want internal errors to go unreported: if there's
3005 an internal problem, IPython should crash and generate a full
3017 an internal problem, IPython should crash and generate a full
3006 report.
3018 report.
3007
3019
3008 2002-11-08 Fernando Perez <fperez@colorado.edu>
3020 2002-11-08 Fernando Perez <fperez@colorado.edu>
3009
3021
3010 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3022 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3011 otherwise uncaught exceptions which can appear if people set
3023 otherwise uncaught exceptions which can appear if people set
3012 sys.stdout to something badly broken. Thanks to a crash report
3024 sys.stdout to something badly broken. Thanks to a crash report
3013 from henni-AT-mail.brainbot.com.
3025 from henni-AT-mail.brainbot.com.
3014
3026
3015 2002-11-04 Fernando Perez <fperez@colorado.edu>
3027 2002-11-04 Fernando Perez <fperez@colorado.edu>
3016
3028
3017 * IPython/iplib.py (InteractiveShell.interact): added
3029 * IPython/iplib.py (InteractiveShell.interact): added
3018 __IPYTHON__active to the builtins. It's a flag which goes on when
3030 __IPYTHON__active to the builtins. It's a flag which goes on when
3019 the interaction starts and goes off again when it stops. This
3031 the interaction starts and goes off again when it stops. This
3020 allows embedding code to detect being inside IPython. Before this
3032 allows embedding code to detect being inside IPython. Before this
3021 was done via __IPYTHON__, but that only shows that an IPython
3033 was done via __IPYTHON__, but that only shows that an IPython
3022 instance has been created.
3034 instance has been created.
3023
3035
3024 * IPython/Magic.py (Magic.magic_env): I realized that in a
3036 * IPython/Magic.py (Magic.magic_env): I realized that in a
3025 UserDict, instance.data holds the data as a normal dict. So I
3037 UserDict, instance.data holds the data as a normal dict. So I
3026 modified @env to return os.environ.data instead of rebuilding a
3038 modified @env to return os.environ.data instead of rebuilding a
3027 dict by hand.
3039 dict by hand.
3028
3040
3029 2002-11-02 Fernando Perez <fperez@colorado.edu>
3041 2002-11-02 Fernando Perez <fperez@colorado.edu>
3030
3042
3031 * IPython/genutils.py (warn): changed so that level 1 prints no
3043 * IPython/genutils.py (warn): changed so that level 1 prints no
3032 header. Level 2 is now the default (with 'WARNING' header, as
3044 header. Level 2 is now the default (with 'WARNING' header, as
3033 before). I think I tracked all places where changes were needed in
3045 before). I think I tracked all places where changes were needed in
3034 IPython, but outside code using the old level numbering may have
3046 IPython, but outside code using the old level numbering may have
3035 broken.
3047 broken.
3036
3048
3037 * IPython/iplib.py (InteractiveShell.runcode): added this to
3049 * IPython/iplib.py (InteractiveShell.runcode): added this to
3038 handle the tracebacks in SystemExit traps correctly. The previous
3050 handle the tracebacks in SystemExit traps correctly. The previous
3039 code (through interact) was printing more of the stack than
3051 code (through interact) was printing more of the stack than
3040 necessary, showing IPython internal code to the user.
3052 necessary, showing IPython internal code to the user.
3041
3053
3042 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3054 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3043 default. Now that the default at the confirmation prompt is yes,
3055 default. Now that the default at the confirmation prompt is yes,
3044 it's not so intrusive. François' argument that ipython sessions
3056 it's not so intrusive. François' argument that ipython sessions
3045 tend to be complex enough not to lose them from an accidental C-d,
3057 tend to be complex enough not to lose them from an accidental C-d,
3046 is a valid one.
3058 is a valid one.
3047
3059
3048 * IPython/iplib.py (InteractiveShell.interact): added a
3060 * IPython/iplib.py (InteractiveShell.interact): added a
3049 showtraceback() call to the SystemExit trap, and modified the exit
3061 showtraceback() call to the SystemExit trap, and modified the exit
3050 confirmation to have yes as the default.
3062 confirmation to have yes as the default.
3051
3063
3052 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3064 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3053 this file. It's been gone from the code for a long time, this was
3065 this file. It's been gone from the code for a long time, this was
3054 simply leftover junk.
3066 simply leftover junk.
3055
3067
3056 2002-11-01 Fernando Perez <fperez@colorado.edu>
3068 2002-11-01 Fernando Perez <fperez@colorado.edu>
3057
3069
3058 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3070 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3059 added. If set, IPython now traps EOF and asks for
3071 added. If set, IPython now traps EOF and asks for
3060 confirmation. After a request by François Pinard.
3072 confirmation. After a request by François Pinard.
3061
3073
3062 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3074 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3063 of @abort, and with a new (better) mechanism for handling the
3075 of @abort, and with a new (better) mechanism for handling the
3064 exceptions.
3076 exceptions.
3065
3077
3066 2002-10-27 Fernando Perez <fperez@colorado.edu>
3078 2002-10-27 Fernando Perez <fperez@colorado.edu>
3067
3079
3068 * IPython/usage.py (__doc__): updated the --help information and
3080 * IPython/usage.py (__doc__): updated the --help information and
3069 the ipythonrc file to indicate that -log generates
3081 the ipythonrc file to indicate that -log generates
3070 ./ipython.log. Also fixed the corresponding info in @logstart.
3082 ./ipython.log. Also fixed the corresponding info in @logstart.
3071 This and several other fixes in the manuals thanks to reports by
3083 This and several other fixes in the manuals thanks to reports by
3072 François Pinard <pinard-AT-iro.umontreal.ca>.
3084 François Pinard <pinard-AT-iro.umontreal.ca>.
3073
3085
3074 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3086 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3075 refer to @logstart (instead of @log, which doesn't exist).
3087 refer to @logstart (instead of @log, which doesn't exist).
3076
3088
3077 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3089 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3078 AttributeError crash. Thanks to Christopher Armstrong
3090 AttributeError crash. Thanks to Christopher Armstrong
3079 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3091 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3080 introduced recently (in 0.2.14pre37) with the fix to the eval
3092 introduced recently (in 0.2.14pre37) with the fix to the eval
3081 problem mentioned below.
3093 problem mentioned below.
3082
3094
3083 2002-10-17 Fernando Perez <fperez@colorado.edu>
3095 2002-10-17 Fernando Perez <fperez@colorado.edu>
3084
3096
3085 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3097 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3086 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3098 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3087
3099
3088 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3100 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3089 this function to fix a problem reported by Alex Schmolck. He saw
3101 this function to fix a problem reported by Alex Schmolck. He saw
3090 it with list comprehensions and generators, which were getting
3102 it with list comprehensions and generators, which were getting
3091 called twice. The real problem was an 'eval' call in testing for
3103 called twice. The real problem was an 'eval' call in testing for
3092 automagic which was evaluating the input line silently.
3104 automagic which was evaluating the input line silently.
3093
3105
3094 This is a potentially very nasty bug, if the input has side
3106 This is a potentially very nasty bug, if the input has side
3095 effects which must not be repeated. The code is much cleaner now,
3107 effects which must not be repeated. The code is much cleaner now,
3096 without any blanket 'except' left and with a regexp test for
3108 without any blanket 'except' left and with a regexp test for
3097 actual function names.
3109 actual function names.
3098
3110
3099 But an eval remains, which I'm not fully comfortable with. I just
3111 But an eval remains, which I'm not fully comfortable with. I just
3100 don't know how to find out if an expression could be a callable in
3112 don't know how to find out if an expression could be a callable in
3101 the user's namespace without doing an eval on the string. However
3113 the user's namespace without doing an eval on the string. However
3102 that string is now much more strictly checked so that no code
3114 that string is now much more strictly checked so that no code
3103 slips by, so the eval should only happen for things that can
3115 slips by, so the eval should only happen for things that can
3104 really be only function/method names.
3116 really be only function/method names.
3105
3117
3106 2002-10-15 Fernando Perez <fperez@colorado.edu>
3118 2002-10-15 Fernando Perez <fperez@colorado.edu>
3107
3119
3108 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3120 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3109 OSX information to main manual, removed README_Mac_OSX file from
3121 OSX information to main manual, removed README_Mac_OSX file from
3110 distribution. Also updated credits for recent additions.
3122 distribution. Also updated credits for recent additions.
3111
3123
3112 2002-10-10 Fernando Perez <fperez@colorado.edu>
3124 2002-10-10 Fernando Perez <fperez@colorado.edu>
3113
3125
3114 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3126 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3115 terminal-related issues. Many thanks to Andrea Riciputi
3127 terminal-related issues. Many thanks to Andrea Riciputi
3116 <andrea.riciputi-AT-libero.it> for writing it.
3128 <andrea.riciputi-AT-libero.it> for writing it.
3117
3129
3118 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3130 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3119 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3131 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3120
3132
3121 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3133 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3122 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3134 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3123 <syver-en-AT-online.no> who both submitted patches for this problem.
3135 <syver-en-AT-online.no> who both submitted patches for this problem.
3124
3136
3125 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3137 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3126 global embedding to make sure that things don't overwrite user
3138 global embedding to make sure that things don't overwrite user
3127 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3139 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3128
3140
3129 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3141 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3130 compatibility. Thanks to Hayden Callow
3142 compatibility. Thanks to Hayden Callow
3131 <h.callow-AT-elec.canterbury.ac.nz>
3143 <h.callow-AT-elec.canterbury.ac.nz>
3132
3144
3133 2002-10-04 Fernando Perez <fperez@colorado.edu>
3145 2002-10-04 Fernando Perez <fperez@colorado.edu>
3134
3146
3135 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3147 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3136 Gnuplot.File objects.
3148 Gnuplot.File objects.
3137
3149
3138 2002-07-23 Fernando Perez <fperez@colorado.edu>
3150 2002-07-23 Fernando Perez <fperez@colorado.edu>
3139
3151
3140 * IPython/genutils.py (timing): Added timings() and timing() for
3152 * IPython/genutils.py (timing): Added timings() and timing() for
3141 quick access to the most commonly needed data, the execution
3153 quick access to the most commonly needed data, the execution
3142 times. Old timing() renamed to timings_out().
3154 times. Old timing() renamed to timings_out().
3143
3155
3144 2002-07-18 Fernando Perez <fperez@colorado.edu>
3156 2002-07-18 Fernando Perez <fperez@colorado.edu>
3145
3157
3146 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3158 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3147 bug with nested instances disrupting the parent's tab completion.
3159 bug with nested instances disrupting the parent's tab completion.
3148
3160
3149 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3161 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3150 all_completions code to begin the emacs integration.
3162 all_completions code to begin the emacs integration.
3151
3163
3152 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3164 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3153 argument to allow titling individual arrays when plotting.
3165 argument to allow titling individual arrays when plotting.
3154
3166
3155 2002-07-15 Fernando Perez <fperez@colorado.edu>
3167 2002-07-15 Fernando Perez <fperez@colorado.edu>
3156
3168
3157 * setup.py (make_shortcut): changed to retrieve the value of
3169 * setup.py (make_shortcut): changed to retrieve the value of
3158 'Program Files' directory from the registry (this value changes in
3170 'Program Files' directory from the registry (this value changes in
3159 non-english versions of Windows). Thanks to Thomas Fanslau
3171 non-english versions of Windows). Thanks to Thomas Fanslau
3160 <tfanslau-AT-gmx.de> for the report.
3172 <tfanslau-AT-gmx.de> for the report.
3161
3173
3162 2002-07-10 Fernando Perez <fperez@colorado.edu>
3174 2002-07-10 Fernando Perez <fperez@colorado.edu>
3163
3175
3164 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3176 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3165 a bug in pdb, which crashes if a line with only whitespace is
3177 a bug in pdb, which crashes if a line with only whitespace is
3166 entered. Bug report submitted to sourceforge.
3178 entered. Bug report submitted to sourceforge.
3167
3179
3168 2002-07-09 Fernando Perez <fperez@colorado.edu>
3180 2002-07-09 Fernando Perez <fperez@colorado.edu>
3169
3181
3170 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3182 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3171 reporting exceptions (it's a bug in inspect.py, I just set a
3183 reporting exceptions (it's a bug in inspect.py, I just set a
3172 workaround).
3184 workaround).
3173
3185
3174 2002-07-08 Fernando Perez <fperez@colorado.edu>
3186 2002-07-08 Fernando Perez <fperez@colorado.edu>
3175
3187
3176 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3188 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3177 __IPYTHON__ in __builtins__ to show up in user_ns.
3189 __IPYTHON__ in __builtins__ to show up in user_ns.
3178
3190
3179 2002-07-03 Fernando Perez <fperez@colorado.edu>
3191 2002-07-03 Fernando Perez <fperez@colorado.edu>
3180
3192
3181 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3193 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3182 name from @gp_set_instance to @gp_set_default.
3194 name from @gp_set_instance to @gp_set_default.
3183
3195
3184 * IPython/ipmaker.py (make_IPython): default editor value set to
3196 * IPython/ipmaker.py (make_IPython): default editor value set to
3185 '0' (a string), to match the rc file. Otherwise will crash when
3197 '0' (a string), to match the rc file. Otherwise will crash when
3186 .strip() is called on it.
3198 .strip() is called on it.
3187
3199
3188
3200
3189 2002-06-28 Fernando Perez <fperez@colorado.edu>
3201 2002-06-28 Fernando Perez <fperez@colorado.edu>
3190
3202
3191 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3203 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3192 of files in current directory when a file is executed via
3204 of files in current directory when a file is executed via
3193 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3205 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3194
3206
3195 * setup.py (manfiles): fix for rpm builds, submitted by RA
3207 * setup.py (manfiles): fix for rpm builds, submitted by RA
3196 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3208 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3197
3209
3198 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3210 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3199 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3211 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3200 string!). A. Schmolck caught this one.
3212 string!). A. Schmolck caught this one.
3201
3213
3202 2002-06-27 Fernando Perez <fperez@colorado.edu>
3214 2002-06-27 Fernando Perez <fperez@colorado.edu>
3203
3215
3204 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3216 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3205 defined files at the cmd line. __name__ wasn't being set to
3217 defined files at the cmd line. __name__ wasn't being set to
3206 __main__.
3218 __main__.
3207
3219
3208 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3220 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3209 regular lists and tuples besides Numeric arrays.
3221 regular lists and tuples besides Numeric arrays.
3210
3222
3211 * IPython/Prompts.py (CachedOutput.__call__): Added output
3223 * IPython/Prompts.py (CachedOutput.__call__): Added output
3212 supression for input ending with ';'. Similar to Mathematica and
3224 supression for input ending with ';'. Similar to Mathematica and
3213 Matlab. The _* vars and Out[] list are still updated, just like
3225 Matlab. The _* vars and Out[] list are still updated, just like
3214 Mathematica behaves.
3226 Mathematica behaves.
3215
3227
3216 2002-06-25 Fernando Perez <fperez@colorado.edu>
3228 2002-06-25 Fernando Perez <fperez@colorado.edu>
3217
3229
3218 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3230 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3219 .ini extensions for profiels under Windows.
3231 .ini extensions for profiels under Windows.
3220
3232
3221 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3233 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3222 string form. Fix contributed by Alexander Schmolck
3234 string form. Fix contributed by Alexander Schmolck
3223 <a.schmolck-AT-gmx.net>
3235 <a.schmolck-AT-gmx.net>
3224
3236
3225 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3237 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3226 pre-configured Gnuplot instance.
3238 pre-configured Gnuplot instance.
3227
3239
3228 2002-06-21 Fernando Perez <fperez@colorado.edu>
3240 2002-06-21 Fernando Perez <fperez@colorado.edu>
3229
3241
3230 * IPython/numutils.py (exp_safe): new function, works around the
3242 * IPython/numutils.py (exp_safe): new function, works around the
3231 underflow problems in Numeric.
3243 underflow problems in Numeric.
3232 (log2): New fn. Safe log in base 2: returns exact integer answer
3244 (log2): New fn. Safe log in base 2: returns exact integer answer
3233 for exact integer powers of 2.
3245 for exact integer powers of 2.
3234
3246
3235 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3247 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3236 properly.
3248 properly.
3237
3249
3238 2002-06-20 Fernando Perez <fperez@colorado.edu>
3250 2002-06-20 Fernando Perez <fperez@colorado.edu>
3239
3251
3240 * IPython/genutils.py (timing): new function like
3252 * IPython/genutils.py (timing): new function like
3241 Mathematica's. Similar to time_test, but returns more info.
3253 Mathematica's. Similar to time_test, but returns more info.
3242
3254
3243 2002-06-18 Fernando Perez <fperez@colorado.edu>
3255 2002-06-18 Fernando Perez <fperez@colorado.edu>
3244
3256
3245 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3257 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3246 according to Mike Heeter's suggestions.
3258 according to Mike Heeter's suggestions.
3247
3259
3248 2002-06-16 Fernando Perez <fperez@colorado.edu>
3260 2002-06-16 Fernando Perez <fperez@colorado.edu>
3249
3261
3250 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3262 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3251 system. GnuplotMagic is gone as a user-directory option. New files
3263 system. GnuplotMagic is gone as a user-directory option. New files
3252 make it easier to use all the gnuplot stuff both from external
3264 make it easier to use all the gnuplot stuff both from external
3253 programs as well as from IPython. Had to rewrite part of
3265 programs as well as from IPython. Had to rewrite part of
3254 hardcopy() b/c of a strange bug: often the ps files simply don't
3266 hardcopy() b/c of a strange bug: often the ps files simply don't
3255 get created, and require a repeat of the command (often several
3267 get created, and require a repeat of the command (often several
3256 times).
3268 times).
3257
3269
3258 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3270 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3259 resolve output channel at call time, so that if sys.stderr has
3271 resolve output channel at call time, so that if sys.stderr has
3260 been redirected by user this gets honored.
3272 been redirected by user this gets honored.
3261
3273
3262 2002-06-13 Fernando Perez <fperez@colorado.edu>
3274 2002-06-13 Fernando Perez <fperez@colorado.edu>
3263
3275
3264 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3276 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3265 IPShell. Kept a copy with the old names to avoid breaking people's
3277 IPShell. Kept a copy with the old names to avoid breaking people's
3266 embedded code.
3278 embedded code.
3267
3279
3268 * IPython/ipython: simplified it to the bare minimum after
3280 * IPython/ipython: simplified it to the bare minimum after
3269 Holger's suggestions. Added info about how to use it in
3281 Holger's suggestions. Added info about how to use it in
3270 PYTHONSTARTUP.
3282 PYTHONSTARTUP.
3271
3283
3272 * IPython/Shell.py (IPythonShell): changed the options passing
3284 * IPython/Shell.py (IPythonShell): changed the options passing
3273 from a string with funky %s replacements to a straight list. Maybe
3285 from a string with funky %s replacements to a straight list. Maybe
3274 a bit more typing, but it follows sys.argv conventions, so there's
3286 a bit more typing, but it follows sys.argv conventions, so there's
3275 less special-casing to remember.
3287 less special-casing to remember.
3276
3288
3277 2002-06-12 Fernando Perez <fperez@colorado.edu>
3289 2002-06-12 Fernando Perez <fperez@colorado.edu>
3278
3290
3279 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3291 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3280 command. Thanks to a suggestion by Mike Heeter.
3292 command. Thanks to a suggestion by Mike Heeter.
3281 (Magic.magic_pfile): added behavior to look at filenames if given
3293 (Magic.magic_pfile): added behavior to look at filenames if given
3282 arg is not a defined object.
3294 arg is not a defined object.
3283 (Magic.magic_save): New @save function to save code snippets. Also
3295 (Magic.magic_save): New @save function to save code snippets. Also
3284 a Mike Heeter idea.
3296 a Mike Heeter idea.
3285
3297
3286 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3298 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3287 plot() and replot(). Much more convenient now, especially for
3299 plot() and replot(). Much more convenient now, especially for
3288 interactive use.
3300 interactive use.
3289
3301
3290 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3302 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3291 filenames.
3303 filenames.
3292
3304
3293 2002-06-02 Fernando Perez <fperez@colorado.edu>
3305 2002-06-02 Fernando Perez <fperez@colorado.edu>
3294
3306
3295 * IPython/Struct.py (Struct.__init__): modified to admit
3307 * IPython/Struct.py (Struct.__init__): modified to admit
3296 initialization via another struct.
3308 initialization via another struct.
3297
3309
3298 * IPython/genutils.py (SystemExec.__init__): New stateful
3310 * IPython/genutils.py (SystemExec.__init__): New stateful
3299 interface to xsys and bq. Useful for writing system scripts.
3311 interface to xsys and bq. Useful for writing system scripts.
3300
3312
3301 2002-05-30 Fernando Perez <fperez@colorado.edu>
3313 2002-05-30 Fernando Perez <fperez@colorado.edu>
3302
3314
3303 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3315 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3304 documents. This will make the user download smaller (it's getting
3316 documents. This will make the user download smaller (it's getting
3305 too big).
3317 too big).
3306
3318
3307 2002-05-29 Fernando Perez <fperez@colorado.edu>
3319 2002-05-29 Fernando Perez <fperez@colorado.edu>
3308
3320
3309 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3321 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3310 fix problems with shelve and pickle. Seems to work, but I don't
3322 fix problems with shelve and pickle. Seems to work, but I don't
3311 know if corner cases break it. Thanks to Mike Heeter
3323 know if corner cases break it. Thanks to Mike Heeter
3312 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3324 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3313
3325
3314 2002-05-24 Fernando Perez <fperez@colorado.edu>
3326 2002-05-24 Fernando Perez <fperez@colorado.edu>
3315
3327
3316 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3328 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3317 macros having broken.
3329 macros having broken.
3318
3330
3319 2002-05-21 Fernando Perez <fperez@colorado.edu>
3331 2002-05-21 Fernando Perez <fperez@colorado.edu>
3320
3332
3321 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3333 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3322 introduced logging bug: all history before logging started was
3334 introduced logging bug: all history before logging started was
3323 being written one character per line! This came from the redesign
3335 being written one character per line! This came from the redesign
3324 of the input history as a special list which slices to strings,
3336 of the input history as a special list which slices to strings,
3325 not to lists.
3337 not to lists.
3326
3338
3327 2002-05-20 Fernando Perez <fperez@colorado.edu>
3339 2002-05-20 Fernando Perez <fperez@colorado.edu>
3328
3340
3329 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3341 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3330 be an attribute of all classes in this module. The design of these
3342 be an attribute of all classes in this module. The design of these
3331 classes needs some serious overhauling.
3343 classes needs some serious overhauling.
3332
3344
3333 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3345 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3334 which was ignoring '_' in option names.
3346 which was ignoring '_' in option names.
3335
3347
3336 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3348 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3337 'Verbose_novars' to 'Context' and made it the new default. It's a
3349 'Verbose_novars' to 'Context' and made it the new default. It's a
3338 bit more readable and also safer than verbose.
3350 bit more readable and also safer than verbose.
3339
3351
3340 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3352 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3341 triple-quoted strings.
3353 triple-quoted strings.
3342
3354
3343 * IPython/OInspect.py (__all__): new module exposing the object
3355 * IPython/OInspect.py (__all__): new module exposing the object
3344 introspection facilities. Now the corresponding magics are dummy
3356 introspection facilities. Now the corresponding magics are dummy
3345 wrappers around this. Having this module will make it much easier
3357 wrappers around this. Having this module will make it much easier
3346 to put these functions into our modified pdb.
3358 to put these functions into our modified pdb.
3347 This new object inspector system uses the new colorizing module,
3359 This new object inspector system uses the new colorizing module,
3348 so source code and other things are nicely syntax highlighted.
3360 so source code and other things are nicely syntax highlighted.
3349
3361
3350 2002-05-18 Fernando Perez <fperez@colorado.edu>
3362 2002-05-18 Fernando Perez <fperez@colorado.edu>
3351
3363
3352 * IPython/ColorANSI.py: Split the coloring tools into a separate
3364 * IPython/ColorANSI.py: Split the coloring tools into a separate
3353 module so I can use them in other code easier (they were part of
3365 module so I can use them in other code easier (they were part of
3354 ultraTB).
3366 ultraTB).
3355
3367
3356 2002-05-17 Fernando Perez <fperez@colorado.edu>
3368 2002-05-17 Fernando Perez <fperez@colorado.edu>
3357
3369
3358 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3370 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3359 fixed it to set the global 'g' also to the called instance, as
3371 fixed it to set the global 'g' also to the called instance, as
3360 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3372 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3361 user's 'g' variables).
3373 user's 'g' variables).
3362
3374
3363 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3375 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3364 global variables (aliases to _ih,_oh) so that users which expect
3376 global variables (aliases to _ih,_oh) so that users which expect
3365 In[5] or Out[7] to work aren't unpleasantly surprised.
3377 In[5] or Out[7] to work aren't unpleasantly surprised.
3366 (InputList.__getslice__): new class to allow executing slices of
3378 (InputList.__getslice__): new class to allow executing slices of
3367 input history directly. Very simple class, complements the use of
3379 input history directly. Very simple class, complements the use of
3368 macros.
3380 macros.
3369
3381
3370 2002-05-16 Fernando Perez <fperez@colorado.edu>
3382 2002-05-16 Fernando Perez <fperez@colorado.edu>
3371
3383
3372 * setup.py (docdirbase): make doc directory be just doc/IPython
3384 * setup.py (docdirbase): make doc directory be just doc/IPython
3373 without version numbers, it will reduce clutter for users.
3385 without version numbers, it will reduce clutter for users.
3374
3386
3375 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3387 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3376 execfile call to prevent possible memory leak. See for details:
3388 execfile call to prevent possible memory leak. See for details:
3377 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3389 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3378
3390
3379 2002-05-15 Fernando Perez <fperez@colorado.edu>
3391 2002-05-15 Fernando Perez <fperez@colorado.edu>
3380
3392
3381 * IPython/Magic.py (Magic.magic_psource): made the object
3393 * IPython/Magic.py (Magic.magic_psource): made the object
3382 introspection names be more standard: pdoc, pdef, pfile and
3394 introspection names be more standard: pdoc, pdef, pfile and
3383 psource. They all print/page their output, and it makes
3395 psource. They all print/page their output, and it makes
3384 remembering them easier. Kept old names for compatibility as
3396 remembering them easier. Kept old names for compatibility as
3385 aliases.
3397 aliases.
3386
3398
3387 2002-05-14 Fernando Perez <fperez@colorado.edu>
3399 2002-05-14 Fernando Perez <fperez@colorado.edu>
3388
3400
3389 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3401 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3390 what the mouse problem was. The trick is to use gnuplot with temp
3402 what the mouse problem was. The trick is to use gnuplot with temp
3391 files and NOT with pipes (for data communication), because having
3403 files and NOT with pipes (for data communication), because having
3392 both pipes and the mouse on is bad news.
3404 both pipes and the mouse on is bad news.
3393
3405
3394 2002-05-13 Fernando Perez <fperez@colorado.edu>
3406 2002-05-13 Fernando Perez <fperez@colorado.edu>
3395
3407
3396 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3408 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3397 bug. Information would be reported about builtins even when
3409 bug. Information would be reported about builtins even when
3398 user-defined functions overrode them.
3410 user-defined functions overrode them.
3399
3411
3400 2002-05-11 Fernando Perez <fperez@colorado.edu>
3412 2002-05-11 Fernando Perez <fperez@colorado.edu>
3401
3413
3402 * IPython/__init__.py (__all__): removed FlexCompleter from
3414 * IPython/__init__.py (__all__): removed FlexCompleter from
3403 __all__ so that things don't fail in platforms without readline.
3415 __all__ so that things don't fail in platforms without readline.
3404
3416
3405 2002-05-10 Fernando Perez <fperez@colorado.edu>
3417 2002-05-10 Fernando Perez <fperez@colorado.edu>
3406
3418
3407 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3419 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3408 it requires Numeric, effectively making Numeric a dependency for
3420 it requires Numeric, effectively making Numeric a dependency for
3409 IPython.
3421 IPython.
3410
3422
3411 * Released 0.2.13
3423 * Released 0.2.13
3412
3424
3413 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3425 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3414 profiler interface. Now all the major options from the profiler
3426 profiler interface. Now all the major options from the profiler
3415 module are directly supported in IPython, both for single
3427 module are directly supported in IPython, both for single
3416 expressions (@prun) and for full programs (@run -p).
3428 expressions (@prun) and for full programs (@run -p).
3417
3429
3418 2002-05-09 Fernando Perez <fperez@colorado.edu>
3430 2002-05-09 Fernando Perez <fperez@colorado.edu>
3419
3431
3420 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3432 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3421 magic properly formatted for screen.
3433 magic properly formatted for screen.
3422
3434
3423 * setup.py (make_shortcut): Changed things to put pdf version in
3435 * setup.py (make_shortcut): Changed things to put pdf version in
3424 doc/ instead of doc/manual (had to change lyxport a bit).
3436 doc/ instead of doc/manual (had to change lyxport a bit).
3425
3437
3426 * IPython/Magic.py (Profile.string_stats): made profile runs go
3438 * IPython/Magic.py (Profile.string_stats): made profile runs go
3427 through pager (they are long and a pager allows searching, saving,
3439 through pager (they are long and a pager allows searching, saving,
3428 etc.)
3440 etc.)
3429
3441
3430 2002-05-08 Fernando Perez <fperez@colorado.edu>
3442 2002-05-08 Fernando Perez <fperez@colorado.edu>
3431
3443
3432 * Released 0.2.12
3444 * Released 0.2.12
3433
3445
3434 2002-05-06 Fernando Perez <fperez@colorado.edu>
3446 2002-05-06 Fernando Perez <fperez@colorado.edu>
3435
3447
3436 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3448 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3437 introduced); 'hist n1 n2' was broken.
3449 introduced); 'hist n1 n2' was broken.
3438 (Magic.magic_pdb): added optional on/off arguments to @pdb
3450 (Magic.magic_pdb): added optional on/off arguments to @pdb
3439 (Magic.magic_run): added option -i to @run, which executes code in
3451 (Magic.magic_run): added option -i to @run, which executes code in
3440 the IPython namespace instead of a clean one. Also added @irun as
3452 the IPython namespace instead of a clean one. Also added @irun as
3441 an alias to @run -i.
3453 an alias to @run -i.
3442
3454
3443 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3455 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3444 fixed (it didn't really do anything, the namespaces were wrong).
3456 fixed (it didn't really do anything, the namespaces were wrong).
3445
3457
3446 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3458 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3447
3459
3448 * IPython/__init__.py (__all__): Fixed package namespace, now
3460 * IPython/__init__.py (__all__): Fixed package namespace, now
3449 'import IPython' does give access to IPython.<all> as
3461 'import IPython' does give access to IPython.<all> as
3450 expected. Also renamed __release__ to Release.
3462 expected. Also renamed __release__ to Release.
3451
3463
3452 * IPython/Debugger.py (__license__): created new Pdb class which
3464 * IPython/Debugger.py (__license__): created new Pdb class which
3453 functions like a drop-in for the normal pdb.Pdb but does NOT
3465 functions like a drop-in for the normal pdb.Pdb but does NOT
3454 import readline by default. This way it doesn't muck up IPython's
3466 import readline by default. This way it doesn't muck up IPython's
3455 readline handling, and now tab-completion finally works in the
3467 readline handling, and now tab-completion finally works in the
3456 debugger -- sort of. It completes things globally visible, but the
3468 debugger -- sort of. It completes things globally visible, but the
3457 completer doesn't track the stack as pdb walks it. That's a bit
3469 completer doesn't track the stack as pdb walks it. That's a bit
3458 tricky, and I'll have to implement it later.
3470 tricky, and I'll have to implement it later.
3459
3471
3460 2002-05-05 Fernando Perez <fperez@colorado.edu>
3472 2002-05-05 Fernando Perez <fperez@colorado.edu>
3461
3473
3462 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3474 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3463 magic docstrings when printed via ? (explicit \'s were being
3475 magic docstrings when printed via ? (explicit \'s were being
3464 printed).
3476 printed).
3465
3477
3466 * IPython/ipmaker.py (make_IPython): fixed namespace
3478 * IPython/ipmaker.py (make_IPython): fixed namespace
3467 identification bug. Now variables loaded via logs or command-line
3479 identification bug. Now variables loaded via logs or command-line
3468 files are recognized in the interactive namespace by @who.
3480 files are recognized in the interactive namespace by @who.
3469
3481
3470 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3482 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3471 log replay system stemming from the string form of Structs.
3483 log replay system stemming from the string form of Structs.
3472
3484
3473 * IPython/Magic.py (Macro.__init__): improved macros to properly
3485 * IPython/Magic.py (Macro.__init__): improved macros to properly
3474 handle magic commands in them.
3486 handle magic commands in them.
3475 (Magic.magic_logstart): usernames are now expanded so 'logstart
3487 (Magic.magic_logstart): usernames are now expanded so 'logstart
3476 ~/mylog' now works.
3488 ~/mylog' now works.
3477
3489
3478 * IPython/iplib.py (complete): fixed bug where paths starting with
3490 * IPython/iplib.py (complete): fixed bug where paths starting with
3479 '/' would be completed as magic names.
3491 '/' would be completed as magic names.
3480
3492
3481 2002-05-04 Fernando Perez <fperez@colorado.edu>
3493 2002-05-04 Fernando Perez <fperez@colorado.edu>
3482
3494
3483 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3495 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3484 allow running full programs under the profiler's control.
3496 allow running full programs under the profiler's control.
3485
3497
3486 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3498 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3487 mode to report exceptions verbosely but without formatting
3499 mode to report exceptions verbosely but without formatting
3488 variables. This addresses the issue of ipython 'freezing' (it's
3500 variables. This addresses the issue of ipython 'freezing' (it's
3489 not frozen, but caught in an expensive formatting loop) when huge
3501 not frozen, but caught in an expensive formatting loop) when huge
3490 variables are in the context of an exception.
3502 variables are in the context of an exception.
3491 (VerboseTB.text): Added '--->' markers at line where exception was
3503 (VerboseTB.text): Added '--->' markers at line where exception was
3492 triggered. Much clearer to read, especially in NoColor modes.
3504 triggered. Much clearer to read, especially in NoColor modes.
3493
3505
3494 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3506 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3495 implemented in reverse when changing to the new parse_options().
3507 implemented in reverse when changing to the new parse_options().
3496
3508
3497 2002-05-03 Fernando Perez <fperez@colorado.edu>
3509 2002-05-03 Fernando Perez <fperez@colorado.edu>
3498
3510
3499 * IPython/Magic.py (Magic.parse_options): new function so that
3511 * IPython/Magic.py (Magic.parse_options): new function so that
3500 magics can parse options easier.
3512 magics can parse options easier.
3501 (Magic.magic_prun): new function similar to profile.run(),
3513 (Magic.magic_prun): new function similar to profile.run(),
3502 suggested by Chris Hart.
3514 suggested by Chris Hart.
3503 (Magic.magic_cd): fixed behavior so that it only changes if
3515 (Magic.magic_cd): fixed behavior so that it only changes if
3504 directory actually is in history.
3516 directory actually is in history.
3505
3517
3506 * IPython/usage.py (__doc__): added information about potential
3518 * IPython/usage.py (__doc__): added information about potential
3507 slowness of Verbose exception mode when there are huge data
3519 slowness of Verbose exception mode when there are huge data
3508 structures to be formatted (thanks to Archie Paulson).
3520 structures to be formatted (thanks to Archie Paulson).
3509
3521
3510 * IPython/ipmaker.py (make_IPython): Changed default logging
3522 * IPython/ipmaker.py (make_IPython): Changed default logging
3511 (when simply called with -log) to use curr_dir/ipython.log in
3523 (when simply called with -log) to use curr_dir/ipython.log in
3512 rotate mode. Fixed crash which was occuring with -log before
3524 rotate mode. Fixed crash which was occuring with -log before
3513 (thanks to Jim Boyle).
3525 (thanks to Jim Boyle).
3514
3526
3515 2002-05-01 Fernando Perez <fperez@colorado.edu>
3527 2002-05-01 Fernando Perez <fperez@colorado.edu>
3516
3528
3517 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3529 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3518 was nasty -- though somewhat of a corner case).
3530 was nasty -- though somewhat of a corner case).
3519
3531
3520 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3532 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3521 text (was a bug).
3533 text (was a bug).
3522
3534
3523 2002-04-30 Fernando Perez <fperez@colorado.edu>
3535 2002-04-30 Fernando Perez <fperez@colorado.edu>
3524
3536
3525 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3537 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3526 a print after ^D or ^C from the user so that the In[] prompt
3538 a print after ^D or ^C from the user so that the In[] prompt
3527 doesn't over-run the gnuplot one.
3539 doesn't over-run the gnuplot one.
3528
3540
3529 2002-04-29 Fernando Perez <fperez@colorado.edu>
3541 2002-04-29 Fernando Perez <fperez@colorado.edu>
3530
3542
3531 * Released 0.2.10
3543 * Released 0.2.10
3532
3544
3533 * IPython/__release__.py (version): get date dynamically.
3545 * IPython/__release__.py (version): get date dynamically.
3534
3546
3535 * Misc. documentation updates thanks to Arnd's comments. Also ran
3547 * Misc. documentation updates thanks to Arnd's comments. Also ran
3536 a full spellcheck on the manual (hadn't been done in a while).
3548 a full spellcheck on the manual (hadn't been done in a while).
3537
3549
3538 2002-04-27 Fernando Perez <fperez@colorado.edu>
3550 2002-04-27 Fernando Perez <fperez@colorado.edu>
3539
3551
3540 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3552 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3541 starting a log in mid-session would reset the input history list.
3553 starting a log in mid-session would reset the input history list.
3542
3554
3543 2002-04-26 Fernando Perez <fperez@colorado.edu>
3555 2002-04-26 Fernando Perez <fperez@colorado.edu>
3544
3556
3545 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3557 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3546 all files were being included in an update. Now anything in
3558 all files were being included in an update. Now anything in
3547 UserConfig that matches [A-Za-z]*.py will go (this excludes
3559 UserConfig that matches [A-Za-z]*.py will go (this excludes
3548 __init__.py)
3560 __init__.py)
3549
3561
3550 2002-04-25 Fernando Perez <fperez@colorado.edu>
3562 2002-04-25 Fernando Perez <fperez@colorado.edu>
3551
3563
3552 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3564 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3553 to __builtins__ so that any form of embedded or imported code can
3565 to __builtins__ so that any form of embedded or imported code can
3554 test for being inside IPython.
3566 test for being inside IPython.
3555
3567
3556 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3568 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3557 changed to GnuplotMagic because it's now an importable module,
3569 changed to GnuplotMagic because it's now an importable module,
3558 this makes the name follow that of the standard Gnuplot module.
3570 this makes the name follow that of the standard Gnuplot module.
3559 GnuplotMagic can now be loaded at any time in mid-session.
3571 GnuplotMagic can now be loaded at any time in mid-session.
3560
3572
3561 2002-04-24 Fernando Perez <fperez@colorado.edu>
3573 2002-04-24 Fernando Perez <fperez@colorado.edu>
3562
3574
3563 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3575 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3564 the globals (IPython has its own namespace) and the
3576 the globals (IPython has its own namespace) and the
3565 PhysicalQuantity stuff is much better anyway.
3577 PhysicalQuantity stuff is much better anyway.
3566
3578
3567 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3579 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3568 embedding example to standard user directory for
3580 embedding example to standard user directory for
3569 distribution. Also put it in the manual.
3581 distribution. Also put it in the manual.
3570
3582
3571 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3583 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3572 instance as first argument (so it doesn't rely on some obscure
3584 instance as first argument (so it doesn't rely on some obscure
3573 hidden global).
3585 hidden global).
3574
3586
3575 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3587 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3576 delimiters. While it prevents ().TAB from working, it allows
3588 delimiters. While it prevents ().TAB from working, it allows
3577 completions in open (... expressions. This is by far a more common
3589 completions in open (... expressions. This is by far a more common
3578 case.
3590 case.
3579
3591
3580 2002-04-23 Fernando Perez <fperez@colorado.edu>
3592 2002-04-23 Fernando Perez <fperez@colorado.edu>
3581
3593
3582 * IPython/Extensions/InterpreterPasteInput.py: new
3594 * IPython/Extensions/InterpreterPasteInput.py: new
3583 syntax-processing module for pasting lines with >>> or ... at the
3595 syntax-processing module for pasting lines with >>> or ... at the
3584 start.
3596 start.
3585
3597
3586 * IPython/Extensions/PhysicalQ_Interactive.py
3598 * IPython/Extensions/PhysicalQ_Interactive.py
3587 (PhysicalQuantityInteractive.__int__): fixed to work with either
3599 (PhysicalQuantityInteractive.__int__): fixed to work with either
3588 Numeric or math.
3600 Numeric or math.
3589
3601
3590 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3602 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3591 provided profiles. Now we have:
3603 provided profiles. Now we have:
3592 -math -> math module as * and cmath with its own namespace.
3604 -math -> math module as * and cmath with its own namespace.
3593 -numeric -> Numeric as *, plus gnuplot & grace
3605 -numeric -> Numeric as *, plus gnuplot & grace
3594 -physics -> same as before
3606 -physics -> same as before
3595
3607
3596 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3608 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3597 user-defined magics wouldn't be found by @magic if they were
3609 user-defined magics wouldn't be found by @magic if they were
3598 defined as class methods. Also cleaned up the namespace search
3610 defined as class methods. Also cleaned up the namespace search
3599 logic and the string building (to use %s instead of many repeated
3611 logic and the string building (to use %s instead of many repeated
3600 string adds).
3612 string adds).
3601
3613
3602 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3614 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3603 of user-defined magics to operate with class methods (cleaner, in
3615 of user-defined magics to operate with class methods (cleaner, in
3604 line with the gnuplot code).
3616 line with the gnuplot code).
3605
3617
3606 2002-04-22 Fernando Perez <fperez@colorado.edu>
3618 2002-04-22 Fernando Perez <fperez@colorado.edu>
3607
3619
3608 * setup.py: updated dependency list so that manual is updated when
3620 * setup.py: updated dependency list so that manual is updated when
3609 all included files change.
3621 all included files change.
3610
3622
3611 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3623 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3612 the delimiter removal option (the fix is ugly right now).
3624 the delimiter removal option (the fix is ugly right now).
3613
3625
3614 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3626 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3615 all of the math profile (quicker loading, no conflict between
3627 all of the math profile (quicker loading, no conflict between
3616 g-9.8 and g-gnuplot).
3628 g-9.8 and g-gnuplot).
3617
3629
3618 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3630 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3619 name of post-mortem files to IPython_crash_report.txt.
3631 name of post-mortem files to IPython_crash_report.txt.
3620
3632
3621 * Cleanup/update of the docs. Added all the new readline info and
3633 * Cleanup/update of the docs. Added all the new readline info and
3622 formatted all lists as 'real lists'.
3634 formatted all lists as 'real lists'.
3623
3635
3624 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3636 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3625 tab-completion options, since the full readline parse_and_bind is
3637 tab-completion options, since the full readline parse_and_bind is
3626 now accessible.
3638 now accessible.
3627
3639
3628 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3640 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3629 handling of readline options. Now users can specify any string to
3641 handling of readline options. Now users can specify any string to
3630 be passed to parse_and_bind(), as well as the delimiters to be
3642 be passed to parse_and_bind(), as well as the delimiters to be
3631 removed.
3643 removed.
3632 (InteractiveShell.__init__): Added __name__ to the global
3644 (InteractiveShell.__init__): Added __name__ to the global
3633 namespace so that things like Itpl which rely on its existence
3645 namespace so that things like Itpl which rely on its existence
3634 don't crash.
3646 don't crash.
3635 (InteractiveShell._prefilter): Defined the default with a _ so
3647 (InteractiveShell._prefilter): Defined the default with a _ so
3636 that prefilter() is easier to override, while the default one
3648 that prefilter() is easier to override, while the default one
3637 remains available.
3649 remains available.
3638
3650
3639 2002-04-18 Fernando Perez <fperez@colorado.edu>
3651 2002-04-18 Fernando Perez <fperez@colorado.edu>
3640
3652
3641 * Added information about pdb in the docs.
3653 * Added information about pdb in the docs.
3642
3654
3643 2002-04-17 Fernando Perez <fperez@colorado.edu>
3655 2002-04-17 Fernando Perez <fperez@colorado.edu>
3644
3656
3645 * IPython/ipmaker.py (make_IPython): added rc_override option to
3657 * IPython/ipmaker.py (make_IPython): added rc_override option to
3646 allow passing config options at creation time which may override
3658 allow passing config options at creation time which may override
3647 anything set in the config files or command line. This is
3659 anything set in the config files or command line. This is
3648 particularly useful for configuring embedded instances.
3660 particularly useful for configuring embedded instances.
3649
3661
3650 2002-04-15 Fernando Perez <fperez@colorado.edu>
3662 2002-04-15 Fernando Perez <fperez@colorado.edu>
3651
3663
3652 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3664 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3653 crash embedded instances because of the input cache falling out of
3665 crash embedded instances because of the input cache falling out of
3654 sync with the output counter.
3666 sync with the output counter.
3655
3667
3656 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3668 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3657 mode which calls pdb after an uncaught exception in IPython itself.
3669 mode which calls pdb after an uncaught exception in IPython itself.
3658
3670
3659 2002-04-14 Fernando Perez <fperez@colorado.edu>
3671 2002-04-14 Fernando Perez <fperez@colorado.edu>
3660
3672
3661 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3673 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3662 readline, fix it back after each call.
3674 readline, fix it back after each call.
3663
3675
3664 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3676 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3665 method to force all access via __call__(), which guarantees that
3677 method to force all access via __call__(), which guarantees that
3666 traceback references are properly deleted.
3678 traceback references are properly deleted.
3667
3679
3668 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3680 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3669 improve printing when pprint is in use.
3681 improve printing when pprint is in use.
3670
3682
3671 2002-04-13 Fernando Perez <fperez@colorado.edu>
3683 2002-04-13 Fernando Perez <fperez@colorado.edu>
3672
3684
3673 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3685 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3674 exceptions aren't caught anymore. If the user triggers one, he
3686 exceptions aren't caught anymore. If the user triggers one, he
3675 should know why he's doing it and it should go all the way up,
3687 should know why he's doing it and it should go all the way up,
3676 just like any other exception. So now @abort will fully kill the
3688 just like any other exception. So now @abort will fully kill the
3677 embedded interpreter and the embedding code (unless that happens
3689 embedded interpreter and the embedding code (unless that happens
3678 to catch SystemExit).
3690 to catch SystemExit).
3679
3691
3680 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3692 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3681 and a debugger() method to invoke the interactive pdb debugger
3693 and a debugger() method to invoke the interactive pdb debugger
3682 after printing exception information. Also added the corresponding
3694 after printing exception information. Also added the corresponding
3683 -pdb option and @pdb magic to control this feature, and updated
3695 -pdb option and @pdb magic to control this feature, and updated
3684 the docs. After a suggestion from Christopher Hart
3696 the docs. After a suggestion from Christopher Hart
3685 (hart-AT-caltech.edu).
3697 (hart-AT-caltech.edu).
3686
3698
3687 2002-04-12 Fernando Perez <fperez@colorado.edu>
3699 2002-04-12 Fernando Perez <fperez@colorado.edu>
3688
3700
3689 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3701 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3690 the exception handlers defined by the user (not the CrashHandler)
3702 the exception handlers defined by the user (not the CrashHandler)
3691 so that user exceptions don't trigger an ipython bug report.
3703 so that user exceptions don't trigger an ipython bug report.
3692
3704
3693 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3705 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3694 configurable (it should have always been so).
3706 configurable (it should have always been so).
3695
3707
3696 2002-03-26 Fernando Perez <fperez@colorado.edu>
3708 2002-03-26 Fernando Perez <fperez@colorado.edu>
3697
3709
3698 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3710 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3699 and there to fix embedding namespace issues. This should all be
3711 and there to fix embedding namespace issues. This should all be
3700 done in a more elegant way.
3712 done in a more elegant way.
3701
3713
3702 2002-03-25 Fernando Perez <fperez@colorado.edu>
3714 2002-03-25 Fernando Perez <fperez@colorado.edu>
3703
3715
3704 * IPython/genutils.py (get_home_dir): Try to make it work under
3716 * IPython/genutils.py (get_home_dir): Try to make it work under
3705 win9x also.
3717 win9x also.
3706
3718
3707 2002-03-20 Fernando Perez <fperez@colorado.edu>
3719 2002-03-20 Fernando Perez <fperez@colorado.edu>
3708
3720
3709 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3721 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3710 sys.displayhook untouched upon __init__.
3722 sys.displayhook untouched upon __init__.
3711
3723
3712 2002-03-19 Fernando Perez <fperez@colorado.edu>
3724 2002-03-19 Fernando Perez <fperez@colorado.edu>
3713
3725
3714 * Released 0.2.9 (for embedding bug, basically).
3726 * Released 0.2.9 (for embedding bug, basically).
3715
3727
3716 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3728 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3717 exceptions so that enclosing shell's state can be restored.
3729 exceptions so that enclosing shell's state can be restored.
3718
3730
3719 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3731 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3720 naming conventions in the .ipython/ dir.
3732 naming conventions in the .ipython/ dir.
3721
3733
3722 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3734 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3723 from delimiters list so filenames with - in them get expanded.
3735 from delimiters list so filenames with - in them get expanded.
3724
3736
3725 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3737 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3726 sys.displayhook not being properly restored after an embedded call.
3738 sys.displayhook not being properly restored after an embedded call.
3727
3739
3728 2002-03-18 Fernando Perez <fperez@colorado.edu>
3740 2002-03-18 Fernando Perez <fperez@colorado.edu>
3729
3741
3730 * Released 0.2.8
3742 * Released 0.2.8
3731
3743
3732 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3744 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3733 some files weren't being included in a -upgrade.
3745 some files weren't being included in a -upgrade.
3734 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3746 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3735 on' so that the first tab completes.
3747 on' so that the first tab completes.
3736 (InteractiveShell.handle_magic): fixed bug with spaces around
3748 (InteractiveShell.handle_magic): fixed bug with spaces around
3737 quotes breaking many magic commands.
3749 quotes breaking many magic commands.
3738
3750
3739 * setup.py: added note about ignoring the syntax error messages at
3751 * setup.py: added note about ignoring the syntax error messages at
3740 installation.
3752 installation.
3741
3753
3742 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3754 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3743 streamlining the gnuplot interface, now there's only one magic @gp.
3755 streamlining the gnuplot interface, now there's only one magic @gp.
3744
3756
3745 2002-03-17 Fernando Perez <fperez@colorado.edu>
3757 2002-03-17 Fernando Perez <fperez@colorado.edu>
3746
3758
3747 * IPython/UserConfig/magic_gnuplot.py: new name for the
3759 * IPython/UserConfig/magic_gnuplot.py: new name for the
3748 example-magic_pm.py file. Much enhanced system, now with a shell
3760 example-magic_pm.py file. Much enhanced system, now with a shell
3749 for communicating directly with gnuplot, one command at a time.
3761 for communicating directly with gnuplot, one command at a time.
3750
3762
3751 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3763 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3752 setting __name__=='__main__'.
3764 setting __name__=='__main__'.
3753
3765
3754 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3766 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3755 mini-shell for accessing gnuplot from inside ipython. Should
3767 mini-shell for accessing gnuplot from inside ipython. Should
3756 extend it later for grace access too. Inspired by Arnd's
3768 extend it later for grace access too. Inspired by Arnd's
3757 suggestion.
3769 suggestion.
3758
3770
3759 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3771 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3760 calling magic functions with () in their arguments. Thanks to Arnd
3772 calling magic functions with () in their arguments. Thanks to Arnd
3761 Baecker for pointing this to me.
3773 Baecker for pointing this to me.
3762
3774
3763 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3775 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3764 infinitely for integer or complex arrays (only worked with floats).
3776 infinitely for integer or complex arrays (only worked with floats).
3765
3777
3766 2002-03-16 Fernando Perez <fperez@colorado.edu>
3778 2002-03-16 Fernando Perez <fperez@colorado.edu>
3767
3779
3768 * setup.py: Merged setup and setup_windows into a single script
3780 * setup.py: Merged setup and setup_windows into a single script
3769 which properly handles things for windows users.
3781 which properly handles things for windows users.
3770
3782
3771 2002-03-15 Fernando Perez <fperez@colorado.edu>
3783 2002-03-15 Fernando Perez <fperez@colorado.edu>
3772
3784
3773 * Big change to the manual: now the magics are all automatically
3785 * Big change to the manual: now the magics are all automatically
3774 documented. This information is generated from their docstrings
3786 documented. This information is generated from their docstrings
3775 and put in a latex file included by the manual lyx file. This way
3787 and put in a latex file included by the manual lyx file. This way
3776 we get always up to date information for the magics. The manual
3788 we get always up to date information for the magics. The manual
3777 now also has proper version information, also auto-synced.
3789 now also has proper version information, also auto-synced.
3778
3790
3779 For this to work, an undocumented --magic_docstrings option was added.
3791 For this to work, an undocumented --magic_docstrings option was added.
3780
3792
3781 2002-03-13 Fernando Perez <fperez@colorado.edu>
3793 2002-03-13 Fernando Perez <fperez@colorado.edu>
3782
3794
3783 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3795 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3784 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3796 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3785
3797
3786 2002-03-12 Fernando Perez <fperez@colorado.edu>
3798 2002-03-12 Fernando Perez <fperez@colorado.edu>
3787
3799
3788 * IPython/ultraTB.py (TermColors): changed color escapes again to
3800 * IPython/ultraTB.py (TermColors): changed color escapes again to
3789 fix the (old, reintroduced) line-wrapping bug. Basically, if
3801 fix the (old, reintroduced) line-wrapping bug. Basically, if
3790 \001..\002 aren't given in the color escapes, lines get wrapped
3802 \001..\002 aren't given in the color escapes, lines get wrapped
3791 weirdly. But giving those screws up old xterms and emacs terms. So
3803 weirdly. But giving those screws up old xterms and emacs terms. So
3792 I added some logic for emacs terms to be ok, but I can't identify old
3804 I added some logic for emacs terms to be ok, but I can't identify old
3793 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3805 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3794
3806
3795 2002-03-10 Fernando Perez <fperez@colorado.edu>
3807 2002-03-10 Fernando Perez <fperez@colorado.edu>
3796
3808
3797 * IPython/usage.py (__doc__): Various documentation cleanups and
3809 * IPython/usage.py (__doc__): Various documentation cleanups and
3798 updates, both in usage docstrings and in the manual.
3810 updates, both in usage docstrings and in the manual.
3799
3811
3800 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3812 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3801 handling of caching. Set minimum acceptabe value for having a
3813 handling of caching. Set minimum acceptabe value for having a
3802 cache at 20 values.
3814 cache at 20 values.
3803
3815
3804 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3816 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3805 install_first_time function to a method, renamed it and added an
3817 install_first_time function to a method, renamed it and added an
3806 'upgrade' mode. Now people can update their config directory with
3818 'upgrade' mode. Now people can update their config directory with
3807 a simple command line switch (-upgrade, also new).
3819 a simple command line switch (-upgrade, also new).
3808
3820
3809 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3821 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3810 @file (convenient for automagic users under Python >= 2.2).
3822 @file (convenient for automagic users under Python >= 2.2).
3811 Removed @files (it seemed more like a plural than an abbrev. of
3823 Removed @files (it seemed more like a plural than an abbrev. of
3812 'file show').
3824 'file show').
3813
3825
3814 * IPython/iplib.py (install_first_time): Fixed crash if there were
3826 * IPython/iplib.py (install_first_time): Fixed crash if there were
3815 backup files ('~') in .ipython/ install directory.
3827 backup files ('~') in .ipython/ install directory.
3816
3828
3817 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3829 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3818 system. Things look fine, but these changes are fairly
3830 system. Things look fine, but these changes are fairly
3819 intrusive. Test them for a few days.
3831 intrusive. Test them for a few days.
3820
3832
3821 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3833 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3822 the prompts system. Now all in/out prompt strings are user
3834 the prompts system. Now all in/out prompt strings are user
3823 controllable. This is particularly useful for embedding, as one
3835 controllable. This is particularly useful for embedding, as one
3824 can tag embedded instances with particular prompts.
3836 can tag embedded instances with particular prompts.
3825
3837
3826 Also removed global use of sys.ps1/2, which now allows nested
3838 Also removed global use of sys.ps1/2, which now allows nested
3827 embeddings without any problems. Added command-line options for
3839 embeddings without any problems. Added command-line options for
3828 the prompt strings.
3840 the prompt strings.
3829
3841
3830 2002-03-08 Fernando Perez <fperez@colorado.edu>
3842 2002-03-08 Fernando Perez <fperez@colorado.edu>
3831
3843
3832 * IPython/UserConfig/example-embed-short.py (ipshell): added
3844 * IPython/UserConfig/example-embed-short.py (ipshell): added
3833 example file with the bare minimum code for embedding.
3845 example file with the bare minimum code for embedding.
3834
3846
3835 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3847 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3836 functionality for the embeddable shell to be activated/deactivated
3848 functionality for the embeddable shell to be activated/deactivated
3837 either globally or at each call.
3849 either globally or at each call.
3838
3850
3839 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3851 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3840 rewriting the prompt with '--->' for auto-inputs with proper
3852 rewriting the prompt with '--->' for auto-inputs with proper
3841 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3853 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3842 this is handled by the prompts class itself, as it should.
3854 this is handled by the prompts class itself, as it should.
3843
3855
3844 2002-03-05 Fernando Perez <fperez@colorado.edu>
3856 2002-03-05 Fernando Perez <fperez@colorado.edu>
3845
3857
3846 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3858 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3847 @logstart to avoid name clashes with the math log function.
3859 @logstart to avoid name clashes with the math log function.
3848
3860
3849 * Big updates to X/Emacs section of the manual.
3861 * Big updates to X/Emacs section of the manual.
3850
3862
3851 * Removed ipython_emacs. Milan explained to me how to pass
3863 * Removed ipython_emacs. Milan explained to me how to pass
3852 arguments to ipython through Emacs. Some day I'm going to end up
3864 arguments to ipython through Emacs. Some day I'm going to end up
3853 learning some lisp...
3865 learning some lisp...
3854
3866
3855 2002-03-04 Fernando Perez <fperez@colorado.edu>
3867 2002-03-04 Fernando Perez <fperez@colorado.edu>
3856
3868
3857 * IPython/ipython_emacs: Created script to be used as the
3869 * IPython/ipython_emacs: Created script to be used as the
3858 py-python-command Emacs variable so we can pass IPython
3870 py-python-command Emacs variable so we can pass IPython
3859 parameters. I can't figure out how to tell Emacs directly to pass
3871 parameters. I can't figure out how to tell Emacs directly to pass
3860 parameters to IPython, so a dummy shell script will do it.
3872 parameters to IPython, so a dummy shell script will do it.
3861
3873
3862 Other enhancements made for things to work better under Emacs'
3874 Other enhancements made for things to work better under Emacs'
3863 various types of terminals. Many thanks to Milan Zamazal
3875 various types of terminals. Many thanks to Milan Zamazal
3864 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3876 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3865
3877
3866 2002-03-01 Fernando Perez <fperez@colorado.edu>
3878 2002-03-01 Fernando Perez <fperez@colorado.edu>
3867
3879
3868 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3880 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3869 that loading of readline is now optional. This gives better
3881 that loading of readline is now optional. This gives better
3870 control to emacs users.
3882 control to emacs users.
3871
3883
3872 * IPython/ultraTB.py (__date__): Modified color escape sequences
3884 * IPython/ultraTB.py (__date__): Modified color escape sequences
3873 and now things work fine under xterm and in Emacs' term buffers
3885 and now things work fine under xterm and in Emacs' term buffers
3874 (though not shell ones). Well, in emacs you get colors, but all
3886 (though not shell ones). Well, in emacs you get colors, but all
3875 seem to be 'light' colors (no difference between dark and light
3887 seem to be 'light' colors (no difference between dark and light
3876 ones). But the garbage chars are gone, and also in xterms. It
3888 ones). But the garbage chars are gone, and also in xterms. It
3877 seems that now I'm using 'cleaner' ansi sequences.
3889 seems that now I'm using 'cleaner' ansi sequences.
3878
3890
3879 2002-02-21 Fernando Perez <fperez@colorado.edu>
3891 2002-02-21 Fernando Perez <fperez@colorado.edu>
3880
3892
3881 * Released 0.2.7 (mainly to publish the scoping fix).
3893 * Released 0.2.7 (mainly to publish the scoping fix).
3882
3894
3883 * IPython/Logger.py (Logger.logstate): added. A corresponding
3895 * IPython/Logger.py (Logger.logstate): added. A corresponding
3884 @logstate magic was created.
3896 @logstate magic was created.
3885
3897
3886 * IPython/Magic.py: fixed nested scoping problem under Python
3898 * IPython/Magic.py: fixed nested scoping problem under Python
3887 2.1.x (automagic wasn't working).
3899 2.1.x (automagic wasn't working).
3888
3900
3889 2002-02-20 Fernando Perez <fperez@colorado.edu>
3901 2002-02-20 Fernando Perez <fperez@colorado.edu>
3890
3902
3891 * Released 0.2.6.
3903 * Released 0.2.6.
3892
3904
3893 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3905 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3894 option so that logs can come out without any headers at all.
3906 option so that logs can come out without any headers at all.
3895
3907
3896 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3908 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3897 SciPy.
3909 SciPy.
3898
3910
3899 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3911 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3900 that embedded IPython calls don't require vars() to be explicitly
3912 that embedded IPython calls don't require vars() to be explicitly
3901 passed. Now they are extracted from the caller's frame (code
3913 passed. Now they are extracted from the caller's frame (code
3902 snatched from Eric Jones' weave). Added better documentation to
3914 snatched from Eric Jones' weave). Added better documentation to
3903 the section on embedding and the example file.
3915 the section on embedding and the example file.
3904
3916
3905 * IPython/genutils.py (page): Changed so that under emacs, it just
3917 * IPython/genutils.py (page): Changed so that under emacs, it just
3906 prints the string. You can then page up and down in the emacs
3918 prints the string. You can then page up and down in the emacs
3907 buffer itself. This is how the builtin help() works.
3919 buffer itself. This is how the builtin help() works.
3908
3920
3909 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3921 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3910 macro scoping: macros need to be executed in the user's namespace
3922 macro scoping: macros need to be executed in the user's namespace
3911 to work as if they had been typed by the user.
3923 to work as if they had been typed by the user.
3912
3924
3913 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3925 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3914 execute automatically (no need to type 'exec...'). They then
3926 execute automatically (no need to type 'exec...'). They then
3915 behave like 'true macros'. The printing system was also modified
3927 behave like 'true macros'. The printing system was also modified
3916 for this to work.
3928 for this to work.
3917
3929
3918 2002-02-19 Fernando Perez <fperez@colorado.edu>
3930 2002-02-19 Fernando Perez <fperez@colorado.edu>
3919
3931
3920 * IPython/genutils.py (page_file): new function for paging files
3932 * IPython/genutils.py (page_file): new function for paging files
3921 in an OS-independent way. Also necessary for file viewing to work
3933 in an OS-independent way. Also necessary for file viewing to work
3922 well inside Emacs buffers.
3934 well inside Emacs buffers.
3923 (page): Added checks for being in an emacs buffer.
3935 (page): Added checks for being in an emacs buffer.
3924 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3936 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3925 same bug in iplib.
3937 same bug in iplib.
3926
3938
3927 2002-02-18 Fernando Perez <fperez@colorado.edu>
3939 2002-02-18 Fernando Perez <fperez@colorado.edu>
3928
3940
3929 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3941 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3930 of readline so that IPython can work inside an Emacs buffer.
3942 of readline so that IPython can work inside an Emacs buffer.
3931
3943
3932 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3944 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3933 method signatures (they weren't really bugs, but it looks cleaner
3945 method signatures (they weren't really bugs, but it looks cleaner
3934 and keeps PyChecker happy).
3946 and keeps PyChecker happy).
3935
3947
3936 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3948 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3937 for implementing various user-defined hooks. Currently only
3949 for implementing various user-defined hooks. Currently only
3938 display is done.
3950 display is done.
3939
3951
3940 * IPython/Prompts.py (CachedOutput._display): changed display
3952 * IPython/Prompts.py (CachedOutput._display): changed display
3941 functions so that they can be dynamically changed by users easily.
3953 functions so that they can be dynamically changed by users easily.
3942
3954
3943 * IPython/Extensions/numeric_formats.py (num_display): added an
3955 * IPython/Extensions/numeric_formats.py (num_display): added an
3944 extension for printing NumPy arrays in flexible manners. It
3956 extension for printing NumPy arrays in flexible manners. It
3945 doesn't do anything yet, but all the structure is in
3957 doesn't do anything yet, but all the structure is in
3946 place. Ultimately the plan is to implement output format control
3958 place. Ultimately the plan is to implement output format control
3947 like in Octave.
3959 like in Octave.
3948
3960
3949 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3961 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3950 methods are found at run-time by all the automatic machinery.
3962 methods are found at run-time by all the automatic machinery.
3951
3963
3952 2002-02-17 Fernando Perez <fperez@colorado.edu>
3964 2002-02-17 Fernando Perez <fperez@colorado.edu>
3953
3965
3954 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3966 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3955 whole file a little.
3967 whole file a little.
3956
3968
3957 * ToDo: closed this document. Now there's a new_design.lyx
3969 * ToDo: closed this document. Now there's a new_design.lyx
3958 document for all new ideas. Added making a pdf of it for the
3970 document for all new ideas. Added making a pdf of it for the
3959 end-user distro.
3971 end-user distro.
3960
3972
3961 * IPython/Logger.py (Logger.switch_log): Created this to replace
3973 * IPython/Logger.py (Logger.switch_log): Created this to replace
3962 logon() and logoff(). It also fixes a nasty crash reported by
3974 logon() and logoff(). It also fixes a nasty crash reported by
3963 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3975 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3964
3976
3965 * IPython/iplib.py (complete): got auto-completion to work with
3977 * IPython/iplib.py (complete): got auto-completion to work with
3966 automagic (I had wanted this for a long time).
3978 automagic (I had wanted this for a long time).
3967
3979
3968 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3980 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3969 to @file, since file() is now a builtin and clashes with automagic
3981 to @file, since file() is now a builtin and clashes with automagic
3970 for @file.
3982 for @file.
3971
3983
3972 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3984 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3973 of this was previously in iplib, which had grown to more than 2000
3985 of this was previously in iplib, which had grown to more than 2000
3974 lines, way too long. No new functionality, but it makes managing
3986 lines, way too long. No new functionality, but it makes managing
3975 the code a bit easier.
3987 the code a bit easier.
3976
3988
3977 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3989 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3978 information to crash reports.
3990 information to crash reports.
3979
3991
3980 2002-02-12 Fernando Perez <fperez@colorado.edu>
3992 2002-02-12 Fernando Perez <fperez@colorado.edu>
3981
3993
3982 * Released 0.2.5.
3994 * Released 0.2.5.
3983
3995
3984 2002-02-11 Fernando Perez <fperez@colorado.edu>
3996 2002-02-11 Fernando Perez <fperez@colorado.edu>
3985
3997
3986 * Wrote a relatively complete Windows installer. It puts
3998 * Wrote a relatively complete Windows installer. It puts
3987 everything in place, creates Start Menu entries and fixes the
3999 everything in place, creates Start Menu entries and fixes the
3988 color issues. Nothing fancy, but it works.
4000 color issues. Nothing fancy, but it works.
3989
4001
3990 2002-02-10 Fernando Perez <fperez@colorado.edu>
4002 2002-02-10 Fernando Perez <fperez@colorado.edu>
3991
4003
3992 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4004 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3993 os.path.expanduser() call so that we can type @run ~/myfile.py and
4005 os.path.expanduser() call so that we can type @run ~/myfile.py and
3994 have thigs work as expected.
4006 have thigs work as expected.
3995
4007
3996 * IPython/genutils.py (page): fixed exception handling so things
4008 * IPython/genutils.py (page): fixed exception handling so things
3997 work both in Unix and Windows correctly. Quitting a pager triggers
4009 work both in Unix and Windows correctly. Quitting a pager triggers
3998 an IOError/broken pipe in Unix, and in windows not finding a pager
4010 an IOError/broken pipe in Unix, and in windows not finding a pager
3999 is also an IOError, so I had to actually look at the return value
4011 is also an IOError, so I had to actually look at the return value
4000 of the exception, not just the exception itself. Should be ok now.
4012 of the exception, not just the exception itself. Should be ok now.
4001
4013
4002 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4014 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4003 modified to allow case-insensitive color scheme changes.
4015 modified to allow case-insensitive color scheme changes.
4004
4016
4005 2002-02-09 Fernando Perez <fperez@colorado.edu>
4017 2002-02-09 Fernando Perez <fperez@colorado.edu>
4006
4018
4007 * IPython/genutils.py (native_line_ends): new function to leave
4019 * IPython/genutils.py (native_line_ends): new function to leave
4008 user config files with os-native line-endings.
4020 user config files with os-native line-endings.
4009
4021
4010 * README and manual updates.
4022 * README and manual updates.
4011
4023
4012 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4024 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4013 instead of StringType to catch Unicode strings.
4025 instead of StringType to catch Unicode strings.
4014
4026
4015 * IPython/genutils.py (filefind): fixed bug for paths with
4027 * IPython/genutils.py (filefind): fixed bug for paths with
4016 embedded spaces (very common in Windows).
4028 embedded spaces (very common in Windows).
4017
4029
4018 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4030 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4019 files under Windows, so that they get automatically associated
4031 files under Windows, so that they get automatically associated
4020 with a text editor. Windows makes it a pain to handle
4032 with a text editor. Windows makes it a pain to handle
4021 extension-less files.
4033 extension-less files.
4022
4034
4023 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4035 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4024 warning about readline only occur for Posix. In Windows there's no
4036 warning about readline only occur for Posix. In Windows there's no
4025 way to get readline, so why bother with the warning.
4037 way to get readline, so why bother with the warning.
4026
4038
4027 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4039 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4028 for __str__ instead of dir(self), since dir() changed in 2.2.
4040 for __str__ instead of dir(self), since dir() changed in 2.2.
4029
4041
4030 * Ported to Windows! Tested on XP, I suspect it should work fine
4042 * Ported to Windows! Tested on XP, I suspect it should work fine
4031 on NT/2000, but I don't think it will work on 98 et al. That
4043 on NT/2000, but I don't think it will work on 98 et al. That
4032 series of Windows is such a piece of junk anyway that I won't try
4044 series of Windows is such a piece of junk anyway that I won't try
4033 porting it there. The XP port was straightforward, showed a few
4045 porting it there. The XP port was straightforward, showed a few
4034 bugs here and there (fixed all), in particular some string
4046 bugs here and there (fixed all), in particular some string
4035 handling stuff which required considering Unicode strings (which
4047 handling stuff which required considering Unicode strings (which
4036 Windows uses). This is good, but hasn't been too tested :) No
4048 Windows uses). This is good, but hasn't been too tested :) No
4037 fancy installer yet, I'll put a note in the manual so people at
4049 fancy installer yet, I'll put a note in the manual so people at
4038 least make manually a shortcut.
4050 least make manually a shortcut.
4039
4051
4040 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4052 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4041 into a single one, "colors". This now controls both prompt and
4053 into a single one, "colors". This now controls both prompt and
4042 exception color schemes, and can be changed both at startup
4054 exception color schemes, and can be changed both at startup
4043 (either via command-line switches or via ipythonrc files) and at
4055 (either via command-line switches or via ipythonrc files) and at
4044 runtime, with @colors.
4056 runtime, with @colors.
4045 (Magic.magic_run): renamed @prun to @run and removed the old
4057 (Magic.magic_run): renamed @prun to @run and removed the old
4046 @run. The two were too similar to warrant keeping both.
4058 @run. The two were too similar to warrant keeping both.
4047
4059
4048 2002-02-03 Fernando Perez <fperez@colorado.edu>
4060 2002-02-03 Fernando Perez <fperez@colorado.edu>
4049
4061
4050 * IPython/iplib.py (install_first_time): Added comment on how to
4062 * IPython/iplib.py (install_first_time): Added comment on how to
4051 configure the color options for first-time users. Put a <return>
4063 configure the color options for first-time users. Put a <return>
4052 request at the end so that small-terminal users get a chance to
4064 request at the end so that small-terminal users get a chance to
4053 read the startup info.
4065 read the startup info.
4054
4066
4055 2002-01-23 Fernando Perez <fperez@colorado.edu>
4067 2002-01-23 Fernando Perez <fperez@colorado.edu>
4056
4068
4057 * IPython/iplib.py (CachedOutput.update): Changed output memory
4069 * IPython/iplib.py (CachedOutput.update): Changed output memory
4058 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4070 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4059 input history we still use _i. Did this b/c these variable are
4071 input history we still use _i. Did this b/c these variable are
4060 very commonly used in interactive work, so the less we need to
4072 very commonly used in interactive work, so the less we need to
4061 type the better off we are.
4073 type the better off we are.
4062 (Magic.magic_prun): updated @prun to better handle the namespaces
4074 (Magic.magic_prun): updated @prun to better handle the namespaces
4063 the file will run in, including a fix for __name__ not being set
4075 the file will run in, including a fix for __name__ not being set
4064 before.
4076 before.
4065
4077
4066 2002-01-20 Fernando Perez <fperez@colorado.edu>
4078 2002-01-20 Fernando Perez <fperez@colorado.edu>
4067
4079
4068 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4080 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4069 extra garbage for Python 2.2. Need to look more carefully into
4081 extra garbage for Python 2.2. Need to look more carefully into
4070 this later.
4082 this later.
4071
4083
4072 2002-01-19 Fernando Perez <fperez@colorado.edu>
4084 2002-01-19 Fernando Perez <fperez@colorado.edu>
4073
4085
4074 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4086 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4075 display SyntaxError exceptions properly formatted when they occur
4087 display SyntaxError exceptions properly formatted when they occur
4076 (they can be triggered by imported code).
4088 (they can be triggered by imported code).
4077
4089
4078 2002-01-18 Fernando Perez <fperez@colorado.edu>
4090 2002-01-18 Fernando Perez <fperez@colorado.edu>
4079
4091
4080 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4092 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4081 SyntaxError exceptions are reported nicely formatted, instead of
4093 SyntaxError exceptions are reported nicely formatted, instead of
4082 spitting out only offset information as before.
4094 spitting out only offset information as before.
4083 (Magic.magic_prun): Added the @prun function for executing
4095 (Magic.magic_prun): Added the @prun function for executing
4084 programs with command line args inside IPython.
4096 programs with command line args inside IPython.
4085
4097
4086 2002-01-16 Fernando Perez <fperez@colorado.edu>
4098 2002-01-16 Fernando Perez <fperez@colorado.edu>
4087
4099
4088 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4100 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4089 to *not* include the last item given in a range. This brings their
4101 to *not* include the last item given in a range. This brings their
4090 behavior in line with Python's slicing:
4102 behavior in line with Python's slicing:
4091 a[n1:n2] -> a[n1]...a[n2-1]
4103 a[n1:n2] -> a[n1]...a[n2-1]
4092 It may be a bit less convenient, but I prefer to stick to Python's
4104 It may be a bit less convenient, but I prefer to stick to Python's
4093 conventions *everywhere*, so users never have to wonder.
4105 conventions *everywhere*, so users never have to wonder.
4094 (Magic.magic_macro): Added @macro function to ease the creation of
4106 (Magic.magic_macro): Added @macro function to ease the creation of
4095 macros.
4107 macros.
4096
4108
4097 2002-01-05 Fernando Perez <fperez@colorado.edu>
4109 2002-01-05 Fernando Perez <fperez@colorado.edu>
4098
4110
4099 * Released 0.2.4.
4111 * Released 0.2.4.
4100
4112
4101 * IPython/iplib.py (Magic.magic_pdef):
4113 * IPython/iplib.py (Magic.magic_pdef):
4102 (InteractiveShell.safe_execfile): report magic lines and error
4114 (InteractiveShell.safe_execfile): report magic lines and error
4103 lines without line numbers so one can easily copy/paste them for
4115 lines without line numbers so one can easily copy/paste them for
4104 re-execution.
4116 re-execution.
4105
4117
4106 * Updated manual with recent changes.
4118 * Updated manual with recent changes.
4107
4119
4108 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4120 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4109 docstring printing when class? is called. Very handy for knowing
4121 docstring printing when class? is called. Very handy for knowing
4110 how to create class instances (as long as __init__ is well
4122 how to create class instances (as long as __init__ is well
4111 documented, of course :)
4123 documented, of course :)
4112 (Magic.magic_doc): print both class and constructor docstrings.
4124 (Magic.magic_doc): print both class and constructor docstrings.
4113 (Magic.magic_pdef): give constructor info if passed a class and
4125 (Magic.magic_pdef): give constructor info if passed a class and
4114 __call__ info for callable object instances.
4126 __call__ info for callable object instances.
4115
4127
4116 2002-01-04 Fernando Perez <fperez@colorado.edu>
4128 2002-01-04 Fernando Perez <fperez@colorado.edu>
4117
4129
4118 * Made deep_reload() off by default. It doesn't always work
4130 * Made deep_reload() off by default. It doesn't always work
4119 exactly as intended, so it's probably safer to have it off. It's
4131 exactly as intended, so it's probably safer to have it off. It's
4120 still available as dreload() anyway, so nothing is lost.
4132 still available as dreload() anyway, so nothing is lost.
4121
4133
4122 2002-01-02 Fernando Perez <fperez@colorado.edu>
4134 2002-01-02 Fernando Perez <fperez@colorado.edu>
4123
4135
4124 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4136 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4125 so I wanted an updated release).
4137 so I wanted an updated release).
4126
4138
4127 2001-12-27 Fernando Perez <fperez@colorado.edu>
4139 2001-12-27 Fernando Perez <fperez@colorado.edu>
4128
4140
4129 * IPython/iplib.py (InteractiveShell.interact): Added the original
4141 * IPython/iplib.py (InteractiveShell.interact): Added the original
4130 code from 'code.py' for this module in order to change the
4142 code from 'code.py' for this module in order to change the
4131 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4143 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4132 the history cache would break when the user hit Ctrl-C, and
4144 the history cache would break when the user hit Ctrl-C, and
4133 interact() offers no way to add any hooks to it.
4145 interact() offers no way to add any hooks to it.
4134
4146
4135 2001-12-23 Fernando Perez <fperez@colorado.edu>
4147 2001-12-23 Fernando Perez <fperez@colorado.edu>
4136
4148
4137 * setup.py: added check for 'MANIFEST' before trying to remove
4149 * setup.py: added check for 'MANIFEST' before trying to remove
4138 it. Thanks to Sean Reifschneider.
4150 it. Thanks to Sean Reifschneider.
4139
4151
4140 2001-12-22 Fernando Perez <fperez@colorado.edu>
4152 2001-12-22 Fernando Perez <fperez@colorado.edu>
4141
4153
4142 * Released 0.2.2.
4154 * Released 0.2.2.
4143
4155
4144 * Finished (reasonably) writing the manual. Later will add the
4156 * Finished (reasonably) writing the manual. Later will add the
4145 python-standard navigation stylesheets, but for the time being
4157 python-standard navigation stylesheets, but for the time being
4146 it's fairly complete. Distribution will include html and pdf
4158 it's fairly complete. Distribution will include html and pdf
4147 versions.
4159 versions.
4148
4160
4149 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4161 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4150 (MayaVi author).
4162 (MayaVi author).
4151
4163
4152 2001-12-21 Fernando Perez <fperez@colorado.edu>
4164 2001-12-21 Fernando Perez <fperez@colorado.edu>
4153
4165
4154 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4166 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4155 good public release, I think (with the manual and the distutils
4167 good public release, I think (with the manual and the distutils
4156 installer). The manual can use some work, but that can go
4168 installer). The manual can use some work, but that can go
4157 slowly. Otherwise I think it's quite nice for end users. Next
4169 slowly. Otherwise I think it's quite nice for end users. Next
4158 summer, rewrite the guts of it...
4170 summer, rewrite the guts of it...
4159
4171
4160 * Changed format of ipythonrc files to use whitespace as the
4172 * Changed format of ipythonrc files to use whitespace as the
4161 separator instead of an explicit '='. Cleaner.
4173 separator instead of an explicit '='. Cleaner.
4162
4174
4163 2001-12-20 Fernando Perez <fperez@colorado.edu>
4175 2001-12-20 Fernando Perez <fperez@colorado.edu>
4164
4176
4165 * Started a manual in LyX. For now it's just a quick merge of the
4177 * Started a manual in LyX. For now it's just a quick merge of the
4166 various internal docstrings and READMEs. Later it may grow into a
4178 various internal docstrings and READMEs. Later it may grow into a
4167 nice, full-blown manual.
4179 nice, full-blown manual.
4168
4180
4169 * Set up a distutils based installer. Installation should now be
4181 * Set up a distutils based installer. Installation should now be
4170 trivially simple for end-users.
4182 trivially simple for end-users.
4171
4183
4172 2001-12-11 Fernando Perez <fperez@colorado.edu>
4184 2001-12-11 Fernando Perez <fperez@colorado.edu>
4173
4185
4174 * Released 0.2.0. First public release, announced it at
4186 * Released 0.2.0. First public release, announced it at
4175 comp.lang.python. From now on, just bugfixes...
4187 comp.lang.python. From now on, just bugfixes...
4176
4188
4177 * Went through all the files, set copyright/license notices and
4189 * Went through all the files, set copyright/license notices and
4178 cleaned up things. Ready for release.
4190 cleaned up things. Ready for release.
4179
4191
4180 2001-12-10 Fernando Perez <fperez@colorado.edu>
4192 2001-12-10 Fernando Perez <fperez@colorado.edu>
4181
4193
4182 * Changed the first-time installer not to use tarfiles. It's more
4194 * Changed the first-time installer not to use tarfiles. It's more
4183 robust now and less unix-dependent. Also makes it easier for
4195 robust now and less unix-dependent. Also makes it easier for
4184 people to later upgrade versions.
4196 people to later upgrade versions.
4185
4197
4186 * Changed @exit to @abort to reflect the fact that it's pretty
4198 * Changed @exit to @abort to reflect the fact that it's pretty
4187 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4199 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4188 becomes significant only when IPyhton is embedded: in that case,
4200 becomes significant only when IPyhton is embedded: in that case,
4189 C-D closes IPython only, but @abort kills the enclosing program
4201 C-D closes IPython only, but @abort kills the enclosing program
4190 too (unless it had called IPython inside a try catching
4202 too (unless it had called IPython inside a try catching
4191 SystemExit).
4203 SystemExit).
4192
4204
4193 * Created Shell module which exposes the actuall IPython Shell
4205 * Created Shell module which exposes the actuall IPython Shell
4194 classes, currently the normal and the embeddable one. This at
4206 classes, currently the normal and the embeddable one. This at
4195 least offers a stable interface we won't need to change when
4207 least offers a stable interface we won't need to change when
4196 (later) the internals are rewritten. That rewrite will be confined
4208 (later) the internals are rewritten. That rewrite will be confined
4197 to iplib and ipmaker, but the Shell interface should remain as is.
4209 to iplib and ipmaker, but the Shell interface should remain as is.
4198
4210
4199 * Added embed module which offers an embeddable IPShell object,
4211 * Added embed module which offers an embeddable IPShell object,
4200 useful to fire up IPython *inside* a running program. Great for
4212 useful to fire up IPython *inside* a running program. Great for
4201 debugging or dynamical data analysis.
4213 debugging or dynamical data analysis.
4202
4214
4203 2001-12-08 Fernando Perez <fperez@colorado.edu>
4215 2001-12-08 Fernando Perez <fperez@colorado.edu>
4204
4216
4205 * Fixed small bug preventing seeing info from methods of defined
4217 * Fixed small bug preventing seeing info from methods of defined
4206 objects (incorrect namespace in _ofind()).
4218 objects (incorrect namespace in _ofind()).
4207
4219
4208 * Documentation cleanup. Moved the main usage docstrings to a
4220 * Documentation cleanup. Moved the main usage docstrings to a
4209 separate file, usage.py (cleaner to maintain, and hopefully in the
4221 separate file, usage.py (cleaner to maintain, and hopefully in the
4210 future some perlpod-like way of producing interactive, man and
4222 future some perlpod-like way of producing interactive, man and
4211 html docs out of it will be found).
4223 html docs out of it will be found).
4212
4224
4213 * Added @profile to see your profile at any time.
4225 * Added @profile to see your profile at any time.
4214
4226
4215 * Added @p as an alias for 'print'. It's especially convenient if
4227 * Added @p as an alias for 'print'. It's especially convenient if
4216 using automagic ('p x' prints x).
4228 using automagic ('p x' prints x).
4217
4229
4218 * Small cleanups and fixes after a pychecker run.
4230 * Small cleanups and fixes after a pychecker run.
4219
4231
4220 * Changed the @cd command to handle @cd - and @cd -<n> for
4232 * Changed the @cd command to handle @cd - and @cd -<n> for
4221 visiting any directory in _dh.
4233 visiting any directory in _dh.
4222
4234
4223 * Introduced _dh, a history of visited directories. @dhist prints
4235 * Introduced _dh, a history of visited directories. @dhist prints
4224 it out with numbers.
4236 it out with numbers.
4225
4237
4226 2001-12-07 Fernando Perez <fperez@colorado.edu>
4238 2001-12-07 Fernando Perez <fperez@colorado.edu>
4227
4239
4228 * Released 0.1.22
4240 * Released 0.1.22
4229
4241
4230 * Made initialization a bit more robust against invalid color
4242 * Made initialization a bit more robust against invalid color
4231 options in user input (exit, not traceback-crash).
4243 options in user input (exit, not traceback-crash).
4232
4244
4233 * Changed the bug crash reporter to write the report only in the
4245 * Changed the bug crash reporter to write the report only in the
4234 user's .ipython directory. That way IPython won't litter people's
4246 user's .ipython directory. That way IPython won't litter people's
4235 hard disks with crash files all over the place. Also print on
4247 hard disks with crash files all over the place. Also print on
4236 screen the necessary mail command.
4248 screen the necessary mail command.
4237
4249
4238 * With the new ultraTB, implemented LightBG color scheme for light
4250 * With the new ultraTB, implemented LightBG color scheme for light
4239 background terminals. A lot of people like white backgrounds, so I
4251 background terminals. A lot of people like white backgrounds, so I
4240 guess we should at least give them something readable.
4252 guess we should at least give them something readable.
4241
4253
4242 2001-12-06 Fernando Perez <fperez@colorado.edu>
4254 2001-12-06 Fernando Perez <fperez@colorado.edu>
4243
4255
4244 * Modified the structure of ultraTB. Now there's a proper class
4256 * Modified the structure of ultraTB. Now there's a proper class
4245 for tables of color schemes which allow adding schemes easily and
4257 for tables of color schemes which allow adding schemes easily and
4246 switching the active scheme without creating a new instance every
4258 switching the active scheme without creating a new instance every
4247 time (which was ridiculous). The syntax for creating new schemes
4259 time (which was ridiculous). The syntax for creating new schemes
4248 is also cleaner. I think ultraTB is finally done, with a clean
4260 is also cleaner. I think ultraTB is finally done, with a clean
4249 class structure. Names are also much cleaner (now there's proper
4261 class structure. Names are also much cleaner (now there's proper
4250 color tables, no need for every variable to also have 'color' in
4262 color tables, no need for every variable to also have 'color' in
4251 its name).
4263 its name).
4252
4264
4253 * Broke down genutils into separate files. Now genutils only
4265 * Broke down genutils into separate files. Now genutils only
4254 contains utility functions, and classes have been moved to their
4266 contains utility functions, and classes have been moved to their
4255 own files (they had enough independent functionality to warrant
4267 own files (they had enough independent functionality to warrant
4256 it): ConfigLoader, OutputTrap, Struct.
4268 it): ConfigLoader, OutputTrap, Struct.
4257
4269
4258 2001-12-05 Fernando Perez <fperez@colorado.edu>
4270 2001-12-05 Fernando Perez <fperez@colorado.edu>
4259
4271
4260 * IPython turns 21! Released version 0.1.21, as a candidate for
4272 * IPython turns 21! Released version 0.1.21, as a candidate for
4261 public consumption. If all goes well, release in a few days.
4273 public consumption. If all goes well, release in a few days.
4262
4274
4263 * Fixed path bug (files in Extensions/ directory wouldn't be found
4275 * Fixed path bug (files in Extensions/ directory wouldn't be found
4264 unless IPython/ was explicitly in sys.path).
4276 unless IPython/ was explicitly in sys.path).
4265
4277
4266 * Extended the FlexCompleter class as MagicCompleter to allow
4278 * Extended the FlexCompleter class as MagicCompleter to allow
4267 completion of @-starting lines.
4279 completion of @-starting lines.
4268
4280
4269 * Created __release__.py file as a central repository for release
4281 * Created __release__.py file as a central repository for release
4270 info that other files can read from.
4282 info that other files can read from.
4271
4283
4272 * Fixed small bug in logging: when logging was turned on in
4284 * Fixed small bug in logging: when logging was turned on in
4273 mid-session, old lines with special meanings (!@?) were being
4285 mid-session, old lines with special meanings (!@?) were being
4274 logged without the prepended comment, which is necessary since
4286 logged without the prepended comment, which is necessary since
4275 they are not truly valid python syntax. This should make session
4287 they are not truly valid python syntax. This should make session
4276 restores produce less errors.
4288 restores produce less errors.
4277
4289
4278 * The namespace cleanup forced me to make a FlexCompleter class
4290 * The namespace cleanup forced me to make a FlexCompleter class
4279 which is nothing but a ripoff of rlcompleter, but with selectable
4291 which is nothing but a ripoff of rlcompleter, but with selectable
4280 namespace (rlcompleter only works in __main__.__dict__). I'll try
4292 namespace (rlcompleter only works in __main__.__dict__). I'll try
4281 to submit a note to the authors to see if this change can be
4293 to submit a note to the authors to see if this change can be
4282 incorporated in future rlcompleter releases (Dec.6: done)
4294 incorporated in future rlcompleter releases (Dec.6: done)
4283
4295
4284 * More fixes to namespace handling. It was a mess! Now all
4296 * More fixes to namespace handling. It was a mess! Now all
4285 explicit references to __main__.__dict__ are gone (except when
4297 explicit references to __main__.__dict__ are gone (except when
4286 really needed) and everything is handled through the namespace
4298 really needed) and everything is handled through the namespace
4287 dicts in the IPython instance. We seem to be getting somewhere
4299 dicts in the IPython instance. We seem to be getting somewhere
4288 with this, finally...
4300 with this, finally...
4289
4301
4290 * Small documentation updates.
4302 * Small documentation updates.
4291
4303
4292 * Created the Extensions directory under IPython (with an
4304 * Created the Extensions directory under IPython (with an
4293 __init__.py). Put the PhysicalQ stuff there. This directory should
4305 __init__.py). Put the PhysicalQ stuff there. This directory should
4294 be used for all special-purpose extensions.
4306 be used for all special-purpose extensions.
4295
4307
4296 * File renaming:
4308 * File renaming:
4297 ipythonlib --> ipmaker
4309 ipythonlib --> ipmaker
4298 ipplib --> iplib
4310 ipplib --> iplib
4299 This makes a bit more sense in terms of what these files actually do.
4311 This makes a bit more sense in terms of what these files actually do.
4300
4312
4301 * Moved all the classes and functions in ipythonlib to ipplib, so
4313 * Moved all the classes and functions in ipythonlib to ipplib, so
4302 now ipythonlib only has make_IPython(). This will ease up its
4314 now ipythonlib only has make_IPython(). This will ease up its
4303 splitting in smaller functional chunks later.
4315 splitting in smaller functional chunks later.
4304
4316
4305 * Cleaned up (done, I think) output of @whos. Better column
4317 * Cleaned up (done, I think) output of @whos. Better column
4306 formatting, and now shows str(var) for as much as it can, which is
4318 formatting, and now shows str(var) for as much as it can, which is
4307 typically what one gets with a 'print var'.
4319 typically what one gets with a 'print var'.
4308
4320
4309 2001-12-04 Fernando Perez <fperez@colorado.edu>
4321 2001-12-04 Fernando Perez <fperez@colorado.edu>
4310
4322
4311 * Fixed namespace problems. Now builtin/IPyhton/user names get
4323 * Fixed namespace problems. Now builtin/IPyhton/user names get
4312 properly reported in their namespace. Internal namespace handling
4324 properly reported in their namespace. Internal namespace handling
4313 is finally getting decent (not perfect yet, but much better than
4325 is finally getting decent (not perfect yet, but much better than
4314 the ad-hoc mess we had).
4326 the ad-hoc mess we had).
4315
4327
4316 * Removed -exit option. If people just want to run a python
4328 * Removed -exit option. If people just want to run a python
4317 script, that's what the normal interpreter is for. Less
4329 script, that's what the normal interpreter is for. Less
4318 unnecessary options, less chances for bugs.
4330 unnecessary options, less chances for bugs.
4319
4331
4320 * Added a crash handler which generates a complete post-mortem if
4332 * Added a crash handler which generates a complete post-mortem if
4321 IPython crashes. This will help a lot in tracking bugs down the
4333 IPython crashes. This will help a lot in tracking bugs down the
4322 road.
4334 road.
4323
4335
4324 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4336 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4325 which were boud to functions being reassigned would bypass the
4337 which were boud to functions being reassigned would bypass the
4326 logger, breaking the sync of _il with the prompt counter. This
4338 logger, breaking the sync of _il with the prompt counter. This
4327 would then crash IPython later when a new line was logged.
4339 would then crash IPython later when a new line was logged.
4328
4340
4329 2001-12-02 Fernando Perez <fperez@colorado.edu>
4341 2001-12-02 Fernando Perez <fperez@colorado.edu>
4330
4342
4331 * Made IPython a package. This means people don't have to clutter
4343 * Made IPython a package. This means people don't have to clutter
4332 their sys.path with yet another directory. Changed the INSTALL
4344 their sys.path with yet another directory. Changed the INSTALL
4333 file accordingly.
4345 file accordingly.
4334
4346
4335 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4347 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4336 sorts its output (so @who shows it sorted) and @whos formats the
4348 sorts its output (so @who shows it sorted) and @whos formats the
4337 table according to the width of the first column. Nicer, easier to
4349 table according to the width of the first column. Nicer, easier to
4338 read. Todo: write a generic table_format() which takes a list of
4350 read. Todo: write a generic table_format() which takes a list of
4339 lists and prints it nicely formatted, with optional row/column
4351 lists and prints it nicely formatted, with optional row/column
4340 separators and proper padding and justification.
4352 separators and proper padding and justification.
4341
4353
4342 * Released 0.1.20
4354 * Released 0.1.20
4343
4355
4344 * Fixed bug in @log which would reverse the inputcache list (a
4356 * Fixed bug in @log which would reverse the inputcache list (a
4345 copy operation was missing).
4357 copy operation was missing).
4346
4358
4347 * Code cleanup. @config was changed to use page(). Better, since
4359 * Code cleanup. @config was changed to use page(). Better, since
4348 its output is always quite long.
4360 its output is always quite long.
4349
4361
4350 * Itpl is back as a dependency. I was having too many problems
4362 * Itpl is back as a dependency. I was having too many problems
4351 getting the parametric aliases to work reliably, and it's just
4363 getting the parametric aliases to work reliably, and it's just
4352 easier to code weird string operations with it than playing %()s
4364 easier to code weird string operations with it than playing %()s
4353 games. It's only ~6k, so I don't think it's too big a deal.
4365 games. It's only ~6k, so I don't think it's too big a deal.
4354
4366
4355 * Found (and fixed) a very nasty bug with history. !lines weren't
4367 * Found (and fixed) a very nasty bug with history. !lines weren't
4356 getting cached, and the out of sync caches would crash
4368 getting cached, and the out of sync caches would crash
4357 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4369 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4358 division of labor a bit better. Bug fixed, cleaner structure.
4370 division of labor a bit better. Bug fixed, cleaner structure.
4359
4371
4360 2001-12-01 Fernando Perez <fperez@colorado.edu>
4372 2001-12-01 Fernando Perez <fperez@colorado.edu>
4361
4373
4362 * Released 0.1.19
4374 * Released 0.1.19
4363
4375
4364 * Added option -n to @hist to prevent line number printing. Much
4376 * Added option -n to @hist to prevent line number printing. Much
4365 easier to copy/paste code this way.
4377 easier to copy/paste code this way.
4366
4378
4367 * Created global _il to hold the input list. Allows easy
4379 * Created global _il to hold the input list. Allows easy
4368 re-execution of blocks of code by slicing it (inspired by Janko's
4380 re-execution of blocks of code by slicing it (inspired by Janko's
4369 comment on 'macros').
4381 comment on 'macros').
4370
4382
4371 * Small fixes and doc updates.
4383 * Small fixes and doc updates.
4372
4384
4373 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4385 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4374 much too fragile with automagic. Handles properly multi-line
4386 much too fragile with automagic. Handles properly multi-line
4375 statements and takes parameters.
4387 statements and takes parameters.
4376
4388
4377 2001-11-30 Fernando Perez <fperez@colorado.edu>
4389 2001-11-30 Fernando Perez <fperez@colorado.edu>
4378
4390
4379 * Version 0.1.18 released.
4391 * Version 0.1.18 released.
4380
4392
4381 * Fixed nasty namespace bug in initial module imports.
4393 * Fixed nasty namespace bug in initial module imports.
4382
4394
4383 * Added copyright/license notes to all code files (except
4395 * Added copyright/license notes to all code files (except
4384 DPyGetOpt). For the time being, LGPL. That could change.
4396 DPyGetOpt). For the time being, LGPL. That could change.
4385
4397
4386 * Rewrote a much nicer README, updated INSTALL, cleaned up
4398 * Rewrote a much nicer README, updated INSTALL, cleaned up
4387 ipythonrc-* samples.
4399 ipythonrc-* samples.
4388
4400
4389 * Overall code/documentation cleanup. Basically ready for
4401 * Overall code/documentation cleanup. Basically ready for
4390 release. Only remaining thing: licence decision (LGPL?).
4402 release. Only remaining thing: licence decision (LGPL?).
4391
4403
4392 * Converted load_config to a class, ConfigLoader. Now recursion
4404 * Converted load_config to a class, ConfigLoader. Now recursion
4393 control is better organized. Doesn't include the same file twice.
4405 control is better organized. Doesn't include the same file twice.
4394
4406
4395 2001-11-29 Fernando Perez <fperez@colorado.edu>
4407 2001-11-29 Fernando Perez <fperez@colorado.edu>
4396
4408
4397 * Got input history working. Changed output history variables from
4409 * Got input history working. Changed output history variables from
4398 _p to _o so that _i is for input and _o for output. Just cleaner
4410 _p to _o so that _i is for input and _o for output. Just cleaner
4399 convention.
4411 convention.
4400
4412
4401 * Implemented parametric aliases. This pretty much allows the
4413 * Implemented parametric aliases. This pretty much allows the
4402 alias system to offer full-blown shell convenience, I think.
4414 alias system to offer full-blown shell convenience, I think.
4403
4415
4404 * Version 0.1.17 released, 0.1.18 opened.
4416 * Version 0.1.17 released, 0.1.18 opened.
4405
4417
4406 * dot_ipython/ipythonrc (alias): added documentation.
4418 * dot_ipython/ipythonrc (alias): added documentation.
4407 (xcolor): Fixed small bug (xcolors -> xcolor)
4419 (xcolor): Fixed small bug (xcolors -> xcolor)
4408
4420
4409 * Changed the alias system. Now alias is a magic command to define
4421 * Changed the alias system. Now alias is a magic command to define
4410 aliases just like the shell. Rationale: the builtin magics should
4422 aliases just like the shell. Rationale: the builtin magics should
4411 be there for things deeply connected to IPython's
4423 be there for things deeply connected to IPython's
4412 architecture. And this is a much lighter system for what I think
4424 architecture. And this is a much lighter system for what I think
4413 is the really important feature: allowing users to define quickly
4425 is the really important feature: allowing users to define quickly
4414 magics that will do shell things for them, so they can customize
4426 magics that will do shell things for them, so they can customize
4415 IPython easily to match their work habits. If someone is really
4427 IPython easily to match their work habits. If someone is really
4416 desperate to have another name for a builtin alias, they can
4428 desperate to have another name for a builtin alias, they can
4417 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4429 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4418 works.
4430 works.
4419
4431
4420 2001-11-28 Fernando Perez <fperez@colorado.edu>
4432 2001-11-28 Fernando Perez <fperez@colorado.edu>
4421
4433
4422 * Changed @file so that it opens the source file at the proper
4434 * Changed @file so that it opens the source file at the proper
4423 line. Since it uses less, if your EDITOR environment is
4435 line. Since it uses less, if your EDITOR environment is
4424 configured, typing v will immediately open your editor of choice
4436 configured, typing v will immediately open your editor of choice
4425 right at the line where the object is defined. Not as quick as
4437 right at the line where the object is defined. Not as quick as
4426 having a direct @edit command, but for all intents and purposes it
4438 having a direct @edit command, but for all intents and purposes it
4427 works. And I don't have to worry about writing @edit to deal with
4439 works. And I don't have to worry about writing @edit to deal with
4428 all the editors, less does that.
4440 all the editors, less does that.
4429
4441
4430 * Version 0.1.16 released, 0.1.17 opened.
4442 * Version 0.1.16 released, 0.1.17 opened.
4431
4443
4432 * Fixed some nasty bugs in the page/page_dumb combo that could
4444 * Fixed some nasty bugs in the page/page_dumb combo that could
4433 crash IPython.
4445 crash IPython.
4434
4446
4435 2001-11-27 Fernando Perez <fperez@colorado.edu>
4447 2001-11-27 Fernando Perez <fperez@colorado.edu>
4436
4448
4437 * Version 0.1.15 released, 0.1.16 opened.
4449 * Version 0.1.15 released, 0.1.16 opened.
4438
4450
4439 * Finally got ? and ?? to work for undefined things: now it's
4451 * Finally got ? and ?? to work for undefined things: now it's
4440 possible to type {}.get? and get information about the get method
4452 possible to type {}.get? and get information about the get method
4441 of dicts, or os.path? even if only os is defined (so technically
4453 of dicts, or os.path? even if only os is defined (so technically
4442 os.path isn't). Works at any level. For example, after import os,
4454 os.path isn't). Works at any level. For example, after import os,
4443 os?, os.path?, os.path.abspath? all work. This is great, took some
4455 os?, os.path?, os.path.abspath? all work. This is great, took some
4444 work in _ofind.
4456 work in _ofind.
4445
4457
4446 * Fixed more bugs with logging. The sanest way to do it was to add
4458 * Fixed more bugs with logging. The sanest way to do it was to add
4447 to @log a 'mode' parameter. Killed two in one shot (this mode
4459 to @log a 'mode' parameter. Killed two in one shot (this mode
4448 option was a request of Janko's). I think it's finally clean
4460 option was a request of Janko's). I think it's finally clean
4449 (famous last words).
4461 (famous last words).
4450
4462
4451 * Added a page_dumb() pager which does a decent job of paging on
4463 * Added a page_dumb() pager which does a decent job of paging on
4452 screen, if better things (like less) aren't available. One less
4464 screen, if better things (like less) aren't available. One less
4453 unix dependency (someday maybe somebody will port this to
4465 unix dependency (someday maybe somebody will port this to
4454 windows).
4466 windows).
4455
4467
4456 * Fixed problem in magic_log: would lock of logging out if log
4468 * Fixed problem in magic_log: would lock of logging out if log
4457 creation failed (because it would still think it had succeeded).
4469 creation failed (because it would still think it had succeeded).
4458
4470
4459 * Improved the page() function using curses to auto-detect screen
4471 * Improved the page() function using curses to auto-detect screen
4460 size. Now it can make a much better decision on whether to print
4472 size. Now it can make a much better decision on whether to print
4461 or page a string. Option screen_length was modified: a value 0
4473 or page a string. Option screen_length was modified: a value 0
4462 means auto-detect, and that's the default now.
4474 means auto-detect, and that's the default now.
4463
4475
4464 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4476 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4465 go out. I'll test it for a few days, then talk to Janko about
4477 go out. I'll test it for a few days, then talk to Janko about
4466 licences and announce it.
4478 licences and announce it.
4467
4479
4468 * Fixed the length of the auto-generated ---> prompt which appears
4480 * Fixed the length of the auto-generated ---> prompt which appears
4469 for auto-parens and auto-quotes. Getting this right isn't trivial,
4481 for auto-parens and auto-quotes. Getting this right isn't trivial,
4470 with all the color escapes, different prompt types and optional
4482 with all the color escapes, different prompt types and optional
4471 separators. But it seems to be working in all the combinations.
4483 separators. But it seems to be working in all the combinations.
4472
4484
4473 2001-11-26 Fernando Perez <fperez@colorado.edu>
4485 2001-11-26 Fernando Perez <fperez@colorado.edu>
4474
4486
4475 * Wrote a regexp filter to get option types from the option names
4487 * Wrote a regexp filter to get option types from the option names
4476 string. This eliminates the need to manually keep two duplicate
4488 string. This eliminates the need to manually keep two duplicate
4477 lists.
4489 lists.
4478
4490
4479 * Removed the unneeded check_option_names. Now options are handled
4491 * Removed the unneeded check_option_names. Now options are handled
4480 in a much saner manner and it's easy to visually check that things
4492 in a much saner manner and it's easy to visually check that things
4481 are ok.
4493 are ok.
4482
4494
4483 * Updated version numbers on all files I modified to carry a
4495 * Updated version numbers on all files I modified to carry a
4484 notice so Janko and Nathan have clear version markers.
4496 notice so Janko and Nathan have clear version markers.
4485
4497
4486 * Updated docstring for ultraTB with my changes. I should send
4498 * Updated docstring for ultraTB with my changes. I should send
4487 this to Nathan.
4499 this to Nathan.
4488
4500
4489 * Lots of small fixes. Ran everything through pychecker again.
4501 * Lots of small fixes. Ran everything through pychecker again.
4490
4502
4491 * Made loading of deep_reload an cmd line option. If it's not too
4503 * Made loading of deep_reload an cmd line option. If it's not too
4492 kosher, now people can just disable it. With -nodeep_reload it's
4504 kosher, now people can just disable it. With -nodeep_reload it's
4493 still available as dreload(), it just won't overwrite reload().
4505 still available as dreload(), it just won't overwrite reload().
4494
4506
4495 * Moved many options to the no| form (-opt and -noopt
4507 * Moved many options to the no| form (-opt and -noopt
4496 accepted). Cleaner.
4508 accepted). Cleaner.
4497
4509
4498 * Changed magic_log so that if called with no parameters, it uses
4510 * Changed magic_log so that if called with no parameters, it uses
4499 'rotate' mode. That way auto-generated logs aren't automatically
4511 'rotate' mode. That way auto-generated logs aren't automatically
4500 over-written. For normal logs, now a backup is made if it exists
4512 over-written. For normal logs, now a backup is made if it exists
4501 (only 1 level of backups). A new 'backup' mode was added to the
4513 (only 1 level of backups). A new 'backup' mode was added to the
4502 Logger class to support this. This was a request by Janko.
4514 Logger class to support this. This was a request by Janko.
4503
4515
4504 * Added @logoff/@logon to stop/restart an active log.
4516 * Added @logoff/@logon to stop/restart an active log.
4505
4517
4506 * Fixed a lot of bugs in log saving/replay. It was pretty
4518 * Fixed a lot of bugs in log saving/replay. It was pretty
4507 broken. Now special lines (!@,/) appear properly in the command
4519 broken. Now special lines (!@,/) appear properly in the command
4508 history after a log replay.
4520 history after a log replay.
4509
4521
4510 * Tried and failed to implement full session saving via pickle. My
4522 * Tried and failed to implement full session saving via pickle. My
4511 idea was to pickle __main__.__dict__, but modules can't be
4523 idea was to pickle __main__.__dict__, but modules can't be
4512 pickled. This would be a better alternative to replaying logs, but
4524 pickled. This would be a better alternative to replaying logs, but
4513 seems quite tricky to get to work. Changed -session to be called
4525 seems quite tricky to get to work. Changed -session to be called
4514 -logplay, which more accurately reflects what it does. And if we
4526 -logplay, which more accurately reflects what it does. And if we
4515 ever get real session saving working, -session is now available.
4527 ever get real session saving working, -session is now available.
4516
4528
4517 * Implemented color schemes for prompts also. As for tracebacks,
4529 * Implemented color schemes for prompts also. As for tracebacks,
4518 currently only NoColor and Linux are supported. But now the
4530 currently only NoColor and Linux are supported. But now the
4519 infrastructure is in place, based on a generic ColorScheme
4531 infrastructure is in place, based on a generic ColorScheme
4520 class. So writing and activating new schemes both for the prompts
4532 class. So writing and activating new schemes both for the prompts
4521 and the tracebacks should be straightforward.
4533 and the tracebacks should be straightforward.
4522
4534
4523 * Version 0.1.13 released, 0.1.14 opened.
4535 * Version 0.1.13 released, 0.1.14 opened.
4524
4536
4525 * Changed handling of options for output cache. Now counter is
4537 * Changed handling of options for output cache. Now counter is
4526 hardwired starting at 1 and one specifies the maximum number of
4538 hardwired starting at 1 and one specifies the maximum number of
4527 entries *in the outcache* (not the max prompt counter). This is
4539 entries *in the outcache* (not the max prompt counter). This is
4528 much better, since many statements won't increase the cache
4540 much better, since many statements won't increase the cache
4529 count. It also eliminated some confusing options, now there's only
4541 count. It also eliminated some confusing options, now there's only
4530 one: cache_size.
4542 one: cache_size.
4531
4543
4532 * Added 'alias' magic function and magic_alias option in the
4544 * Added 'alias' magic function and magic_alias option in the
4533 ipythonrc file. Now the user can easily define whatever names he
4545 ipythonrc file. Now the user can easily define whatever names he
4534 wants for the magic functions without having to play weird
4546 wants for the magic functions without having to play weird
4535 namespace games. This gives IPython a real shell-like feel.
4547 namespace games. This gives IPython a real shell-like feel.
4536
4548
4537 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4549 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4538 @ or not).
4550 @ or not).
4539
4551
4540 This was one of the last remaining 'visible' bugs (that I know
4552 This was one of the last remaining 'visible' bugs (that I know
4541 of). I think if I can clean up the session loading so it works
4553 of). I think if I can clean up the session loading so it works
4542 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4554 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4543 about licensing).
4555 about licensing).
4544
4556
4545 2001-11-25 Fernando Perez <fperez@colorado.edu>
4557 2001-11-25 Fernando Perez <fperez@colorado.edu>
4546
4558
4547 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4559 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4548 there's a cleaner distinction between what ? and ?? show.
4560 there's a cleaner distinction between what ? and ?? show.
4549
4561
4550 * Added screen_length option. Now the user can define his own
4562 * Added screen_length option. Now the user can define his own
4551 screen size for page() operations.
4563 screen size for page() operations.
4552
4564
4553 * Implemented magic shell-like functions with automatic code
4565 * Implemented magic shell-like functions with automatic code
4554 generation. Now adding another function is just a matter of adding
4566 generation. Now adding another function is just a matter of adding
4555 an entry to a dict, and the function is dynamically generated at
4567 an entry to a dict, and the function is dynamically generated at
4556 run-time. Python has some really cool features!
4568 run-time. Python has some really cool features!
4557
4569
4558 * Renamed many options to cleanup conventions a little. Now all
4570 * Renamed many options to cleanup conventions a little. Now all
4559 are lowercase, and only underscores where needed. Also in the code
4571 are lowercase, and only underscores where needed. Also in the code
4560 option name tables are clearer.
4572 option name tables are clearer.
4561
4573
4562 * Changed prompts a little. Now input is 'In [n]:' instead of
4574 * Changed prompts a little. Now input is 'In [n]:' instead of
4563 'In[n]:='. This allows it the numbers to be aligned with the
4575 'In[n]:='. This allows it the numbers to be aligned with the
4564 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4576 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4565 Python (it was a Mathematica thing). The '...' continuation prompt
4577 Python (it was a Mathematica thing). The '...' continuation prompt
4566 was also changed a little to align better.
4578 was also changed a little to align better.
4567
4579
4568 * Fixed bug when flushing output cache. Not all _p<n> variables
4580 * Fixed bug when flushing output cache. Not all _p<n> variables
4569 exist, so their deletion needs to be wrapped in a try:
4581 exist, so their deletion needs to be wrapped in a try:
4570
4582
4571 * Figured out how to properly use inspect.formatargspec() (it
4583 * Figured out how to properly use inspect.formatargspec() (it
4572 requires the args preceded by *). So I removed all the code from
4584 requires the args preceded by *). So I removed all the code from
4573 _get_pdef in Magic, which was just replicating that.
4585 _get_pdef in Magic, which was just replicating that.
4574
4586
4575 * Added test to prefilter to allow redefining magic function names
4587 * Added test to prefilter to allow redefining magic function names
4576 as variables. This is ok, since the @ form is always available,
4588 as variables. This is ok, since the @ form is always available,
4577 but whe should allow the user to define a variable called 'ls' if
4589 but whe should allow the user to define a variable called 'ls' if
4578 he needs it.
4590 he needs it.
4579
4591
4580 * Moved the ToDo information from README into a separate ToDo.
4592 * Moved the ToDo information from README into a separate ToDo.
4581
4593
4582 * General code cleanup and small bugfixes. I think it's close to a
4594 * General code cleanup and small bugfixes. I think it's close to a
4583 state where it can be released, obviously with a big 'beta'
4595 state where it can be released, obviously with a big 'beta'
4584 warning on it.
4596 warning on it.
4585
4597
4586 * Got the magic function split to work. Now all magics are defined
4598 * Got the magic function split to work. Now all magics are defined
4587 in a separate class. It just organizes things a bit, and now
4599 in a separate class. It just organizes things a bit, and now
4588 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4600 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4589 was too long).
4601 was too long).
4590
4602
4591 * Changed @clear to @reset to avoid potential confusions with
4603 * Changed @clear to @reset to avoid potential confusions with
4592 the shell command clear. Also renamed @cl to @clear, which does
4604 the shell command clear. Also renamed @cl to @clear, which does
4593 exactly what people expect it to from their shell experience.
4605 exactly what people expect it to from their shell experience.
4594
4606
4595 Added a check to the @reset command (since it's so
4607 Added a check to the @reset command (since it's so
4596 destructive, it's probably a good idea to ask for confirmation).
4608 destructive, it's probably a good idea to ask for confirmation).
4597 But now reset only works for full namespace resetting. Since the
4609 But now reset only works for full namespace resetting. Since the
4598 del keyword is already there for deleting a few specific
4610 del keyword is already there for deleting a few specific
4599 variables, I don't see the point of having a redundant magic
4611 variables, I don't see the point of having a redundant magic
4600 function for the same task.
4612 function for the same task.
4601
4613
4602 2001-11-24 Fernando Perez <fperez@colorado.edu>
4614 2001-11-24 Fernando Perez <fperez@colorado.edu>
4603
4615
4604 * Updated the builtin docs (esp. the ? ones).
4616 * Updated the builtin docs (esp. the ? ones).
4605
4617
4606 * Ran all the code through pychecker. Not terribly impressed with
4618 * Ran all the code through pychecker. Not terribly impressed with
4607 it: lots of spurious warnings and didn't really find anything of
4619 it: lots of spurious warnings and didn't really find anything of
4608 substance (just a few modules being imported and not used).
4620 substance (just a few modules being imported and not used).
4609
4621
4610 * Implemented the new ultraTB functionality into IPython. New
4622 * Implemented the new ultraTB functionality into IPython. New
4611 option: xcolors. This chooses color scheme. xmode now only selects
4623 option: xcolors. This chooses color scheme. xmode now only selects
4612 between Plain and Verbose. Better orthogonality.
4624 between Plain and Verbose. Better orthogonality.
4613
4625
4614 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4626 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4615 mode and color scheme for the exception handlers. Now it's
4627 mode and color scheme for the exception handlers. Now it's
4616 possible to have the verbose traceback with no coloring.
4628 possible to have the verbose traceback with no coloring.
4617
4629
4618 2001-11-23 Fernando Perez <fperez@colorado.edu>
4630 2001-11-23 Fernando Perez <fperez@colorado.edu>
4619
4631
4620 * Version 0.1.12 released, 0.1.13 opened.
4632 * Version 0.1.12 released, 0.1.13 opened.
4621
4633
4622 * Removed option to set auto-quote and auto-paren escapes by
4634 * Removed option to set auto-quote and auto-paren escapes by
4623 user. The chances of breaking valid syntax are just too high. If
4635 user. The chances of breaking valid syntax are just too high. If
4624 someone *really* wants, they can always dig into the code.
4636 someone *really* wants, they can always dig into the code.
4625
4637
4626 * Made prompt separators configurable.
4638 * Made prompt separators configurable.
4627
4639
4628 2001-11-22 Fernando Perez <fperez@colorado.edu>
4640 2001-11-22 Fernando Perez <fperez@colorado.edu>
4629
4641
4630 * Small bugfixes in many places.
4642 * Small bugfixes in many places.
4631
4643
4632 * Removed the MyCompleter class from ipplib. It seemed redundant
4644 * Removed the MyCompleter class from ipplib. It seemed redundant
4633 with the C-p,C-n history search functionality. Less code to
4645 with the C-p,C-n history search functionality. Less code to
4634 maintain.
4646 maintain.
4635
4647
4636 * Moved all the original ipython.py code into ipythonlib.py. Right
4648 * Moved all the original ipython.py code into ipythonlib.py. Right
4637 now it's just one big dump into a function called make_IPython, so
4649 now it's just one big dump into a function called make_IPython, so
4638 no real modularity has been gained. But at least it makes the
4650 no real modularity has been gained. But at least it makes the
4639 wrapper script tiny, and since ipythonlib is a module, it gets
4651 wrapper script tiny, and since ipythonlib is a module, it gets
4640 compiled and startup is much faster.
4652 compiled and startup is much faster.
4641
4653
4642 This is a reasobably 'deep' change, so we should test it for a
4654 This is a reasobably 'deep' change, so we should test it for a
4643 while without messing too much more with the code.
4655 while without messing too much more with the code.
4644
4656
4645 2001-11-21 Fernando Perez <fperez@colorado.edu>
4657 2001-11-21 Fernando Perez <fperez@colorado.edu>
4646
4658
4647 * Version 0.1.11 released, 0.1.12 opened for further work.
4659 * Version 0.1.11 released, 0.1.12 opened for further work.
4648
4660
4649 * Removed dependency on Itpl. It was only needed in one place. It
4661 * Removed dependency on Itpl. It was only needed in one place. It
4650 would be nice if this became part of python, though. It makes life
4662 would be nice if this became part of python, though. It makes life
4651 *a lot* easier in some cases.
4663 *a lot* easier in some cases.
4652
4664
4653 * Simplified the prefilter code a bit. Now all handlers are
4665 * Simplified the prefilter code a bit. Now all handlers are
4654 expected to explicitly return a value (at least a blank string).
4666 expected to explicitly return a value (at least a blank string).
4655
4667
4656 * Heavy edits in ipplib. Removed the help system altogether. Now
4668 * Heavy edits in ipplib. Removed the help system altogether. Now
4657 obj?/?? is used for inspecting objects, a magic @doc prints
4669 obj?/?? is used for inspecting objects, a magic @doc prints
4658 docstrings, and full-blown Python help is accessed via the 'help'
4670 docstrings, and full-blown Python help is accessed via the 'help'
4659 keyword. This cleans up a lot of code (less to maintain) and does
4671 keyword. This cleans up a lot of code (less to maintain) and does
4660 the job. Since 'help' is now a standard Python component, might as
4672 the job. Since 'help' is now a standard Python component, might as
4661 well use it and remove duplicate functionality.
4673 well use it and remove duplicate functionality.
4662
4674
4663 Also removed the option to use ipplib as a standalone program. By
4675 Also removed the option to use ipplib as a standalone program. By
4664 now it's too dependent on other parts of IPython to function alone.
4676 now it's too dependent on other parts of IPython to function alone.
4665
4677
4666 * Fixed bug in genutils.pager. It would crash if the pager was
4678 * Fixed bug in genutils.pager. It would crash if the pager was
4667 exited immediately after opening (broken pipe).
4679 exited immediately after opening (broken pipe).
4668
4680
4669 * Trimmed down the VerboseTB reporting a little. The header is
4681 * Trimmed down the VerboseTB reporting a little. The header is
4670 much shorter now and the repeated exception arguments at the end
4682 much shorter now and the repeated exception arguments at the end
4671 have been removed. For interactive use the old header seemed a bit
4683 have been removed. For interactive use the old header seemed a bit
4672 excessive.
4684 excessive.
4673
4685
4674 * Fixed small bug in output of @whos for variables with multi-word
4686 * Fixed small bug in output of @whos for variables with multi-word
4675 types (only first word was displayed).
4687 types (only first word was displayed).
4676
4688
4677 2001-11-17 Fernando Perez <fperez@colorado.edu>
4689 2001-11-17 Fernando Perez <fperez@colorado.edu>
4678
4690
4679 * Version 0.1.10 released, 0.1.11 opened for further work.
4691 * Version 0.1.10 released, 0.1.11 opened for further work.
4680
4692
4681 * Modified dirs and friends. dirs now *returns* the stack (not
4693 * Modified dirs and friends. dirs now *returns* the stack (not
4682 prints), so one can manipulate it as a variable. Convenient to
4694 prints), so one can manipulate it as a variable. Convenient to
4683 travel along many directories.
4695 travel along many directories.
4684
4696
4685 * Fixed bug in magic_pdef: would only work with functions with
4697 * Fixed bug in magic_pdef: would only work with functions with
4686 arguments with default values.
4698 arguments with default values.
4687
4699
4688 2001-11-14 Fernando Perez <fperez@colorado.edu>
4700 2001-11-14 Fernando Perez <fperez@colorado.edu>
4689
4701
4690 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4702 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4691 example with IPython. Various other minor fixes and cleanups.
4703 example with IPython. Various other minor fixes and cleanups.
4692
4704
4693 * Version 0.1.9 released, 0.1.10 opened for further work.
4705 * Version 0.1.9 released, 0.1.10 opened for further work.
4694
4706
4695 * Added sys.path to the list of directories searched in the
4707 * Added sys.path to the list of directories searched in the
4696 execfile= option. It used to be the current directory and the
4708 execfile= option. It used to be the current directory and the
4697 user's IPYTHONDIR only.
4709 user's IPYTHONDIR only.
4698
4710
4699 2001-11-13 Fernando Perez <fperez@colorado.edu>
4711 2001-11-13 Fernando Perez <fperez@colorado.edu>
4700
4712
4701 * Reinstated the raw_input/prefilter separation that Janko had
4713 * Reinstated the raw_input/prefilter separation that Janko had
4702 initially. This gives a more convenient setup for extending the
4714 initially. This gives a more convenient setup for extending the
4703 pre-processor from the outside: raw_input always gets a string,
4715 pre-processor from the outside: raw_input always gets a string,
4704 and prefilter has to process it. We can then redefine prefilter
4716 and prefilter has to process it. We can then redefine prefilter
4705 from the outside and implement extensions for special
4717 from the outside and implement extensions for special
4706 purposes.
4718 purposes.
4707
4719
4708 Today I got one for inputting PhysicalQuantity objects
4720 Today I got one for inputting PhysicalQuantity objects
4709 (from Scientific) without needing any function calls at
4721 (from Scientific) without needing any function calls at
4710 all. Extremely convenient, and it's all done as a user-level
4722 all. Extremely convenient, and it's all done as a user-level
4711 extension (no IPython code was touched). Now instead of:
4723 extension (no IPython code was touched). Now instead of:
4712 a = PhysicalQuantity(4.2,'m/s**2')
4724 a = PhysicalQuantity(4.2,'m/s**2')
4713 one can simply say
4725 one can simply say
4714 a = 4.2 m/s**2
4726 a = 4.2 m/s**2
4715 or even
4727 or even
4716 a = 4.2 m/s^2
4728 a = 4.2 m/s^2
4717
4729
4718 I use this, but it's also a proof of concept: IPython really is
4730 I use this, but it's also a proof of concept: IPython really is
4719 fully user-extensible, even at the level of the parsing of the
4731 fully user-extensible, even at the level of the parsing of the
4720 command line. It's not trivial, but it's perfectly doable.
4732 command line. It's not trivial, but it's perfectly doable.
4721
4733
4722 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4734 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4723 the problem of modules being loaded in the inverse order in which
4735 the problem of modules being loaded in the inverse order in which
4724 they were defined in
4736 they were defined in
4725
4737
4726 * Version 0.1.8 released, 0.1.9 opened for further work.
4738 * Version 0.1.8 released, 0.1.9 opened for further work.
4727
4739
4728 * Added magics pdef, source and file. They respectively show the
4740 * Added magics pdef, source and file. They respectively show the
4729 definition line ('prototype' in C), source code and full python
4741 definition line ('prototype' in C), source code and full python
4730 file for any callable object. The object inspector oinfo uses
4742 file for any callable object. The object inspector oinfo uses
4731 these to show the same information.
4743 these to show the same information.
4732
4744
4733 * Version 0.1.7 released, 0.1.8 opened for further work.
4745 * Version 0.1.7 released, 0.1.8 opened for further work.
4734
4746
4735 * Separated all the magic functions into a class called Magic. The
4747 * Separated all the magic functions into a class called Magic. The
4736 InteractiveShell class was becoming too big for Xemacs to handle
4748 InteractiveShell class was becoming too big for Xemacs to handle
4737 (de-indenting a line would lock it up for 10 seconds while it
4749 (de-indenting a line would lock it up for 10 seconds while it
4738 backtracked on the whole class!)
4750 backtracked on the whole class!)
4739
4751
4740 FIXME: didn't work. It can be done, but right now namespaces are
4752 FIXME: didn't work. It can be done, but right now namespaces are
4741 all messed up. Do it later (reverted it for now, so at least
4753 all messed up. Do it later (reverted it for now, so at least
4742 everything works as before).
4754 everything works as before).
4743
4755
4744 * Got the object introspection system (magic_oinfo) working! I
4756 * Got the object introspection system (magic_oinfo) working! I
4745 think this is pretty much ready for release to Janko, so he can
4757 think this is pretty much ready for release to Janko, so he can
4746 test it for a while and then announce it. Pretty much 100% of what
4758 test it for a while and then announce it. Pretty much 100% of what
4747 I wanted for the 'phase 1' release is ready. Happy, tired.
4759 I wanted for the 'phase 1' release is ready. Happy, tired.
4748
4760
4749 2001-11-12 Fernando Perez <fperez@colorado.edu>
4761 2001-11-12 Fernando Perez <fperez@colorado.edu>
4750
4762
4751 * Version 0.1.6 released, 0.1.7 opened for further work.
4763 * Version 0.1.6 released, 0.1.7 opened for further work.
4752
4764
4753 * Fixed bug in printing: it used to test for truth before
4765 * Fixed bug in printing: it used to test for truth before
4754 printing, so 0 wouldn't print. Now checks for None.
4766 printing, so 0 wouldn't print. Now checks for None.
4755
4767
4756 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4768 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4757 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4769 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4758 reaches by hand into the outputcache. Think of a better way to do
4770 reaches by hand into the outputcache. Think of a better way to do
4759 this later.
4771 this later.
4760
4772
4761 * Various small fixes thanks to Nathan's comments.
4773 * Various small fixes thanks to Nathan's comments.
4762
4774
4763 * Changed magic_pprint to magic_Pprint. This way it doesn't
4775 * Changed magic_pprint to magic_Pprint. This way it doesn't
4764 collide with pprint() and the name is consistent with the command
4776 collide with pprint() and the name is consistent with the command
4765 line option.
4777 line option.
4766
4778
4767 * Changed prompt counter behavior to be fully like
4779 * Changed prompt counter behavior to be fully like
4768 Mathematica's. That is, even input that doesn't return a result
4780 Mathematica's. That is, even input that doesn't return a result
4769 raises the prompt counter. The old behavior was kind of confusing
4781 raises the prompt counter. The old behavior was kind of confusing
4770 (getting the same prompt number several times if the operation
4782 (getting the same prompt number several times if the operation
4771 didn't return a result).
4783 didn't return a result).
4772
4784
4773 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4785 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4774
4786
4775 * Fixed -Classic mode (wasn't working anymore).
4787 * Fixed -Classic mode (wasn't working anymore).
4776
4788
4777 * Added colored prompts using Nathan's new code. Colors are
4789 * Added colored prompts using Nathan's new code. Colors are
4778 currently hardwired, they can be user-configurable. For
4790 currently hardwired, they can be user-configurable. For
4779 developers, they can be chosen in file ipythonlib.py, at the
4791 developers, they can be chosen in file ipythonlib.py, at the
4780 beginning of the CachedOutput class def.
4792 beginning of the CachedOutput class def.
4781
4793
4782 2001-11-11 Fernando Perez <fperez@colorado.edu>
4794 2001-11-11 Fernando Perez <fperez@colorado.edu>
4783
4795
4784 * Version 0.1.5 released, 0.1.6 opened for further work.
4796 * Version 0.1.5 released, 0.1.6 opened for further work.
4785
4797
4786 * Changed magic_env to *return* the environment as a dict (not to
4798 * Changed magic_env to *return* the environment as a dict (not to
4787 print it). This way it prints, but it can also be processed.
4799 print it). This way it prints, but it can also be processed.
4788
4800
4789 * Added Verbose exception reporting to interactive
4801 * Added Verbose exception reporting to interactive
4790 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4802 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4791 traceback. Had to make some changes to the ultraTB file. This is
4803 traceback. Had to make some changes to the ultraTB file. This is
4792 probably the last 'big' thing in my mental todo list. This ties
4804 probably the last 'big' thing in my mental todo list. This ties
4793 in with the next entry:
4805 in with the next entry:
4794
4806
4795 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4807 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4796 has to specify is Plain, Color or Verbose for all exception
4808 has to specify is Plain, Color or Verbose for all exception
4797 handling.
4809 handling.
4798
4810
4799 * Removed ShellServices option. All this can really be done via
4811 * Removed ShellServices option. All this can really be done via
4800 the magic system. It's easier to extend, cleaner and has automatic
4812 the magic system. It's easier to extend, cleaner and has automatic
4801 namespace protection and documentation.
4813 namespace protection and documentation.
4802
4814
4803 2001-11-09 Fernando Perez <fperez@colorado.edu>
4815 2001-11-09 Fernando Perez <fperez@colorado.edu>
4804
4816
4805 * Fixed bug in output cache flushing (missing parameter to
4817 * Fixed bug in output cache flushing (missing parameter to
4806 __init__). Other small bugs fixed (found using pychecker).
4818 __init__). Other small bugs fixed (found using pychecker).
4807
4819
4808 * Version 0.1.4 opened for bugfixing.
4820 * Version 0.1.4 opened for bugfixing.
4809
4821
4810 2001-11-07 Fernando Perez <fperez@colorado.edu>
4822 2001-11-07 Fernando Perez <fperez@colorado.edu>
4811
4823
4812 * Version 0.1.3 released, mainly because of the raw_input bug.
4824 * Version 0.1.3 released, mainly because of the raw_input bug.
4813
4825
4814 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4826 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4815 and when testing for whether things were callable, a call could
4827 and when testing for whether things were callable, a call could
4816 actually be made to certain functions. They would get called again
4828 actually be made to certain functions. They would get called again
4817 once 'really' executed, with a resulting double call. A disaster
4829 once 'really' executed, with a resulting double call. A disaster
4818 in many cases (list.reverse() would never work!).
4830 in many cases (list.reverse() would never work!).
4819
4831
4820 * Removed prefilter() function, moved its code to raw_input (which
4832 * Removed prefilter() function, moved its code to raw_input (which
4821 after all was just a near-empty caller for prefilter). This saves
4833 after all was just a near-empty caller for prefilter). This saves
4822 a function call on every prompt, and simplifies the class a tiny bit.
4834 a function call on every prompt, and simplifies the class a tiny bit.
4823
4835
4824 * Fix _ip to __ip name in magic example file.
4836 * Fix _ip to __ip name in magic example file.
4825
4837
4826 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4838 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4827 work with non-gnu versions of tar.
4839 work with non-gnu versions of tar.
4828
4840
4829 2001-11-06 Fernando Perez <fperez@colorado.edu>
4841 2001-11-06 Fernando Perez <fperez@colorado.edu>
4830
4842
4831 * Version 0.1.2. Just to keep track of the recent changes.
4843 * Version 0.1.2. Just to keep track of the recent changes.
4832
4844
4833 * Fixed nasty bug in output prompt routine. It used to check 'if
4845 * Fixed nasty bug in output prompt routine. It used to check 'if
4834 arg != None...'. Problem is, this fails if arg implements a
4846 arg != None...'. Problem is, this fails if arg implements a
4835 special comparison (__cmp__) which disallows comparing to
4847 special comparison (__cmp__) which disallows comparing to
4836 None. Found it when trying to use the PhysicalQuantity module from
4848 None. Found it when trying to use the PhysicalQuantity module from
4837 ScientificPython.
4849 ScientificPython.
4838
4850
4839 2001-11-05 Fernando Perez <fperez@colorado.edu>
4851 2001-11-05 Fernando Perez <fperez@colorado.edu>
4840
4852
4841 * Also added dirs. Now the pushd/popd/dirs family functions
4853 * Also added dirs. Now the pushd/popd/dirs family functions
4842 basically like the shell, with the added convenience of going home
4854 basically like the shell, with the added convenience of going home
4843 when called with no args.
4855 when called with no args.
4844
4856
4845 * pushd/popd slightly modified to mimic shell behavior more
4857 * pushd/popd slightly modified to mimic shell behavior more
4846 closely.
4858 closely.
4847
4859
4848 * Added env,pushd,popd from ShellServices as magic functions. I
4860 * Added env,pushd,popd from ShellServices as magic functions. I
4849 think the cleanest will be to port all desired functions from
4861 think the cleanest will be to port all desired functions from
4850 ShellServices as magics and remove ShellServices altogether. This
4862 ShellServices as magics and remove ShellServices altogether. This
4851 will provide a single, clean way of adding functionality
4863 will provide a single, clean way of adding functionality
4852 (shell-type or otherwise) to IP.
4864 (shell-type or otherwise) to IP.
4853
4865
4854 2001-11-04 Fernando Perez <fperez@colorado.edu>
4866 2001-11-04 Fernando Perez <fperez@colorado.edu>
4855
4867
4856 * Added .ipython/ directory to sys.path. This way users can keep
4868 * Added .ipython/ directory to sys.path. This way users can keep
4857 customizations there and access them via import.
4869 customizations there and access them via import.
4858
4870
4859 2001-11-03 Fernando Perez <fperez@colorado.edu>
4871 2001-11-03 Fernando Perez <fperez@colorado.edu>
4860
4872
4861 * Opened version 0.1.1 for new changes.
4873 * Opened version 0.1.1 for new changes.
4862
4874
4863 * Changed version number to 0.1.0: first 'public' release, sent to
4875 * Changed version number to 0.1.0: first 'public' release, sent to
4864 Nathan and Janko.
4876 Nathan and Janko.
4865
4877
4866 * Lots of small fixes and tweaks.
4878 * Lots of small fixes and tweaks.
4867
4879
4868 * Minor changes to whos format. Now strings are shown, snipped if
4880 * Minor changes to whos format. Now strings are shown, snipped if
4869 too long.
4881 too long.
4870
4882
4871 * Changed ShellServices to work on __main__ so they show up in @who
4883 * Changed ShellServices to work on __main__ so they show up in @who
4872
4884
4873 * Help also works with ? at the end of a line:
4885 * Help also works with ? at the end of a line:
4874 ?sin and sin?
4886 ?sin and sin?
4875 both produce the same effect. This is nice, as often I use the
4887 both produce the same effect. This is nice, as often I use the
4876 tab-complete to find the name of a method, but I used to then have
4888 tab-complete to find the name of a method, but I used to then have
4877 to go to the beginning of the line to put a ? if I wanted more
4889 to go to the beginning of the line to put a ? if I wanted more
4878 info. Now I can just add the ? and hit return. Convenient.
4890 info. Now I can just add the ? and hit return. Convenient.
4879
4891
4880 2001-11-02 Fernando Perez <fperez@colorado.edu>
4892 2001-11-02 Fernando Perez <fperez@colorado.edu>
4881
4893
4882 * Python version check (>=2.1) added.
4894 * Python version check (>=2.1) added.
4883
4895
4884 * Added LazyPython documentation. At this point the docs are quite
4896 * Added LazyPython documentation. At this point the docs are quite
4885 a mess. A cleanup is in order.
4897 a mess. A cleanup is in order.
4886
4898
4887 * Auto-installer created. For some bizarre reason, the zipfiles
4899 * Auto-installer created. For some bizarre reason, the zipfiles
4888 module isn't working on my system. So I made a tar version
4900 module isn't working on my system. So I made a tar version
4889 (hopefully the command line options in various systems won't kill
4901 (hopefully the command line options in various systems won't kill
4890 me).
4902 me).
4891
4903
4892 * Fixes to Struct in genutils. Now all dictionary-like methods are
4904 * Fixes to Struct in genutils. Now all dictionary-like methods are
4893 protected (reasonably).
4905 protected (reasonably).
4894
4906
4895 * Added pager function to genutils and changed ? to print usage
4907 * Added pager function to genutils and changed ? to print usage
4896 note through it (it was too long).
4908 note through it (it was too long).
4897
4909
4898 * Added the LazyPython functionality. Works great! I changed the
4910 * Added the LazyPython functionality. Works great! I changed the
4899 auto-quote escape to ';', it's on home row and next to '. But
4911 auto-quote escape to ';', it's on home row and next to '. But
4900 both auto-quote and auto-paren (still /) escapes are command-line
4912 both auto-quote and auto-paren (still /) escapes are command-line
4901 parameters.
4913 parameters.
4902
4914
4903
4915
4904 2001-11-01 Fernando Perez <fperez@colorado.edu>
4916 2001-11-01 Fernando Perez <fperez@colorado.edu>
4905
4917
4906 * Version changed to 0.0.7. Fairly large change: configuration now
4918 * Version changed to 0.0.7. Fairly large change: configuration now
4907 is all stored in a directory, by default .ipython. There, all
4919 is all stored in a directory, by default .ipython. There, all
4908 config files have normal looking names (not .names)
4920 config files have normal looking names (not .names)
4909
4921
4910 * Version 0.0.6 Released first to Lucas and Archie as a test
4922 * Version 0.0.6 Released first to Lucas and Archie as a test
4911 run. Since it's the first 'semi-public' release, change version to
4923 run. Since it's the first 'semi-public' release, change version to
4912 > 0.0.6 for any changes now.
4924 > 0.0.6 for any changes now.
4913
4925
4914 * Stuff I had put in the ipplib.py changelog:
4926 * Stuff I had put in the ipplib.py changelog:
4915
4927
4916 Changes to InteractiveShell:
4928 Changes to InteractiveShell:
4917
4929
4918 - Made the usage message a parameter.
4930 - Made the usage message a parameter.
4919
4931
4920 - Require the name of the shell variable to be given. It's a bit
4932 - Require the name of the shell variable to be given. It's a bit
4921 of a hack, but allows the name 'shell' not to be hardwire in the
4933 of a hack, but allows the name 'shell' not to be hardwire in the
4922 magic (@) handler, which is problematic b/c it requires
4934 magic (@) handler, which is problematic b/c it requires
4923 polluting the global namespace with 'shell'. This in turn is
4935 polluting the global namespace with 'shell'. This in turn is
4924 fragile: if a user redefines a variable called shell, things
4936 fragile: if a user redefines a variable called shell, things
4925 break.
4937 break.
4926
4938
4927 - magic @: all functions available through @ need to be defined
4939 - magic @: all functions available through @ need to be defined
4928 as magic_<name>, even though they can be called simply as
4940 as magic_<name>, even though they can be called simply as
4929 @<name>. This allows the special command @magic to gather
4941 @<name>. This allows the special command @magic to gather
4930 information automatically about all existing magic functions,
4942 information automatically about all existing magic functions,
4931 even if they are run-time user extensions, by parsing the shell
4943 even if they are run-time user extensions, by parsing the shell
4932 instance __dict__ looking for special magic_ names.
4944 instance __dict__ looking for special magic_ names.
4933
4945
4934 - mainloop: added *two* local namespace parameters. This allows
4946 - mainloop: added *two* local namespace parameters. This allows
4935 the class to differentiate between parameters which were there
4947 the class to differentiate between parameters which were there
4936 before and after command line initialization was processed. This
4948 before and after command line initialization was processed. This
4937 way, later @who can show things loaded at startup by the
4949 way, later @who can show things loaded at startup by the
4938 user. This trick was necessary to make session saving/reloading
4950 user. This trick was necessary to make session saving/reloading
4939 really work: ideally after saving/exiting/reloading a session,
4951 really work: ideally after saving/exiting/reloading a session,
4940 *everythin* should look the same, including the output of @who. I
4952 *everythin* should look the same, including the output of @who. I
4941 was only able to make this work with this double namespace
4953 was only able to make this work with this double namespace
4942 trick.
4954 trick.
4943
4955
4944 - added a header to the logfile which allows (almost) full
4956 - added a header to the logfile which allows (almost) full
4945 session restoring.
4957 session restoring.
4946
4958
4947 - prepend lines beginning with @ or !, with a and log
4959 - prepend lines beginning with @ or !, with a and log
4948 them. Why? !lines: may be useful to know what you did @lines:
4960 them. Why? !lines: may be useful to know what you did @lines:
4949 they may affect session state. So when restoring a session, at
4961 they may affect session state. So when restoring a session, at
4950 least inform the user of their presence. I couldn't quite get
4962 least inform the user of their presence. I couldn't quite get
4951 them to properly re-execute, but at least the user is warned.
4963 them to properly re-execute, but at least the user is warned.
4952
4964
4953 * Started ChangeLog.
4965 * Started ChangeLog.
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now