##// END OF EJS Templates
Fix tab-completion bug in threaded shells.x
fperez -
Show More
@@ -1,900 +1,913 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """IPython Shell classes.
2 """IPython Shell classes.
3
3
4 All the matplotlib support code was co-developed with John Hunter,
4 All the matplotlib support code was co-developed with John Hunter,
5 matplotlib's author.
5 matplotlib's author.
6
6
7 $Id: Shell.py 958 2005-12-27 23:17:51Z fperez $"""
7 $Id: Shell.py 964 2005-12-28 21:03:01Z fperez $"""
8
8
9 #*****************************************************************************
9 #*****************************************************************************
10 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
10 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 from IPython import Release
16 from IPython import Release
17 __author__ = '%s <%s>' % Release.authors['Fernando']
17 __author__ = '%s <%s>' % Release.authors['Fernando']
18 __license__ = Release.license
18 __license__ = Release.license
19
19
20 # Code begins
20 # Code begins
21 import __main__
21 import __main__
22 import __builtin__
22 import __builtin__
23 import os
23 import os
24 import sys
24 import sys
25 import signal
25 import signal
26 import threading
26 import threading
27
27
28 import IPython
28 import IPython
29 from IPython import ultraTB
29 from IPython import ultraTB
30 from IPython.genutils import Term,warn,error,flag_calls
30 from IPython.genutils import Term,warn,error,flag_calls
31 from IPython.iplib import InteractiveShell
31 from IPython.iplib import InteractiveShell
32 from IPython.ipmaker import make_IPython
32 from IPython.ipmaker import make_IPython
33 from IPython.Magic import Magic
33 from IPython.Magic import Magic
34 from IPython.Struct import Struct
34 from IPython.Struct import Struct
35
35
36 # global flag to pass around information about Ctrl-C without exceptions
36 # global flag to pass around information about Ctrl-C without exceptions
37 KBINT = False
37 KBINT = False
38
38
39 # global flag to turn on/off Tk support.
39 # global flag to turn on/off Tk support.
40 USE_TK = False
40 USE_TK = False
41
41
42 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
43 # This class is trivial now, but I want to have it in to publish a clean
43 # This class is trivial now, but I want to have it in to publish a clean
44 # interface. Later when the internals are reorganized, code that uses this
44 # interface. Later when the internals are reorganized, code that uses this
45 # shouldn't have to change.
45 # shouldn't have to change.
46
46
47 class IPShell:
47 class IPShell:
48 """Create an IPython instance."""
48 """Create an IPython instance."""
49
49
50 def __init__(self,argv=None,user_ns=None,debug=1,
50 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
51 shell_class=InteractiveShell):
51 debug=1,shell_class=InteractiveShell):
52 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
52 self.IP = make_IPython(argv,user_ns=user_ns,user_global_ns=user_global_ns,
53 shell_class=shell_class)
53 debug=debug,shell_class=shell_class)
54
54
55 def mainloop(self,sys_exit=0,banner=None):
55 def mainloop(self,sys_exit=0,banner=None):
56 self.IP.mainloop(banner)
56 self.IP.mainloop(banner)
57 if sys_exit:
57 if sys_exit:
58 sys.exit()
58 sys.exit()
59
59
60 #-----------------------------------------------------------------------------
60 #-----------------------------------------------------------------------------
61 class IPShellEmbed:
61 class IPShellEmbed:
62 """Allow embedding an IPython shell into a running program.
62 """Allow embedding an IPython shell into a running program.
63
63
64 Instances of this class are callable, with the __call__ method being an
64 Instances of this class are callable, with the __call__ method being an
65 alias to the embed() method of an InteractiveShell instance.
65 alias to the embed() method of an InteractiveShell instance.
66
66
67 Usage (see also the example-embed.py file for a running example):
67 Usage (see also the example-embed.py file for a running example):
68
68
69 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
69 ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override])
70
70
71 - argv: list containing valid command-line options for IPython, as they
71 - argv: list containing valid command-line options for IPython, as they
72 would appear in sys.argv[1:].
72 would appear in sys.argv[1:].
73
73
74 For example, the following command-line options:
74 For example, the following command-line options:
75
75
76 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
76 $ ipython -prompt_in1 'Input <\\#>' -colors LightBG
77
77
78 would be passed in the argv list as:
78 would be passed in the argv list as:
79
79
80 ['-prompt_in1','Input <\\#>','-colors','LightBG']
80 ['-prompt_in1','Input <\\#>','-colors','LightBG']
81
81
82 - banner: string which gets printed every time the interpreter starts.
82 - banner: string which gets printed every time the interpreter starts.
83
83
84 - exit_msg: string which gets printed every time the interpreter exits.
84 - exit_msg: string which gets printed every time the interpreter exits.
85
85
86 - rc_override: a dict or Struct of configuration options such as those
86 - rc_override: a dict or Struct of configuration options such as those
87 used by IPython. These options are read from your ~/.ipython/ipythonrc
87 used by IPython. These options are read from your ~/.ipython/ipythonrc
88 file when the Shell object is created. Passing an explicit rc_override
88 file when the Shell object is created. Passing an explicit rc_override
89 dict with any options you want allows you to override those values at
89 dict with any options you want allows you to override those values at
90 creation time without having to modify the file. This way you can create
90 creation time without having to modify the file. This way you can create
91 embeddable instances configured in any way you want without editing any
91 embeddable instances configured in any way you want without editing any
92 global files (thus keeping your interactive IPython configuration
92 global files (thus keeping your interactive IPython configuration
93 unchanged).
93 unchanged).
94
94
95 Then the ipshell instance can be called anywhere inside your code:
95 Then the ipshell instance can be called anywhere inside your code:
96
96
97 ipshell(header='') -> Opens up an IPython shell.
97 ipshell(header='') -> Opens up an IPython shell.
98
98
99 - header: string printed by the IPython shell upon startup. This can let
99 - header: string printed by the IPython shell upon startup. This can let
100 you know where in your code you are when dropping into the shell. Note
100 you know where in your code you are when dropping into the shell. Note
101 that 'banner' gets prepended to all calls, so header is used for
101 that 'banner' gets prepended to all calls, so header is used for
102 location-specific information.
102 location-specific information.
103
103
104 For more details, see the __call__ method below.
104 For more details, see the __call__ method below.
105
105
106 When the IPython shell is exited with Ctrl-D, normal program execution
106 When the IPython shell is exited with Ctrl-D, normal program execution
107 resumes.
107 resumes.
108
108
109 This functionality was inspired by a posting on comp.lang.python by cmkl
109 This functionality was inspired by a posting on comp.lang.python by cmkl
110 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
110 <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and
111 by the IDL stop/continue commands."""
111 by the IDL stop/continue commands."""
112
112
113 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
113 def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None):
114 """Note that argv here is a string, NOT a list."""
114 """Note that argv here is a string, NOT a list."""
115 self.set_banner(banner)
115 self.set_banner(banner)
116 self.set_exit_msg(exit_msg)
116 self.set_exit_msg(exit_msg)
117 self.set_dummy_mode(0)
117 self.set_dummy_mode(0)
118
118
119 # sys.displayhook is a global, we need to save the user's original
119 # sys.displayhook is a global, we need to save the user's original
120 # Don't rely on __displayhook__, as the user may have changed that.
120 # Don't rely on __displayhook__, as the user may have changed that.
121 self.sys_displayhook_ori = sys.displayhook
121 self.sys_displayhook_ori = sys.displayhook
122
122
123 # save readline completer status
123 # save readline completer status
124 try:
124 try:
125 #print 'Save completer',sys.ipcompleter # dbg
125 #print 'Save completer',sys.ipcompleter # dbg
126 self.sys_ipcompleter_ori = sys.ipcompleter
126 self.sys_ipcompleter_ori = sys.ipcompleter
127 except:
127 except:
128 pass # not nested with IPython
128 pass # not nested with IPython
129
129
130 # FIXME. Passing user_ns breaks namespace handling.
130 # FIXME. Passing user_ns breaks namespace handling.
131 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
131 #self.IP = make_IPython(argv,user_ns=__main__.__dict__)
132 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
132 self.IP = make_IPython(argv,rc_override=rc_override,embedded=True)
133
133
134 # copy our own displayhook also
134 # copy our own displayhook also
135 self.sys_displayhook_embed = sys.displayhook
135 self.sys_displayhook_embed = sys.displayhook
136 # and leave the system's display hook clean
136 # and leave the system's display hook clean
137 sys.displayhook = self.sys_displayhook_ori
137 sys.displayhook = self.sys_displayhook_ori
138 # don't use the ipython crash handler so that user exceptions aren't
138 # don't use the ipython crash handler so that user exceptions aren't
139 # trapped
139 # trapped
140 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
140 sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors,
141 mode = self.IP.rc.xmode,
141 mode = self.IP.rc.xmode,
142 call_pdb = self.IP.rc.pdb)
142 call_pdb = self.IP.rc.pdb)
143 self.restore_system_completer()
143 self.restore_system_completer()
144
144
145 def restore_system_completer(self):
145 def restore_system_completer(self):
146 """Restores the readline completer which was in place.
146 """Restores the readline completer which was in place.
147
147
148 This allows embedded IPython within IPython not to disrupt the
148 This allows embedded IPython within IPython not to disrupt the
149 parent's completion.
149 parent's completion.
150 """
150 """
151
151
152 try:
152 try:
153 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
153 self.IP.readline.set_completer(self.sys_ipcompleter_ori)
154 sys.ipcompleter = self.sys_ipcompleter_ori
154 sys.ipcompleter = self.sys_ipcompleter_ori
155 except:
155 except:
156 pass
156 pass
157
157
158 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
158 def __call__(self,header='',local_ns=None,global_ns=None,dummy=None):
159 """Activate the interactive interpreter.
159 """Activate the interactive interpreter.
160
160
161 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
161 __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start
162 the interpreter shell with the given local and global namespaces, and
162 the interpreter shell with the given local and global namespaces, and
163 optionally print a header string at startup.
163 optionally print a header string at startup.
164
164
165 The shell can be globally activated/deactivated using the
165 The shell can be globally activated/deactivated using the
166 set/get_dummy_mode methods. This allows you to turn off a shell used
166 set/get_dummy_mode methods. This allows you to turn off a shell used
167 for debugging globally.
167 for debugging globally.
168
168
169 However, *each* time you call the shell you can override the current
169 However, *each* time you call the shell you can override the current
170 state of dummy_mode with the optional keyword parameter 'dummy'. For
170 state of dummy_mode with the optional keyword parameter 'dummy'. For
171 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
171 example, if you set dummy mode on with IPShell.set_dummy_mode(1), you
172 can still have a specific call work by making it as IPShell(dummy=0).
172 can still have a specific call work by making it as IPShell(dummy=0).
173
173
174 The optional keyword parameter dummy controls whether the call
174 The optional keyword parameter dummy controls whether the call
175 actually does anything. """
175 actually does anything. """
176
176
177 # Allow the dummy parameter to override the global __dummy_mode
177 # Allow the dummy parameter to override the global __dummy_mode
178 if dummy or (dummy != 0 and self.__dummy_mode):
178 if dummy or (dummy != 0 and self.__dummy_mode):
179 return
179 return
180
180
181 # Set global subsystems (display,completions) to our values
181 # Set global subsystems (display,completions) to our values
182 sys.displayhook = self.sys_displayhook_embed
182 sys.displayhook = self.sys_displayhook_embed
183 if self.IP.has_readline:
183 if self.IP.has_readline:
184 self.IP.readline.set_completer(self.IP.Completer.complete)
184 self.IP.readline.set_completer(self.IP.Completer.complete)
185
185
186 if self.banner and header:
186 if self.banner and header:
187 format = '%s\n%s\n'
187 format = '%s\n%s\n'
188 else:
188 else:
189 format = '%s%s\n'
189 format = '%s%s\n'
190 banner = format % (self.banner,header)
190 banner = format % (self.banner,header)
191
191
192 # Call the embedding code with a stack depth of 1 so it can skip over
192 # Call the embedding code with a stack depth of 1 so it can skip over
193 # our call and get the original caller's namespaces.
193 # our call and get the original caller's namespaces.
194 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
194 self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1)
195
195
196 if self.exit_msg:
196 if self.exit_msg:
197 print self.exit_msg
197 print self.exit_msg
198
198
199 # Restore global systems (display, completion)
199 # Restore global systems (display, completion)
200 sys.displayhook = self.sys_displayhook_ori
200 sys.displayhook = self.sys_displayhook_ori
201 self.restore_system_completer()
201 self.restore_system_completer()
202
202
203 def set_dummy_mode(self,dummy):
203 def set_dummy_mode(self,dummy):
204 """Sets the embeddable shell's dummy mode parameter.
204 """Sets the embeddable shell's dummy mode parameter.
205
205
206 set_dummy_mode(dummy): dummy = 0 or 1.
206 set_dummy_mode(dummy): dummy = 0 or 1.
207
207
208 This parameter is persistent and makes calls to the embeddable shell
208 This parameter is persistent and makes calls to the embeddable shell
209 silently return without performing any action. This allows you to
209 silently return without performing any action. This allows you to
210 globally activate or deactivate a shell you're using with a single call.
210 globally activate or deactivate a shell you're using with a single call.
211
211
212 If you need to manually"""
212 If you need to manually"""
213
213
214 if dummy not in [0,1,False,True]:
214 if dummy not in [0,1,False,True]:
215 raise ValueError,'dummy parameter must be boolean'
215 raise ValueError,'dummy parameter must be boolean'
216 self.__dummy_mode = dummy
216 self.__dummy_mode = dummy
217
217
218 def get_dummy_mode(self):
218 def get_dummy_mode(self):
219 """Return the current value of the dummy mode parameter.
219 """Return the current value of the dummy mode parameter.
220 """
220 """
221 return self.__dummy_mode
221 return self.__dummy_mode
222
222
223 def set_banner(self,banner):
223 def set_banner(self,banner):
224 """Sets the global banner.
224 """Sets the global banner.
225
225
226 This banner gets prepended to every header printed when the shell
226 This banner gets prepended to every header printed when the shell
227 instance is called."""
227 instance is called."""
228
228
229 self.banner = banner
229 self.banner = banner
230
230
231 def set_exit_msg(self,exit_msg):
231 def set_exit_msg(self,exit_msg):
232 """Sets the global exit_msg.
232 """Sets the global exit_msg.
233
233
234 This exit message gets printed upon exiting every time the embedded
234 This exit message gets printed upon exiting every time the embedded
235 shell is called. It is None by default. """
235 shell is called. It is None by default. """
236
236
237 self.exit_msg = exit_msg
237 self.exit_msg = exit_msg
238
238
239 #-----------------------------------------------------------------------------
239 #-----------------------------------------------------------------------------
240 def sigint_handler (signum,stack_frame):
240 def sigint_handler (signum,stack_frame):
241 """Sigint handler for threaded apps.
241 """Sigint handler for threaded apps.
242
242
243 This is a horrible hack to pass information about SIGINT _without_ using
243 This is a horrible hack to pass information about SIGINT _without_ using
244 exceptions, since I haven't been able to properly manage cross-thread
244 exceptions, since I haven't been able to properly manage cross-thread
245 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
245 exceptions in GTK/WX. In fact, I don't think it can be done (or at least
246 that's my understanding from a c.l.py thread where this was discussed)."""
246 that's my understanding from a c.l.py thread where this was discussed)."""
247
247
248 global KBINT
248 global KBINT
249
249
250 print '\nKeyboardInterrupt - Press <Enter> to continue.',
250 print '\nKeyboardInterrupt - Press <Enter> to continue.',
251 Term.cout.flush()
251 Term.cout.flush()
252 # Set global flag so that runsource can know that Ctrl-C was hit
252 # Set global flag so that runsource can know that Ctrl-C was hit
253 KBINT = True
253 KBINT = True
254
254
255 class MTInteractiveShell(InteractiveShell):
255 class MTInteractiveShell(InteractiveShell):
256 """Simple multi-threaded shell."""
256 """Simple multi-threaded shell."""
257
257
258 # Threading strategy taken from:
258 # Threading strategy taken from:
259 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
259 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian
260 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
260 # McErlean and John Finlay. Modified with corrections by Antoon Pardon,
261 # from the pygtk mailing list, to avoid lockups with system calls.
261 # from the pygtk mailing list, to avoid lockups with system calls.
262
262
263 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
263 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
264 user_ns = None, banner2='',**kw):
264 user_ns=None,user_global_ns=None,banner2='',**kw):
265 """Similar to the normal InteractiveShell, but with threading control"""
265 """Similar to the normal InteractiveShell, but with threading control"""
266
266
267 IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2)
267 InteractiveShell.__init__(self,name,usage,rc,user_ns,
268 user_global_ns,banner2)
268
269
269 # Locking control variable
270 # Locking control variable
270 self.thread_ready = threading.Condition()
271 self.thread_ready = threading.Condition()
271
272
272 # Stuff to do at closing time
273 # Stuff to do at closing time
273 self._kill = False
274 self._kill = False
274 on_kill = kw.get('on_kill')
275 on_kill = kw.get('on_kill')
275 if on_kill is None:
276 if on_kill is None:
276 on_kill = []
277 on_kill = []
277 # Check that all things to kill are callable:
278 # Check that all things to kill are callable:
278 for t in on_kill:
279 for t in on_kill:
279 if not callable(t):
280 if not callable(t):
280 raise TypeError,'on_kill must be a list of callables'
281 raise TypeError,'on_kill must be a list of callables'
281 self.on_kill = on_kill
282 self.on_kill = on_kill
282
283
283 def runsource(self, source, filename="<input>", symbol="single"):
284 def runsource(self, source, filename="<input>", symbol="single"):
284 """Compile and run some source in the interpreter.
285 """Compile and run some source in the interpreter.
285
286
286 Modified version of code.py's runsource(), to handle threading issues.
287 Modified version of code.py's runsource(), to handle threading issues.
287 See the original for full docstring details."""
288 See the original for full docstring details."""
288
289
289 global KBINT
290 global KBINT
290
291
291 # If Ctrl-C was typed, we reset the flag and return right away
292 # If Ctrl-C was typed, we reset the flag and return right away
292 if KBINT:
293 if KBINT:
293 KBINT = False
294 KBINT = False
294 return False
295 return False
295
296
296 try:
297 try:
297 code = self.compile(source, filename, symbol)
298 code = self.compile(source, filename, symbol)
298 except (OverflowError, SyntaxError, ValueError):
299 except (OverflowError, SyntaxError, ValueError):
299 # Case 1
300 # Case 1
300 self.showsyntaxerror(filename)
301 self.showsyntaxerror(filename)
301 return False
302 return False
302
303
303 if code is None:
304 if code is None:
304 # Case 2
305 # Case 2
305 return True
306 return True
306
307
307 # Case 3
308 # Case 3
308 # Store code in self, so the execution thread can handle it
309 # Store code in self, so the execution thread can handle it
309 self.thread_ready.acquire()
310 self.thread_ready.acquire()
310 self.code_to_run = code
311 self.code_to_run = code
311 self.thread_ready.wait() # Wait until processed in timeout interval
312 self.thread_ready.wait() # Wait until processed in timeout interval
312 self.thread_ready.release()
313 self.thread_ready.release()
313
314
314 return False
315 return False
315
316
316 def runcode(self):
317 def runcode(self):
317 """Execute a code object.
318 """Execute a code object.
318
319
319 Multithreaded wrapper around IPython's runcode()."""
320 Multithreaded wrapper around IPython's runcode()."""
320
321
321 # lock thread-protected stuff
322 # lock thread-protected stuff
322 self.thread_ready.acquire()
323 self.thread_ready.acquire()
323
324
324 # Install sigint handler
325 # Install sigint handler
325 try:
326 try:
326 signal.signal(signal.SIGINT, sigint_handler)
327 signal.signal(signal.SIGINT, sigint_handler)
327 except SystemError:
328 except SystemError:
328 # This happens under Windows, which seems to have all sorts
329 # This happens under Windows, which seems to have all sorts
329 # of problems with signal handling. Oh well...
330 # of problems with signal handling. Oh well...
330 pass
331 pass
331
332
332 if self._kill:
333 if self._kill:
333 print >>Term.cout, 'Closing threads...',
334 print >>Term.cout, 'Closing threads...',
334 Term.cout.flush()
335 Term.cout.flush()
335 for tokill in self.on_kill:
336 for tokill in self.on_kill:
336 tokill()
337 tokill()
337 print >>Term.cout, 'Done.'
338 print >>Term.cout, 'Done.'
338
339
339 # Run pending code by calling parent class
340 # Run pending code by calling parent class
340 if self.code_to_run is not None:
341 if self.code_to_run is not None:
341 self.thread_ready.notify()
342 self.thread_ready.notify()
342 InteractiveShell.runcode(self,self.code_to_run)
343 InteractiveShell.runcode(self,self.code_to_run)
343
344
344 # We're done with thread-protected variables
345 # We're done with thread-protected variables
345 self.thread_ready.release()
346 self.thread_ready.release()
346 # This MUST return true for gtk threading to work
347 # This MUST return true for gtk threading to work
347 return True
348 return True
348
349
349 def kill (self):
350 def kill (self):
350 """Kill the thread, returning when it has been shut down."""
351 """Kill the thread, returning when it has been shut down."""
351 self.thread_ready.acquire()
352 self.thread_ready.acquire()
352 self._kill = True
353 self._kill = True
353 self.thread_ready.release()
354 self.thread_ready.release()
354
355
355 class MatplotlibShellBase:
356 class MatplotlibShellBase:
356 """Mixin class to provide the necessary modifications to regular IPython
357 """Mixin class to provide the necessary modifications to regular IPython
357 shell classes for matplotlib support.
358 shell classes for matplotlib support.
358
359
359 Given Python's MRO, this should be used as the FIRST class in the
360 Given Python's MRO, this should be used as the FIRST class in the
360 inheritance hierarchy, so that it overrides the relevant methods."""
361 inheritance hierarchy, so that it overrides the relevant methods."""
361
362
362 def _matplotlib_config(self,name):
363 def _matplotlib_config(self,name):
363 """Return various items needed to setup the user's shell with matplotlib"""
364 """Return various items needed to setup the user's shell with matplotlib"""
364
365
365 # Initialize matplotlib to interactive mode always
366 # Initialize matplotlib to interactive mode always
366 import matplotlib
367 import matplotlib
367 from matplotlib import backends
368 from matplotlib import backends
368 matplotlib.interactive(True)
369 matplotlib.interactive(True)
369
370
370 def use(arg):
371 def use(arg):
371 """IPython wrapper for matplotlib's backend switcher.
372 """IPython wrapper for matplotlib's backend switcher.
372
373
373 In interactive use, we can not allow switching to a different
374 In interactive use, we can not allow switching to a different
374 interactive backend, since thread conflicts will most likely crash
375 interactive backend, since thread conflicts will most likely crash
375 the python interpreter. This routine does a safety check first,
376 the python interpreter. This routine does a safety check first,
376 and refuses to perform a dangerous switch. It still allows
377 and refuses to perform a dangerous switch. It still allows
377 switching to non-interactive backends."""
378 switching to non-interactive backends."""
378
379
379 if arg in backends.interactive_bk and arg != self.mpl_backend:
380 if arg in backends.interactive_bk and arg != self.mpl_backend:
380 m=('invalid matplotlib backend switch.\n'
381 m=('invalid matplotlib backend switch.\n'
381 'This script attempted to switch to the interactive '
382 'This script attempted to switch to the interactive '
382 'backend: `%s`\n'
383 'backend: `%s`\n'
383 'Your current choice of interactive backend is: `%s`\n\n'
384 'Your current choice of interactive backend is: `%s`\n\n'
384 'Switching interactive matplotlib backends at runtime\n'
385 'Switching interactive matplotlib backends at runtime\n'
385 'would crash the python interpreter, '
386 'would crash the python interpreter, '
386 'and IPython has blocked it.\n\n'
387 'and IPython has blocked it.\n\n'
387 'You need to either change your choice of matplotlib backend\n'
388 'You need to either change your choice of matplotlib backend\n'
388 'by editing your .matplotlibrc file, or run this script as a \n'
389 'by editing your .matplotlibrc file, or run this script as a \n'
389 'standalone file from the command line, not using IPython.\n' %
390 'standalone file from the command line, not using IPython.\n' %
390 (arg,self.mpl_backend) )
391 (arg,self.mpl_backend) )
391 raise RuntimeError, m
392 raise RuntimeError, m
392 else:
393 else:
393 self.mpl_use(arg)
394 self.mpl_use(arg)
394 self.mpl_use._called = True
395 self.mpl_use._called = True
395
396
396 self.matplotlib = matplotlib
397 self.matplotlib = matplotlib
397 self.mpl_backend = matplotlib.rcParams['backend']
398 self.mpl_backend = matplotlib.rcParams['backend']
398
399
399 # we also need to block switching of interactive backends by use()
400 # we also need to block switching of interactive backends by use()
400 self.mpl_use = matplotlib.use
401 self.mpl_use = matplotlib.use
401 self.mpl_use._called = False
402 self.mpl_use._called = False
402 # overwrite the original matplotlib.use with our wrapper
403 # overwrite the original matplotlib.use with our wrapper
403 matplotlib.use = use
404 matplotlib.use = use
404
405
405
406
406 # This must be imported last in the matplotlib series, after
407 # This must be imported last in the matplotlib series, after
407 # backend/interactivity choices have been made
408 # backend/interactivity choices have been made
408 try:
409 try:
409 import matplotlib.pylab as pylab
410 import matplotlib.pylab as pylab
410 self.pylab = pylab
411 self.pylab = pylab
411 self.pylab_name = 'pylab'
412 self.pylab_name = 'pylab'
412 except ImportError:
413 except ImportError:
413 import matplotlib.matlab as matlab
414 import matplotlib.matlab as matlab
414 self.pylab = matlab
415 self.pylab = matlab
415 self.pylab_name = 'matlab'
416 self.pylab_name = 'matlab'
416
417
417 self.pylab.show._needmain = False
418 self.pylab.show._needmain = False
418 # We need to detect at runtime whether show() is called by the user.
419 # We need to detect at runtime whether show() is called by the user.
419 # For this, we wrap it into a decorator which adds a 'called' flag.
420 # For this, we wrap it into a decorator which adds a 'called' flag.
420 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
421 self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive)
421
422
422 # Build a user namespace initialized with matplotlib/matlab features.
423 # Build a user namespace initialized with matplotlib/matlab features.
423 user_ns = {'__name__':'__main__',
424 user_ns = {'__name__':'__main__',
424 '__builtins__' : __builtin__ }
425 '__builtins__' : __builtin__ }
425
426
426 # Be careful not to remove the final \n in the code string below, or
427 # Be careful not to remove the final \n in the code string below, or
427 # things will break badly with py22 (I think it's a python bug, 2.3 is
428 # things will break badly with py22 (I think it's a python bug, 2.3 is
428 # OK).
429 # OK).
429 pname = self.pylab_name # Python can't interpolate dotted var names
430 pname = self.pylab_name # Python can't interpolate dotted var names
430 exec ("import matplotlib\n"
431 exec ("import matplotlib\n"
431 "import matplotlib.%(pname)s as %(pname)s\n"
432 "import matplotlib.%(pname)s as %(pname)s\n"
432 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
433 "from matplotlib.%(pname)s import *\n" % locals()) in user_ns
433
434
434 # Build matplotlib info banner
435 # Build matplotlib info banner
435 b="""
436 b="""
436 Welcome to pylab, a matplotlib-based Python environment.
437 Welcome to pylab, a matplotlib-based Python environment.
437 For more information, type 'help(pylab)'.
438 For more information, type 'help(pylab)'.
438 """
439 """
439 return user_ns,b
440 return user_ns,b
440
441
441 def mplot_exec(self,fname,*where,**kw):
442 def mplot_exec(self,fname,*where,**kw):
442 """Execute a matplotlib script.
443 """Execute a matplotlib script.
443
444
444 This is a call to execfile(), but wrapped in safeties to properly
445 This is a call to execfile(), but wrapped in safeties to properly
445 handle interactive rendering and backend switching."""
446 handle interactive rendering and backend switching."""
446
447
447 #print '*** Matplotlib runner ***' # dbg
448 #print '*** Matplotlib runner ***' # dbg
448 # turn off rendering until end of script
449 # turn off rendering until end of script
449 isInteractive = self.matplotlib.rcParams['interactive']
450 isInteractive = self.matplotlib.rcParams['interactive']
450 self.matplotlib.interactive(False)
451 self.matplotlib.interactive(False)
451 self.safe_execfile(fname,*where,**kw)
452 self.safe_execfile(fname,*where,**kw)
452 self.matplotlib.interactive(isInteractive)
453 self.matplotlib.interactive(isInteractive)
453 # make rendering call now, if the user tried to do it
454 # make rendering call now, if the user tried to do it
454 if self.pylab.draw_if_interactive.called:
455 if self.pylab.draw_if_interactive.called:
455 self.pylab.draw()
456 self.pylab.draw()
456 self.pylab.draw_if_interactive.called = False
457 self.pylab.draw_if_interactive.called = False
457
458
458 # if a backend switch was performed, reverse it now
459 # if a backend switch was performed, reverse it now
459 if self.mpl_use._called:
460 if self.mpl_use._called:
460 self.matplotlib.rcParams['backend'] = self.mpl_backend
461 self.matplotlib.rcParams['backend'] = self.mpl_backend
461
462
462 def magic_run(self,parameter_s=''):
463 def magic_run(self,parameter_s=''):
463 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
464 Magic.magic_run(self,parameter_s,runner=self.mplot_exec)
464
465
465 # Fix the docstring so users see the original as well
466 # Fix the docstring so users see the original as well
466 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
467 magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__,
467 "\n *** Modified %run for Matplotlib,"
468 "\n *** Modified %run for Matplotlib,"
468 " with proper interactive handling ***")
469 " with proper interactive handling ***")
469
470
470 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
471 # Now we provide 2 versions of a matplotlib-aware IPython base shells, single
471 # and multithreaded. Note that these are meant for internal use, the IPShell*
472 # and multithreaded. Note that these are meant for internal use, the IPShell*
472 # classes below are the ones meant for public consumption.
473 # classes below are the ones meant for public consumption.
473
474
474 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
475 class MatplotlibShell(MatplotlibShellBase,InteractiveShell):
475 """Single-threaded shell with matplotlib support."""
476 """Single-threaded shell with matplotlib support."""
476
477
477 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
478 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
478 user_ns = None, **kw):
479 user_ns=None,user_global_ns=None,**kw):
479 user_ns,b2 = self._matplotlib_config(name)
480 user_ns,b2 = self._matplotlib_config(name)
480 InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
481 InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
482 banner2=b2,**kw)
481
483
482 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
484 class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell):
483 """Multi-threaded shell with matplotlib support."""
485 """Multi-threaded shell with matplotlib support."""
484
486
485 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
487 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
486 user_ns = None, **kw):
488 user_ns=None,user_global_ns=None, **kw):
487 user_ns,b2 = self._matplotlib_config(name)
489 user_ns,b2 = self._matplotlib_config(name)
488 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw)
490 MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns,
491 banner2=b2,**kw)
489
492
490 #-----------------------------------------------------------------------------
493 #-----------------------------------------------------------------------------
491 # Utility functions for the different GUI enabled IPShell* classes.
494 # Utility functions for the different GUI enabled IPShell* classes.
492
495
493 def get_tk():
496 def get_tk():
494 """Tries to import Tkinter and returns a withdrawn Tkinter root
497 """Tries to import Tkinter and returns a withdrawn Tkinter root
495 window. If Tkinter is already imported or not available, this
498 window. If Tkinter is already imported or not available, this
496 returns None. This function calls `hijack_tk` underneath.
499 returns None. This function calls `hijack_tk` underneath.
497 """
500 """
498 if not USE_TK or sys.modules.has_key('Tkinter'):
501 if not USE_TK or sys.modules.has_key('Tkinter'):
499 return None
502 return None
500 else:
503 else:
501 try:
504 try:
502 import Tkinter
505 import Tkinter
503 except ImportError:
506 except ImportError:
504 return None
507 return None
505 else:
508 else:
506 hijack_tk()
509 hijack_tk()
507 r = Tkinter.Tk()
510 r = Tkinter.Tk()
508 r.withdraw()
511 r.withdraw()
509 return r
512 return r
510
513
511 def hijack_tk():
514 def hijack_tk():
512 """Modifies Tkinter's mainloop with a dummy so when a module calls
515 """Modifies Tkinter's mainloop with a dummy so when a module calls
513 mainloop, it does not block.
516 mainloop, it does not block.
514
517
515 """
518 """
516 def misc_mainloop(self, n=0):
519 def misc_mainloop(self, n=0):
517 pass
520 pass
518 def tkinter_mainloop(n=0):
521 def tkinter_mainloop(n=0):
519 pass
522 pass
520
523
521 import Tkinter
524 import Tkinter
522 Tkinter.Misc.mainloop = misc_mainloop
525 Tkinter.Misc.mainloop = misc_mainloop
523 Tkinter.mainloop = tkinter_mainloop
526 Tkinter.mainloop = tkinter_mainloop
524
527
525 def update_tk(tk):
528 def update_tk(tk):
526 """Updates the Tkinter event loop. This is typically called from
529 """Updates the Tkinter event loop. This is typically called from
527 the respective WX or GTK mainloops.
530 the respective WX or GTK mainloops.
528 """
531 """
529 if tk:
532 if tk:
530 tk.update()
533 tk.update()
531
534
532 def hijack_wx():
535 def hijack_wx():
533 """Modifies wxPython's MainLoop with a dummy so user code does not
536 """Modifies wxPython's MainLoop with a dummy so user code does not
534 block IPython. The hijacked mainloop function is returned.
537 block IPython. The hijacked mainloop function is returned.
535 """
538 """
536 def dummy_mainloop(*args, **kw):
539 def dummy_mainloop(*args, **kw):
537 pass
540 pass
538 import wxPython
541 import wxPython
539 ver = wxPython.__version__
542 ver = wxPython.__version__
540 orig_mainloop = None
543 orig_mainloop = None
541 if ver[:3] >= '2.5':
544 if ver[:3] >= '2.5':
542 import wx
545 import wx
543 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
546 if hasattr(wx, '_core_'): core = getattr(wx, '_core_')
544 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
547 elif hasattr(wx, '_core'): core = getattr(wx, '_core')
545 else: raise AttributeError('Could not find wx core module')
548 else: raise AttributeError('Could not find wx core module')
546 orig_mainloop = core.PyApp_MainLoop
549 orig_mainloop = core.PyApp_MainLoop
547 core.PyApp_MainLoop = dummy_mainloop
550 core.PyApp_MainLoop = dummy_mainloop
548 elif ver[:3] == '2.4':
551 elif ver[:3] == '2.4':
549 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
552 orig_mainloop = wxPython.wxc.wxPyApp_MainLoop
550 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
553 wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop
551 else:
554 else:
552 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
555 warn("Unable to find either wxPython version 2.4 or >= 2.5.")
553 return orig_mainloop
556 return orig_mainloop
554
557
555 def hijack_gtk():
558 def hijack_gtk():
556 """Modifies pyGTK's mainloop with a dummy so user code does not
559 """Modifies pyGTK's mainloop with a dummy so user code does not
557 block IPython. This function returns the original `gtk.mainloop`
560 block IPython. This function returns the original `gtk.mainloop`
558 function that has been hijacked.
561 function that has been hijacked.
559 """
562 """
560 def dummy_mainloop(*args, **kw):
563 def dummy_mainloop(*args, **kw):
561 pass
564 pass
562 import gtk
565 import gtk
563 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
566 if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main
564 else: orig_mainloop = gtk.mainloop
567 else: orig_mainloop = gtk.mainloop
565 gtk.mainloop = dummy_mainloop
568 gtk.mainloop = dummy_mainloop
566 gtk.main = dummy_mainloop
569 gtk.main = dummy_mainloop
567 return orig_mainloop
570 return orig_mainloop
568
571
569 #-----------------------------------------------------------------------------
572 #-----------------------------------------------------------------------------
570 # The IPShell* classes below are the ones meant to be run by external code as
573 # The IPShell* classes below are the ones meant to be run by external code as
571 # IPython instances. Note that unless a specific threading strategy is
574 # IPython instances. Note that unless a specific threading strategy is
572 # desired, the factory function start() below should be used instead (it
575 # desired, the factory function start() below should be used instead (it
573 # selects the proper threaded class).
576 # selects the proper threaded class).
574
577
575 class IPShellGTK(threading.Thread):
578 class IPShellGTK(threading.Thread):
576 """Run a gtk mainloop() in a separate thread.
579 """Run a gtk mainloop() in a separate thread.
577
580
578 Python commands can be passed to the thread where they will be executed.
581 Python commands can be passed to the thread where they will be executed.
579 This is implemented by periodically checking for passed code using a
582 This is implemented by periodically checking for passed code using a
580 GTK timeout callback."""
583 GTK timeout callback."""
581
584
582 TIMEOUT = 100 # Millisecond interval between timeouts.
585 TIMEOUT = 100 # Millisecond interval between timeouts.
583
586
584 def __init__(self,argv=None,user_ns=None,debug=1,
587 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
585 shell_class=MTInteractiveShell):
588 debug=1,shell_class=MTInteractiveShell):
586
589
587 import gtk
590 import gtk
588
591
589 self.gtk = gtk
592 self.gtk = gtk
590 self.gtk_mainloop = hijack_gtk()
593 self.gtk_mainloop = hijack_gtk()
591
594
592 # Allows us to use both Tk and GTK.
595 # Allows us to use both Tk and GTK.
593 self.tk = get_tk()
596 self.tk = get_tk()
594
597
595 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
598 if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit
596 else: mainquit = self.gtk.mainquit
599 else: mainquit = self.gtk.mainquit
597
600
598 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
601 self.IP = make_IPython(argv,user_ns=user_ns,
602 user_global_ns=user_global_ns,
603 debug=debug,
599 shell_class=shell_class,
604 shell_class=shell_class,
600 on_kill=[mainquit])
605 on_kill=[mainquit])
601
606
602 # HACK: slot for banner in self; it will be passed to the mainloop
607 # HACK: slot for banner in self; it will be passed to the mainloop
603 # method only and .run() needs it. The actual value will be set by
608 # method only and .run() needs it. The actual value will be set by
604 # .mainloop().
609 # .mainloop().
605 self._banner = None
610 self._banner = None
606
611
607 threading.Thread.__init__(self)
612 threading.Thread.__init__(self)
608
613
609 def run(self):
614 def run(self):
610 self.IP.mainloop(self._banner)
615 self.IP.mainloop(self._banner)
611 self.IP.kill()
616 self.IP.kill()
612
617
613 def mainloop(self,sys_exit=0,banner=None):
618 def mainloop(self,sys_exit=0,banner=None):
614
619
615 self._banner = banner
620 self._banner = banner
616
621
617 if self.gtk.pygtk_version >= (2,4,0):
622 if self.gtk.pygtk_version >= (2,4,0):
618 import gobject
623 import gobject
619 gobject.idle_add(self.on_timer)
624 gobject.idle_add(self.on_timer)
620 else:
625 else:
621 self.gtk.idle_add(self.on_timer)
626 self.gtk.idle_add(self.on_timer)
622
627
623 if sys.platform != 'win32':
628 if sys.platform != 'win32':
624 try:
629 try:
625 if self.gtk.gtk_version[0] >= 2:
630 if self.gtk.gtk_version[0] >= 2:
626 self.gtk.threads_init()
631 self.gtk.threads_init()
627 except AttributeError:
632 except AttributeError:
628 pass
633 pass
629 except RuntimeError:
634 except RuntimeError:
630 error('Your pyGTK likely has not been compiled with '
635 error('Your pyGTK likely has not been compiled with '
631 'threading support.\n'
636 'threading support.\n'
632 'The exception printout is below.\n'
637 'The exception printout is below.\n'
633 'You can either rebuild pyGTK with threads, or '
638 'You can either rebuild pyGTK with threads, or '
634 'try using \n'
639 'try using \n'
635 'matplotlib with a different backend (like Tk or WX).\n'
640 'matplotlib with a different backend (like Tk or WX).\n'
636 'Note that matplotlib will most likely not work in its '
641 'Note that matplotlib will most likely not work in its '
637 'current state!')
642 'current state!')
638 self.IP.InteractiveTB()
643 self.IP.InteractiveTB()
639 self.start()
644 self.start()
640 self.gtk.threads_enter()
645 self.gtk.threads_enter()
641 self.gtk_mainloop()
646 self.gtk_mainloop()
642 self.gtk.threads_leave()
647 self.gtk.threads_leave()
643 self.join()
648 self.join()
644
649
645 def on_timer(self):
650 def on_timer(self):
646 update_tk(self.tk)
651 update_tk(self.tk)
647 return self.IP.runcode()
652 return self.IP.runcode()
648
653
649
654
650 class IPShellWX(threading.Thread):
655 class IPShellWX(threading.Thread):
651 """Run a wx mainloop() in a separate thread.
656 """Run a wx mainloop() in a separate thread.
652
657
653 Python commands can be passed to the thread where they will be executed.
658 Python commands can be passed to the thread where they will be executed.
654 This is implemented by periodically checking for passed code using a
659 This is implemented by periodically checking for passed code using a
655 GTK timeout callback."""
660 GTK timeout callback."""
656
661
657 TIMEOUT = 100 # Millisecond interval between timeouts.
662 TIMEOUT = 100 # Millisecond interval between timeouts.
658
663
659 def __init__(self,argv=None,user_ns=None,debug=1,
664 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
660 shell_class=MTInteractiveShell):
665 debug=1,shell_class=MTInteractiveShell):
661
666
662 import wxPython.wx as wx
667 import wxPython.wx as wx
663
668
664 threading.Thread.__init__(self)
669 threading.Thread.__init__(self)
665 self.wx = wx
670 self.wx = wx
666 self.wx_mainloop = hijack_wx()
671 self.wx_mainloop = hijack_wx()
667
672
668 # Allows us to use both Tk and GTK.
673 # Allows us to use both Tk and GTK.
669 self.tk = get_tk()
674 self.tk = get_tk()
670
675
671 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
676 self.IP = make_IPython(argv,user_ns=user_ns,
677 user_global_ns=user_global_ns,
678 debug=debug,
672 shell_class=shell_class,
679 shell_class=shell_class,
673 on_kill=[self.wxexit])
680 on_kill=[self.wxexit])
674 # HACK: slot for banner in self; it will be passed to the mainloop
681 # HACK: slot for banner in self; it will be passed to the mainloop
675 # method only and .run() needs it. The actual value will be set by
682 # method only and .run() needs it. The actual value will be set by
676 # .mainloop().
683 # .mainloop().
677 self._banner = None
684 self._banner = None
678
685
679 self.app = None
686 self.app = None
680
687
681 def wxexit(self, *args):
688 def wxexit(self, *args):
682 if self.app is not None:
689 if self.app is not None:
683 self.app.agent.timer.Stop()
690 self.app.agent.timer.Stop()
684 self.app.ExitMainLoop()
691 self.app.ExitMainLoop()
685
692
686 def run(self):
693 def run(self):
687 self.IP.mainloop(self._banner)
694 self.IP.mainloop(self._banner)
688 self.IP.kill()
695 self.IP.kill()
689
696
690 def mainloop(self,sys_exit=0,banner=None):
697 def mainloop(self,sys_exit=0,banner=None):
691
698
692 self._banner = banner
699 self._banner = banner
693
700
694 self.start()
701 self.start()
695
702
696 class TimerAgent(self.wx.wxMiniFrame):
703 class TimerAgent(self.wx.wxMiniFrame):
697 wx = self.wx
704 wx = self.wx
698 IP = self.IP
705 IP = self.IP
699 tk = self.tk
706 tk = self.tk
700 def __init__(self, parent, interval):
707 def __init__(self, parent, interval):
701 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
708 style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ
702 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
709 self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200),
703 size=(100, 100),style=style)
710 size=(100, 100),style=style)
704 self.Show(False)
711 self.Show(False)
705 self.interval = interval
712 self.interval = interval
706 self.timerId = self.wx.wxNewId()
713 self.timerId = self.wx.wxNewId()
707
714
708 def StartWork(self):
715 def StartWork(self):
709 self.timer = self.wx.wxTimer(self, self.timerId)
716 self.timer = self.wx.wxTimer(self, self.timerId)
710 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
717 self.wx.EVT_TIMER(self, self.timerId, self.OnTimer)
711 self.timer.Start(self.interval)
718 self.timer.Start(self.interval)
712
719
713 def OnTimer(self, event):
720 def OnTimer(self, event):
714 update_tk(self.tk)
721 update_tk(self.tk)
715 self.IP.runcode()
722 self.IP.runcode()
716
723
717 class App(self.wx.wxApp):
724 class App(self.wx.wxApp):
718 wx = self.wx
725 wx = self.wx
719 TIMEOUT = self.TIMEOUT
726 TIMEOUT = self.TIMEOUT
720 def OnInit(self):
727 def OnInit(self):
721 'Create the main window and insert the custom frame'
728 'Create the main window and insert the custom frame'
722 self.agent = TimerAgent(None, self.TIMEOUT)
729 self.agent = TimerAgent(None, self.TIMEOUT)
723 self.agent.Show(self.wx.false)
730 self.agent.Show(self.wx.false)
724 self.agent.StartWork()
731 self.agent.StartWork()
725 return self.wx.true
732 return self.wx.true
726
733
727 self.app = App(redirect=False)
734 self.app = App(redirect=False)
728 self.wx_mainloop(self.app)
735 self.wx_mainloop(self.app)
729 self.join()
736 self.join()
730
737
731
738
732 class IPShellQt(threading.Thread):
739 class IPShellQt(threading.Thread):
733 """Run a Qt event loop in a separate thread.
740 """Run a Qt event loop in a separate thread.
734
741
735 Python commands can be passed to the thread where they will be executed.
742 Python commands can be passed to the thread where they will be executed.
736 This is implemented by periodically checking for passed code using a
743 This is implemented by periodically checking for passed code using a
737 Qt timer / slot."""
744 Qt timer / slot."""
738
745
739 TIMEOUT = 100 # Millisecond interval between timeouts.
746 TIMEOUT = 100 # Millisecond interval between timeouts.
740
747
741 def __init__(self,argv=None,user_ns=None,debug=0,
748 def __init__(self,argv=None,user_ns=None,user_global_ns=None,
742 shell_class=MTInteractiveShell):
749 debug=0,shell_class=MTInteractiveShell):
743
750
744 import qt
751 import qt
745
752
746 class newQApplication:
753 class newQApplication:
747 def __init__( self ):
754 def __init__( self ):
748 self.QApplication = qt.QApplication
755 self.QApplication = qt.QApplication
749
756
750 def __call__( *args, **kwargs ):
757 def __call__( *args, **kwargs ):
751 return qt.qApp
758 return qt.qApp
752
759
753 def exec_loop( *args, **kwargs ):
760 def exec_loop( *args, **kwargs ):
754 pass
761 pass
755
762
756 def __getattr__( self, name ):
763 def __getattr__( self, name ):
757 return getattr( self.QApplication, name )
764 return getattr( self.QApplication, name )
758
765
759 qt.QApplication = newQApplication()
766 qt.QApplication = newQApplication()
760
767
761 # Allows us to use both Tk and QT.
768 # Allows us to use both Tk and QT.
762 self.tk = get_tk()
769 self.tk = get_tk()
763
770
764 self.IP = make_IPython(argv,user_ns=user_ns,debug=debug,
771 self.IP = make_IPython(argv,user_ns=user_ns,
772 user_global_ns=user_global_ns,
773 debug=debug,
765 shell_class=shell_class,
774 shell_class=shell_class,
766 on_kill=[qt.qApp.exit])
775 on_kill=[qt.qApp.exit])
767
776
768 # HACK: slot for banner in self; it will be passed to the mainloop
777 # HACK: slot for banner in self; it will be passed to the mainloop
769 # method only and .run() needs it. The actual value will be set by
778 # method only and .run() needs it. The actual value will be set by
770 # .mainloop().
779 # .mainloop().
771 self._banner = None
780 self._banner = None
772
781
773 threading.Thread.__init__(self)
782 threading.Thread.__init__(self)
774
783
775 def run(self):
784 def run(self):
776 self.IP.mainloop(self._banner)
785 self.IP.mainloop(self._banner)
777 self.IP.kill()
786 self.IP.kill()
778
787
779 def mainloop(self,sys_exit=0,banner=None):
788 def mainloop(self,sys_exit=0,banner=None):
780
789
781 import qt
790 import qt
782
791
783 self._banner = banner
792 self._banner = banner
784
793
785 if qt.QApplication.startingUp():
794 if qt.QApplication.startingUp():
786 a = qt.QApplication.QApplication(sys.argv)
795 a = qt.QApplication.QApplication(sys.argv)
787 self.timer = qt.QTimer()
796 self.timer = qt.QTimer()
788 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
797 qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer )
789
798
790 self.start()
799 self.start()
791 self.timer.start( self.TIMEOUT, True )
800 self.timer.start( self.TIMEOUT, True )
792 while True:
801 while True:
793 if self.IP._kill: break
802 if self.IP._kill: break
794 qt.qApp.exec_loop()
803 qt.qApp.exec_loop()
795 self.join()
804 self.join()
796
805
797 def on_timer(self):
806 def on_timer(self):
798 update_tk(self.tk)
807 update_tk(self.tk)
799 result = self.IP.runcode()
808 result = self.IP.runcode()
800 self.timer.start( self.TIMEOUT, True )
809 self.timer.start( self.TIMEOUT, True )
801 return result
810 return result
802
811
803 # A set of matplotlib public IPython shell classes, for single-threaded
812 # A set of matplotlib public IPython shell classes, for single-threaded
804 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
813 # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use.
805 class IPShellMatplotlib(IPShell):
814 class IPShellMatplotlib(IPShell):
806 """Subclass IPShell with MatplotlibShell as the internal shell.
815 """Subclass IPShell with MatplotlibShell as the internal shell.
807
816
808 Single-threaded class, meant for the Tk* and FLTK* backends.
817 Single-threaded class, meant for the Tk* and FLTK* backends.
809
818
810 Having this on a separate class simplifies the external driver code."""
819 Having this on a separate class simplifies the external driver code."""
811
820
812 def __init__(self,argv=None,user_ns=None,debug=1):
821 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
813 IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell)
822 IPShell.__init__(self,argv,user_ns,user_global_ns,debug,
823 shell_class=MatplotlibShell)
814
824
815 class IPShellMatplotlibGTK(IPShellGTK):
825 class IPShellMatplotlibGTK(IPShellGTK):
816 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
826 """Subclass IPShellGTK with MatplotlibMTShell as the internal shell.
817
827
818 Multi-threaded class, meant for the GTK* backends."""
828 Multi-threaded class, meant for the GTK* backends."""
819
829
820 def __init__(self,argv=None,user_ns=None,debug=1):
830 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
821 IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
831 IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug,
832 shell_class=MatplotlibMTShell)
822
833
823 class IPShellMatplotlibWX(IPShellWX):
834 class IPShellMatplotlibWX(IPShellWX):
824 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
835 """Subclass IPShellWX with MatplotlibMTShell as the internal shell.
825
836
826 Multi-threaded class, meant for the WX* backends."""
837 Multi-threaded class, meant for the WX* backends."""
827
838
828 def __init__(self,argv=None,user_ns=None,debug=1):
839 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
829 IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
840 IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug,
841 shell_class=MatplotlibMTShell)
830
842
831 class IPShellMatplotlibQt(IPShellQt):
843 class IPShellMatplotlibQt(IPShellQt):
832 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
844 """Subclass IPShellQt with MatplotlibMTShell as the internal shell.
833
845
834 Multi-threaded class, meant for the Qt* backends."""
846 Multi-threaded class, meant for the Qt* backends."""
835
847
836 def __init__(self,argv=None,user_ns=None,debug=1):
848 def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1):
837 IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell)
849 IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug,
850 shell_class=MatplotlibMTShell)
838
851
839 #-----------------------------------------------------------------------------
852 #-----------------------------------------------------------------------------
840 # Factory functions to actually start the proper thread-aware shell
853 # Factory functions to actually start the proper thread-aware shell
841
854
842 def _matplotlib_shell_class():
855 def _matplotlib_shell_class():
843 """Factory function to handle shell class selection for matplotlib.
856 """Factory function to handle shell class selection for matplotlib.
844
857
845 The proper shell class to use depends on the matplotlib backend, since
858 The proper shell class to use depends on the matplotlib backend, since
846 each backend requires a different threading strategy."""
859 each backend requires a different threading strategy."""
847
860
848 try:
861 try:
849 import matplotlib
862 import matplotlib
850 except ImportError:
863 except ImportError:
851 error('matplotlib could NOT be imported! Starting normal IPython.')
864 error('matplotlib could NOT be imported! Starting normal IPython.')
852 sh_class = IPShell
865 sh_class = IPShell
853 else:
866 else:
854 backend = matplotlib.rcParams['backend']
867 backend = matplotlib.rcParams['backend']
855 if backend.startswith('GTK'):
868 if backend.startswith('GTK'):
856 sh_class = IPShellMatplotlibGTK
869 sh_class = IPShellMatplotlibGTK
857 elif backend.startswith('WX'):
870 elif backend.startswith('WX'):
858 sh_class = IPShellMatplotlibWX
871 sh_class = IPShellMatplotlibWX
859 elif backend.startswith('Qt'):
872 elif backend.startswith('Qt'):
860 sh_class = IPShellMatplotlibQt
873 sh_class = IPShellMatplotlibQt
861 else:
874 else:
862 sh_class = IPShellMatplotlib
875 sh_class = IPShellMatplotlib
863 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
876 #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg
864 return sh_class
877 return sh_class
865
878
866 # This is the one which should be called by external code.
879 # This is the one which should be called by external code.
867 def start():
880 def start():
868 """Return a running shell instance, dealing with threading options.
881 """Return a running shell instance, dealing with threading options.
869
882
870 This is a factory function which will instantiate the proper IPython shell
883 This is a factory function which will instantiate the proper IPython shell
871 based on the user's threading choice. Such a selector is needed because
884 based on the user's threading choice. Such a selector is needed because
872 different GUI toolkits require different thread handling details."""
885 different GUI toolkits require different thread handling details."""
873
886
874 global USE_TK
887 global USE_TK
875 # Crude sys.argv hack to extract the threading options.
888 # Crude sys.argv hack to extract the threading options.
876 argv = sys.argv
889 argv = sys.argv
877 if len(argv) > 1:
890 if len(argv) > 1:
878 if len(argv) > 2:
891 if len(argv) > 2:
879 arg2 = argv[2]
892 arg2 = argv[2]
880 if arg2.endswith('-tk'):
893 if arg2.endswith('-tk'):
881 USE_TK = True
894 USE_TK = True
882 arg1 = argv[1]
895 arg1 = argv[1]
883 if arg1.endswith('-gthread'):
896 if arg1.endswith('-gthread'):
884 shell = IPShellGTK
897 shell = IPShellGTK
885 elif arg1.endswith( '-qthread' ):
898 elif arg1.endswith( '-qthread' ):
886 shell = IPShellQt
899 shell = IPShellQt
887 elif arg1.endswith('-wthread'):
900 elif arg1.endswith('-wthread'):
888 shell = IPShellWX
901 shell = IPShellWX
889 elif arg1.endswith('-pylab'):
902 elif arg1.endswith('-pylab'):
890 shell = _matplotlib_shell_class()
903 shell = _matplotlib_shell_class()
891 else:
904 else:
892 shell = IPShell
905 shell = IPShell
893 else:
906 else:
894 shell = IPShell
907 shell = IPShell
895 return shell()
908 return shell()
896
909
897 # Some aliases for backwards compatibility
910 # Some aliases for backwards compatibility
898 IPythonShell = IPShell
911 IPythonShell = IPShell
899 IPythonShellEmbed = IPShellEmbed
912 IPythonShellEmbed = IPShellEmbed
900 #************************ End of file <Shell.py> ***************************
913 #************************ End of file <Shell.py> ***************************
@@ -1,523 +1,526 b''
1 """Word completion for IPython.
1 """Word completion for IPython.
2
2
3 This module is a fork of the rlcompleter module in the Python standard
3 This module is a fork of the rlcompleter module in the Python standard
4 library. The original enhancements made to rlcompleter have been sent
4 library. The original enhancements made to rlcompleter have been sent
5 upstream and were accepted as of Python 2.3, but we need a lot more
5 upstream and were accepted as of Python 2.3, but we need a lot more
6 functionality specific to IPython, so this module will continue to live as an
6 functionality specific to IPython, so this module will continue to live as an
7 IPython-specific utility.
7 IPython-specific utility.
8
8
9 ---------------------------------------------------------------------------
9 ---------------------------------------------------------------------------
10 Original rlcompleter documentation:
10 Original rlcompleter documentation:
11
11
12 This requires the latest extension to the readline module (the
12 This requires the latest extension to the readline module (the
13 completes keywords, built-ins and globals in __main__; when completing
13 completes keywords, built-ins and globals in __main__; when completing
14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
15 completes its attributes.
15 completes its attributes.
16
16
17 It's very cool to do "import string" type "string.", hit the
17 It's very cool to do "import string" type "string.", hit the
18 completion key (twice), and see the list of names defined by the
18 completion key (twice), and see the list of names defined by the
19 string module!
19 string module!
20
20
21 Tip: to use the tab key as the completion key, call
21 Tip: to use the tab key as the completion key, call
22
22
23 readline.parse_and_bind("tab: complete")
23 readline.parse_and_bind("tab: complete")
24
24
25 Notes:
25 Notes:
26
26
27 - Exceptions raised by the completer function are *ignored* (and
27 - Exceptions raised by the completer function are *ignored* (and
28 generally cause the completion to fail). This is a feature -- since
28 generally cause the completion to fail). This is a feature -- since
29 readline sets the tty device in raw (or cbreak) mode, printing a
29 readline sets the tty device in raw (or cbreak) mode, printing a
30 traceback wouldn't work well without some complicated hoopla to save,
30 traceback wouldn't work well without some complicated hoopla to save,
31 reset and restore the tty state.
31 reset and restore the tty state.
32
32
33 - The evaluation of the NAME.NAME... form may cause arbitrary
33 - The evaluation of the NAME.NAME... form may cause arbitrary
34 application defined code to be executed if an object with a
34 application defined code to be executed if an object with a
35 __getattr__ hook is found. Since it is the responsibility of the
35 __getattr__ hook is found. Since it is the responsibility of the
36 application (or the user) to enable this feature, I consider this an
36 application (or the user) to enable this feature, I consider this an
37 acceptable risk. More complicated expressions (e.g. function calls or
37 acceptable risk. More complicated expressions (e.g. function calls or
38 indexing operations) are *not* evaluated.
38 indexing operations) are *not* evaluated.
39
39
40 - GNU readline is also used by the built-in functions input() and
40 - GNU readline is also used by the built-in functions input() and
41 raw_input(), and thus these also benefit/suffer from the completer
41 raw_input(), and thus these also benefit/suffer from the completer
42 features. Clearly an interactive application can benefit by
42 features. Clearly an interactive application can benefit by
43 specifying its own completer function and using raw_input() for all
43 specifying its own completer function and using raw_input() for all
44 its input.
44 its input.
45
45
46 - When the original stdin is not a tty device, GNU readline is never
46 - When the original stdin is not a tty device, GNU readline is never
47 used, and this module (and the readline module) are silently inactive.
47 used, and this module (and the readline module) are silently inactive.
48
48
49 """
49 """
50
50
51 #*****************************************************************************
51 #*****************************************************************************
52 #
52 #
53 # Since this file is essentially a minimally modified copy of the rlcompleter
53 # Since this file is essentially a minimally modified copy of the rlcompleter
54 # module which is part of the standard Python distribution, I assume that the
54 # module which is part of the standard Python distribution, I assume that the
55 # proper procedure is to maintain its copyright as belonging to the Python
55 # proper procedure is to maintain its copyright as belonging to the Python
56 # Software Foundation (in addition to my own, for all new code).
56 # Software Foundation (in addition to my own, for all new code).
57 #
57 #
58 # Copyright (C) 2001 Python Software Foundation, www.python.org
58 # Copyright (C) 2001 Python Software Foundation, www.python.org
59 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
59 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
60 #
60 #
61 # Distributed under the terms of the BSD License. The full license is in
61 # Distributed under the terms of the BSD License. The full license is in
62 # the file COPYING, distributed as part of this software.
62 # the file COPYING, distributed as part of this software.
63 #
63 #
64 #*****************************************************************************
64 #*****************************************************************************
65
65
66 import __builtin__
66 import __builtin__
67 import __main__
67 import __main__
68 import glob
68 import glob
69 import keyword
69 import keyword
70 import os
70 import os
71 import re
71 import re
72 import readline
72 import readline
73 import sys
73 import sys
74 import types
74 import types
75
75
76 from IPython.genutils import shlex_split
76 from IPython.genutils import shlex_split
77
77
78 __all__ = ['Completer','IPCompleter']
78 __all__ = ['Completer','IPCompleter']
79
79
80 def get_class_members(cls):
80 def get_class_members(cls):
81 ret = dir(cls)
81 ret = dir(cls)
82 if hasattr(cls,'__bases__'):
82 if hasattr(cls,'__bases__'):
83 for base in cls.__bases__:
83 for base in cls.__bases__:
84 ret.extend(get_class_members(base))
84 ret.extend(get_class_members(base))
85 return ret
85 return ret
86
86
87 class Completer:
87 class Completer:
88 def __init__(self,namespace=None,global_namespace=None):
88 def __init__(self,namespace=None,global_namespace=None):
89 """Create a new completer for the command line.
89 """Create a new completer for the command line.
90
90
91 Completer([namespace,global_namespace]) -> completer instance.
91 Completer([namespace,global_namespace]) -> completer instance.
92
92
93 If unspecified, the default namespace where completions are performed
93 If unspecified, the default namespace where completions are performed
94 is __main__ (technically, __main__.__dict__). Namespaces should be
94 is __main__ (technically, __main__.__dict__). Namespaces should be
95 given as dictionaries.
95 given as dictionaries.
96
96
97 An optional second namespace can be given. This allows the completer
97 An optional second namespace can be given. This allows the completer
98 to handle cases where both the local and global scopes need to be
98 to handle cases where both the local and global scopes need to be
99 distinguished.
99 distinguished.
100
100
101 Completer instances should be used as the completion mechanism of
101 Completer instances should be used as the completion mechanism of
102 readline via the set_completer() call:
102 readline via the set_completer() call:
103
103
104 readline.set_completer(Completer(my_namespace).complete)
104 readline.set_completer(Completer(my_namespace).complete)
105 """
105 """
106
107 if namespace and type(namespace) != types.DictType:
108 raise TypeError,'namespace must be a dictionary'
109
106
110 if global_namespace and type(global_namespace) != types.DictType:
107 # some minimal strict typechecks. For some core data structures, I
111 raise TypeError,'global_namespace must be a dictionary'
108 # want actual basic python types, not just anything that looks like
109 # one. This is especially true for namespaces.
110 for ns in (namespace,global_namespace):
111 if ns is not None and type(ns) != types.DictType:
112 raise TypeError,'namespace must be a dictionary'
112
113
113 # Don't bind to namespace quite yet, but flag whether the user wants a
114 # Don't bind to namespace quite yet, but flag whether the user wants a
114 # specific namespace or to use __main__.__dict__. This will allow us
115 # specific namespace or to use __main__.__dict__. This will allow us
115 # to bind to __main__.__dict__ at completion time, not now.
116 # to bind to __main__.__dict__ at completion time, not now.
116 if namespace is None:
117 if namespace is None:
117 self.use_main_ns = 1
118 self.use_main_ns = 1
118 else:
119 else:
119 self.use_main_ns = 0
120 self.use_main_ns = 0
120 self.namespace = namespace
121 self.namespace = namespace
121
122
122 # The global namespace, if given, can be bound directly
123 # The global namespace, if given, can be bound directly
123 if global_namespace is None:
124 if global_namespace is None:
124 self.global_namespace = {}
125 self.global_namespace = {}
125 else:
126 else:
126 self.global_namespace = global_namespace
127 self.global_namespace = global_namespace
127
128
128 def complete(self, text, state):
129 def complete(self, text, state):
129 """Return the next possible completion for 'text'.
130 """Return the next possible completion for 'text'.
130
131
131 This is called successively with state == 0, 1, 2, ... until it
132 This is called successively with state == 0, 1, 2, ... until it
132 returns None. The completion should begin with 'text'.
133 returns None. The completion should begin with 'text'.
133
134
134 """
135 """
135 if self.use_main_ns:
136 if self.use_main_ns:
136 self.namespace = __main__.__dict__
137 self.namespace = __main__.__dict__
137
138
138 if state == 0:
139 if state == 0:
139 if "." in text:
140 if "." in text:
140 self.matches = self.attr_matches(text)
141 self.matches = self.attr_matches(text)
141 else:
142 else:
142 self.matches = self.global_matches(text)
143 self.matches = self.global_matches(text)
143 try:
144 try:
144 return self.matches[state]
145 return self.matches[state]
145 except IndexError:
146 except IndexError:
146 return None
147 return None
147
148
148 def global_matches(self, text):
149 def global_matches(self, text):
149 """Compute matches when text is a simple name.
150 """Compute matches when text is a simple name.
150
151
151 Return a list of all keywords, built-in functions and names currently
152 Return a list of all keywords, built-in functions and names currently
152 defined in self.namespace or self.global_namespace that match.
153 defined in self.namespace or self.global_namespace that match.
153
154
154 """
155 """
155 matches = []
156 matches = []
156 match_append = matches.append
157 match_append = matches.append
157 n = len(text)
158 n = len(text)
158 for lst in [keyword.kwlist,
159 for lst in [keyword.kwlist,
159 __builtin__.__dict__.keys(),
160 __builtin__.__dict__.keys(),
160 self.namespace.keys(),
161 self.namespace.keys(),
161 self.global_namespace.keys()]:
162 self.global_namespace.keys()]:
162 for word in lst:
163 for word in lst:
163 if word[:n] == text and word != "__builtins__":
164 if word[:n] == text and word != "__builtins__":
164 match_append(word)
165 match_append(word)
165 return matches
166 return matches
166
167
167 def attr_matches(self, text):
168 def attr_matches(self, text):
168 """Compute matches when text contains a dot.
169 """Compute matches when text contains a dot.
169
170
170 Assuming the text is of the form NAME.NAME....[NAME], and is
171 Assuming the text is of the form NAME.NAME....[NAME], and is
171 evaluatable in self.namespace or self.global_namespace, it will be
172 evaluatable in self.namespace or self.global_namespace, it will be
172 evaluated and its attributes (as revealed by dir()) are used as
173 evaluated and its attributes (as revealed by dir()) are used as
173 possible completions. (For class instances, class members are are
174 possible completions. (For class instances, class members are are
174 also considered.)
175 also considered.)
175
176
176 WARNING: this can still invoke arbitrary C code, if an object
177 WARNING: this can still invoke arbitrary C code, if an object
177 with a __getattr__ hook is evaluated.
178 with a __getattr__ hook is evaluated.
178
179
179 """
180 """
180 import re
181 import re
181
182
182 # Another option, seems to work great. Catches things like ''.<tab>
183 # Another option, seems to work great. Catches things like ''.<tab>
183 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
184 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
184
185
185 if not m:
186 if not m:
186 return []
187 return []
187 expr, attr = m.group(1, 3)
188 expr, attr = m.group(1, 3)
188 try:
189 try:
189 object = eval(expr, self.namespace)
190 object = eval(expr, self.namespace)
190 except:
191 except:
191 object = eval(expr, self.global_namespace)
192 object = eval(expr, self.global_namespace)
192 words = [w for w in dir(object) if isinstance(w, basestring)]
193 words = [w for w in dir(object) if isinstance(w, basestring)]
193 if hasattr(object,'__class__'):
194 if hasattr(object,'__class__'):
194 words.append('__class__')
195 words.append('__class__')
195 words.extend(get_class_members(object.__class__))
196 words.extend(get_class_members(object.__class__))
196 n = len(attr)
197 n = len(attr)
197 matches = []
198 matches = []
198 for word in words:
199 for word in words:
199 if word[:n] == attr and word != "__builtins__":
200 if word[:n] == attr and word != "__builtins__":
200 matches.append("%s.%s" % (expr, word))
201 matches.append("%s.%s" % (expr, word))
201 return matches
202 return matches
202
203
203 class IPCompleter(Completer):
204 class IPCompleter(Completer):
204 """Extension of the completer class with IPython-specific features"""
205 """Extension of the completer class with IPython-specific features"""
205
206
206 def __init__(self,shell,namespace=None,global_namespace=None,
207 def __init__(self,shell,namespace=None,global_namespace=None,
207 omit__names=0,alias_table=None):
208 omit__names=0,alias_table=None):
208 """IPCompleter() -> completer
209 """IPCompleter() -> completer
209
210
210 Return a completer object suitable for use by the readline library
211 Return a completer object suitable for use by the readline library
211 via readline.set_completer().
212 via readline.set_completer().
212
213
213 Inputs:
214 Inputs:
214
215
215 - shell: a pointer to the ipython shell itself. This is needed
216 - shell: a pointer to the ipython shell itself. This is needed
216 because this completer knows about magic functions, and those can
217 because this completer knows about magic functions, and those can
217 only be accessed via the ipython instance.
218 only be accessed via the ipython instance.
218
219
219 - namespace: an optional dict where completions are performed.
220 - namespace: an optional dict where completions are performed.
220
221
221 - global_namespace: secondary optional dict for completions, to
222 - global_namespace: secondary optional dict for completions, to
222 handle cases (such as IPython embedded inside functions) where
223 handle cases (such as IPython embedded inside functions) where
223 both Python scopes are visible.
224 both Python scopes are visible.
224
225
225 - The optional omit__names parameter sets the completer to omit the
226 - The optional omit__names parameter sets the completer to omit the
226 'magic' names (__magicname__) for python objects unless the text
227 'magic' names (__magicname__) for python objects unless the text
227 to be completed explicitly starts with one or more underscores.
228 to be completed explicitly starts with one or more underscores.
228
229
229 - If alias_table is supplied, it should be a dictionary of aliases
230 - If alias_table is supplied, it should be a dictionary of aliases
230 to complete. """
231 to complete. """
231
232
232 Completer.__init__(self,namespace,global_namespace)
233 Completer.__init__(self,namespace,global_namespace)
233 self.magic_prefix = shell.name+'.magic_'
234 self.magic_prefix = shell.name+'.magic_'
234 self.magic_escape = shell.ESC_MAGIC
235 self.magic_escape = shell.ESC_MAGIC
235 self.readline = readline
236 self.readline = readline
236 delims = self.readline.get_completer_delims()
237 delims = self.readline.get_completer_delims()
237 delims = delims.replace(self.magic_escape,'')
238 delims = delims.replace(self.magic_escape,'')
238 self.readline.set_completer_delims(delims)
239 self.readline.set_completer_delims(delims)
239 self.get_line_buffer = self.readline.get_line_buffer
240 self.get_line_buffer = self.readline.get_line_buffer
240 self.omit__names = omit__names
241 self.omit__names = omit__names
241 self.merge_completions = shell.rc.readline_merge_completions
242 self.merge_completions = shell.rc.readline_merge_completions
242
243
243 if alias_table is None:
244 if alias_table is None:
244 alias_table = {}
245 alias_table = {}
245 self.alias_table = alias_table
246 self.alias_table = alias_table
246 # Regexp to split filenames with spaces in them
247 # Regexp to split filenames with spaces in them
247 self.space_name_re = re.compile(r'([^\\] )')
248 self.space_name_re = re.compile(r'([^\\] )')
248 # Hold a local ref. to glob.glob for speed
249 # Hold a local ref. to glob.glob for speed
249 self.glob = glob.glob
250 self.glob = glob.glob
250 # Special handling of backslashes needed in win32 platforms
251 # Special handling of backslashes needed in win32 platforms
251 if sys.platform == "win32":
252 if sys.platform == "win32":
252 self.clean_glob = self._clean_glob_win32
253 self.clean_glob = self._clean_glob_win32
253 else:
254 else:
254 self.clean_glob = self._clean_glob
255 self.clean_glob = self._clean_glob
255 self.matchers = [self.python_matches,
256 self.matchers = [self.python_matches,
256 self.file_matches,
257 self.file_matches,
257 self.alias_matches,
258 self.alias_matches,
258 self.python_func_kw_matches]
259 self.python_func_kw_matches]
259
260
260 # Code contributed by Alex Schmolck, for ipython/emacs integration
261 # Code contributed by Alex Schmolck, for ipython/emacs integration
261 def all_completions(self, text):
262 def all_completions(self, text):
262 """Return all possible completions for the benefit of emacs."""
263 """Return all possible completions for the benefit of emacs."""
263
264
264 completions = []
265 completions = []
265 comp_append = completions.append
266 comp_append = completions.append
266 try:
267 try:
267 for i in xrange(sys.maxint):
268 for i in xrange(sys.maxint):
268 res = self.complete(text, i)
269 res = self.complete(text, i)
269
270
270 if not res: break
271 if not res: break
271
272
272 comp_append(res)
273 comp_append(res)
273 #XXX workaround for ``notDefined.<tab>``
274 #XXX workaround for ``notDefined.<tab>``
274 except NameError:
275 except NameError:
275 pass
276 pass
276 return completions
277 return completions
277 # /end Alex Schmolck code.
278 # /end Alex Schmolck code.
278
279
279 def _clean_glob(self,text):
280 def _clean_glob(self,text):
280 return self.glob("%s*" % text)
281 return self.glob("%s*" % text)
281
282
282 def _clean_glob_win32(self,text):
283 def _clean_glob_win32(self,text):
283 return [f.replace("\\","/")
284 return [f.replace("\\","/")
284 for f in self.glob("%s*" % text)]
285 for f in self.glob("%s*" % text)]
285
286
286 def file_matches(self, text):
287 def file_matches(self, text):
287 """Match filneames, expanding ~USER type strings.
288 """Match filneames, expanding ~USER type strings.
288
289
289 Most of the seemingly convoluted logic in this completer is an
290 Most of the seemingly convoluted logic in this completer is an
290 attempt to handle filenames with spaces in them. And yet it's not
291 attempt to handle filenames with spaces in them. And yet it's not
291 quite perfect, because Python's readline doesn't expose all of the
292 quite perfect, because Python's readline doesn't expose all of the
292 GNU readline details needed for this to be done correctly.
293 GNU readline details needed for this to be done correctly.
293
294
294 For a filename with a space in it, the printed completions will be
295 For a filename with a space in it, the printed completions will be
295 only the parts after what's already been typed (instead of the
296 only the parts after what's already been typed (instead of the
296 full completions, as is normally done). I don't think with the
297 full completions, as is normally done). I don't think with the
297 current (as of Python 2.3) Python readline it's possible to do
298 current (as of Python 2.3) Python readline it's possible to do
298 better."""
299 better."""
299
300
300 #print 'Completer->file_matches: <%s>' % text # dbg
301 #print 'Completer->file_matches: <%s>' % text # dbg
301
302
302 # chars that require escaping with backslash - i.e. chars
303 # chars that require escaping with backslash - i.e. chars
303 # that readline treats incorrectly as delimiters, but we
304 # that readline treats incorrectly as delimiters, but we
304 # don't want to treat as delimiters in filename matching
305 # don't want to treat as delimiters in filename matching
305 # when escaped with backslash
306 # when escaped with backslash
306
307
307 protectables = ' ()[]{}'
308 protectables = ' ()[]{}'
308
309
309 def protect_filename(s):
310 def protect_filename(s):
310 return "".join([(ch in protectables and '\\' + ch or ch)
311 return "".join([(ch in protectables and '\\' + ch or ch)
311 for ch in s])
312 for ch in s])
312
313
313 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
314 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
314 open_quotes = 0 # track strings with open quotes
315 open_quotes = 0 # track strings with open quotes
315 try:
316 try:
316 lsplit = shlex_split(lbuf)[-1]
317 lsplit = shlex_split(lbuf)[-1]
317 except ValueError:
318 except ValueError:
318 # typically an unmatched ", or backslash without escaped char.
319 # typically an unmatched ", or backslash without escaped char.
319 if lbuf.count('"')==1:
320 if lbuf.count('"')==1:
320 open_quotes = 1
321 open_quotes = 1
321 lsplit = lbuf.split('"')[-1]
322 lsplit = lbuf.split('"')[-1]
322 elif lbuf.count("'")==1:
323 elif lbuf.count("'")==1:
323 open_quotes = 1
324 open_quotes = 1
324 lsplit = lbuf.split("'")[-1]
325 lsplit = lbuf.split("'")[-1]
325 else:
326 else:
326 return None
327 return None
327 except IndexError:
328 except IndexError:
328 # tab pressed on empty line
329 # tab pressed on empty line
329 lsplit = ""
330 lsplit = ""
330
331
331 if lsplit != protect_filename(lsplit):
332 if lsplit != protect_filename(lsplit):
332 # if protectables are found, do matching on the whole escaped
333 # if protectables are found, do matching on the whole escaped
333 # name
334 # name
334 has_protectables = 1
335 has_protectables = 1
335 text0,text = text,lsplit
336 text0,text = text,lsplit
336 else:
337 else:
337 has_protectables = 0
338 has_protectables = 0
338 text = os.path.expanduser(text)
339 text = os.path.expanduser(text)
339
340
340 if text == "":
341 if text == "":
341 return [protect_filename(f) for f in self.glob("*")]
342 return [protect_filename(f) for f in self.glob("*")]
342
343
343 m0 = self.clean_glob(text.replace('\\',''))
344 m0 = self.clean_glob(text.replace('\\',''))
344 if has_protectables:
345 if has_protectables:
345 # If we had protectables, we need to revert our changes to the
346 # If we had protectables, we need to revert our changes to the
346 # beginning of filename so that we don't double-write the part
347 # beginning of filename so that we don't double-write the part
347 # of the filename we have so far
348 # of the filename we have so far
348 len_lsplit = len(lsplit)
349 len_lsplit = len(lsplit)
349 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
350 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
350 else:
351 else:
351 if open_quotes:
352 if open_quotes:
352 # if we have a string with an open quote, we don't need to
353 # if we have a string with an open quote, we don't need to
353 # protect the names at all (and we _shouldn't_, as it
354 # protect the names at all (and we _shouldn't_, as it
354 # would cause bugs when the filesystem call is made).
355 # would cause bugs when the filesystem call is made).
355 matches = m0
356 matches = m0
356 else:
357 else:
357 matches = [protect_filename(f) for f in m0]
358 matches = [protect_filename(f) for f in m0]
358 if len(matches) == 1 and os.path.isdir(matches[0]):
359 if len(matches) == 1 and os.path.isdir(matches[0]):
359 # Takes care of links to directories also. Use '/'
360 # Takes care of links to directories also. Use '/'
360 # explicitly, even under Windows, so that name completions
361 # explicitly, even under Windows, so that name completions
361 # don't end up escaped.
362 # don't end up escaped.
362 matches[0] += '/'
363 matches[0] += '/'
363 return matches
364 return matches
364
365
365 def alias_matches(self, text):
366 def alias_matches(self, text):
366 """Match internal system aliases"""
367 """Match internal system aliases"""
367 #print 'Completer->alias_matches:',text # dbg
368 #print 'Completer->alias_matches:',text # dbg
368 text = os.path.expanduser(text)
369 text = os.path.expanduser(text)
369 aliases = self.alias_table.keys()
370 aliases = self.alias_table.keys()
370 if text == "":
371 if text == "":
371 return aliases
372 return aliases
372 else:
373 else:
373 return [alias for alias in aliases if alias.startswith(text)]
374 return [alias for alias in aliases if alias.startswith(text)]
374
375
375 def python_matches(self,text):
376 def python_matches(self,text):
376 """Match attributes or global python names"""
377 """Match attributes or global python names"""
377 #print 'Completer->python_matches' # dbg
378 #print 'Completer->python_matches' # dbg
378 if "." in text:
379 if "." in text:
379 try:
380 try:
380 matches = self.attr_matches(text)
381 matches = self.attr_matches(text)
381 if text.endswith('.') and self.omit__names:
382 if text.endswith('.') and self.omit__names:
382 if self.omit__names == 1:
383 if self.omit__names == 1:
383 # true if txt is _not_ a __ name, false otherwise:
384 # true if txt is _not_ a __ name, false otherwise:
384 no__name = (lambda txt:
385 no__name = (lambda txt:
385 re.match(r'.*\.__.*?__',txt) is None)
386 re.match(r'.*\.__.*?__',txt) is None)
386 else:
387 else:
387 # true if txt is _not_ a _ name, false otherwise:
388 # true if txt is _not_ a _ name, false otherwise:
388 no__name = (lambda txt:
389 no__name = (lambda txt:
389 re.match(r'.*\._.*?',txt) is None)
390 re.match(r'.*\._.*?',txt) is None)
390 matches = filter(no__name, matches)
391 matches = filter(no__name, matches)
391 except NameError:
392 except NameError:
392 # catches <undefined attributes>.<tab>
393 # catches <undefined attributes>.<tab>
393 matches = []
394 matches = []
394 else:
395 else:
395 matches = self.global_matches(text)
396 matches = self.global_matches(text)
396 # this is so completion finds magics when automagic is on:
397 # this is so completion finds magics when automagic is on:
397 if matches == [] and not text.startswith(os.sep):
398 if matches == [] and not text.startswith(os.sep):
398 matches = self.attr_matches(self.magic_prefix+text)
399 matches = self.attr_matches(self.magic_prefix+text)
399 return matches
400 return matches
400
401
401 def _default_arguments(self, obj):
402 def _default_arguments(self, obj):
402 """Return the list of default arguments of obj if it is callable,
403 """Return the list of default arguments of obj if it is callable,
403 or empty list otherwise."""
404 or empty list otherwise."""
404
405
405 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
406 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
406 # for classes, check for __init__,__new__
407 # for classes, check for __init__,__new__
407 if inspect.isclass(obj):
408 if inspect.isclass(obj):
408 obj = (getattr(obj,'__init__',None) or
409 obj = (getattr(obj,'__init__',None) or
409 getattr(obj,'__new__',None))
410 getattr(obj,'__new__',None))
410 # for all others, check if they are __call__able
411 # for all others, check if they are __call__able
411 elif hasattr(obj, '__call__'):
412 elif hasattr(obj, '__call__'):
412 obj = obj.__call__
413 obj = obj.__call__
413 # XXX: is there a way to handle the builtins ?
414 # XXX: is there a way to handle the builtins ?
414 try:
415 try:
415 args,_,_1,defaults = inspect.getargspec(obj)
416 args,_,_1,defaults = inspect.getargspec(obj)
416 if defaults:
417 if defaults:
417 return args[-len(defaults):]
418 return args[-len(defaults):]
418 except TypeError: pass
419 except TypeError: pass
419 return []
420 return []
420
421
421 def python_func_kw_matches(self,text):
422 def python_func_kw_matches(self,text):
422 """Match named parameters (kwargs) of the last open function"""
423 """Match named parameters (kwargs) of the last open function"""
423
424
424 if "." in text: # a parameter cannot be dotted
425 if "." in text: # a parameter cannot be dotted
425 return []
426 return []
426 try: regexp = self.__funcParamsRegex
427 try: regexp = self.__funcParamsRegex
427 except AttributeError:
428 except AttributeError:
428 regexp = self.__funcParamsRegex = re.compile(r'''
429 regexp = self.__funcParamsRegex = re.compile(r'''
429 '.*?' | # single quoted strings or
430 '.*?' | # single quoted strings or
430 ".*?" | # double quoted strings or
431 ".*?" | # double quoted strings or
431 \w+ | # identifier
432 \w+ | # identifier
432 \S # other characters
433 \S # other characters
433 ''', re.VERBOSE | re.DOTALL)
434 ''', re.VERBOSE | re.DOTALL)
434 # 1. find the nearest identifier that comes before an unclosed
435 # 1. find the nearest identifier that comes before an unclosed
435 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
436 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
436 tokens = regexp.findall(self.get_line_buffer())
437 tokens = regexp.findall(self.get_line_buffer())
437 tokens.reverse()
438 tokens.reverse()
438 iterTokens = iter(tokens); openPar = 0
439 iterTokens = iter(tokens); openPar = 0
439 for token in iterTokens:
440 for token in iterTokens:
440 if token == ')':
441 if token == ')':
441 openPar -= 1
442 openPar -= 1
442 elif token == '(':
443 elif token == '(':
443 openPar += 1
444 openPar += 1
444 if openPar > 0:
445 if openPar > 0:
445 # found the last unclosed parenthesis
446 # found the last unclosed parenthesis
446 break
447 break
447 else:
448 else:
448 return []
449 return []
449 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
450 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
450 ids = []
451 ids = []
451 isId = re.compile(r'\w+$').match
452 isId = re.compile(r'\w+$').match
452 while True:
453 while True:
453 try:
454 try:
454 ids.append(iterTokens.next())
455 ids.append(iterTokens.next())
455 if not isId(ids[-1]):
456 if not isId(ids[-1]):
456 ids.pop(); break
457 ids.pop(); break
457 if not iterTokens.next() == '.':
458 if not iterTokens.next() == '.':
458 break
459 break
459 except StopIteration:
460 except StopIteration:
460 break
461 break
461 # lookup the candidate callable matches either using global_matches
462 # lookup the candidate callable matches either using global_matches
462 # or attr_matches for dotted names
463 # or attr_matches for dotted names
463 if len(ids) == 1:
464 if len(ids) == 1:
464 callableMatches = self.global_matches(ids[0])
465 callableMatches = self.global_matches(ids[0])
465 else:
466 else:
466 callableMatches = self.attr_matches('.'.join(ids[::-1]))
467 callableMatches = self.attr_matches('.'.join(ids[::-1]))
467 argMatches = []
468 argMatches = []
468 for callableMatch in callableMatches:
469 for callableMatch in callableMatches:
469 try: namedArgs = self._default_arguments(eval(callableMatch,
470 try: namedArgs = self._default_arguments(eval(callableMatch,
470 self.namespace))
471 self.namespace))
471 except: continue
472 except: continue
472 for namedArg in namedArgs:
473 for namedArg in namedArgs:
473 if namedArg.startswith(text):
474 if namedArg.startswith(text):
474 argMatches.append("%s=" %namedArg)
475 argMatches.append("%s=" %namedArg)
475 return argMatches
476 return argMatches
476
477
477 def complete(self, text, state):
478 def complete(self, text, state):
478 """Return the next possible completion for 'text'.
479 """Return the next possible completion for 'text'.
479
480
480 This is called successively with state == 0, 1, 2, ... until it
481 This is called successively with state == 0, 1, 2, ... until it
481 returns None. The completion should begin with 'text'. """
482 returns None. The completion should begin with 'text'. """
482
483
483 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
484 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
484
485
485 # if there is only a tab on a line with only whitespace, instead
486 # if there is only a tab on a line with only whitespace, instead
486 # of the mostly useless 'do you want to see all million
487 # of the mostly useless 'do you want to see all million
487 # completions' message, just do the right thing and give the user
488 # completions' message, just do the right thing and give the user
488 # his tab! Incidentally, this enables pasting of tabbed text from
489 # his tab! Incidentally, this enables pasting of tabbed text from
489 # an editor (as long as autoindent is off).
490 # an editor (as long as autoindent is off).
490 if not self.get_line_buffer().strip():
491 if not self.get_line_buffer().strip():
491 self.readline.insert_text('\t')
492 self.readline.insert_text('\t')
492 return None
493 return None
493
494
494 magic_escape = self.magic_escape
495 magic_escape = self.magic_escape
495 magic_prefix = self.magic_prefix
496 magic_prefix = self.magic_prefix
496
497
497 try:
498 try:
498 if text.startswith(magic_escape):
499 if text.startswith(magic_escape):
499 text = text.replace(magic_escape,magic_prefix)
500 text = text.replace(magic_escape,magic_prefix)
500 elif text.startswith('~'):
501 elif text.startswith('~'):
501 text = os.path.expanduser(text)
502 text = os.path.expanduser(text)
502 if state == 0:
503 if state == 0:
503 # Extend the list of completions with the results of each
504 # Extend the list of completions with the results of each
504 # matcher, so we return results to the user from all
505 # matcher, so we return results to the user from all
505 # namespaces.
506 # namespaces.
506 if self.merge_completions:
507 if self.merge_completions:
507 self.matches = []
508 self.matches = []
508 for matcher in self.matchers:
509 for matcher in self.matchers:
509 self.matches.extend(matcher(text))
510 self.matches.extend(matcher(text))
510 else:
511 else:
511 for matcher in self.matchers:
512 for matcher in self.matchers:
512 self.matches = matcher(text)
513 self.matches = matcher(text)
513 if self.matches:
514 if self.matches:
514 break
515 break
515
516
516 try:
517 try:
517 return self.matches[state].replace(magic_prefix,magic_escape)
518 return self.matches[state].replace(magic_prefix,magic_escape)
518 except IndexError:
519 except IndexError:
519 return None
520 return None
520 except:
521 except:
521 #import traceback; traceback.print_exc() # dbg
522 #from IPython.ultraTB import AutoFormattedTB; # dbg
523 #tb=AutoFormattedTB('Verbose');tb() #dbg
524
522 # If completion fails, don't annoy the user.
525 # If completion fails, don't annoy the user.
523 return None
526 return None
@@ -1,1961 +1,1968 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or newer.
5 Requires Python 2.1 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 963 2005-12-28 19:21:29Z fperez $
9 $Id: iplib.py 964 2005-12-28 21:03:01Z 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-2005 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2005 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 traceback
58 import traceback
59 import types
59 import types
60
60
61 from pprint import pprint, pformat
61 from pprint import pprint, pformat
62
62
63 # IPython's own modules
63 # IPython's own modules
64 import IPython
64 import IPython
65 from IPython import OInspect,PyColorize,ultraTB
65 from IPython import OInspect,PyColorize,ultraTB
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
67 from IPython.FakeModule import FakeModule
67 from IPython.FakeModule import FakeModule
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
69 from IPython.Logger import Logger
69 from IPython.Logger import Logger
70 from IPython.Magic import Magic,magic2python
70 from IPython.Magic import Magic,magic2python
71 from IPython.Struct import Struct
71 from IPython.Struct import Struct
72 from IPython.background_jobs import BackgroundJobManager
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
74 from IPython.genutils import *
75
75
76 # store the builtin raw_input globally, and use this always, in case user code
76 # store the builtin raw_input globally, and use this always, in case user code
77 # overwrites it (like wx.py.PyShell does)
77 # overwrites it (like wx.py.PyShell does)
78 raw_input_original = raw_input
78 raw_input_original = raw_input
79
79
80 #****************************************************************************
80 #****************************************************************************
81 # Some utility function definitions
81 # Some utility function definitions
82
82
83 # This can be replaced with an isspace() call once we drop 2.2 compatibility
83 # This can be replaced with an isspace() call once we drop 2.2 compatibility
84 _isspace_match = re.compile(r'^\s+$').match
84 _isspace_match = re.compile(r'^\s+$').match
85 def isspace(s):
85 def isspace(s):
86 return bool(_isspace_match(s))
86 return bool(_isspace_match(s))
87
87
88 def esc_quotes(strng):
88 def esc_quotes(strng):
89 """Return the input string with single and double quotes escaped out"""
89 """Return the input string with single and double quotes escaped out"""
90
90
91 return strng.replace('"','\\"').replace("'","\\'")
91 return strng.replace('"','\\"').replace("'","\\'")
92
92
93 def import_fail_info(mod_name,fns=None):
93 def import_fail_info(mod_name,fns=None):
94 """Inform load failure for a module."""
94 """Inform load failure for a module."""
95
95
96 if fns == None:
96 if fns == None:
97 warn("Loading of %s failed.\n" % (mod_name,))
97 warn("Loading of %s failed.\n" % (mod_name,))
98 else:
98 else:
99 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
99 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
100
100
101 def qw_lol(indata):
101 def qw_lol(indata):
102 """qw_lol('a b') -> [['a','b']],
102 """qw_lol('a b') -> [['a','b']],
103 otherwise it's just a call to qw().
103 otherwise it's just a call to qw().
104
104
105 We need this to make sure the modules_some keys *always* end up as a
105 We need this to make sure the modules_some keys *always* end up as a
106 list of lists."""
106 list of lists."""
107
107
108 if type(indata) in StringTypes:
108 if type(indata) in StringTypes:
109 return [qw(indata)]
109 return [qw(indata)]
110 else:
110 else:
111 return qw(indata)
111 return qw(indata)
112
112
113 def ipmagic(arg_s):
113 def ipmagic(arg_s):
114 """Call a magic function by name.
114 """Call a magic function by name.
115
115
116 Input: a string containing the name of the magic function to call and any
116 Input: a string containing the name of the magic function to call and any
117 additional arguments to be passed to the magic.
117 additional arguments to be passed to the magic.
118
118
119 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
119 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
120 prompt:
120 prompt:
121
121
122 In[1]: %name -opt foo bar
122 In[1]: %name -opt foo bar
123
123
124 To call a magic without arguments, simply use ipmagic('name').
124 To call a magic without arguments, simply use ipmagic('name').
125
125
126 This provides a proper Python function to call IPython's magics in any
126 This provides a proper Python function to call IPython's magics in any
127 valid Python code you can type at the interpreter, including loops and
127 valid Python code you can type at the interpreter, including loops and
128 compound statements. It is added by IPython to the Python builtin
128 compound statements. It is added by IPython to the Python builtin
129 namespace upon initialization."""
129 namespace upon initialization."""
130
130
131 args = arg_s.split(' ',1)
131 args = arg_s.split(' ',1)
132 magic_name = args[0]
132 magic_name = args[0]
133 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
133 if magic_name.startswith(__IPYTHON__.ESC_MAGIC):
134 magic_name = magic_name[1:]
134 magic_name = magic_name[1:]
135 try:
135 try:
136 magic_args = args[1]
136 magic_args = args[1]
137 except IndexError:
137 except IndexError:
138 magic_args = ''
138 magic_args = ''
139 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
139 fn = getattr(__IPYTHON__,'magic_'+magic_name,None)
140 if fn is None:
140 if fn is None:
141 error("Magic function `%s` not found." % magic_name)
141 error("Magic function `%s` not found." % magic_name)
142 else:
142 else:
143 magic_args = __IPYTHON__.var_expand(magic_args)
143 magic_args = __IPYTHON__.var_expand(magic_args)
144 return fn(magic_args)
144 return fn(magic_args)
145
145
146 def ipalias(arg_s):
146 def ipalias(arg_s):
147 """Call an alias by name.
147 """Call an alias by name.
148
148
149 Input: a string containing the name of the alias to call and any
149 Input: a string containing the name of the alias to call and any
150 additional arguments to be passed to the magic.
150 additional arguments to be passed to the magic.
151
151
152 ipalias('name -opt foo bar') is equivalent to typing at the ipython
152 ipalias('name -opt foo bar') is equivalent to typing at the ipython
153 prompt:
153 prompt:
154
154
155 In[1]: name -opt foo bar
155 In[1]: name -opt foo bar
156
156
157 To call an alias without arguments, simply use ipalias('name').
157 To call an alias without arguments, simply use ipalias('name').
158
158
159 This provides a proper Python function to call IPython's aliases in any
159 This provides a proper Python function to call IPython's aliases in any
160 valid Python code you can type at the interpreter, including loops and
160 valid Python code you can type at the interpreter, including loops and
161 compound statements. It is added by IPython to the Python builtin
161 compound statements. It is added by IPython to the Python builtin
162 namespace upon initialization."""
162 namespace upon initialization."""
163
163
164 args = arg_s.split(' ',1)
164 args = arg_s.split(' ',1)
165 alias_name = args[0]
165 alias_name = args[0]
166 try:
166 try:
167 alias_args = args[1]
167 alias_args = args[1]
168 except IndexError:
168 except IndexError:
169 alias_args = ''
169 alias_args = ''
170 if alias_name in __IPYTHON__.alias_table:
170 if alias_name in __IPYTHON__.alias_table:
171 __IPYTHON__.call_alias(alias_name,alias_args)
171 __IPYTHON__.call_alias(alias_name,alias_args)
172 else:
172 else:
173 error("Alias `%s` not found." % alias_name)
173 error("Alias `%s` not found." % alias_name)
174
174
175 def softspace(file, newvalue):
175 def softspace(file, newvalue):
176 """Copied from code.py, to remove the dependency"""
176 """Copied from code.py, to remove the dependency"""
177 oldvalue = 0
177 oldvalue = 0
178 try:
178 try:
179 oldvalue = file.softspace
179 oldvalue = file.softspace
180 except AttributeError:
180 except AttributeError:
181 pass
181 pass
182 try:
182 try:
183 file.softspace = newvalue
183 file.softspace = newvalue
184 except (AttributeError, TypeError):
184 except (AttributeError, TypeError):
185 # "attribute-less object" or "read-only attributes"
185 # "attribute-less object" or "read-only attributes"
186 pass
186 pass
187 return oldvalue
187 return oldvalue
188
188
189
189
190 #****************************************************************************
190 #****************************************************************************
191 # Local use exceptions
191 # Local use exceptions
192 class SpaceInInput(exceptions.Exception): pass
192 class SpaceInInput(exceptions.Exception): pass
193
193
194 #****************************************************************************
194 #****************************************************************************
195 # Local use classes
195 # Local use classes
196 class Bunch: pass
196 class Bunch: pass
197
197
198 class InputList(list):
198 class InputList(list):
199 """Class to store user input.
199 """Class to store user input.
200
200
201 It's basically a list, but slices return a string instead of a list, thus
201 It's basically a list, but slices return a string instead of a list, thus
202 allowing things like (assuming 'In' is an instance):
202 allowing things like (assuming 'In' is an instance):
203
203
204 exec In[4:7]
204 exec In[4:7]
205
205
206 or
206 or
207
207
208 exec In[5:9] + In[14] + In[21:25]"""
208 exec In[5:9] + In[14] + In[21:25]"""
209
209
210 def __getslice__(self,i,j):
210 def __getslice__(self,i,j):
211 return ''.join(list.__getslice__(self,i,j))
211 return ''.join(list.__getslice__(self,i,j))
212
212
213 class SyntaxTB(ultraTB.ListTB):
213 class SyntaxTB(ultraTB.ListTB):
214 """Extension which holds some state: the last exception value"""
214 """Extension which holds some state: the last exception value"""
215
215
216 def __init__(self,color_scheme = 'NoColor'):
216 def __init__(self,color_scheme = 'NoColor'):
217 ultraTB.ListTB.__init__(self,color_scheme)
217 ultraTB.ListTB.__init__(self,color_scheme)
218 self.last_syntax_error = None
218 self.last_syntax_error = None
219
219
220 def __call__(self, etype, value, elist):
220 def __call__(self, etype, value, elist):
221 self.last_syntax_error = value
221 self.last_syntax_error = value
222 ultraTB.ListTB.__call__(self,etype,value,elist)
222 ultraTB.ListTB.__call__(self,etype,value,elist)
223
223
224 def clear_err_state(self):
224 def clear_err_state(self):
225 """Return the current error state and clear it"""
225 """Return the current error state and clear it"""
226 e = self.last_syntax_error
226 e = self.last_syntax_error
227 self.last_syntax_error = None
227 self.last_syntax_error = None
228 return e
228 return e
229
229
230 #****************************************************************************
230 #****************************************************************************
231 # Main IPython class
231 # Main IPython class
232 class InteractiveShell(Logger, Magic):
232 class InteractiveShell(Logger, Magic):
233 """An enhanced console for Python."""
233 """An enhanced console for Python."""
234
234
235 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
235 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
236 user_ns = None,user_global_ns=None,banner2='',
236 user_ns = None,user_global_ns=None,banner2='',
237 custom_exceptions=((),None),embedded=False):
237 custom_exceptions=((),None),embedded=False):
238
238
239 # some minimal strict typechecks. For some core data structures, I
240 # want actual basic python types, not just anything that looks like
241 # one. This is especially true for namespaces.
242 for ns in (user_ns,user_global_ns):
243 if ns is not None and type(ns) != types.DictType:
244 raise TypeError,'namespace must be a dictionary'
245
239 # Put a reference to self in builtins so that any form of embedded or
246 # Put a reference to self in builtins so that any form of embedded or
240 # imported code can test for being inside IPython.
247 # imported code can test for being inside IPython.
241 __builtin__.__IPYTHON__ = self
248 __builtin__.__IPYTHON__ = self
242
249
243 # And load into builtins ipmagic/ipalias as well
250 # And load into builtins ipmagic/ipalias as well
244 __builtin__.ipmagic = ipmagic
251 __builtin__.ipmagic = ipmagic
245 __builtin__.ipalias = ipalias
252 __builtin__.ipalias = ipalias
246
253
247 # Add to __builtin__ other parts of IPython's public API
254 # Add to __builtin__ other parts of IPython's public API
248 __builtin__.ip_set_hook = self.set_hook
255 __builtin__.ip_set_hook = self.set_hook
249
256
250 # Keep in the builtins a flag for when IPython is active. We set it
257 # Keep in the builtins a flag for when IPython is active. We set it
251 # with setdefault so that multiple nested IPythons don't clobber one
258 # with setdefault so that multiple nested IPythons don't clobber one
252 # another. Each will increase its value by one upon being activated,
259 # another. Each will increase its value by one upon being activated,
253 # which also gives us a way to determine the nesting level.
260 # which also gives us a way to determine the nesting level.
254 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
261 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
255
262
256 # Do the intuitively correct thing for quit/exit: we remove the
263 # Do the intuitively correct thing for quit/exit: we remove the
257 # builtins if they exist, and our own prefilter routine will handle
264 # builtins if they exist, and our own prefilter routine will handle
258 # these special cases
265 # these special cases
259 try:
266 try:
260 del __builtin__.exit, __builtin__.quit
267 del __builtin__.exit, __builtin__.quit
261 except AttributeError:
268 except AttributeError:
262 pass
269 pass
263
270
264 # We need to know whether the instance is meant for embedding, since
271 # We need to know whether the instance is meant for embedding, since
265 # global/local namespaces need to be handled differently in that case
272 # global/local namespaces need to be handled differently in that case
266 self.embedded = embedded
273 self.embedded = embedded
267
274
268 # command compiler
275 # command compiler
269 self.compile = codeop.CommandCompiler()
276 self.compile = codeop.CommandCompiler()
270
277
271 # User input buffer
278 # User input buffer
272 self.buffer = []
279 self.buffer = []
273
280
274 # Default name given in compilation of code
281 # Default name given in compilation of code
275 self.filename = '<ipython console>'
282 self.filename = '<ipython console>'
276
283
277 # Create the namespace where the user will operate. user_ns is
284 # Create the namespace where the user will operate. user_ns is
278 # normally the only one used, and it is passed to the exec calls as
285 # normally the only one used, and it is passed to the exec calls as
279 # the locals argument. But we do carry a user_global_ns namespace
286 # the locals argument. But we do carry a user_global_ns namespace
280 # given as the exec 'globals' argument, This is useful in embedding
287 # given as the exec 'globals' argument, This is useful in embedding
281 # situations where the ipython shell opens in a context where the
288 # situations where the ipython shell opens in a context where the
282 # distinction between locals and globals is meaningful.
289 # distinction between locals and globals is meaningful.
283
290
284 # FIXME. For some strange reason, __builtins__ is showing up at user
291 # FIXME. For some strange reason, __builtins__ is showing up at user
285 # level as a dict instead of a module. This is a manual fix, but I
292 # level as a dict instead of a module. This is a manual fix, but I
286 # should really track down where the problem is coming from. Alex
293 # should really track down where the problem is coming from. Alex
287 # Schmolck reported this problem first.
294 # Schmolck reported this problem first.
288
295
289 # A useful post by Alex Martelli on this topic:
296 # A useful post by Alex Martelli on this topic:
290 # Re: inconsistent value from __builtins__
297 # Re: inconsistent value from __builtins__
291 # Von: Alex Martelli <aleaxit@yahoo.com>
298 # Von: Alex Martelli <aleaxit@yahoo.com>
292 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
299 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
293 # Gruppen: comp.lang.python
300 # Gruppen: comp.lang.python
294 # Referenzen: 1
301 # Referenzen: 1
295
302
296 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
303 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
297 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
304 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
298 # > <type 'dict'>
305 # > <type 'dict'>
299 # > >>> print type(__builtins__)
306 # > >>> print type(__builtins__)
300 # > <type 'module'>
307 # > <type 'module'>
301 # > Is this difference in return value intentional?
308 # > Is this difference in return value intentional?
302
309
303 # Well, it's documented that '__builtins__' can be either a dictionary
310 # Well, it's documented that '__builtins__' can be either a dictionary
304 # or a module, and it's been that way for a long time. Whether it's
311 # or a module, and it's been that way for a long time. Whether it's
305 # intentional (or sensible), I don't know. In any case, the idea is
312 # intentional (or sensible), I don't know. In any case, the idea is
306 # that if you need to access the built-in namespace directly, you
313 # that if you need to access the built-in namespace directly, you
307 # should start with "import __builtin__" (note, no 's') which will
314 # should start with "import __builtin__" (note, no 's') which will
308 # definitely give you a module. Yeah, it's somewhatΒ confusing:-(.
315 # definitely give you a module. Yeah, it's somewhatΒ confusing:-(.
309
316
310 if user_ns is None:
317 if user_ns is None:
311 # Set __name__ to __main__ to better match the behavior of the
318 # Set __name__ to __main__ to better match the behavior of the
312 # normal interpreter.
319 # normal interpreter.
313 user_ns = {'__name__' :'__main__',
320 user_ns = {'__name__' :'__main__',
314 '__builtins__' : __builtin__,
321 '__builtins__' : __builtin__,
315 }
322 }
316
323
317 if user_global_ns is None:
324 if user_global_ns is None:
318 user_global_ns = {}
325 user_global_ns = {}
319
326
320 # Assign namespaces
327 # Assign namespaces
321 # This is the namespace where all normal user variables live
328 # This is the namespace where all normal user variables live
322 self.user_ns = user_ns
329 self.user_ns = user_ns
323 # Embedded instances require a separate namespace for globals.
330 # Embedded instances require a separate namespace for globals.
324 # Normally this one is unused by non-embedded instances.
331 # Normally this one is unused by non-embedded instances.
325 self.user_global_ns = user_global_ns
332 self.user_global_ns = user_global_ns
326 # A namespace to keep track of internal data structures to prevent
333 # A namespace to keep track of internal data structures to prevent
327 # them from cluttering user-visible stuff. Will be updated later
334 # them from cluttering user-visible stuff. Will be updated later
328 self.internal_ns = {}
335 self.internal_ns = {}
329
336
330 # Namespace of system aliases. Each entry in the alias
337 # Namespace of system aliases. Each entry in the alias
331 # table must be a 2-tuple of the form (N,name), where N is the number
338 # table must be a 2-tuple of the form (N,name), where N is the number
332 # of positional arguments of the alias.
339 # of positional arguments of the alias.
333 self.alias_table = {}
340 self.alias_table = {}
334
341
335 # A table holding all the namespaces IPython deals with, so that
342 # A table holding all the namespaces IPython deals with, so that
336 # introspection facilities can search easily.
343 # introspection facilities can search easily.
337 self.ns_table = {'user':user_ns,
344 self.ns_table = {'user':user_ns,
338 'user_global':user_global_ns,
345 'user_global':user_global_ns,
339 'alias':self.alias_table,
346 'alias':self.alias_table,
340 'internal':self.internal_ns,
347 'internal':self.internal_ns,
341 'builtin':__builtin__.__dict__
348 'builtin':__builtin__.__dict__
342 }
349 }
343
350
344 # The user namespace MUST have a pointer to the shell itself.
351 # The user namespace MUST have a pointer to the shell itself.
345 self.user_ns[name] = self
352 self.user_ns[name] = self
346
353
347 # We need to insert into sys.modules something that looks like a
354 # We need to insert into sys.modules something that looks like a
348 # module but which accesses the IPython namespace, for shelve and
355 # module but which accesses the IPython namespace, for shelve and
349 # pickle to work interactively. Normally they rely on getting
356 # pickle to work interactively. Normally they rely on getting
350 # everything out of __main__, but for embedding purposes each IPython
357 # everything out of __main__, but for embedding purposes each IPython
351 # instance has its own private namespace, so we can't go shoving
358 # instance has its own private namespace, so we can't go shoving
352 # everything into __main__.
359 # everything into __main__.
353
360
354 # note, however, that we should only do this for non-embedded
361 # note, however, that we should only do this for non-embedded
355 # ipythons, which really mimic the __main__.__dict__ with their own
362 # ipythons, which really mimic the __main__.__dict__ with their own
356 # namespace. Embedded instances, on the other hand, should not do
363 # namespace. Embedded instances, on the other hand, should not do
357 # this because they need to manage the user local/global namespaces
364 # this because they need to manage the user local/global namespaces
358 # only, but they live within a 'normal' __main__ (meaning, they
365 # only, but they live within a 'normal' __main__ (meaning, they
359 # shouldn't overtake the execution environment of the script they're
366 # shouldn't overtake the execution environment of the script they're
360 # embedded in).
367 # embedded in).
361
368
362 if not embedded:
369 if not embedded:
363 try:
370 try:
364 main_name = self.user_ns['__name__']
371 main_name = self.user_ns['__name__']
365 except KeyError:
372 except KeyError:
366 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
373 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
367 else:
374 else:
368 #print "pickle hack in place" # dbg
375 #print "pickle hack in place" # dbg
369 sys.modules[main_name] = FakeModule(self.user_ns)
376 sys.modules[main_name] = FakeModule(self.user_ns)
370
377
371 # List of input with multi-line handling.
378 # List of input with multi-line handling.
372 # Fill its zero entry, user counter starts at 1
379 # Fill its zero entry, user counter starts at 1
373 self.input_hist = InputList(['\n'])
380 self.input_hist = InputList(['\n'])
374
381
375 # list of visited directories
382 # list of visited directories
376 try:
383 try:
377 self.dir_hist = [os.getcwd()]
384 self.dir_hist = [os.getcwd()]
378 except IOError, e:
385 except IOError, e:
379 self.dir_hist = []
386 self.dir_hist = []
380
387
381 # dict of output history
388 # dict of output history
382 self.output_hist = {}
389 self.output_hist = {}
383
390
384 # dict of things NOT to alias (keywords, builtins and some magics)
391 # dict of things NOT to alias (keywords, builtins and some magics)
385 no_alias = {}
392 no_alias = {}
386 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
393 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
387 for key in keyword.kwlist + no_alias_magics:
394 for key in keyword.kwlist + no_alias_magics:
388 no_alias[key] = 1
395 no_alias[key] = 1
389 no_alias.update(__builtin__.__dict__)
396 no_alias.update(__builtin__.__dict__)
390 self.no_alias = no_alias
397 self.no_alias = no_alias
391
398
392 # make global variables for user access to these
399 # make global variables for user access to these
393 self.user_ns['_ih'] = self.input_hist
400 self.user_ns['_ih'] = self.input_hist
394 self.user_ns['_oh'] = self.output_hist
401 self.user_ns['_oh'] = self.output_hist
395 self.user_ns['_dh'] = self.dir_hist
402 self.user_ns['_dh'] = self.dir_hist
396
403
397 # user aliases to input and output histories
404 # user aliases to input and output histories
398 self.user_ns['In'] = self.input_hist
405 self.user_ns['In'] = self.input_hist
399 self.user_ns['Out'] = self.output_hist
406 self.user_ns['Out'] = self.output_hist
400
407
401 # Store the actual shell's name
408 # Store the actual shell's name
402 self.name = name
409 self.name = name
403
410
404 # Object variable to store code object waiting execution. This is
411 # Object variable to store code object waiting execution. This is
405 # used mainly by the multithreaded shells, but it can come in handy in
412 # used mainly by the multithreaded shells, but it can come in handy in
406 # other situations. No need to use a Queue here, since it's a single
413 # other situations. No need to use a Queue here, since it's a single
407 # item which gets cleared once run.
414 # item which gets cleared once run.
408 self.code_to_run = None
415 self.code_to_run = None
409
416
410 # Job manager (for jobs run as background threads)
417 # Job manager (for jobs run as background threads)
411 self.jobs = BackgroundJobManager()
418 self.jobs = BackgroundJobManager()
412 # Put the job manager into builtins so it's always there.
419 # Put the job manager into builtins so it's always there.
413 __builtin__.jobs = self.jobs
420 __builtin__.jobs = self.jobs
414
421
415 # escapes for automatic behavior on the command line
422 # escapes for automatic behavior on the command line
416 self.ESC_SHELL = '!'
423 self.ESC_SHELL = '!'
417 self.ESC_HELP = '?'
424 self.ESC_HELP = '?'
418 self.ESC_MAGIC = '%'
425 self.ESC_MAGIC = '%'
419 self.ESC_QUOTE = ','
426 self.ESC_QUOTE = ','
420 self.ESC_QUOTE2 = ';'
427 self.ESC_QUOTE2 = ';'
421 self.ESC_PAREN = '/'
428 self.ESC_PAREN = '/'
422
429
423 # And their associated handlers
430 # And their associated handlers
424 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
431 self.esc_handlers = {self.ESC_PAREN:self.handle_auto,
425 self.ESC_QUOTE:self.handle_auto,
432 self.ESC_QUOTE:self.handle_auto,
426 self.ESC_QUOTE2:self.handle_auto,
433 self.ESC_QUOTE2:self.handle_auto,
427 self.ESC_MAGIC:self.handle_magic,
434 self.ESC_MAGIC:self.handle_magic,
428 self.ESC_HELP:self.handle_help,
435 self.ESC_HELP:self.handle_help,
429 self.ESC_SHELL:self.handle_shell_escape,
436 self.ESC_SHELL:self.handle_shell_escape,
430 }
437 }
431
438
432 # class initializations
439 # class initializations
433 Logger.__init__(self,log_ns = self.user_ns)
440 Logger.__init__(self,log_ns = self.user_ns)
434 Magic.__init__(self,self)
441 Magic.__init__(self,self)
435
442
436 # an ugly hack to get a pointer to the shell, so I can start writing
443 # an ugly hack to get a pointer to the shell, so I can start writing
437 # magic code via this pointer instead of the current mixin salad.
444 # magic code via this pointer instead of the current mixin salad.
438 Magic.set_shell(self,self)
445 Magic.set_shell(self,self)
439
446
440 # Python source parser/formatter for syntax highlighting
447 # Python source parser/formatter for syntax highlighting
441 pyformat = PyColorize.Parser().format
448 pyformat = PyColorize.Parser().format
442 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
449 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
443
450
444 # hooks holds pointers used for user-side customizations
451 # hooks holds pointers used for user-side customizations
445 self.hooks = Struct()
452 self.hooks = Struct()
446
453
447 # Set all default hooks, defined in the IPython.hooks module.
454 # Set all default hooks, defined in the IPython.hooks module.
448 hooks = IPython.hooks
455 hooks = IPython.hooks
449 for hook_name in hooks.__all__:
456 for hook_name in hooks.__all__:
450 self.set_hook(hook_name,getattr(hooks,hook_name))
457 self.set_hook(hook_name,getattr(hooks,hook_name))
451
458
452 # Flag to mark unconditional exit
459 # Flag to mark unconditional exit
453 self.exit_now = False
460 self.exit_now = False
454
461
455 self.usage_min = """\
462 self.usage_min = """\
456 An enhanced console for Python.
463 An enhanced console for Python.
457 Some of its features are:
464 Some of its features are:
458 - Readline support if the readline library is present.
465 - Readline support if the readline library is present.
459 - Tab completion in the local namespace.
466 - Tab completion in the local namespace.
460 - Logging of input, see command-line options.
467 - Logging of input, see command-line options.
461 - System shell escape via ! , eg !ls.
468 - System shell escape via ! , eg !ls.
462 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
469 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
463 - Keeps track of locally defined variables via %who, %whos.
470 - Keeps track of locally defined variables via %who, %whos.
464 - Show object information with a ? eg ?x or x? (use ?? for more info).
471 - Show object information with a ? eg ?x or x? (use ?? for more info).
465 """
472 """
466 if usage: self.usage = usage
473 if usage: self.usage = usage
467 else: self.usage = self.usage_min
474 else: self.usage = self.usage_min
468
475
469 # Storage
476 # Storage
470 self.rc = rc # This will hold all configuration information
477 self.rc = rc # This will hold all configuration information
471 self.inputcache = []
478 self.inputcache = []
472 self._boundcache = []
479 self._boundcache = []
473 self.pager = 'less'
480 self.pager = 'less'
474 # temporary files used for various purposes. Deleted at exit.
481 # temporary files used for various purposes. Deleted at exit.
475 self.tempfiles = []
482 self.tempfiles = []
476
483
477 # Keep track of readline usage (later set by init_readline)
484 # Keep track of readline usage (later set by init_readline)
478 self.has_readline = False
485 self.has_readline = False
479
486
480 # for pushd/popd management
487 # for pushd/popd management
481 try:
488 try:
482 self.home_dir = get_home_dir()
489 self.home_dir = get_home_dir()
483 except HomeDirError,msg:
490 except HomeDirError,msg:
484 fatal(msg)
491 fatal(msg)
485
492
486 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
493 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
487
494
488 # Functions to call the underlying shell.
495 # Functions to call the underlying shell.
489
496
490 # utility to expand user variables via Itpl
497 # utility to expand user variables via Itpl
491 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
498 self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'),
492 self.user_ns))
499 self.user_ns))
493 # The first is similar to os.system, but it doesn't return a value,
500 # The first is similar to os.system, but it doesn't return a value,
494 # and it allows interpolation of variables in the user's namespace.
501 # and it allows interpolation of variables in the user's namespace.
495 self.system = lambda cmd: shell(self.var_expand(cmd),
502 self.system = lambda cmd: shell(self.var_expand(cmd),
496 header='IPython system call: ',
503 header='IPython system call: ',
497 verbose=self.rc.system_verbose)
504 verbose=self.rc.system_verbose)
498 # These are for getoutput and getoutputerror:
505 # These are for getoutput and getoutputerror:
499 self.getoutput = lambda cmd: \
506 self.getoutput = lambda cmd: \
500 getoutput(self.var_expand(cmd),
507 getoutput(self.var_expand(cmd),
501 header='IPython system call: ',
508 header='IPython system call: ',
502 verbose=self.rc.system_verbose)
509 verbose=self.rc.system_verbose)
503 self.getoutputerror = lambda cmd: \
510 self.getoutputerror = lambda cmd: \
504 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
511 getoutputerror(str(ItplNS(cmd.replace('#','\#'),
505 self.user_ns)),
512 self.user_ns)),
506 header='IPython system call: ',
513 header='IPython system call: ',
507 verbose=self.rc.system_verbose)
514 verbose=self.rc.system_verbose)
508
515
509 # RegExp for splitting line contents into pre-char//first
516 # RegExp for splitting line contents into pre-char//first
510 # word-method//rest. For clarity, each group in on one line.
517 # word-method//rest. For clarity, each group in on one line.
511
518
512 # WARNING: update the regexp if the above escapes are changed, as they
519 # WARNING: update the regexp if the above escapes are changed, as they
513 # are hardwired in.
520 # are hardwired in.
514
521
515 # Don't get carried away with trying to make the autocalling catch too
522 # Don't get carried away with trying to make the autocalling catch too
516 # much: it's better to be conservative rather than to trigger hidden
523 # much: it's better to be conservative rather than to trigger hidden
517 # evals() somewhere and end up causing side effects.
524 # evals() somewhere and end up causing side effects.
518
525
519 self.line_split = re.compile(r'^([\s*,;/])'
526 self.line_split = re.compile(r'^([\s*,;/])'
520 r'([\?\w\.]+\w*\s*)'
527 r'([\?\w\.]+\w*\s*)'
521 r'(\(?.*$)')
528 r'(\(?.*$)')
522
529
523 # Original re, keep around for a while in case changes break something
530 # Original re, keep around for a while in case changes break something
524 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
531 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
525 # r'(\s*[\?\w\.]+\w*\s*)'
532 # r'(\s*[\?\w\.]+\w*\s*)'
526 # r'(\(?.*$)')
533 # r'(\(?.*$)')
527
534
528 # RegExp to identify potential function names
535 # RegExp to identify potential function names
529 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
536 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
530 # RegExp to exclude strings with this start from autocalling
537 # RegExp to exclude strings with this start from autocalling
531 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
538 self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ')
532
539
533 # try to catch also methods for stuff in lists/tuples/dicts: off
540 # try to catch also methods for stuff in lists/tuples/dicts: off
534 # (experimental). For this to work, the line_split regexp would need
541 # (experimental). For this to work, the line_split regexp would need
535 # to be modified so it wouldn't break things at '['. That line is
542 # to be modified so it wouldn't break things at '['. That line is
536 # nasty enough that I shouldn't change it until I can test it _well_.
543 # nasty enough that I shouldn't change it until I can test it _well_.
537 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
544 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
538
545
539 # keep track of where we started running (mainly for crash post-mortem)
546 # keep track of where we started running (mainly for crash post-mortem)
540 self.starting_dir = os.getcwd()
547 self.starting_dir = os.getcwd()
541
548
542 # Attributes for Logger mixin class, make defaults here
549 # Attributes for Logger mixin class, make defaults here
543 self._dolog = False
550 self._dolog = False
544 self.LOG = ''
551 self.LOG = ''
545 self.LOGDEF = '.InteractiveShell.log'
552 self.LOGDEF = '.InteractiveShell.log'
546 self.LOGMODE = 'over'
553 self.LOGMODE = 'over'
547 self.LOGHEAD = Itpl(
554 self.LOGHEAD = Itpl(
548 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
555 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
549 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
556 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
550 #log# opts = $self.rc.opts
557 #log# opts = $self.rc.opts
551 #log# args = $self.rc.args
558 #log# args = $self.rc.args
552 #log# It is safe to make manual edits below here.
559 #log# It is safe to make manual edits below here.
553 #log#-----------------------------------------------------------------------
560 #log#-----------------------------------------------------------------------
554 """)
561 """)
555 # Various switches which can be set
562 # Various switches which can be set
556 self.CACHELENGTH = 5000 # this is cheap, it's just text
563 self.CACHELENGTH = 5000 # this is cheap, it's just text
557 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
564 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
558 self.banner2 = banner2
565 self.banner2 = banner2
559
566
560 # TraceBack handlers:
567 # TraceBack handlers:
561 # Need two, one for syntax errors and one for other exceptions.
568 # Need two, one for syntax errors and one for other exceptions.
562 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
569 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
563 # The interactive one is initialized with an offset, meaning we always
570 # The interactive one is initialized with an offset, meaning we always
564 # want to remove the topmost item in the traceback, which is our own
571 # want to remove the topmost item in the traceback, which is our own
565 # internal code. Valid modes: ['Plain','Context','Verbose']
572 # internal code. Valid modes: ['Plain','Context','Verbose']
566 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
573 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
567 color_scheme='NoColor',
574 color_scheme='NoColor',
568 tb_offset = 1)
575 tb_offset = 1)
569 # and add any custom exception handlers the user may have specified
576 # and add any custom exception handlers the user may have specified
570 self.set_custom_exc(*custom_exceptions)
577 self.set_custom_exc(*custom_exceptions)
571
578
572 # Object inspector
579 # Object inspector
573 self.inspector = OInspect.Inspector(OInspect.InspectColors,
580 self.inspector = OInspect.Inspector(OInspect.InspectColors,
574 PyColorize.ANSICodeColors,
581 PyColorize.ANSICodeColors,
575 'NoColor')
582 'NoColor')
576 # indentation management
583 # indentation management
577 self.autoindent = False
584 self.autoindent = False
578 self.indent_current_nsp = 0
585 self.indent_current_nsp = 0
579 self.indent_current = '' # actual indent string
586 self.indent_current = '' # actual indent string
580
587
581 # Make some aliases automatically
588 # Make some aliases automatically
582 # Prepare list of shell aliases to auto-define
589 # Prepare list of shell aliases to auto-define
583 if os.name == 'posix':
590 if os.name == 'posix':
584 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
591 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
585 'mv mv -i','rm rm -i','cp cp -i',
592 'mv mv -i','rm rm -i','cp cp -i',
586 'cat cat','less less','clear clear',
593 'cat cat','less less','clear clear',
587 # a better ls
594 # a better ls
588 'ls ls -F',
595 'ls ls -F',
589 # long ls
596 # long ls
590 'll ls -lF',
597 'll ls -lF',
591 # color ls
598 # color ls
592 'lc ls -F -o --color',
599 'lc ls -F -o --color',
593 # ls normal files only
600 # ls normal files only
594 'lf ls -F -o --color %l | grep ^-',
601 'lf ls -F -o --color %l | grep ^-',
595 # ls symbolic links
602 # ls symbolic links
596 'lk ls -F -o --color %l | grep ^l',
603 'lk ls -F -o --color %l | grep ^l',
597 # directories or links to directories,
604 # directories or links to directories,
598 'ldir ls -F -o --color %l | grep /$',
605 'ldir ls -F -o --color %l | grep /$',
599 # things which are executable
606 # things which are executable
600 'lx ls -F -o --color %l | grep ^-..x',
607 'lx ls -F -o --color %l | grep ^-..x',
601 )
608 )
602 elif os.name in ['nt','dos']:
609 elif os.name in ['nt','dos']:
603 auto_alias = ('dir dir /on', 'ls dir /on',
610 auto_alias = ('dir dir /on', 'ls dir /on',
604 'ddir dir /ad /on', 'ldir dir /ad /on',
611 'ddir dir /ad /on', 'ldir dir /ad /on',
605 'mkdir mkdir','rmdir rmdir','echo echo',
612 'mkdir mkdir','rmdir rmdir','echo echo',
606 'ren ren','cls cls','copy copy')
613 'ren ren','cls cls','copy copy')
607 else:
614 else:
608 auto_alias = ()
615 auto_alias = ()
609 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
616 self.auto_alias = map(lambda s:s.split(None,1),auto_alias)
610 # Call the actual (public) initializer
617 # Call the actual (public) initializer
611 self.init_auto_alias()
618 self.init_auto_alias()
612 # end __init__
619 # end __init__
613
620
614 def set_hook(self,name,hook):
621 def set_hook(self,name,hook):
615 """set_hook(name,hook) -> sets an internal IPython hook.
622 """set_hook(name,hook) -> sets an internal IPython hook.
616
623
617 IPython exposes some of its internal API as user-modifiable hooks. By
624 IPython exposes some of its internal API as user-modifiable hooks. By
618 resetting one of these hooks, you can modify IPython's behavior to
625 resetting one of these hooks, you can modify IPython's behavior to
619 call at runtime your own routines."""
626 call at runtime your own routines."""
620
627
621 # At some point in the future, this should validate the hook before it
628 # At some point in the future, this should validate the hook before it
622 # accepts it. Probably at least check that the hook takes the number
629 # accepts it. Probably at least check that the hook takes the number
623 # of args it's supposed to.
630 # of args it's supposed to.
624 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
631 setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
625
632
626 def set_custom_exc(self,exc_tuple,handler):
633 def set_custom_exc(self,exc_tuple,handler):
627 """set_custom_exc(exc_tuple,handler)
634 """set_custom_exc(exc_tuple,handler)
628
635
629 Set a custom exception handler, which will be called if any of the
636 Set a custom exception handler, which will be called if any of the
630 exceptions in exc_tuple occur in the mainloop (specifically, in the
637 exceptions in exc_tuple occur in the mainloop (specifically, in the
631 runcode() method.
638 runcode() method.
632
639
633 Inputs:
640 Inputs:
634
641
635 - exc_tuple: a *tuple* of valid exceptions to call the defined
642 - exc_tuple: a *tuple* of valid exceptions to call the defined
636 handler for. It is very important that you use a tuple, and NOT A
643 handler for. It is very important that you use a tuple, and NOT A
637 LIST here, because of the way Python's except statement works. If
644 LIST here, because of the way Python's except statement works. If
638 you only want to trap a single exception, use a singleton tuple:
645 you only want to trap a single exception, use a singleton tuple:
639
646
640 exc_tuple == (MyCustomException,)
647 exc_tuple == (MyCustomException,)
641
648
642 - handler: this must be defined as a function with the following
649 - handler: this must be defined as a function with the following
643 basic interface: def my_handler(self,etype,value,tb).
650 basic interface: def my_handler(self,etype,value,tb).
644
651
645 This will be made into an instance method (via new.instancemethod)
652 This will be made into an instance method (via new.instancemethod)
646 of IPython itself, and it will be called if any of the exceptions
653 of IPython itself, and it will be called if any of the exceptions
647 listed in the exc_tuple are caught. If the handler is None, an
654 listed in the exc_tuple are caught. If the handler is None, an
648 internal basic one is used, which just prints basic info.
655 internal basic one is used, which just prints basic info.
649
656
650 WARNING: by putting in your own exception handler into IPython's main
657 WARNING: by putting in your own exception handler into IPython's main
651 execution loop, you run a very good chance of nasty crashes. This
658 execution loop, you run a very good chance of nasty crashes. This
652 facility should only be used if you really know what you are doing."""
659 facility should only be used if you really know what you are doing."""
653
660
654 assert type(exc_tuple)==type(()) , \
661 assert type(exc_tuple)==type(()) , \
655 "The custom exceptions must be given AS A TUPLE."
662 "The custom exceptions must be given AS A TUPLE."
656
663
657 def dummy_handler(self,etype,value,tb):
664 def dummy_handler(self,etype,value,tb):
658 print '*** Simple custom exception handler ***'
665 print '*** Simple custom exception handler ***'
659 print 'Exception type :',etype
666 print 'Exception type :',etype
660 print 'Exception value:',value
667 print 'Exception value:',value
661 print 'Traceback :',tb
668 print 'Traceback :',tb
662 print 'Source code :','\n'.join(self.buffer)
669 print 'Source code :','\n'.join(self.buffer)
663
670
664 if handler is None: handler = dummy_handler
671 if handler is None: handler = dummy_handler
665
672
666 self.CustomTB = new.instancemethod(handler,self,self.__class__)
673 self.CustomTB = new.instancemethod(handler,self,self.__class__)
667 self.custom_exceptions = exc_tuple
674 self.custom_exceptions = exc_tuple
668
675
669 def set_custom_completer(self,completer,pos=0):
676 def set_custom_completer(self,completer,pos=0):
670 """set_custom_completer(completer,pos=0)
677 """set_custom_completer(completer,pos=0)
671
678
672 Adds a new custom completer function.
679 Adds a new custom completer function.
673
680
674 The position argument (defaults to 0) is the index in the completers
681 The position argument (defaults to 0) is the index in the completers
675 list where you want the completer to be inserted."""
682 list where you want the completer to be inserted."""
676
683
677 newcomp = new.instancemethod(completer,self.Completer,
684 newcomp = new.instancemethod(completer,self.Completer,
678 self.Completer.__class__)
685 self.Completer.__class__)
679 self.Completer.matchers.insert(pos,newcomp)
686 self.Completer.matchers.insert(pos,newcomp)
680
687
681 def complete(self,text):
688 def complete(self,text):
682 """Return a sorted list of all possible completions on text.
689 """Return a sorted list of all possible completions on text.
683
690
684 Inputs:
691 Inputs:
685
692
686 - text: a string of text to be completed on.
693 - text: a string of text to be completed on.
687
694
688 This is a wrapper around the completion mechanism, similar to what
695 This is a wrapper around the completion mechanism, similar to what
689 readline does at the command line when the TAB key is hit. By
696 readline does at the command line when the TAB key is hit. By
690 exposing it as a method, it can be used by other non-readline
697 exposing it as a method, it can be used by other non-readline
691 environments (such as GUIs) for text completion.
698 environments (such as GUIs) for text completion.
692
699
693 Simple usage example:
700 Simple usage example:
694
701
695 In [1]: x = 'hello'
702 In [1]: x = 'hello'
696
703
697 In [2]: __IP.complete('x.l')
704 In [2]: __IP.complete('x.l')
698 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
705 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
699
706
700 complete = self.Completer.complete
707 complete = self.Completer.complete
701 state = 0
708 state = 0
702 # use a dict so we get unique keys, since ipyhton's multiple
709 # use a dict so we get unique keys, since ipyhton's multiple
703 # completers can return duplicates.
710 # completers can return duplicates.
704 comps = {}
711 comps = {}
705 while True:
712 while True:
706 newcomp = complete(text,state)
713 newcomp = complete(text,state)
707 if newcomp is None:
714 if newcomp is None:
708 break
715 break
709 comps[newcomp] = 1
716 comps[newcomp] = 1
710 state += 1
717 state += 1
711 outcomps = comps.keys()
718 outcomps = comps.keys()
712 outcomps.sort()
719 outcomps.sort()
713 return outcomps
720 return outcomps
714
721
715 def set_completer_frame(self, frame):
722 def set_completer_frame(self, frame):
716 if frame:
723 if frame:
717 self.Completer.namespace = frame.f_locals
724 self.Completer.namespace = frame.f_locals
718 self.Completer.global_namespace = frame.f_globals
725 self.Completer.global_namespace = frame.f_globals
719 else:
726 else:
720 self.Completer.namespace = self.user_ns
727 self.Completer.namespace = self.user_ns
721 self.Completer.global_namespace = self.user_global_ns
728 self.Completer.global_namespace = self.user_global_ns
722
729
723 def post_config_initialization(self):
730 def post_config_initialization(self):
724 """Post configuration init method
731 """Post configuration init method
725
732
726 This is called after the configuration files have been processed to
733 This is called after the configuration files have been processed to
727 'finalize' the initialization."""
734 'finalize' the initialization."""
728
735
729 rc = self.rc
736 rc = self.rc
730
737
731 # Load readline proper
738 # Load readline proper
732 if rc.readline:
739 if rc.readline:
733 self.init_readline()
740 self.init_readline()
734
741
735 # Set user colors (don't do it in the constructor above so that it
742 # Set user colors (don't do it in the constructor above so that it
736 # doesn't crash if colors option is invalid)
743 # doesn't crash if colors option is invalid)
737 self.magic_colors(rc.colors)
744 self.magic_colors(rc.colors)
738
745
739 # Load user aliases
746 # Load user aliases
740 for alias in rc.alias:
747 for alias in rc.alias:
741 self.magic_alias(alias)
748 self.magic_alias(alias)
742
749
743 # dynamic data that survives through sessions
750 # dynamic data that survives through sessions
744 # XXX make the filename a config option?
751 # XXX make the filename a config option?
745 persist_base = 'persist'
752 persist_base = 'persist'
746 if rc.profile:
753 if rc.profile:
747 persist_base += '_%s' % rc.profile
754 persist_base += '_%s' % rc.profile
748 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
755 self.persist_fname = os.path.join(rc.ipythondir,persist_base)
749
756
750 try:
757 try:
751 self.persist = pickle.load(file(self.persist_fname))
758 self.persist = pickle.load(file(self.persist_fname))
752 except:
759 except:
753 self.persist = {}
760 self.persist = {}
754
761
755 def init_auto_alias(self):
762 def init_auto_alias(self):
756 """Define some aliases automatically.
763 """Define some aliases automatically.
757
764
758 These are ALL parameter-less aliases"""
765 These are ALL parameter-less aliases"""
759 for alias,cmd in self.auto_alias:
766 for alias,cmd in self.auto_alias:
760 self.alias_table[alias] = (0,cmd)
767 self.alias_table[alias] = (0,cmd)
761
768
762 def alias_table_validate(self,verbose=0):
769 def alias_table_validate(self,verbose=0):
763 """Update information about the alias table.
770 """Update information about the alias table.
764
771
765 In particular, make sure no Python keywords/builtins are in it."""
772 In particular, make sure no Python keywords/builtins are in it."""
766
773
767 no_alias = self.no_alias
774 no_alias = self.no_alias
768 for k in self.alias_table.keys():
775 for k in self.alias_table.keys():
769 if k in no_alias:
776 if k in no_alias:
770 del self.alias_table[k]
777 del self.alias_table[k]
771 if verbose:
778 if verbose:
772 print ("Deleting alias <%s>, it's a Python "
779 print ("Deleting alias <%s>, it's a Python "
773 "keyword or builtin." % k)
780 "keyword or builtin." % k)
774
781
775 def set_autoindent(self,value=None):
782 def set_autoindent(self,value=None):
776 """Set the autoindent flag, checking for readline support.
783 """Set the autoindent flag, checking for readline support.
777
784
778 If called with no arguments, it acts as a toggle."""
785 If called with no arguments, it acts as a toggle."""
779
786
780 if not self.has_readline:
787 if not self.has_readline:
781 if os.name == 'posix':
788 if os.name == 'posix':
782 warn("The auto-indent feature requires the readline library")
789 warn("The auto-indent feature requires the readline library")
783 self.autoindent = 0
790 self.autoindent = 0
784 return
791 return
785 if value is None:
792 if value is None:
786 self.autoindent = not self.autoindent
793 self.autoindent = not self.autoindent
787 else:
794 else:
788 self.autoindent = value
795 self.autoindent = value
789
796
790 def rc_set_toggle(self,rc_field,value=None):
797 def rc_set_toggle(self,rc_field,value=None):
791 """Set or toggle a field in IPython's rc config. structure.
798 """Set or toggle a field in IPython's rc config. structure.
792
799
793 If called with no arguments, it acts as a toggle.
800 If called with no arguments, it acts as a toggle.
794
801
795 If called with a non-existent field, the resulting AttributeError
802 If called with a non-existent field, the resulting AttributeError
796 exception will propagate out."""
803 exception will propagate out."""
797
804
798 rc_val = getattr(self.rc,rc_field)
805 rc_val = getattr(self.rc,rc_field)
799 if value is None:
806 if value is None:
800 value = not rc_val
807 value = not rc_val
801 setattr(self.rc,rc_field,value)
808 setattr(self.rc,rc_field,value)
802
809
803 def user_setup(self,ipythondir,rc_suffix,mode='install'):
810 def user_setup(self,ipythondir,rc_suffix,mode='install'):
804 """Install the user configuration directory.
811 """Install the user configuration directory.
805
812
806 Can be called when running for the first time or to upgrade the user's
813 Can be called when running for the first time or to upgrade the user's
807 .ipython/ directory with the mode parameter. Valid modes are 'install'
814 .ipython/ directory with the mode parameter. Valid modes are 'install'
808 and 'upgrade'."""
815 and 'upgrade'."""
809
816
810 def wait():
817 def wait():
811 try:
818 try:
812 raw_input("Please press <RETURN> to start IPython.")
819 raw_input("Please press <RETURN> to start IPython.")
813 except EOFError:
820 except EOFError:
814 print >> Term.cout
821 print >> Term.cout
815 print '*'*70
822 print '*'*70
816
823
817 cwd = os.getcwd() # remember where we started
824 cwd = os.getcwd() # remember where we started
818 glb = glob.glob
825 glb = glob.glob
819 print '*'*70
826 print '*'*70
820 if mode == 'install':
827 if mode == 'install':
821 print \
828 print \
822 """Welcome to IPython. I will try to create a personal configuration directory
829 """Welcome to IPython. I will try to create a personal configuration directory
823 where you can customize many aspects of IPython's functionality in:\n"""
830 where you can customize many aspects of IPython's functionality in:\n"""
824 else:
831 else:
825 print 'I am going to upgrade your configuration in:'
832 print 'I am going to upgrade your configuration in:'
826
833
827 print ipythondir
834 print ipythondir
828
835
829 rcdirend = os.path.join('IPython','UserConfig')
836 rcdirend = os.path.join('IPython','UserConfig')
830 cfg = lambda d: os.path.join(d,rcdirend)
837 cfg = lambda d: os.path.join(d,rcdirend)
831 try:
838 try:
832 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
839 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
833 except IOError:
840 except IOError:
834 warning = """
841 warning = """
835 Installation error. IPython's directory was not found.
842 Installation error. IPython's directory was not found.
836
843
837 Check the following:
844 Check the following:
838
845
839 The ipython/IPython directory should be in a directory belonging to your
846 The ipython/IPython directory should be in a directory belonging to your
840 PYTHONPATH environment variable (that is, it should be in a directory
847 PYTHONPATH environment variable (that is, it should be in a directory
841 belonging to sys.path). You can copy it explicitly there or just link to it.
848 belonging to sys.path). You can copy it explicitly there or just link to it.
842
849
843 IPython will proceed with builtin defaults.
850 IPython will proceed with builtin defaults.
844 """
851 """
845 warn(warning)
852 warn(warning)
846 wait()
853 wait()
847 return
854 return
848
855
849 if mode == 'install':
856 if mode == 'install':
850 try:
857 try:
851 shutil.copytree(rcdir,ipythondir)
858 shutil.copytree(rcdir,ipythondir)
852 os.chdir(ipythondir)
859 os.chdir(ipythondir)
853 rc_files = glb("ipythonrc*")
860 rc_files = glb("ipythonrc*")
854 for rc_file in rc_files:
861 for rc_file in rc_files:
855 os.rename(rc_file,rc_file+rc_suffix)
862 os.rename(rc_file,rc_file+rc_suffix)
856 except:
863 except:
857 warning = """
864 warning = """
858
865
859 There was a problem with the installation:
866 There was a problem with the installation:
860 %s
867 %s
861 Try to correct it or contact the developers if you think it's a bug.
868 Try to correct it or contact the developers if you think it's a bug.
862 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
869 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
863 warn(warning)
870 warn(warning)
864 wait()
871 wait()
865 return
872 return
866
873
867 elif mode == 'upgrade':
874 elif mode == 'upgrade':
868 try:
875 try:
869 os.chdir(ipythondir)
876 os.chdir(ipythondir)
870 except:
877 except:
871 print """
878 print """
872 Can not upgrade: changing to directory %s failed. Details:
879 Can not upgrade: changing to directory %s failed. Details:
873 %s
880 %s
874 """ % (ipythondir,sys.exc_info()[1])
881 """ % (ipythondir,sys.exc_info()[1])
875 wait()
882 wait()
876 return
883 return
877 else:
884 else:
878 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
885 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
879 for new_full_path in sources:
886 for new_full_path in sources:
880 new_filename = os.path.basename(new_full_path)
887 new_filename = os.path.basename(new_full_path)
881 if new_filename.startswith('ipythonrc'):
888 if new_filename.startswith('ipythonrc'):
882 new_filename = new_filename + rc_suffix
889 new_filename = new_filename + rc_suffix
883 # The config directory should only contain files, skip any
890 # The config directory should only contain files, skip any
884 # directories which may be there (like CVS)
891 # directories which may be there (like CVS)
885 if os.path.isdir(new_full_path):
892 if os.path.isdir(new_full_path):
886 continue
893 continue
887 if os.path.exists(new_filename):
894 if os.path.exists(new_filename):
888 old_file = new_filename+'.old'
895 old_file = new_filename+'.old'
889 if os.path.exists(old_file):
896 if os.path.exists(old_file):
890 os.remove(old_file)
897 os.remove(old_file)
891 os.rename(new_filename,old_file)
898 os.rename(new_filename,old_file)
892 shutil.copy(new_full_path,new_filename)
899 shutil.copy(new_full_path,new_filename)
893 else:
900 else:
894 raise ValueError,'unrecognized mode for install:',`mode`
901 raise ValueError,'unrecognized mode for install:',`mode`
895
902
896 # Fix line-endings to those native to each platform in the config
903 # Fix line-endings to those native to each platform in the config
897 # directory.
904 # directory.
898 try:
905 try:
899 os.chdir(ipythondir)
906 os.chdir(ipythondir)
900 except:
907 except:
901 print """
908 print """
902 Problem: changing to directory %s failed.
909 Problem: changing to directory %s failed.
903 Details:
910 Details:
904 %s
911 %s
905
912
906 Some configuration files may have incorrect line endings. This should not
913 Some configuration files may have incorrect line endings. This should not
907 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
914 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
908 wait()
915 wait()
909 else:
916 else:
910 for fname in glb('ipythonrc*'):
917 for fname in glb('ipythonrc*'):
911 try:
918 try:
912 native_line_ends(fname,backup=0)
919 native_line_ends(fname,backup=0)
913 except IOError:
920 except IOError:
914 pass
921 pass
915
922
916 if mode == 'install':
923 if mode == 'install':
917 print """
924 print """
918 Successful installation!
925 Successful installation!
919
926
920 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
927 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
921 IPython manual (there are both HTML and PDF versions supplied with the
928 IPython manual (there are both HTML and PDF versions supplied with the
922 distribution) to make sure that your system environment is properly configured
929 distribution) to make sure that your system environment is properly configured
923 to take advantage of IPython's features."""
930 to take advantage of IPython's features."""
924 else:
931 else:
925 print """
932 print """
926 Successful upgrade!
933 Successful upgrade!
927
934
928 All files in your directory:
935 All files in your directory:
929 %(ipythondir)s
936 %(ipythondir)s
930 which would have been overwritten by the upgrade were backed up with a .old
937 which would have been overwritten by the upgrade were backed up with a .old
931 extension. If you had made particular customizations in those files you may
938 extension. If you had made particular customizations in those files you may
932 want to merge them back into the new files.""" % locals()
939 want to merge them back into the new files.""" % locals()
933 wait()
940 wait()
934 os.chdir(cwd)
941 os.chdir(cwd)
935 # end user_setup()
942 # end user_setup()
936
943
937 def atexit_operations(self):
944 def atexit_operations(self):
938 """This will be executed at the time of exit.
945 """This will be executed at the time of exit.
939
946
940 Saving of persistent data should be performed here. """
947 Saving of persistent data should be performed here. """
941
948
942 # input history
949 # input history
943 self.savehist()
950 self.savehist()
944
951
945 # Cleanup all tempfiles left around
952 # Cleanup all tempfiles left around
946 for tfile in self.tempfiles:
953 for tfile in self.tempfiles:
947 try:
954 try:
948 os.unlink(tfile)
955 os.unlink(tfile)
949 except OSError:
956 except OSError:
950 pass
957 pass
951
958
952 # save the "persistent data" catch-all dictionary
959 # save the "persistent data" catch-all dictionary
953 try:
960 try:
954 pickle.dump(self.persist, open(self.persist_fname,"w"))
961 pickle.dump(self.persist, open(self.persist_fname,"w"))
955 except:
962 except:
956 print "*** ERROR *** persistent data saving failed."
963 print "*** ERROR *** persistent data saving failed."
957
964
958 def savehist(self):
965 def savehist(self):
959 """Save input history to a file (via readline library)."""
966 """Save input history to a file (via readline library)."""
960 try:
967 try:
961 self.readline.write_history_file(self.histfile)
968 self.readline.write_history_file(self.histfile)
962 except:
969 except:
963 print 'Unable to save IPython command history to file: ' + \
970 print 'Unable to save IPython command history to file: ' + \
964 `self.histfile`
971 `self.histfile`
965
972
966 def pre_readline(self):
973 def pre_readline(self):
967 """readline hook to be used at the start of each line.
974 """readline hook to be used at the start of each line.
968
975
969 Currently it handles auto-indent only."""
976 Currently it handles auto-indent only."""
970
977
971 self.readline.insert_text(self.indent_current)
978 self.readline.insert_text(self.indent_current)
972
979
973 def init_readline(self):
980 def init_readline(self):
974 """Command history completion/saving/reloading."""
981 """Command history completion/saving/reloading."""
975 try:
982 try:
976 import readline
983 import readline
977 except ImportError:
984 except ImportError:
978 self.has_readline = 0
985 self.has_readline = 0
979 self.readline = None
986 self.readline = None
980 # no point in bugging windows users with this every time:
987 # no point in bugging windows users with this every time:
981 if os.name == 'posix':
988 if os.name == 'posix':
982 warn('Readline services not available on this platform.')
989 warn('Readline services not available on this platform.')
983 else:
990 else:
984 import atexit
991 import atexit
985 from IPython.completer import IPCompleter
992 from IPython.completer import IPCompleter
986 self.Completer = IPCompleter(self,
993 self.Completer = IPCompleter(self,
987 self.user_ns,
994 self.user_ns,
988 self.user_global_ns,
995 self.user_global_ns,
989 self.rc.readline_omit__names,
996 self.rc.readline_omit__names,
990 self.alias_table)
997 self.alias_table)
991
998
992 # Platform-specific configuration
999 # Platform-specific configuration
993 if os.name == 'nt':
1000 if os.name == 'nt':
994 self.readline_startup_hook = readline.set_pre_input_hook
1001 self.readline_startup_hook = readline.set_pre_input_hook
995 else:
1002 else:
996 self.readline_startup_hook = readline.set_startup_hook
1003 self.readline_startup_hook = readline.set_startup_hook
997
1004
998 # Load user's initrc file (readline config)
1005 # Load user's initrc file (readline config)
999 inputrc_name = os.environ.get('INPUTRC')
1006 inputrc_name = os.environ.get('INPUTRC')
1000 if inputrc_name is None:
1007 if inputrc_name is None:
1001 home_dir = get_home_dir()
1008 home_dir = get_home_dir()
1002 if home_dir is not None:
1009 if home_dir is not None:
1003 inputrc_name = os.path.join(home_dir,'.inputrc')
1010 inputrc_name = os.path.join(home_dir,'.inputrc')
1004 if os.path.isfile(inputrc_name):
1011 if os.path.isfile(inputrc_name):
1005 try:
1012 try:
1006 readline.read_init_file(inputrc_name)
1013 readline.read_init_file(inputrc_name)
1007 except:
1014 except:
1008 warn('Problems reading readline initialization file <%s>'
1015 warn('Problems reading readline initialization file <%s>'
1009 % inputrc_name)
1016 % inputrc_name)
1010
1017
1011 self.has_readline = 1
1018 self.has_readline = 1
1012 self.readline = readline
1019 self.readline = readline
1013 # save this in sys so embedded copies can restore it properly
1020 # save this in sys so embedded copies can restore it properly
1014 sys.ipcompleter = self.Completer.complete
1021 sys.ipcompleter = self.Completer.complete
1015 readline.set_completer(self.Completer.complete)
1022 readline.set_completer(self.Completer.complete)
1016
1023
1017 # Configure readline according to user's prefs
1024 # Configure readline according to user's prefs
1018 for rlcommand in self.rc.readline_parse_and_bind:
1025 for rlcommand in self.rc.readline_parse_and_bind:
1019 readline.parse_and_bind(rlcommand)
1026 readline.parse_and_bind(rlcommand)
1020
1027
1021 # remove some chars from the delimiters list
1028 # remove some chars from the delimiters list
1022 delims = readline.get_completer_delims()
1029 delims = readline.get_completer_delims()
1023 delims = delims.translate(string._idmap,
1030 delims = delims.translate(string._idmap,
1024 self.rc.readline_remove_delims)
1031 self.rc.readline_remove_delims)
1025 readline.set_completer_delims(delims)
1032 readline.set_completer_delims(delims)
1026 # otherwise we end up with a monster history after a while:
1033 # otherwise we end up with a monster history after a while:
1027 readline.set_history_length(1000)
1034 readline.set_history_length(1000)
1028 try:
1035 try:
1029 #print '*** Reading readline history' # dbg
1036 #print '*** Reading readline history' # dbg
1030 readline.read_history_file(self.histfile)
1037 readline.read_history_file(self.histfile)
1031 except IOError:
1038 except IOError:
1032 pass # It doesn't exist yet.
1039 pass # It doesn't exist yet.
1033
1040
1034 atexit.register(self.atexit_operations)
1041 atexit.register(self.atexit_operations)
1035 del atexit
1042 del atexit
1036
1043
1037 # Configure auto-indent for all platforms
1044 # Configure auto-indent for all platforms
1038 self.set_autoindent(self.rc.autoindent)
1045 self.set_autoindent(self.rc.autoindent)
1039
1046
1040 def _should_recompile(self,e):
1047 def _should_recompile(self,e):
1041 """Utility routine for edit_syntax_error"""
1048 """Utility routine for edit_syntax_error"""
1042
1049
1043 if e.filename in ('<ipython console>','<input>','<string>',
1050 if e.filename in ('<ipython console>','<input>','<string>',
1044 '<console>'):
1051 '<console>'):
1045 return False
1052 return False
1046 try:
1053 try:
1047 if not ask_yes_no('Return to editor to correct syntax error? '
1054 if not ask_yes_no('Return to editor to correct syntax error? '
1048 '[Y/n] ','y'):
1055 '[Y/n] ','y'):
1049 return False
1056 return False
1050 except EOFError:
1057 except EOFError:
1051 return False
1058 return False
1052 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1059 self.hooks.fix_error_editor(e.filename,e.lineno,e.offset,e.msg)
1053 return True
1060 return True
1054
1061
1055 def edit_syntax_error(self):
1062 def edit_syntax_error(self):
1056 """The bottom half of the syntax error handler called in the main loop.
1063 """The bottom half of the syntax error handler called in the main loop.
1057
1064
1058 Loop until syntax error is fixed or user cancels.
1065 Loop until syntax error is fixed or user cancels.
1059 """
1066 """
1060
1067
1061 while self.SyntaxTB.last_syntax_error:
1068 while self.SyntaxTB.last_syntax_error:
1062 # copy and clear last_syntax_error
1069 # copy and clear last_syntax_error
1063 err = self.SyntaxTB.clear_err_state()
1070 err = self.SyntaxTB.clear_err_state()
1064 if not self._should_recompile(err):
1071 if not self._should_recompile(err):
1065 return
1072 return
1066 try:
1073 try:
1067 # may set last_syntax_error again if a SyntaxError is raised
1074 # may set last_syntax_error again if a SyntaxError is raised
1068 self.safe_execfile(err.filename,self.shell.user_ns)
1075 self.safe_execfile(err.filename,self.shell.user_ns)
1069 except:
1076 except:
1070 self.showtraceback()
1077 self.showtraceback()
1071 else:
1078 else:
1072 f = file(err.filename)
1079 f = file(err.filename)
1073 try:
1080 try:
1074 sys.displayhook(f.read())
1081 sys.displayhook(f.read())
1075 finally:
1082 finally:
1076 f.close()
1083 f.close()
1077
1084
1078 def showsyntaxerror(self, filename=None):
1085 def showsyntaxerror(self, filename=None):
1079 """Display the syntax error that just occurred.
1086 """Display the syntax error that just occurred.
1080
1087
1081 This doesn't display a stack trace because there isn't one.
1088 This doesn't display a stack trace because there isn't one.
1082
1089
1083 If a filename is given, it is stuffed in the exception instead
1090 If a filename is given, it is stuffed in the exception instead
1084 of what was there before (because Python's parser always uses
1091 of what was there before (because Python's parser always uses
1085 "<string>" when reading from a string).
1092 "<string>" when reading from a string).
1086 """
1093 """
1087 type, value, sys.last_traceback = sys.exc_info()
1094 type, value, sys.last_traceback = sys.exc_info()
1088 sys.last_type = type
1095 sys.last_type = type
1089 sys.last_value = value
1096 sys.last_value = value
1090 if filename and type is SyntaxError:
1097 if filename and type is SyntaxError:
1091 # Work hard to stuff the correct filename in the exception
1098 # Work hard to stuff the correct filename in the exception
1092 try:
1099 try:
1093 msg, (dummy_filename, lineno, offset, line) = value
1100 msg, (dummy_filename, lineno, offset, line) = value
1094 except:
1101 except:
1095 # Not the format we expect; leave it alone
1102 # Not the format we expect; leave it alone
1096 pass
1103 pass
1097 else:
1104 else:
1098 # Stuff in the right filename
1105 # Stuff in the right filename
1099 try:
1106 try:
1100 # Assume SyntaxError is a class exception
1107 # Assume SyntaxError is a class exception
1101 value = SyntaxError(msg, (filename, lineno, offset, line))
1108 value = SyntaxError(msg, (filename, lineno, offset, line))
1102 except:
1109 except:
1103 # If that failed, assume SyntaxError is a string
1110 # If that failed, assume SyntaxError is a string
1104 value = msg, (filename, lineno, offset, line)
1111 value = msg, (filename, lineno, offset, line)
1105 self.SyntaxTB(type,value,[])
1112 self.SyntaxTB(type,value,[])
1106
1113
1107 def debugger(self):
1114 def debugger(self):
1108 """Call the pdb debugger."""
1115 """Call the pdb debugger."""
1109
1116
1110 if not self.rc.pdb:
1117 if not self.rc.pdb:
1111 return
1118 return
1112 pdb.pm()
1119 pdb.pm()
1113
1120
1114 def showtraceback(self,exc_tuple = None,filename=None):
1121 def showtraceback(self,exc_tuple = None,filename=None):
1115 """Display the exception that just occurred."""
1122 """Display the exception that just occurred."""
1116
1123
1117 # Though this won't be called by syntax errors in the input line,
1124 # Though this won't be called by syntax errors in the input line,
1118 # there may be SyntaxError cases whith imported code.
1125 # there may be SyntaxError cases whith imported code.
1119 if exc_tuple is None:
1126 if exc_tuple is None:
1120 type, value, tb = sys.exc_info()
1127 type, value, tb = sys.exc_info()
1121 else:
1128 else:
1122 type, value, tb = exc_tuple
1129 type, value, tb = exc_tuple
1123 if type is SyntaxError:
1130 if type is SyntaxError:
1124 self.showsyntaxerror(filename)
1131 self.showsyntaxerror(filename)
1125 else:
1132 else:
1126 sys.last_type = type
1133 sys.last_type = type
1127 sys.last_value = value
1134 sys.last_value = value
1128 sys.last_traceback = tb
1135 sys.last_traceback = tb
1129 self.InteractiveTB()
1136 self.InteractiveTB()
1130 if self.InteractiveTB.call_pdb and self.has_readline:
1137 if self.InteractiveTB.call_pdb and self.has_readline:
1131 # pdb mucks up readline, fix it back
1138 # pdb mucks up readline, fix it back
1132 self.readline.set_completer(self.Completer.complete)
1139 self.readline.set_completer(self.Completer.complete)
1133
1140
1134 def update_cache(self, line):
1141 def update_cache(self, line):
1135 """puts line into cache"""
1142 """puts line into cache"""
1136 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1143 self.inputcache.insert(0, line) # This copies the cache every time ... :-(
1137 if len(self.inputcache) >= self.CACHELENGTH:
1144 if len(self.inputcache) >= self.CACHELENGTH:
1138 self.inputcache.pop() # This doesn't :-)
1145 self.inputcache.pop() # This doesn't :-)
1139
1146
1140 def mainloop(self,banner=None):
1147 def mainloop(self,banner=None):
1141 """Creates the local namespace and starts the mainloop.
1148 """Creates the local namespace and starts the mainloop.
1142
1149
1143 If an optional banner argument is given, it will override the
1150 If an optional banner argument is given, it will override the
1144 internally created default banner."""
1151 internally created default banner."""
1145
1152
1146 if self.rc.c: # Emulate Python's -c option
1153 if self.rc.c: # Emulate Python's -c option
1147 self.exec_init_cmd()
1154 self.exec_init_cmd()
1148 if banner is None:
1155 if banner is None:
1149 if self.rc.banner:
1156 if self.rc.banner:
1150 banner = self.BANNER+self.banner2
1157 banner = self.BANNER+self.banner2
1151 else:
1158 else:
1152 banner = ''
1159 banner = ''
1153 self.interact(banner)
1160 self.interact(banner)
1154
1161
1155 def exec_init_cmd(self):
1162 def exec_init_cmd(self):
1156 """Execute a command given at the command line.
1163 """Execute a command given at the command line.
1157
1164
1158 This emulates Python's -c option."""
1165 This emulates Python's -c option."""
1159
1166
1160 sys.argv = ['-c']
1167 sys.argv = ['-c']
1161 self.push(self.rc.c)
1168 self.push(self.rc.c)
1162
1169
1163 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1170 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1164 """Embeds IPython into a running python program.
1171 """Embeds IPython into a running python program.
1165
1172
1166 Input:
1173 Input:
1167
1174
1168 - header: An optional header message can be specified.
1175 - header: An optional header message can be specified.
1169
1176
1170 - local_ns, global_ns: working namespaces. If given as None, the
1177 - local_ns, global_ns: working namespaces. If given as None, the
1171 IPython-initialized one is updated with __main__.__dict__, so that
1178 IPython-initialized one is updated with __main__.__dict__, so that
1172 program variables become visible but user-specific configuration
1179 program variables become visible but user-specific configuration
1173 remains possible.
1180 remains possible.
1174
1181
1175 - stack_depth: specifies how many levels in the stack to go to
1182 - stack_depth: specifies how many levels in the stack to go to
1176 looking for namespaces (when local_ns and global_ns are None). This
1183 looking for namespaces (when local_ns and global_ns are None). This
1177 allows an intermediate caller to make sure that this function gets
1184 allows an intermediate caller to make sure that this function gets
1178 the namespace from the intended level in the stack. By default (0)
1185 the namespace from the intended level in the stack. By default (0)
1179 it will get its locals and globals from the immediate caller.
1186 it will get its locals and globals from the immediate caller.
1180
1187
1181 Warning: it's possible to use this in a program which is being run by
1188 Warning: it's possible to use this in a program which is being run by
1182 IPython itself (via %run), but some funny things will happen (a few
1189 IPython itself (via %run), but some funny things will happen (a few
1183 globals get overwritten). In the future this will be cleaned up, as
1190 globals get overwritten). In the future this will be cleaned up, as
1184 there is no fundamental reason why it can't work perfectly."""
1191 there is no fundamental reason why it can't work perfectly."""
1185
1192
1186 # Get locals and globals from caller
1193 # Get locals and globals from caller
1187 if local_ns is None or global_ns is None:
1194 if local_ns is None or global_ns is None:
1188 call_frame = sys._getframe(stack_depth).f_back
1195 call_frame = sys._getframe(stack_depth).f_back
1189
1196
1190 if local_ns is None:
1197 if local_ns is None:
1191 local_ns = call_frame.f_locals
1198 local_ns = call_frame.f_locals
1192 if global_ns is None:
1199 if global_ns is None:
1193 global_ns = call_frame.f_globals
1200 global_ns = call_frame.f_globals
1194
1201
1195 # Update namespaces and fire up interpreter
1202 # Update namespaces and fire up interpreter
1196 self.user_ns = local_ns
1203 self.user_ns = local_ns
1197 self.user_global_ns = global_ns
1204 self.user_global_ns = global_ns
1198
1205
1199 # Patch for global embedding to make sure that things don't overwrite
1206 # Patch for global embedding to make sure that things don't overwrite
1200 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1207 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1201 # FIXME. Test this a bit more carefully (the if.. is new)
1208 # FIXME. Test this a bit more carefully (the if.. is new)
1202 if local_ns is None and global_ns is None:
1209 if local_ns is None and global_ns is None:
1203 self.user_global_ns.update(__main__.__dict__)
1210 self.user_global_ns.update(__main__.__dict__)
1204
1211
1205 # make sure the tab-completer has the correct frame information, so it
1212 # make sure the tab-completer has the correct frame information, so it
1206 # actually completes using the frame's locals/globals
1213 # actually completes using the frame's locals/globals
1207 self.set_completer_frame(call_frame)
1214 self.set_completer_frame(call_frame)
1208
1215
1209 self.interact(header)
1216 self.interact(header)
1210
1217
1211 def interact(self, banner=None):
1218 def interact(self, banner=None):
1212 """Closely emulate the interactive Python console.
1219 """Closely emulate the interactive Python console.
1213
1220
1214 The optional banner argument specify the banner to print
1221 The optional banner argument specify the banner to print
1215 before the first interaction; by default it prints a banner
1222 before the first interaction; by default it prints a banner
1216 similar to the one printed by the real Python interpreter,
1223 similar to the one printed by the real Python interpreter,
1217 followed by the current class name in parentheses (so as not
1224 followed by the current class name in parentheses (so as not
1218 to confuse this with the real interpreter -- since it's so
1225 to confuse this with the real interpreter -- since it's so
1219 close!).
1226 close!).
1220
1227
1221 """
1228 """
1222 cprt = 'Type "copyright", "credits" or "license" for more information.'
1229 cprt = 'Type "copyright", "credits" or "license" for more information.'
1223 if banner is None:
1230 if banner is None:
1224 self.write("Python %s on %s\n%s\n(%s)\n" %
1231 self.write("Python %s on %s\n%s\n(%s)\n" %
1225 (sys.version, sys.platform, cprt,
1232 (sys.version, sys.platform, cprt,
1226 self.__class__.__name__))
1233 self.__class__.__name__))
1227 else:
1234 else:
1228 self.write(banner)
1235 self.write(banner)
1229
1236
1230 more = 0
1237 more = 0
1231
1238
1232 # Mark activity in the builtins
1239 # Mark activity in the builtins
1233 __builtin__.__dict__['__IPYTHON__active'] += 1
1240 __builtin__.__dict__['__IPYTHON__active'] += 1
1234
1241
1235 # compiled regexps for autoindent management
1242 # compiled regexps for autoindent management
1236 ini_spaces_re = re.compile(r'^(\s+)')
1243 ini_spaces_re = re.compile(r'^(\s+)')
1237 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1244 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
1238
1245
1239 # exit_now is set by a call to %Exit or %Quit
1246 # exit_now is set by a call to %Exit or %Quit
1240 while not self.exit_now:
1247 while not self.exit_now:
1241 try:
1248 try:
1242 if more:
1249 if more:
1243 prompt = self.outputcache.prompt2
1250 prompt = self.outputcache.prompt2
1244 if self.autoindent:
1251 if self.autoindent:
1245 self.readline_startup_hook(self.pre_readline)
1252 self.readline_startup_hook(self.pre_readline)
1246 else:
1253 else:
1247 prompt = self.outputcache.prompt1
1254 prompt = self.outputcache.prompt1
1248 try:
1255 try:
1249 line = self.raw_input(prompt,more)
1256 line = self.raw_input(prompt,more)
1250 if self.autoindent:
1257 if self.autoindent:
1251 self.readline_startup_hook(None)
1258 self.readline_startup_hook(None)
1252 except EOFError:
1259 except EOFError:
1253 if self.autoindent:
1260 if self.autoindent:
1254 self.readline_startup_hook(None)
1261 self.readline_startup_hook(None)
1255 self.write("\n")
1262 self.write("\n")
1256 self.exit()
1263 self.exit()
1257 else:
1264 else:
1258 more = self.push(line)
1265 more = self.push(line)
1259 # Auto-indent management
1266 # Auto-indent management
1260 if self.autoindent:
1267 if self.autoindent:
1261 if line:
1268 if line:
1262 ini_spaces = ini_spaces_re.match(line)
1269 ini_spaces = ini_spaces_re.match(line)
1263 if ini_spaces:
1270 if ini_spaces:
1264 nspaces = ini_spaces.end()
1271 nspaces = ini_spaces.end()
1265 else:
1272 else:
1266 nspaces = 0
1273 nspaces = 0
1267 self.indent_current_nsp = nspaces
1274 self.indent_current_nsp = nspaces
1268
1275
1269 if line[-1] == ':':
1276 if line[-1] == ':':
1270 self.indent_current_nsp += 4
1277 self.indent_current_nsp += 4
1271 elif dedent_re.match(line):
1278 elif dedent_re.match(line):
1272 self.indent_current_nsp -= 4
1279 self.indent_current_nsp -= 4
1273 else:
1280 else:
1274 self.indent_current_nsp = 0
1281 self.indent_current_nsp = 0
1275
1282
1276 # indent_current is the actual string to be inserted
1283 # indent_current is the actual string to be inserted
1277 # by the readline hooks for indentation
1284 # by the readline hooks for indentation
1278 self.indent_current = ' '* self.indent_current_nsp
1285 self.indent_current = ' '* self.indent_current_nsp
1279
1286
1280 if (self.SyntaxTB.last_syntax_error and
1287 if (self.SyntaxTB.last_syntax_error and
1281 self.rc.autoedit_syntax):
1288 self.rc.autoedit_syntax):
1282 self.edit_syntax_error()
1289 self.edit_syntax_error()
1283
1290
1284 except KeyboardInterrupt:
1291 except KeyboardInterrupt:
1285 self.write("\nKeyboardInterrupt\n")
1292 self.write("\nKeyboardInterrupt\n")
1286 self.resetbuffer()
1293 self.resetbuffer()
1287 more = 0
1294 more = 0
1288 # keep cache in sync with the prompt counter:
1295 # keep cache in sync with the prompt counter:
1289 self.outputcache.prompt_count -= 1
1296 self.outputcache.prompt_count -= 1
1290
1297
1291 if self.autoindent:
1298 if self.autoindent:
1292 self.indent_current_nsp = 0
1299 self.indent_current_nsp = 0
1293 self.indent_current = ' '* self.indent_current_nsp
1300 self.indent_current = ' '* self.indent_current_nsp
1294
1301
1295 except bdb.BdbQuit:
1302 except bdb.BdbQuit:
1296 warn("The Python debugger has exited with a BdbQuit exception.\n"
1303 warn("The Python debugger has exited with a BdbQuit exception.\n"
1297 "Because of how pdb handles the stack, it is impossible\n"
1304 "Because of how pdb handles the stack, it is impossible\n"
1298 "for IPython to properly format this particular exception.\n"
1305 "for IPython to properly format this particular exception.\n"
1299 "IPython will resume normal operation.")
1306 "IPython will resume normal operation.")
1300
1307
1301 # We are off again...
1308 # We are off again...
1302 __builtin__.__dict__['__IPYTHON__active'] -= 1
1309 __builtin__.__dict__['__IPYTHON__active'] -= 1
1303
1310
1304 def excepthook(self, type, value, tb):
1311 def excepthook(self, type, value, tb):
1305 """One more defense for GUI apps that call sys.excepthook.
1312 """One more defense for GUI apps that call sys.excepthook.
1306
1313
1307 GUI frameworks like wxPython trap exceptions and call
1314 GUI frameworks like wxPython trap exceptions and call
1308 sys.excepthook themselves. I guess this is a feature that
1315 sys.excepthook themselves. I guess this is a feature that
1309 enables them to keep running after exceptions that would
1316 enables them to keep running after exceptions that would
1310 otherwise kill their mainloop. This is a bother for IPython
1317 otherwise kill their mainloop. This is a bother for IPython
1311 which excepts to catch all of the program exceptions with a try:
1318 which excepts to catch all of the program exceptions with a try:
1312 except: statement.
1319 except: statement.
1313
1320
1314 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1321 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1315 any app directly invokes sys.excepthook, it will look to the user like
1322 any app directly invokes sys.excepthook, it will look to the user like
1316 IPython crashed. In order to work around this, we can disable the
1323 IPython crashed. In order to work around this, we can disable the
1317 CrashHandler and replace it with this excepthook instead, which prints a
1324 CrashHandler and replace it with this excepthook instead, which prints a
1318 regular traceback using our InteractiveTB. In this fashion, apps which
1325 regular traceback using our InteractiveTB. In this fashion, apps which
1319 call sys.excepthook will generate a regular-looking exception from
1326 call sys.excepthook will generate a regular-looking exception from
1320 IPython, and the CrashHandler will only be triggered by real IPython
1327 IPython, and the CrashHandler will only be triggered by real IPython
1321 crashes.
1328 crashes.
1322
1329
1323 This hook should be used sparingly, only in places which are not likely
1330 This hook should be used sparingly, only in places which are not likely
1324 to be true IPython errors.
1331 to be true IPython errors.
1325 """
1332 """
1326
1333
1327 self.InteractiveTB(type, value, tb, tb_offset=0)
1334 self.InteractiveTB(type, value, tb, tb_offset=0)
1328 if self.InteractiveTB.call_pdb and self.has_readline:
1335 if self.InteractiveTB.call_pdb and self.has_readline:
1329 self.readline.set_completer(self.Completer.complete)
1336 self.readline.set_completer(self.Completer.complete)
1330
1337
1331 def call_alias(self,alias,rest=''):
1338 def call_alias(self,alias,rest=''):
1332 """Call an alias given its name and the rest of the line.
1339 """Call an alias given its name and the rest of the line.
1333
1340
1334 This function MUST be given a proper alias, because it doesn't make
1341 This function MUST be given a proper alias, because it doesn't make
1335 any checks when looking up into the alias table. The caller is
1342 any checks when looking up into the alias table. The caller is
1336 responsible for invoking it only with a valid alias."""
1343 responsible for invoking it only with a valid alias."""
1337
1344
1338 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1345 #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg
1339 nargs,cmd = self.alias_table[alias]
1346 nargs,cmd = self.alias_table[alias]
1340 # Expand the %l special to be the user's input line
1347 # Expand the %l special to be the user's input line
1341 if cmd.find('%l') >= 0:
1348 if cmd.find('%l') >= 0:
1342 cmd = cmd.replace('%l',rest)
1349 cmd = cmd.replace('%l',rest)
1343 rest = ''
1350 rest = ''
1344 if nargs==0:
1351 if nargs==0:
1345 # Simple, argument-less aliases
1352 # Simple, argument-less aliases
1346 cmd = '%s %s' % (cmd,rest)
1353 cmd = '%s %s' % (cmd,rest)
1347 else:
1354 else:
1348 # Handle aliases with positional arguments
1355 # Handle aliases with positional arguments
1349 args = rest.split(None,nargs)
1356 args = rest.split(None,nargs)
1350 if len(args)< nargs:
1357 if len(args)< nargs:
1351 error('Alias <%s> requires %s arguments, %s given.' %
1358 error('Alias <%s> requires %s arguments, %s given.' %
1352 (alias,nargs,len(args)))
1359 (alias,nargs,len(args)))
1353 return
1360 return
1354 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1361 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1355 # Now call the macro, evaluating in the user's namespace
1362 # Now call the macro, evaluating in the user's namespace
1356 try:
1363 try:
1357 self.system(cmd)
1364 self.system(cmd)
1358 except:
1365 except:
1359 self.showtraceback()
1366 self.showtraceback()
1360
1367
1361 def runlines(self,lines):
1368 def runlines(self,lines):
1362 """Run a string of one or more lines of source.
1369 """Run a string of one or more lines of source.
1363
1370
1364 This method is capable of running a string containing multiple source
1371 This method is capable of running a string containing multiple source
1365 lines, as if they had been entered at the IPython prompt. Since it
1372 lines, as if they had been entered at the IPython prompt. Since it
1366 exposes IPython's processing machinery, the given strings can contain
1373 exposes IPython's processing machinery, the given strings can contain
1367 magic calls (%magic), special shell access (!cmd), etc."""
1374 magic calls (%magic), special shell access (!cmd), etc."""
1368
1375
1369 # We must start with a clean buffer, in case this is run from an
1376 # We must start with a clean buffer, in case this is run from an
1370 # interactive IPython session (via a magic, for example).
1377 # interactive IPython session (via a magic, for example).
1371 self.resetbuffer()
1378 self.resetbuffer()
1372 lines = lines.split('\n')
1379 lines = lines.split('\n')
1373 more = 0
1380 more = 0
1374 for line in lines:
1381 for line in lines:
1375 # skip blank lines so we don't mess up the prompt counter, but do
1382 # skip blank lines so we don't mess up the prompt counter, but do
1376 # NOT skip even a blank line if we are in a code block (more is
1383 # NOT skip even a blank line if we are in a code block (more is
1377 # true)
1384 # true)
1378 if line or more:
1385 if line or more:
1379 more = self.push((self.prefilter(line,more)))
1386 more = self.push((self.prefilter(line,more)))
1380 # IPython's runsource returns None if there was an error
1387 # IPython's runsource returns None if there was an error
1381 # compiling the code. This allows us to stop processing right
1388 # compiling the code. This allows us to stop processing right
1382 # away, so the user gets the error message at the right place.
1389 # away, so the user gets the error message at the right place.
1383 if more is None:
1390 if more is None:
1384 break
1391 break
1385 # final newline in case the input didn't have it, so that the code
1392 # final newline in case the input didn't have it, so that the code
1386 # actually does get executed
1393 # actually does get executed
1387 if more:
1394 if more:
1388 self.push('\n')
1395 self.push('\n')
1389
1396
1390 def runsource(self, source, filename='<input>', symbol='single'):
1397 def runsource(self, source, filename='<input>', symbol='single'):
1391 """Compile and run some source in the interpreter.
1398 """Compile and run some source in the interpreter.
1392
1399
1393 Arguments are as for compile_command().
1400 Arguments are as for compile_command().
1394
1401
1395 One several things can happen:
1402 One several things can happen:
1396
1403
1397 1) The input is incorrect; compile_command() raised an
1404 1) The input is incorrect; compile_command() raised an
1398 exception (SyntaxError or OverflowError). A syntax traceback
1405 exception (SyntaxError or OverflowError). A syntax traceback
1399 will be printed by calling the showsyntaxerror() method.
1406 will be printed by calling the showsyntaxerror() method.
1400
1407
1401 2) The input is incomplete, and more input is required;
1408 2) The input is incomplete, and more input is required;
1402 compile_command() returned None. Nothing happens.
1409 compile_command() returned None. Nothing happens.
1403
1410
1404 3) The input is complete; compile_command() returned a code
1411 3) The input is complete; compile_command() returned a code
1405 object. The code is executed by calling self.runcode() (which
1412 object. The code is executed by calling self.runcode() (which
1406 also handles run-time exceptions, except for SystemExit).
1413 also handles run-time exceptions, except for SystemExit).
1407
1414
1408 The return value is:
1415 The return value is:
1409
1416
1410 - True in case 2
1417 - True in case 2
1411
1418
1412 - False in the other cases, unless an exception is raised, where
1419 - False in the other cases, unless an exception is raised, where
1413 None is returned instead. This can be used by external callers to
1420 None is returned instead. This can be used by external callers to
1414 know whether to continue feeding input or not.
1421 know whether to continue feeding input or not.
1415
1422
1416 The return value can be used to decide whether to use sys.ps1 or
1423 The return value can be used to decide whether to use sys.ps1 or
1417 sys.ps2 to prompt the next line."""
1424 sys.ps2 to prompt the next line."""
1418
1425
1419 try:
1426 try:
1420 code = self.compile(source,filename,symbol)
1427 code = self.compile(source,filename,symbol)
1421 except (OverflowError, SyntaxError, ValueError):
1428 except (OverflowError, SyntaxError, ValueError):
1422 # Case 1
1429 # Case 1
1423 self.showsyntaxerror(filename)
1430 self.showsyntaxerror(filename)
1424 return None
1431 return None
1425
1432
1426 if code is None:
1433 if code is None:
1427 # Case 2
1434 # Case 2
1428 return True
1435 return True
1429
1436
1430 # Case 3
1437 # Case 3
1431 # We store the code object so that threaded shells and
1438 # We store the code object so that threaded shells and
1432 # custom exception handlers can access all this info if needed.
1439 # custom exception handlers can access all this info if needed.
1433 # The source corresponding to this can be obtained from the
1440 # The source corresponding to this can be obtained from the
1434 # buffer attribute as '\n'.join(self.buffer).
1441 # buffer attribute as '\n'.join(self.buffer).
1435 self.code_to_run = code
1442 self.code_to_run = code
1436 # now actually execute the code object
1443 # now actually execute the code object
1437 if self.runcode(code) == 0:
1444 if self.runcode(code) == 0:
1438 return False
1445 return False
1439 else:
1446 else:
1440 return None
1447 return None
1441
1448
1442 def runcode(self,code_obj):
1449 def runcode(self,code_obj):
1443 """Execute a code object.
1450 """Execute a code object.
1444
1451
1445 When an exception occurs, self.showtraceback() is called to display a
1452 When an exception occurs, self.showtraceback() is called to display a
1446 traceback.
1453 traceback.
1447
1454
1448 Return value: a flag indicating whether the code to be run completed
1455 Return value: a flag indicating whether the code to be run completed
1449 successfully:
1456 successfully:
1450
1457
1451 - 0: successful execution.
1458 - 0: successful execution.
1452 - 1: an error occurred.
1459 - 1: an error occurred.
1453 """
1460 """
1454
1461
1455 # Set our own excepthook in case the user code tries to call it
1462 # Set our own excepthook in case the user code tries to call it
1456 # directly, so that the IPython crash handler doesn't get triggered
1463 # directly, so that the IPython crash handler doesn't get triggered
1457 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1464 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1458 outflag = 1 # happens in more places, so it's easier as default
1465 outflag = 1 # happens in more places, so it's easier as default
1459 try:
1466 try:
1460 try:
1467 try:
1461 # Embedded instances require separate global/local namespaces
1468 # Embedded instances require separate global/local namespaces
1462 # so they can see both the surrounding (local) namespace and
1469 # so they can see both the surrounding (local) namespace and
1463 # the module-level globals when called inside another function.
1470 # the module-level globals when called inside another function.
1464 if self.embedded:
1471 if self.embedded:
1465 exec code_obj in self.user_global_ns, self.user_ns
1472 exec code_obj in self.user_global_ns, self.user_ns
1466 # Normal (non-embedded) instances should only have a single
1473 # Normal (non-embedded) instances should only have a single
1467 # namespace for user code execution, otherwise functions won't
1474 # namespace for user code execution, otherwise functions won't
1468 # see interactive top-level globals.
1475 # see interactive top-level globals.
1469 else:
1476 else:
1470 exec code_obj in self.user_ns
1477 exec code_obj in self.user_ns
1471 finally:
1478 finally:
1472 # Reset our crash handler in place
1479 # Reset our crash handler in place
1473 sys.excepthook = old_excepthook
1480 sys.excepthook = old_excepthook
1474 except SystemExit:
1481 except SystemExit:
1475 self.resetbuffer()
1482 self.resetbuffer()
1476 self.showtraceback()
1483 self.showtraceback()
1477 warn("Type exit or quit to exit IPython "
1484 warn("Type exit or quit to exit IPython "
1478 "(%Exit or %Quit do so unconditionally).",level=1)
1485 "(%Exit or %Quit do so unconditionally).",level=1)
1479 except self.custom_exceptions:
1486 except self.custom_exceptions:
1480 etype,value,tb = sys.exc_info()
1487 etype,value,tb = sys.exc_info()
1481 self.CustomTB(etype,value,tb)
1488 self.CustomTB(etype,value,tb)
1482 except:
1489 except:
1483 self.showtraceback()
1490 self.showtraceback()
1484 else:
1491 else:
1485 outflag = 0
1492 outflag = 0
1486 if softspace(sys.stdout, 0):
1493 if softspace(sys.stdout, 0):
1487 print
1494 print
1488 # Flush out code object which has been run (and source)
1495 # Flush out code object which has been run (and source)
1489 self.code_to_run = None
1496 self.code_to_run = None
1490 return outflag
1497 return outflag
1491
1498
1492 def push(self, line):
1499 def push(self, line):
1493 """Push a line to the interpreter.
1500 """Push a line to the interpreter.
1494
1501
1495 The line should not have a trailing newline; it may have
1502 The line should not have a trailing newline; it may have
1496 internal newlines. The line is appended to a buffer and the
1503 internal newlines. The line is appended to a buffer and the
1497 interpreter's runsource() method is called with the
1504 interpreter's runsource() method is called with the
1498 concatenated contents of the buffer as source. If this
1505 concatenated contents of the buffer as source. If this
1499 indicates that the command was executed or invalid, the buffer
1506 indicates that the command was executed or invalid, the buffer
1500 is reset; otherwise, the command is incomplete, and the buffer
1507 is reset; otherwise, the command is incomplete, and the buffer
1501 is left as it was after the line was appended. The return
1508 is left as it was after the line was appended. The return
1502 value is 1 if more input is required, 0 if the line was dealt
1509 value is 1 if more input is required, 0 if the line was dealt
1503 with in some way (this is the same as runsource()).
1510 with in some way (this is the same as runsource()).
1504
1511
1505 """
1512 """
1506 self.buffer.append(line)
1513 self.buffer.append(line)
1507 more = self.runsource('\n'.join(self.buffer), self.filename)
1514 more = self.runsource('\n'.join(self.buffer), self.filename)
1508 if not more:
1515 if not more:
1509 self.resetbuffer()
1516 self.resetbuffer()
1510 return more
1517 return more
1511
1518
1512 def resetbuffer(self):
1519 def resetbuffer(self):
1513 """Reset the input buffer."""
1520 """Reset the input buffer."""
1514 self.buffer[:] = []
1521 self.buffer[:] = []
1515
1522
1516 def raw_input(self,prompt='',continue_prompt=False):
1523 def raw_input(self,prompt='',continue_prompt=False):
1517 """Write a prompt and read a line.
1524 """Write a prompt and read a line.
1518
1525
1519 The returned line does not include the trailing newline.
1526 The returned line does not include the trailing newline.
1520 When the user enters the EOF key sequence, EOFError is raised.
1527 When the user enters the EOF key sequence, EOFError is raised.
1521
1528
1522 Optional inputs:
1529 Optional inputs:
1523
1530
1524 - prompt(''): a string to be printed to prompt the user.
1531 - prompt(''): a string to be printed to prompt the user.
1525
1532
1526 - continue_prompt(False): whether this line is the first one or a
1533 - continue_prompt(False): whether this line is the first one or a
1527 continuation in a sequence of inputs.
1534 continuation in a sequence of inputs.
1528 """
1535 """
1529
1536
1530 line = raw_input_original(prompt)
1537 line = raw_input_original(prompt)
1531 # Try to be reasonably smart about not re-indenting pasted input more
1538 # Try to be reasonably smart about not re-indenting pasted input more
1532 # than necessary. We do this by trimming out the auto-indent initial
1539 # than necessary. We do this by trimming out the auto-indent initial
1533 # spaces, if the user's actual input started itself with whitespace.
1540 # spaces, if the user's actual input started itself with whitespace.
1534 if self.autoindent:
1541 if self.autoindent:
1535 line2 = line[self.indent_current_nsp:]
1542 line2 = line[self.indent_current_nsp:]
1536 if line2[0:1] in (' ','\t'):
1543 if line2[0:1] in (' ','\t'):
1537 line = line2
1544 line = line2
1538 return self.prefilter(line,continue_prompt)
1545 return self.prefilter(line,continue_prompt)
1539
1546
1540 def split_user_input(self,line):
1547 def split_user_input(self,line):
1541 """Split user input into pre-char, function part and rest."""
1548 """Split user input into pre-char, function part and rest."""
1542
1549
1543 lsplit = self.line_split.match(line)
1550 lsplit = self.line_split.match(line)
1544 if lsplit is None: # no regexp match returns None
1551 if lsplit is None: # no regexp match returns None
1545 try:
1552 try:
1546 iFun,theRest = line.split(None,1)
1553 iFun,theRest = line.split(None,1)
1547 except ValueError:
1554 except ValueError:
1548 iFun,theRest = line,''
1555 iFun,theRest = line,''
1549 pre = re.match('^(\s*)(.*)',line).groups()[0]
1556 pre = re.match('^(\s*)(.*)',line).groups()[0]
1550 else:
1557 else:
1551 pre,iFun,theRest = lsplit.groups()
1558 pre,iFun,theRest = lsplit.groups()
1552
1559
1553 #print 'line:<%s>' % line # dbg
1560 #print 'line:<%s>' % line # dbg
1554 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1561 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
1555 return pre,iFun.strip(),theRest
1562 return pre,iFun.strip(),theRest
1556
1563
1557 def _prefilter(self, line, continue_prompt):
1564 def _prefilter(self, line, continue_prompt):
1558 """Calls different preprocessors, depending on the form of line."""
1565 """Calls different preprocessors, depending on the form of line."""
1559
1566
1560 # All handlers *must* return a value, even if it's blank ('').
1567 # All handlers *must* return a value, even if it's blank ('').
1561
1568
1562 # Lines are NOT logged here. Handlers should process the line as
1569 # Lines are NOT logged here. Handlers should process the line as
1563 # needed, update the cache AND log it (so that the input cache array
1570 # needed, update the cache AND log it (so that the input cache array
1564 # stays synced).
1571 # stays synced).
1565
1572
1566 # This function is _very_ delicate, and since it's also the one which
1573 # This function is _very_ delicate, and since it's also the one which
1567 # determines IPython's response to user input, it must be as efficient
1574 # determines IPython's response to user input, it must be as efficient
1568 # as possible. For this reason it has _many_ returns in it, trying
1575 # as possible. For this reason it has _many_ returns in it, trying
1569 # always to exit as quickly as it can figure out what it needs to do.
1576 # always to exit as quickly as it can figure out what it needs to do.
1570
1577
1571 # This function is the main responsible for maintaining IPython's
1578 # This function is the main responsible for maintaining IPython's
1572 # behavior respectful of Python's semantics. So be _very_ careful if
1579 # behavior respectful of Python's semantics. So be _very_ careful if
1573 # making changes to anything here.
1580 # making changes to anything here.
1574
1581
1575 #.....................................................................
1582 #.....................................................................
1576 # Code begins
1583 # Code begins
1577
1584
1578 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1585 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
1579
1586
1580 # save the line away in case we crash, so the post-mortem handler can
1587 # save the line away in case we crash, so the post-mortem handler can
1581 # record it
1588 # record it
1582 self._last_input_line = line
1589 self._last_input_line = line
1583
1590
1584 #print '***line: <%s>' % line # dbg
1591 #print '***line: <%s>' % line # dbg
1585
1592
1586 # the input history needs to track even empty lines
1593 # the input history needs to track even empty lines
1587 if not line.strip():
1594 if not line.strip():
1588 if not continue_prompt:
1595 if not continue_prompt:
1589 self.outputcache.prompt_count -= 1
1596 self.outputcache.prompt_count -= 1
1590 return self.handle_normal(line,continue_prompt)
1597 return self.handle_normal(line,continue_prompt)
1591 #return self.handle_normal('',continue_prompt)
1598 #return self.handle_normal('',continue_prompt)
1592
1599
1593 # print '***cont',continue_prompt # dbg
1600 # print '***cont',continue_prompt # dbg
1594 # special handlers are only allowed for single line statements
1601 # special handlers are only allowed for single line statements
1595 if continue_prompt and not self.rc.multi_line_specials:
1602 if continue_prompt and not self.rc.multi_line_specials:
1596 return self.handle_normal(line,continue_prompt)
1603 return self.handle_normal(line,continue_prompt)
1597
1604
1598 # For the rest, we need the structure of the input
1605 # For the rest, we need the structure of the input
1599 pre,iFun,theRest = self.split_user_input(line)
1606 pre,iFun,theRest = self.split_user_input(line)
1600 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1607 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1601
1608
1602 # First check for explicit escapes in the last/first character
1609 # First check for explicit escapes in the last/first character
1603 handler = None
1610 handler = None
1604 if line[-1] == self.ESC_HELP:
1611 if line[-1] == self.ESC_HELP:
1605 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1612 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
1606 if handler is None:
1613 if handler is None:
1607 # look at the first character of iFun, NOT of line, so we skip
1614 # look at the first character of iFun, NOT of line, so we skip
1608 # leading whitespace in multiline input
1615 # leading whitespace in multiline input
1609 handler = self.esc_handlers.get(iFun[0:1])
1616 handler = self.esc_handlers.get(iFun[0:1])
1610 if handler is not None:
1617 if handler is not None:
1611 return handler(line,continue_prompt,pre,iFun,theRest)
1618 return handler(line,continue_prompt,pre,iFun,theRest)
1612 # Emacs ipython-mode tags certain input lines
1619 # Emacs ipython-mode tags certain input lines
1613 if line.endswith('# PYTHON-MODE'):
1620 if line.endswith('# PYTHON-MODE'):
1614 return self.handle_emacs(line,continue_prompt)
1621 return self.handle_emacs(line,continue_prompt)
1615
1622
1616 # Next, check if we can automatically execute this thing
1623 # Next, check if we can automatically execute this thing
1617
1624
1618 # Allow ! in multi-line statements if multi_line_specials is on:
1625 # Allow ! in multi-line statements if multi_line_specials is on:
1619 if continue_prompt and self.rc.multi_line_specials and \
1626 if continue_prompt and self.rc.multi_line_specials and \
1620 iFun.startswith(self.ESC_SHELL):
1627 iFun.startswith(self.ESC_SHELL):
1621 return self.handle_shell_escape(line,continue_prompt,
1628 return self.handle_shell_escape(line,continue_prompt,
1622 pre=pre,iFun=iFun,
1629 pre=pre,iFun=iFun,
1623 theRest=theRest)
1630 theRest=theRest)
1624
1631
1625 # Let's try to find if the input line is a magic fn
1632 # Let's try to find if the input line is a magic fn
1626 oinfo = None
1633 oinfo = None
1627 if hasattr(self,'magic_'+iFun):
1634 if hasattr(self,'magic_'+iFun):
1628 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1635 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1629 if oinfo['ismagic']:
1636 if oinfo['ismagic']:
1630 # Be careful not to call magics when a variable assignment is
1637 # Be careful not to call magics when a variable assignment is
1631 # being made (ls='hi', for example)
1638 # being made (ls='hi', for example)
1632 if self.rc.automagic and \
1639 if self.rc.automagic and \
1633 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1640 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
1634 (self.rc.multi_line_specials or not continue_prompt):
1641 (self.rc.multi_line_specials or not continue_prompt):
1635 return self.handle_magic(line,continue_prompt,
1642 return self.handle_magic(line,continue_prompt,
1636 pre,iFun,theRest)
1643 pre,iFun,theRest)
1637 else:
1644 else:
1638 return self.handle_normal(line,continue_prompt)
1645 return self.handle_normal(line,continue_prompt)
1639
1646
1640 # If the rest of the line begins with an (in)equality, assginment or
1647 # If the rest of the line begins with an (in)equality, assginment or
1641 # function call, we should not call _ofind but simply execute it.
1648 # function call, we should not call _ofind but simply execute it.
1642 # This avoids spurious geattr() accesses on objects upon assignment.
1649 # This avoids spurious geattr() accesses on objects upon assignment.
1643 #
1650 #
1644 # It also allows users to assign to either alias or magic names true
1651 # It also allows users to assign to either alias or magic names true
1645 # python variables (the magic/alias systems always take second seat to
1652 # python variables (the magic/alias systems always take second seat to
1646 # true python code).
1653 # true python code).
1647 if theRest and theRest[0] in '!=()':
1654 if theRest and theRest[0] in '!=()':
1648 return self.handle_normal(line,continue_prompt)
1655 return self.handle_normal(line,continue_prompt)
1649
1656
1650 if oinfo is None:
1657 if oinfo is None:
1651 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1658 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
1652
1659
1653 if not oinfo['found']:
1660 if not oinfo['found']:
1654 return self.handle_normal(line,continue_prompt)
1661 return self.handle_normal(line,continue_prompt)
1655 else:
1662 else:
1656 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1663 #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg
1657 if oinfo['isalias']:
1664 if oinfo['isalias']:
1658 return self.handle_alias(line,continue_prompt,
1665 return self.handle_alias(line,continue_prompt,
1659 pre,iFun,theRest)
1666 pre,iFun,theRest)
1660
1667
1661 if self.rc.autocall and \
1668 if self.rc.autocall and \
1662 not self.re_exclude_auto.match(theRest) and \
1669 not self.re_exclude_auto.match(theRest) and \
1663 self.re_fun_name.match(iFun) and \
1670 self.re_fun_name.match(iFun) and \
1664 callable(oinfo['obj']) :
1671 callable(oinfo['obj']) :
1665 #print 'going auto' # dbg
1672 #print 'going auto' # dbg
1666 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1673 return self.handle_auto(line,continue_prompt,pre,iFun,theRest)
1667 else:
1674 else:
1668 #print 'was callable?', callable(oinfo['obj']) # dbg
1675 #print 'was callable?', callable(oinfo['obj']) # dbg
1669 return self.handle_normal(line,continue_prompt)
1676 return self.handle_normal(line,continue_prompt)
1670
1677
1671 # If we get here, we have a normal Python line. Log and return.
1678 # If we get here, we have a normal Python line. Log and return.
1672 return self.handle_normal(line,continue_prompt)
1679 return self.handle_normal(line,continue_prompt)
1673
1680
1674 def _prefilter_dumb(self, line, continue_prompt):
1681 def _prefilter_dumb(self, line, continue_prompt):
1675 """simple prefilter function, for debugging"""
1682 """simple prefilter function, for debugging"""
1676 return self.handle_normal(line,continue_prompt)
1683 return self.handle_normal(line,continue_prompt)
1677
1684
1678 # Set the default prefilter() function (this can be user-overridden)
1685 # Set the default prefilter() function (this can be user-overridden)
1679 prefilter = _prefilter
1686 prefilter = _prefilter
1680
1687
1681 def handle_normal(self,line,continue_prompt=None,
1688 def handle_normal(self,line,continue_prompt=None,
1682 pre=None,iFun=None,theRest=None):
1689 pre=None,iFun=None,theRest=None):
1683 """Handle normal input lines. Use as a template for handlers."""
1690 """Handle normal input lines. Use as a template for handlers."""
1684
1691
1685 # With autoindent on, we need some way to exit the input loop, and I
1692 # With autoindent on, we need some way to exit the input loop, and I
1686 # don't want to force the user to have to backspace all the way to
1693 # don't want to force the user to have to backspace all the way to
1687 # clear the line. The rule will be in this case, that either two
1694 # clear the line. The rule will be in this case, that either two
1688 # lines of pure whitespace in a row, or a line of pure whitespace but
1695 # lines of pure whitespace in a row, or a line of pure whitespace but
1689 # of a size different to the indent level, will exit the input loop.
1696 # of a size different to the indent level, will exit the input loop.
1690 if (continue_prompt and self.autoindent and isspace(line) and
1697 if (continue_prompt and self.autoindent and isspace(line) and
1691 (line != self.indent_current or isspace(self.buffer[-1]))):
1698 (line != self.indent_current or isspace(self.buffer[-1]))):
1692 line = ''
1699 line = ''
1693
1700
1694 self.log(line,continue_prompt)
1701 self.log(line,continue_prompt)
1695 self.update_cache(line)
1702 self.update_cache(line)
1696 return line
1703 return line
1697
1704
1698 def handle_alias(self,line,continue_prompt=None,
1705 def handle_alias(self,line,continue_prompt=None,
1699 pre=None,iFun=None,theRest=None):
1706 pre=None,iFun=None,theRest=None):
1700 """Handle alias input lines. """
1707 """Handle alias input lines. """
1701
1708
1702 theRest = esc_quotes(theRest)
1709 theRest = esc_quotes(theRest)
1703 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1710 line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest)
1704 self.log(line_out,continue_prompt)
1711 self.log(line_out,continue_prompt)
1705 self.update_cache(line_out)
1712 self.update_cache(line_out)
1706 return line_out
1713 return line_out
1707
1714
1708 def handle_shell_escape(self, line, continue_prompt=None,
1715 def handle_shell_escape(self, line, continue_prompt=None,
1709 pre=None,iFun=None,theRest=None):
1716 pre=None,iFun=None,theRest=None):
1710 """Execute the line in a shell, empty return value"""
1717 """Execute the line in a shell, empty return value"""
1711
1718
1712 #print 'line in :', `line` # dbg
1719 #print 'line in :', `line` # dbg
1713 # Example of a special handler. Others follow a similar pattern.
1720 # Example of a special handler. Others follow a similar pattern.
1714 if continue_prompt: # multi-line statements
1721 if continue_prompt: # multi-line statements
1715 if iFun.startswith('!!'):
1722 if iFun.startswith('!!'):
1716 print 'SyntaxError: !! is not allowed in multiline statements'
1723 print 'SyntaxError: !! is not allowed in multiline statements'
1717 return pre
1724 return pre
1718 else:
1725 else:
1719 cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"')
1726 cmd = ("%s %s" % (iFun[1:],theRest)) #.replace('"','\\"')
1720 #line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1727 #line_out = '%s%s.system("%s")' % (pre,self.name,cmd)
1721 line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_")
1728 line_out = '%s%s.system(r"""%s"""[:-1])' % (pre,self.name,cmd + "_")
1722 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1729 #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')'
1723 else: # single-line input
1730 else: # single-line input
1724 if line.startswith('!!'):
1731 if line.startswith('!!'):
1725 # rewrite iFun/theRest to properly hold the call to %sx and
1732 # rewrite iFun/theRest to properly hold the call to %sx and
1726 # the actual command to be executed, so handle_magic can work
1733 # the actual command to be executed, so handle_magic can work
1727 # correctly
1734 # correctly
1728 theRest = '%s %s' % (iFun[2:],theRest)
1735 theRest = '%s %s' % (iFun[2:],theRest)
1729 iFun = 'sx'
1736 iFun = 'sx'
1730 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1737 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]),
1731 continue_prompt,pre,iFun,theRest)
1738 continue_prompt,pre,iFun,theRest)
1732 else:
1739 else:
1733 #cmd = esc_quotes(line[1:])
1740 #cmd = esc_quotes(line[1:])
1734 cmd=line[1:]
1741 cmd=line[1:]
1735 #line_out = '%s.system("%s")' % (self.name,cmd)
1742 #line_out = '%s.system("%s")' % (self.name,cmd)
1736 line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_")
1743 line_out = '%s.system(r"""%s"""[:-1])' % (self.name,cmd +"_")
1737 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1744 #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')'
1738 # update cache/log and return
1745 # update cache/log and return
1739 self.log(line_out,continue_prompt)
1746 self.log(line_out,continue_prompt)
1740 self.update_cache(line_out) # readline cache gets normal line
1747 self.update_cache(line_out) # readline cache gets normal line
1741 #print 'line out r:', `line_out` # dbg
1748 #print 'line out r:', `line_out` # dbg
1742 #print 'line out s:', line_out # dbg
1749 #print 'line out s:', line_out # dbg
1743 return line_out
1750 return line_out
1744
1751
1745 def handle_magic(self, line, continue_prompt=None,
1752 def handle_magic(self, line, continue_prompt=None,
1746 pre=None,iFun=None,theRest=None):
1753 pre=None,iFun=None,theRest=None):
1747 """Execute magic functions.
1754 """Execute magic functions.
1748
1755
1749 Also log them with a prepended # so the log is clean Python."""
1756 Also log them with a prepended # so the log is clean Python."""
1750
1757
1751 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1758 cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest)))
1752 self.log(cmd,continue_prompt)
1759 self.log(cmd,continue_prompt)
1753 self.update_cache(line)
1760 self.update_cache(line)
1754 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1761 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
1755 return cmd
1762 return cmd
1756
1763
1757 def handle_auto(self, line, continue_prompt=None,
1764 def handle_auto(self, line, continue_prompt=None,
1758 pre=None,iFun=None,theRest=None):
1765 pre=None,iFun=None,theRest=None):
1759 """Hande lines which can be auto-executed, quoting if requested."""
1766 """Hande lines which can be auto-executed, quoting if requested."""
1760
1767
1761 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1768 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1762
1769
1763 # This should only be active for single-line input!
1770 # This should only be active for single-line input!
1764 if continue_prompt:
1771 if continue_prompt:
1765 return line
1772 return line
1766
1773
1767 if pre == self.ESC_QUOTE:
1774 if pre == self.ESC_QUOTE:
1768 # Auto-quote splitting on whitespace
1775 # Auto-quote splitting on whitespace
1769 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1776 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
1770 elif pre == self.ESC_QUOTE2:
1777 elif pre == self.ESC_QUOTE2:
1771 # Auto-quote whole string
1778 # Auto-quote whole string
1772 newcmd = '%s("%s")' % (iFun,theRest)
1779 newcmd = '%s("%s")' % (iFun,theRest)
1773 else:
1780 else:
1774 # Auto-paren
1781 # Auto-paren
1775 if theRest[0:1] in ('=','['):
1782 if theRest[0:1] in ('=','['):
1776 # Don't autocall in these cases. They can be either
1783 # Don't autocall in these cases. They can be either
1777 # rebindings of an existing callable's name, or item access
1784 # rebindings of an existing callable's name, or item access
1778 # for an object which is BOTH callable and implements
1785 # for an object which is BOTH callable and implements
1779 # __getitem__.
1786 # __getitem__.
1780 return '%s %s' % (iFun,theRest)
1787 return '%s %s' % (iFun,theRest)
1781 if theRest.endswith(';'):
1788 if theRest.endswith(';'):
1782 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1789 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
1783 else:
1790 else:
1784 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1791 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
1785
1792
1786 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1793 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
1787 # log what is now valid Python, not the actual user input (without the
1794 # log what is now valid Python, not the actual user input (without the
1788 # final newline)
1795 # final newline)
1789 self.log(newcmd,continue_prompt)
1796 self.log(newcmd,continue_prompt)
1790 return newcmd
1797 return newcmd
1791
1798
1792 def handle_help(self, line, continue_prompt=None,
1799 def handle_help(self, line, continue_prompt=None,
1793 pre=None,iFun=None,theRest=None):
1800 pre=None,iFun=None,theRest=None):
1794 """Try to get some help for the object.
1801 """Try to get some help for the object.
1795
1802
1796 obj? or ?obj -> basic information.
1803 obj? or ?obj -> basic information.
1797 obj?? or ??obj -> more details.
1804 obj?? or ??obj -> more details.
1798 """
1805 """
1799
1806
1800 # We need to make sure that we don't process lines which would be
1807 # We need to make sure that we don't process lines which would be
1801 # otherwise valid python, such as "x=1 # what?"
1808 # otherwise valid python, such as "x=1 # what?"
1802 try:
1809 try:
1803 codeop.compile_command(line)
1810 codeop.compile_command(line)
1804 except SyntaxError:
1811 except SyntaxError:
1805 # We should only handle as help stuff which is NOT valid syntax
1812 # We should only handle as help stuff which is NOT valid syntax
1806 if line[0]==self.ESC_HELP:
1813 if line[0]==self.ESC_HELP:
1807 line = line[1:]
1814 line = line[1:]
1808 elif line[-1]==self.ESC_HELP:
1815 elif line[-1]==self.ESC_HELP:
1809 line = line[:-1]
1816 line = line[:-1]
1810 self.log('#?'+line)
1817 self.log('#?'+line)
1811 self.update_cache(line)
1818 self.update_cache(line)
1812 if line:
1819 if line:
1813 self.magic_pinfo(line)
1820 self.magic_pinfo(line)
1814 else:
1821 else:
1815 page(self.usage,screen_lines=self.rc.screen_length)
1822 page(self.usage,screen_lines=self.rc.screen_length)
1816 return '' # Empty string is needed here!
1823 return '' # Empty string is needed here!
1817 except:
1824 except:
1818 # Pass any other exceptions through to the normal handler
1825 # Pass any other exceptions through to the normal handler
1819 return self.handle_normal(line,continue_prompt)
1826 return self.handle_normal(line,continue_prompt)
1820 else:
1827 else:
1821 # If the code compiles ok, we should handle it normally
1828 # If the code compiles ok, we should handle it normally
1822 return self.handle_normal(line,continue_prompt)
1829 return self.handle_normal(line,continue_prompt)
1823
1830
1824 def handle_emacs(self,line,continue_prompt=None,
1831 def handle_emacs(self,line,continue_prompt=None,
1825 pre=None,iFun=None,theRest=None):
1832 pre=None,iFun=None,theRest=None):
1826 """Handle input lines marked by python-mode."""
1833 """Handle input lines marked by python-mode."""
1827
1834
1828 # Currently, nothing is done. Later more functionality can be added
1835 # Currently, nothing is done. Later more functionality can be added
1829 # here if needed.
1836 # here if needed.
1830
1837
1831 # The input cache shouldn't be updated
1838 # The input cache shouldn't be updated
1832
1839
1833 return line
1840 return line
1834
1841
1835 def write(self,data):
1842 def write(self,data):
1836 """Write a string to the default output"""
1843 """Write a string to the default output"""
1837 Term.cout.write(data)
1844 Term.cout.write(data)
1838
1845
1839 def write_err(self,data):
1846 def write_err(self,data):
1840 """Write a string to the default error output"""
1847 """Write a string to the default error output"""
1841 Term.cerr.write(data)
1848 Term.cerr.write(data)
1842
1849
1843 def exit(self):
1850 def exit(self):
1844 """Handle interactive exit.
1851 """Handle interactive exit.
1845
1852
1846 This method sets the exit_now attribute."""
1853 This method sets the exit_now attribute."""
1847
1854
1848 if self.rc.confirm_exit:
1855 if self.rc.confirm_exit:
1849 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1856 if ask_yes_no('Do you really want to exit ([y]/n)?','y'):
1850 self.exit_now = True
1857 self.exit_now = True
1851 else:
1858 else:
1852 self.exit_now = True
1859 self.exit_now = True
1853 return self.exit_now
1860 return self.exit_now
1854
1861
1855 def safe_execfile(self,fname,*where,**kw):
1862 def safe_execfile(self,fname,*where,**kw):
1856 fname = os.path.expanduser(fname)
1863 fname = os.path.expanduser(fname)
1857
1864
1858 # find things also in current directory
1865 # find things also in current directory
1859 dname = os.path.dirname(fname)
1866 dname = os.path.dirname(fname)
1860 if not sys.path.count(dname):
1867 if not sys.path.count(dname):
1861 sys.path.append(dname)
1868 sys.path.append(dname)
1862
1869
1863 try:
1870 try:
1864 xfile = open(fname)
1871 xfile = open(fname)
1865 except:
1872 except:
1866 print >> Term.cerr, \
1873 print >> Term.cerr, \
1867 'Could not open file <%s> for safe execution.' % fname
1874 'Could not open file <%s> for safe execution.' % fname
1868 return None
1875 return None
1869
1876
1870 kw.setdefault('islog',0)
1877 kw.setdefault('islog',0)
1871 kw.setdefault('quiet',1)
1878 kw.setdefault('quiet',1)
1872 kw.setdefault('exit_ignore',0)
1879 kw.setdefault('exit_ignore',0)
1873 first = xfile.readline()
1880 first = xfile.readline()
1874 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1881 _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip()
1875 xfile.close()
1882 xfile.close()
1876 # line by line execution
1883 # line by line execution
1877 if first.startswith(_LOGHEAD) or kw['islog']:
1884 if first.startswith(_LOGHEAD) or kw['islog']:
1878 print 'Loading log file <%s> one line at a time...' % fname
1885 print 'Loading log file <%s> one line at a time...' % fname
1879 if kw['quiet']:
1886 if kw['quiet']:
1880 stdout_save = sys.stdout
1887 stdout_save = sys.stdout
1881 sys.stdout = StringIO.StringIO()
1888 sys.stdout = StringIO.StringIO()
1882 try:
1889 try:
1883 globs,locs = where[0:2]
1890 globs,locs = where[0:2]
1884 except:
1891 except:
1885 try:
1892 try:
1886 globs = locs = where[0]
1893 globs = locs = where[0]
1887 except:
1894 except:
1888 globs = locs = globals()
1895 globs = locs = globals()
1889 badblocks = []
1896 badblocks = []
1890
1897
1891 # we also need to identify indented blocks of code when replaying
1898 # we also need to identify indented blocks of code when replaying
1892 # logs and put them together before passing them to an exec
1899 # logs and put them together before passing them to an exec
1893 # statement. This takes a bit of regexp and look-ahead work in the
1900 # statement. This takes a bit of regexp and look-ahead work in the
1894 # file. It's easiest if we swallow the whole thing in memory
1901 # file. It's easiest if we swallow the whole thing in memory
1895 # first, and manually walk through the lines list moving the
1902 # first, and manually walk through the lines list moving the
1896 # counter ourselves.
1903 # counter ourselves.
1897 indent_re = re.compile('\s+\S')
1904 indent_re = re.compile('\s+\S')
1898 xfile = open(fname)
1905 xfile = open(fname)
1899 filelines = xfile.readlines()
1906 filelines = xfile.readlines()
1900 xfile.close()
1907 xfile.close()
1901 nlines = len(filelines)
1908 nlines = len(filelines)
1902 lnum = 0
1909 lnum = 0
1903 while lnum < nlines:
1910 while lnum < nlines:
1904 line = filelines[lnum]
1911 line = filelines[lnum]
1905 lnum += 1
1912 lnum += 1
1906 # don't re-insert logger status info into cache
1913 # don't re-insert logger status info into cache
1907 if line.startswith('#log#'):
1914 if line.startswith('#log#'):
1908 continue
1915 continue
1909 elif line.startswith('#%s'% self.ESC_MAGIC):
1916 elif line.startswith('#%s'% self.ESC_MAGIC):
1910 self.update_cache(line[1:])
1917 self.update_cache(line[1:])
1911 line = magic2python(line)
1918 line = magic2python(line)
1912 elif line.startswith('#!'):
1919 elif line.startswith('#!'):
1913 self.update_cache(line[1:])
1920 self.update_cache(line[1:])
1914 else:
1921 else:
1915 # build a block of code (maybe a single line) for execution
1922 # build a block of code (maybe a single line) for execution
1916 block = line
1923 block = line
1917 try:
1924 try:
1918 next = filelines[lnum] # lnum has already incremented
1925 next = filelines[lnum] # lnum has already incremented
1919 except:
1926 except:
1920 next = None
1927 next = None
1921 while next and indent_re.match(next):
1928 while next and indent_re.match(next):
1922 block += next
1929 block += next
1923 lnum += 1
1930 lnum += 1
1924 try:
1931 try:
1925 next = filelines[lnum]
1932 next = filelines[lnum]
1926 except:
1933 except:
1927 next = None
1934 next = None
1928 # now execute the block of one or more lines
1935 # now execute the block of one or more lines
1929 try:
1936 try:
1930 exec block in globs,locs
1937 exec block in globs,locs
1931 self.update_cache(block.rstrip())
1938 self.update_cache(block.rstrip())
1932 except SystemExit:
1939 except SystemExit:
1933 pass
1940 pass
1934 except:
1941 except:
1935 badblocks.append(block.rstrip())
1942 badblocks.append(block.rstrip())
1936 if kw['quiet']: # restore stdout
1943 if kw['quiet']: # restore stdout
1937 sys.stdout.close()
1944 sys.stdout.close()
1938 sys.stdout = stdout_save
1945 sys.stdout = stdout_save
1939 print 'Finished replaying log file <%s>' % fname
1946 print 'Finished replaying log file <%s>' % fname
1940 if badblocks:
1947 if badblocks:
1941 print >> sys.stderr, ('\nThe following lines/blocks in file '
1948 print >> sys.stderr, ('\nThe following lines/blocks in file '
1942 '<%s> reported errors:' % fname)
1949 '<%s> reported errors:' % fname)
1943
1950
1944 for badline in badblocks:
1951 for badline in badblocks:
1945 print >> sys.stderr, badline
1952 print >> sys.stderr, badline
1946 else: # regular file execution
1953 else: # regular file execution
1947 try:
1954 try:
1948 execfile(fname,*where)
1955 execfile(fname,*where)
1949 except SyntaxError:
1956 except SyntaxError:
1950 etype, evalue = sys.exc_info()[0:2]
1957 etype, evalue = sys.exc_info()[0:2]
1951 self.SyntaxTB(etype,evalue,[])
1958 self.SyntaxTB(etype,evalue,[])
1952 warn('Failure executing file: <%s>' % fname)
1959 warn('Failure executing file: <%s>' % fname)
1953 except SystemExit,status:
1960 except SystemExit,status:
1954 if not kw['exit_ignore']:
1961 if not kw['exit_ignore']:
1955 self.InteractiveTB()
1962 self.InteractiveTB()
1956 warn('Failure executing file: <%s>' % fname)
1963 warn('Failure executing file: <%s>' % fname)
1957 except:
1964 except:
1958 self.InteractiveTB()
1965 self.InteractiveTB()
1959 warn('Failure executing file: <%s>' % fname)
1966 warn('Failure executing file: <%s>' % fname)
1960
1967
1961 #************************* end of file <iplib.py> *****************************
1968 #************************* end of file <iplib.py> *****************************
@@ -1,737 +1,739 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or better.
5 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 963 2005-12-28 19:21:29Z fperez $"""
9 $Id: ipmaker.py 964 2005-12-28 21:03:01Z fperez $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __license__ = Release.license
20 __license__ = Release.license
21 __version__ = Release.version
21 __version__ = Release.version
22
22
23 credits._Printer__data = """
23 credits._Printer__data = """
24 Python: %s
24 Python: %s
25
25
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 See http://ipython.scipy.org for more information.""" \
27 See http://ipython.scipy.org for more information.""" \
28 % credits._Printer__data
28 % credits._Printer__data
29
29
30 copyright._Printer__data += """
30 copyright._Printer__data += """
31
31
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 All Rights Reserved."""
33 All Rights Reserved."""
34
34
35 #****************************************************************************
35 #****************************************************************************
36 # Required modules
36 # Required modules
37
37
38 # From the standard library
38 # From the standard library
39 import __main__
39 import __main__
40 import __builtin__
40 import __builtin__
41 import os
41 import os
42 import re
42 import re
43 import sys
43 import sys
44 import types
44 import types
45 from pprint import pprint,pformat
45 from pprint import pprint,pformat
46
46
47 # Our own
47 # Our own
48 from IPython import DPyGetOpt
48 from IPython import DPyGetOpt
49 from IPython.Struct import Struct
49 from IPython.Struct import Struct
50 from IPython.OutputTrap import OutputTrap
50 from IPython.OutputTrap import OutputTrap
51 from IPython.ConfigLoader import ConfigLoader
51 from IPython.ConfigLoader import ConfigLoader
52 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
52 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
53 from IPython.usage import cmd_line_usage,interactive_usage
53 from IPython.usage import cmd_line_usage,interactive_usage
54 from IPython.Prompts import CachedOutput
54 from IPython.Prompts import CachedOutput
55 from IPython.genutils import *
55 from IPython.genutils import *
56
56
57 #-----------------------------------------------------------------------------
57 #-----------------------------------------------------------------------------
58 def make_IPython(argv=None,user_ns=None,debug=1,rc_override=None,
58 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
59 shell_class=InteractiveShell,embedded=False,**kw):
59 rc_override=None,shell_class=InteractiveShell,
60 embedded=False,**kw):
60 """This is a dump of IPython into a single function.
61 """This is a dump of IPython into a single function.
61
62
62 Later it will have to be broken up in a sensible manner.
63 Later it will have to be broken up in a sensible manner.
63
64
64 Arguments:
65 Arguments:
65
66
66 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
67 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
67 script name, b/c DPyGetOpt strips the first argument only for the real
68 script name, b/c DPyGetOpt strips the first argument only for the real
68 sys.argv.
69 sys.argv.
69
70
70 - user_ns: a dict to be used as the user's namespace."""
71 - user_ns: a dict to be used as the user's namespace."""
71
72
72 #----------------------------------------------------------------------
73 #----------------------------------------------------------------------
73 # Defaults and initialization
74 # Defaults and initialization
74
75
75 # For developer debugging, deactivates crash handler and uses pdb.
76 # For developer debugging, deactivates crash handler and uses pdb.
76 DEVDEBUG = False
77 DEVDEBUG = False
77
78
78 if argv is None:
79 if argv is None:
79 argv = sys.argv
80 argv = sys.argv
80
81
81 # __IP is the main global that lives throughout and represents the whole
82 # __IP is the main global that lives throughout and represents the whole
82 # application. If the user redefines it, all bets are off as to what
83 # application. If the user redefines it, all bets are off as to what
83 # happens.
84 # happens.
84
85
85 # __IP is the name of he global which the caller will have accessible as
86 # __IP is the name of he global which the caller will have accessible as
86 # __IP.name. We set its name via the first parameter passed to
87 # __IP.name. We set its name via the first parameter passed to
87 # InteractiveShell:
88 # InteractiveShell:
88
89
89 IP = shell_class('__IP',user_ns=user_ns,embedded=embedded,**kw)
90 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
91 embedded=embedded,**kw)
90
92
91 # Put 'help' in the user namespace
93 # Put 'help' in the user namespace
92 from site import _Helper
94 from site import _Helper
93 IP.user_ns['help'] = _Helper()
95 IP.user_ns['help'] = _Helper()
94
96
95 if DEVDEBUG:
97 if DEVDEBUG:
96 # For developer debugging only (global flag)
98 # For developer debugging only (global flag)
97 from IPython import ultraTB
99 from IPython import ultraTB
98 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
100 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
99 else:
101 else:
100 # IPython itself shouldn't crash. This will produce a detailed
102 # IPython itself shouldn't crash. This will produce a detailed
101 # post-mortem if it does
103 # post-mortem if it does
102 from IPython import CrashHandler
104 from IPython import CrashHandler
103 sys.excepthook = CrashHandler.CrashHandler(IP)
105 sys.excepthook = CrashHandler.CrashHandler(IP)
104
106
105 IP.BANNER_PARTS = ['Python %s\n'
107 IP.BANNER_PARTS = ['Python %s\n'
106 'Type "copyright", "credits" or "license" '
108 'Type "copyright", "credits" or "license" '
107 'for more information.\n'
109 'for more information.\n'
108 % (sys.version.split('\n')[0],),
110 % (sys.version.split('\n')[0],),
109 "IPython %s -- An enhanced Interactive Python."
111 "IPython %s -- An enhanced Interactive Python."
110 % (__version__,),
112 % (__version__,),
111 """? -> Introduction to IPython's features.
113 """? -> Introduction to IPython's features.
112 %magic -> Information about IPython's 'magic' % functions.
114 %magic -> Information about IPython's 'magic' % functions.
113 help -> Python's own help system.
115 help -> Python's own help system.
114 object? -> Details about 'object'. ?object also works, ?? prints more.
116 object? -> Details about 'object'. ?object also works, ?? prints more.
115 """ ]
117 """ ]
116
118
117 IP.usage = interactive_usage
119 IP.usage = interactive_usage
118
120
119 # Platform-dependent suffix and directory names. We use _ipython instead
121 # Platform-dependent suffix and directory names. We use _ipython instead
120 # of .ipython under win32 b/c there's software that breaks with .named
122 # of .ipython under win32 b/c there's software that breaks with .named
121 # directories on that platform.
123 # directories on that platform.
122 if os.name == 'posix':
124 if os.name == 'posix':
123 rc_suffix = ''
125 rc_suffix = ''
124 ipdir_def = '.ipython'
126 ipdir_def = '.ipython'
125 else:
127 else:
126 rc_suffix = '.ini'
128 rc_suffix = '.ini'
127 ipdir_def = '_ipython'
129 ipdir_def = '_ipython'
128
130
129 # default directory for configuration
131 # default directory for configuration
130 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
132 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
131 os.path.join(IP.home_dir,ipdir_def)))
133 os.path.join(IP.home_dir,ipdir_def)))
132
134
133 # we need the directory where IPython itself is installed
135 # we need the directory where IPython itself is installed
134 import IPython
136 import IPython
135 IPython_dir = os.path.dirname(IPython.__file__)
137 IPython_dir = os.path.dirname(IPython.__file__)
136 del IPython
138 del IPython
137
139
138 #-------------------------------------------------------------------------
140 #-------------------------------------------------------------------------
139 # Command line handling
141 # Command line handling
140
142
141 # Valid command line options (uses DPyGetOpt syntax, like Perl's
143 # Valid command line options (uses DPyGetOpt syntax, like Perl's
142 # GetOpt::Long)
144 # GetOpt::Long)
143
145
144 # Any key not listed here gets deleted even if in the file (like session
146 # Any key not listed here gets deleted even if in the file (like session
145 # or profile). That's deliberate, to maintain the rc namespace clean.
147 # or profile). That's deliberate, to maintain the rc namespace clean.
146
148
147 # Each set of options appears twice: under _conv only the names are
149 # Each set of options appears twice: under _conv only the names are
148 # listed, indicating which type they must be converted to when reading the
150 # listed, indicating which type they must be converted to when reading the
149 # ipythonrc file. And under DPyGetOpt they are listed with the regular
151 # ipythonrc file. And under DPyGetOpt they are listed with the regular
150 # DPyGetOpt syntax (=s,=i,:f,etc).
152 # DPyGetOpt syntax (=s,=i,:f,etc).
151
153
152 # Make sure there's a space before each end of line (they get auto-joined!)
154 # Make sure there's a space before each end of line (they get auto-joined!)
153 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
155 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
154 'c=s classic|cl color_info! colors=s confirm_exit! '
156 'c=s classic|cl color_info! colors=s confirm_exit! '
155 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
157 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
156 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
158 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
157 'quick screen_length|sl=i prompts_pad_left=i '
159 'quick screen_length|sl=i prompts_pad_left=i '
158 'logfile|lf=s logplay|lp=s profile|p=s '
160 'logfile|lf=s logplay|lp=s profile|p=s '
159 'readline! readline_merge_completions! '
161 'readline! readline_merge_completions! '
160 'readline_omit__names! '
162 'readline_omit__names! '
161 'rcfile=s separate_in|si=s separate_out|so=s '
163 'rcfile=s separate_in|si=s separate_out|so=s '
162 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
164 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
163 'magic_docstrings system_verbose! '
165 'magic_docstrings system_verbose! '
164 'multi_line_specials! '
166 'multi_line_specials! '
165 'autoedit_syntax!')
167 'autoedit_syntax!')
166
168
167 # Options that can *only* appear at the cmd line (not in rcfiles).
169 # Options that can *only* appear at the cmd line (not in rcfiles).
168
170
169 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
171 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
170 # the 'C-c !' command in emacs automatically appends a -i option at the end.
172 # the 'C-c !' command in emacs automatically appends a -i option at the end.
171 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
173 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
172 'gthread! qthread! wthread! pylab! tk!')
174 'gthread! qthread! wthread! pylab! tk!')
173
175
174 # Build the actual name list to be used by DPyGetOpt
176 # Build the actual name list to be used by DPyGetOpt
175 opts_names = qw(cmdline_opts) + qw(cmdline_only)
177 opts_names = qw(cmdline_opts) + qw(cmdline_only)
176
178
177 # Set sensible command line defaults.
179 # Set sensible command line defaults.
178 # This should have everything from cmdline_opts and cmdline_only
180 # This should have everything from cmdline_opts and cmdline_only
179 opts_def = Struct(autocall = 1,
181 opts_def = Struct(autocall = 1,
180 autoedit_syntax = 1,
182 autoedit_syntax = 1,
181 autoindent=0,
183 autoindent=0,
182 automagic = 1,
184 automagic = 1,
183 banner = 1,
185 banner = 1,
184 cache_size = 1000,
186 cache_size = 1000,
185 c = '',
187 c = '',
186 classic = 0,
188 classic = 0,
187 colors = 'NoColor',
189 colors = 'NoColor',
188 color_info = 0,
190 color_info = 0,
189 confirm_exit = 1,
191 confirm_exit = 1,
190 debug = 0,
192 debug = 0,
191 deep_reload = 0,
193 deep_reload = 0,
192 editor = '0',
194 editor = '0',
193 help = 0,
195 help = 0,
194 ignore = 0,
196 ignore = 0,
195 ipythondir = ipythondir,
197 ipythondir = ipythondir,
196 log = 0,
198 log = 0,
197 logfile = '',
199 logfile = '',
198 logplay = '',
200 logplay = '',
199 multi_line_specials = 1,
201 multi_line_specials = 1,
200 messages = 1,
202 messages = 1,
201 nosep = 0,
203 nosep = 0,
202 pdb = 0,
204 pdb = 0,
203 pprint = 0,
205 pprint = 0,
204 profile = '',
206 profile = '',
205 prompt_in1 = 'In [\\#]: ',
207 prompt_in1 = 'In [\\#]: ',
206 prompt_in2 = ' .\\D.: ',
208 prompt_in2 = ' .\\D.: ',
207 prompt_out = 'Out[\\#]: ',
209 prompt_out = 'Out[\\#]: ',
208 prompts_pad_left = 1,
210 prompts_pad_left = 1,
209 quick = 0,
211 quick = 0,
210 readline = 1,
212 readline = 1,
211 readline_merge_completions = 1,
213 readline_merge_completions = 1,
212 readline_omit__names = 0,
214 readline_omit__names = 0,
213 rcfile = 'ipythonrc' + rc_suffix,
215 rcfile = 'ipythonrc' + rc_suffix,
214 screen_length = 0,
216 screen_length = 0,
215 separate_in = '\n',
217 separate_in = '\n',
216 separate_out = '\n',
218 separate_out = '\n',
217 separate_out2 = '',
219 separate_out2 = '',
218 system_verbose = 0,
220 system_verbose = 0,
219 gthread = 0,
221 gthread = 0,
220 qthread = 0,
222 qthread = 0,
221 wthread = 0,
223 wthread = 0,
222 pylab = 0,
224 pylab = 0,
223 tk = 0,
225 tk = 0,
224 upgrade = 0,
226 upgrade = 0,
225 Version = 0,
227 Version = 0,
226 xmode = 'Verbose',
228 xmode = 'Verbose',
227 wildcards_case_sensitive = 1,
229 wildcards_case_sensitive = 1,
228 magic_docstrings = 0, # undocumented, for doc generation
230 magic_docstrings = 0, # undocumented, for doc generation
229 )
231 )
230
232
231 # Things that will *only* appear in rcfiles (not at the command line).
233 # Things that will *only* appear in rcfiles (not at the command line).
232 # Make sure there's a space before each end of line (they get auto-joined!)
234 # Make sure there's a space before each end of line (they get auto-joined!)
233 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
235 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
234 qw_lol: 'import_some ',
236 qw_lol: 'import_some ',
235 # for things with embedded whitespace:
237 # for things with embedded whitespace:
236 list_strings:'execute alias readline_parse_and_bind ',
238 list_strings:'execute alias readline_parse_and_bind ',
237 # Regular strings need no conversion:
239 # Regular strings need no conversion:
238 None:'readline_remove_delims ',
240 None:'readline_remove_delims ',
239 }
241 }
240 # Default values for these
242 # Default values for these
241 rc_def = Struct(include = [],
243 rc_def = Struct(include = [],
242 import_mod = [],
244 import_mod = [],
243 import_all = [],
245 import_all = [],
244 import_some = [[]],
246 import_some = [[]],
245 execute = [],
247 execute = [],
246 execfile = [],
248 execfile = [],
247 alias = [],
249 alias = [],
248 readline_parse_and_bind = [],
250 readline_parse_and_bind = [],
249 readline_remove_delims = '',
251 readline_remove_delims = '',
250 )
252 )
251
253
252 # Build the type conversion dictionary from the above tables:
254 # Build the type conversion dictionary from the above tables:
253 typeconv = rcfile_opts.copy()
255 typeconv = rcfile_opts.copy()
254 typeconv.update(optstr2types(cmdline_opts))
256 typeconv.update(optstr2types(cmdline_opts))
255
257
256 # FIXME: the None key appears in both, put that back together by hand. Ugly!
258 # FIXME: the None key appears in both, put that back together by hand. Ugly!
257 typeconv[None] += ' ' + rcfile_opts[None]
259 typeconv[None] += ' ' + rcfile_opts[None]
258
260
259 # Remove quotes at ends of all strings (used to protect spaces)
261 # Remove quotes at ends of all strings (used to protect spaces)
260 typeconv[unquote_ends] = typeconv[None]
262 typeconv[unquote_ends] = typeconv[None]
261 del typeconv[None]
263 del typeconv[None]
262
264
263 # Build the list we'll use to make all config decisions with defaults:
265 # Build the list we'll use to make all config decisions with defaults:
264 opts_all = opts_def.copy()
266 opts_all = opts_def.copy()
265 opts_all.update(rc_def)
267 opts_all.update(rc_def)
266
268
267 # Build conflict resolver for recursive loading of config files:
269 # Build conflict resolver for recursive loading of config files:
268 # - preserve means the outermost file maintains the value, it is not
270 # - preserve means the outermost file maintains the value, it is not
269 # overwritten if an included file has the same key.
271 # overwritten if an included file has the same key.
270 # - add_flip applies + to the two values, so it better make sense to add
272 # - add_flip applies + to the two values, so it better make sense to add
271 # those types of keys. But it flips them first so that things loaded
273 # those types of keys. But it flips them first so that things loaded
272 # deeper in the inclusion chain have lower precedence.
274 # deeper in the inclusion chain have lower precedence.
273 conflict = {'preserve': ' '.join([ typeconv[int],
275 conflict = {'preserve': ' '.join([ typeconv[int],
274 typeconv[unquote_ends] ]),
276 typeconv[unquote_ends] ]),
275 'add_flip': ' '.join([ typeconv[qwflat],
277 'add_flip': ' '.join([ typeconv[qwflat],
276 typeconv[qw_lol],
278 typeconv[qw_lol],
277 typeconv[list_strings] ])
279 typeconv[list_strings] ])
278 }
280 }
279
281
280 # Now actually process the command line
282 # Now actually process the command line
281 getopt = DPyGetOpt.DPyGetOpt()
283 getopt = DPyGetOpt.DPyGetOpt()
282 getopt.setIgnoreCase(0)
284 getopt.setIgnoreCase(0)
283
285
284 getopt.parseConfiguration(opts_names)
286 getopt.parseConfiguration(opts_names)
285
287
286 try:
288 try:
287 getopt.processArguments(argv)
289 getopt.processArguments(argv)
288 except:
290 except:
289 print cmd_line_usage
291 print cmd_line_usage
290 warn('\nError in Arguments: ' + `sys.exc_value`)
292 warn('\nError in Arguments: ' + `sys.exc_value`)
291 sys.exit(1)
293 sys.exit(1)
292
294
293 # convert the options dict to a struct for much lighter syntax later
295 # convert the options dict to a struct for much lighter syntax later
294 opts = Struct(getopt.optionValues)
296 opts = Struct(getopt.optionValues)
295 args = getopt.freeValues
297 args = getopt.freeValues
296
298
297 # this is the struct (which has default values at this point) with which
299 # this is the struct (which has default values at this point) with which
298 # we make all decisions:
300 # we make all decisions:
299 opts_all.update(opts)
301 opts_all.update(opts)
300
302
301 # Options that force an immediate exit
303 # Options that force an immediate exit
302 if opts_all.help:
304 if opts_all.help:
303 page(cmd_line_usage)
305 page(cmd_line_usage)
304 sys.exit()
306 sys.exit()
305
307
306 if opts_all.Version:
308 if opts_all.Version:
307 print __version__
309 print __version__
308 sys.exit()
310 sys.exit()
309
311
310 if opts_all.magic_docstrings:
312 if opts_all.magic_docstrings:
311 IP.magic_magic('-latex')
313 IP.magic_magic('-latex')
312 sys.exit()
314 sys.exit()
313
315
314 # Create user config directory if it doesn't exist. This must be done
316 # Create user config directory if it doesn't exist. This must be done
315 # *after* getting the cmd line options.
317 # *after* getting the cmd line options.
316 if not os.path.isdir(opts_all.ipythondir):
318 if not os.path.isdir(opts_all.ipythondir):
317 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
319 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
318
320
319 # upgrade user config files while preserving a copy of the originals
321 # upgrade user config files while preserving a copy of the originals
320 if opts_all.upgrade:
322 if opts_all.upgrade:
321 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
323 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
322
324
323 # check mutually exclusive options in the *original* command line
325 # check mutually exclusive options in the *original* command line
324 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
326 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
325 qw('classic profile'),qw('classic rcfile')])
327 qw('classic profile'),qw('classic rcfile')])
326
328
327 # default logfilename used when -log is called.
329 # default logfilename used when -log is called.
328 IP.LOGDEF = 'ipython.log'
330 IP.LOGDEF = 'ipython.log'
329
331
330 #---------------------------------------------------------------------------
332 #---------------------------------------------------------------------------
331 # Log replay
333 # Log replay
332
334
333 # if -logplay, we need to 'become' the other session. That basically means
335 # if -logplay, we need to 'become' the other session. That basically means
334 # replacing the current command line environment with that of the old
336 # replacing the current command line environment with that of the old
335 # session and moving on.
337 # session and moving on.
336
338
337 # this is needed so that later we know we're in session reload mode, as
339 # this is needed so that later we know we're in session reload mode, as
338 # opts_all will get overwritten:
340 # opts_all will get overwritten:
339 load_logplay = 0
341 load_logplay = 0
340
342
341 if opts_all.logplay:
343 if opts_all.logplay:
342 load_logplay = opts_all.logplay
344 load_logplay = opts_all.logplay
343 opts_debug_save = opts_all.debug
345 opts_debug_save = opts_all.debug
344 try:
346 try:
345 logplay = open(opts_all.logplay)
347 logplay = open(opts_all.logplay)
346 except IOError:
348 except IOError:
347 if opts_all.debug: IP.InteractiveTB()
349 if opts_all.debug: IP.InteractiveTB()
348 warn('Could not open logplay file '+`opts_all.logplay`)
350 warn('Could not open logplay file '+`opts_all.logplay`)
349 # restore state as if nothing had happened and move on, but make
351 # restore state as if nothing had happened and move on, but make
350 # sure that later we don't try to actually load the session file
352 # sure that later we don't try to actually load the session file
351 logplay = None
353 logplay = None
352 load_logplay = 0
354 load_logplay = 0
353 del opts_all.logplay
355 del opts_all.logplay
354 else:
356 else:
355 try:
357 try:
356 logplay.readline()
358 logplay.readline()
357 logplay.readline();
359 logplay.readline();
358 # this reloads that session's command line
360 # this reloads that session's command line
359 cmd = logplay.readline()[6:]
361 cmd = logplay.readline()[6:]
360 exec cmd
362 exec cmd
361 # restore the true debug flag given so that the process of
363 # restore the true debug flag given so that the process of
362 # session loading itself can be monitored.
364 # session loading itself can be monitored.
363 opts.debug = opts_debug_save
365 opts.debug = opts_debug_save
364 # save the logplay flag so later we don't overwrite the log
366 # save the logplay flag so later we don't overwrite the log
365 opts.logplay = load_logplay
367 opts.logplay = load_logplay
366 # now we must update our own structure with defaults
368 # now we must update our own structure with defaults
367 opts_all.update(opts)
369 opts_all.update(opts)
368 # now load args
370 # now load args
369 cmd = logplay.readline()[6:]
371 cmd = logplay.readline()[6:]
370 exec cmd
372 exec cmd
371 logplay.close()
373 logplay.close()
372 except:
374 except:
373 logplay.close()
375 logplay.close()
374 if opts_all.debug: IP.InteractiveTB()
376 if opts_all.debug: IP.InteractiveTB()
375 warn("Logplay file lacking full configuration information.\n"
377 warn("Logplay file lacking full configuration information.\n"
376 "I'll try to read it, but some things may not work.")
378 "I'll try to read it, but some things may not work.")
377
379
378 #-------------------------------------------------------------------------
380 #-------------------------------------------------------------------------
379 # set up output traps: catch all output from files, being run, modules
381 # set up output traps: catch all output from files, being run, modules
380 # loaded, etc. Then give it to the user in a clean form at the end.
382 # loaded, etc. Then give it to the user in a clean form at the end.
381
383
382 msg_out = 'Output messages. '
384 msg_out = 'Output messages. '
383 msg_err = 'Error messages. '
385 msg_err = 'Error messages. '
384 msg_sep = '\n'
386 msg_sep = '\n'
385 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
387 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
386 msg_err,msg_sep,debug,
388 msg_err,msg_sep,debug,
387 quiet_out=1),
389 quiet_out=1),
388 user_exec = OutputTrap('User File Execution',msg_out,
390 user_exec = OutputTrap('User File Execution',msg_out,
389 msg_err,msg_sep,debug),
391 msg_err,msg_sep,debug),
390 logplay = OutputTrap('Log Loader',msg_out,
392 logplay = OutputTrap('Log Loader',msg_out,
391 msg_err,msg_sep,debug),
393 msg_err,msg_sep,debug),
392 summary = ''
394 summary = ''
393 )
395 )
394
396
395 #-------------------------------------------------------------------------
397 #-------------------------------------------------------------------------
396 # Process user ipythonrc-type configuration files
398 # Process user ipythonrc-type configuration files
397
399
398 # turn on output trapping and log to msg.config
400 # turn on output trapping and log to msg.config
399 # remember that with debug on, trapping is actually disabled
401 # remember that with debug on, trapping is actually disabled
400 msg.config.trap_all()
402 msg.config.trap_all()
401
403
402 # look for rcfile in current or default directory
404 # look for rcfile in current or default directory
403 try:
405 try:
404 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
406 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
405 except IOError:
407 except IOError:
406 if opts_all.debug: IP.InteractiveTB()
408 if opts_all.debug: IP.InteractiveTB()
407 warn('Configuration file %s not found. Ignoring request.'
409 warn('Configuration file %s not found. Ignoring request.'
408 % (opts_all.rcfile) )
410 % (opts_all.rcfile) )
409
411
410 # 'profiles' are a shorthand notation for config filenames
412 # 'profiles' are a shorthand notation for config filenames
411 if opts_all.profile:
413 if opts_all.profile:
412 try:
414 try:
413 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
415 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
414 + rc_suffix,
416 + rc_suffix,
415 opts_all.ipythondir)
417 opts_all.ipythondir)
416 except IOError:
418 except IOError:
417 if opts_all.debug: IP.InteractiveTB()
419 if opts_all.debug: IP.InteractiveTB()
418 opts.profile = '' # remove profile from options if invalid
420 opts.profile = '' # remove profile from options if invalid
419 warn('Profile configuration file %s not found. Ignoring request.'
421 warn('Profile configuration file %s not found. Ignoring request.'
420 % (opts_all.profile) )
422 % (opts_all.profile) )
421
423
422 # load the config file
424 # load the config file
423 rcfiledata = None
425 rcfiledata = None
424 if opts_all.quick:
426 if opts_all.quick:
425 print 'Launching IPython in quick mode. No config file read.'
427 print 'Launching IPython in quick mode. No config file read.'
426 elif opts_all.classic:
428 elif opts_all.classic:
427 print 'Launching IPython in classic mode. No config file read.'
429 print 'Launching IPython in classic mode. No config file read.'
428 elif opts_all.rcfile:
430 elif opts_all.rcfile:
429 try:
431 try:
430 cfg_loader = ConfigLoader(conflict)
432 cfg_loader = ConfigLoader(conflict)
431 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
433 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
432 'include',opts_all.ipythondir,
434 'include',opts_all.ipythondir,
433 purge = 1,
435 purge = 1,
434 unique = conflict['preserve'])
436 unique = conflict['preserve'])
435 except:
437 except:
436 IP.InteractiveTB()
438 IP.InteractiveTB()
437 warn('Problems loading configuration file '+
439 warn('Problems loading configuration file '+
438 `opts_all.rcfile`+
440 `opts_all.rcfile`+
439 '\nStarting with default -bare bones- configuration.')
441 '\nStarting with default -bare bones- configuration.')
440 else:
442 else:
441 warn('No valid configuration file found in either currrent directory\n'+
443 warn('No valid configuration file found in either currrent directory\n'+
442 'or in the IPython config. directory: '+`opts_all.ipythondir`+
444 'or in the IPython config. directory: '+`opts_all.ipythondir`+
443 '\nProceeding with internal defaults.')
445 '\nProceeding with internal defaults.')
444
446
445 #------------------------------------------------------------------------
447 #------------------------------------------------------------------------
446 # Set exception handlers in mode requested by user.
448 # Set exception handlers in mode requested by user.
447 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
449 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
448 IP.magic_xmode(opts_all.xmode)
450 IP.magic_xmode(opts_all.xmode)
449 otrap.release_out()
451 otrap.release_out()
450
452
451 #------------------------------------------------------------------------
453 #------------------------------------------------------------------------
452 # Execute user config
454 # Execute user config
453
455
454 # Create a valid config structure with the right precedence order:
456 # Create a valid config structure with the right precedence order:
455 # defaults < rcfile < command line. This needs to be in the instance, so
457 # defaults < rcfile < command line. This needs to be in the instance, so
456 # that method calls below that rely on it find it.
458 # that method calls below that rely on it find it.
457 IP.rc = rc_def.copy()
459 IP.rc = rc_def.copy()
458
460
459 # Work with a local alias inside this routine to avoid unnecessary
461 # Work with a local alias inside this routine to avoid unnecessary
460 # attribute lookups.
462 # attribute lookups.
461 IP_rc = IP.rc
463 IP_rc = IP.rc
462
464
463 IP_rc.update(opts_def)
465 IP_rc.update(opts_def)
464 if rcfiledata:
466 if rcfiledata:
465 # now we can update
467 # now we can update
466 IP_rc.update(rcfiledata)
468 IP_rc.update(rcfiledata)
467 IP_rc.update(opts)
469 IP_rc.update(opts)
468 IP_rc.update(rc_override)
470 IP_rc.update(rc_override)
469
471
470 # Store the original cmd line for reference:
472 # Store the original cmd line for reference:
471 IP_rc.opts = opts
473 IP_rc.opts = opts
472 IP_rc.args = args
474 IP_rc.args = args
473
475
474 # create a *runtime* Struct like rc for holding parameters which may be
476 # create a *runtime* Struct like rc for holding parameters which may be
475 # created and/or modified by runtime user extensions.
477 # created and/or modified by runtime user extensions.
476 IP.runtime_rc = Struct()
478 IP.runtime_rc = Struct()
477
479
478 # from this point on, all config should be handled through IP_rc,
480 # from this point on, all config should be handled through IP_rc,
479 # opts* shouldn't be used anymore.
481 # opts* shouldn't be used anymore.
480
482
481 # add personal .ipython dir to sys.path so that users can put things in
483 # add personal .ipython dir to sys.path so that users can put things in
482 # there for customization
484 # there for customization
483 sys.path.append(IP_rc.ipythondir)
485 sys.path.append(IP_rc.ipythondir)
484 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
486 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
485
487
486 # update IP_rc with some special things that need manual
488 # update IP_rc with some special things that need manual
487 # tweaks. Basically options which affect other options. I guess this
489 # tweaks. Basically options which affect other options. I guess this
488 # should just be written so that options are fully orthogonal and we
490 # should just be written so that options are fully orthogonal and we
489 # wouldn't worry about this stuff!
491 # wouldn't worry about this stuff!
490
492
491 if IP_rc.classic:
493 if IP_rc.classic:
492 IP_rc.quick = 1
494 IP_rc.quick = 1
493 IP_rc.cache_size = 0
495 IP_rc.cache_size = 0
494 IP_rc.pprint = 0
496 IP_rc.pprint = 0
495 IP_rc.prompt_in1 = '>>> '
497 IP_rc.prompt_in1 = '>>> '
496 IP_rc.prompt_in2 = '... '
498 IP_rc.prompt_in2 = '... '
497 IP_rc.prompt_out = ''
499 IP_rc.prompt_out = ''
498 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
500 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
499 IP_rc.colors = 'NoColor'
501 IP_rc.colors = 'NoColor'
500 IP_rc.xmode = 'Plain'
502 IP_rc.xmode = 'Plain'
501
503
502 # configure readline
504 # configure readline
503 # Define the history file for saving commands in between sessions
505 # Define the history file for saving commands in between sessions
504 if IP_rc.profile:
506 if IP_rc.profile:
505 histfname = 'history-%s' % IP_rc.profile
507 histfname = 'history-%s' % IP_rc.profile
506 else:
508 else:
507 histfname = 'history'
509 histfname = 'history'
508 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
510 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
509
511
510 # update exception handlers with rc file status
512 # update exception handlers with rc file status
511 otrap.trap_out() # I don't want these messages ever.
513 otrap.trap_out() # I don't want these messages ever.
512 IP.magic_xmode(IP_rc.xmode)
514 IP.magic_xmode(IP_rc.xmode)
513 otrap.release_out()
515 otrap.release_out()
514
516
515 # activate logging if requested and not reloading a log
517 # activate logging if requested and not reloading a log
516 if IP_rc.logplay:
518 if IP_rc.logplay:
517 IP.magic_logstart(IP_rc.logplay + ' append')
519 IP.magic_logstart(IP_rc.logplay + ' append')
518 elif IP_rc.logfile:
520 elif IP_rc.logfile:
519 IP.magic_logstart(IP_rc.logfile)
521 IP.magic_logstart(IP_rc.logfile)
520 elif IP_rc.log:
522 elif IP_rc.log:
521 IP.magic_logstart()
523 IP.magic_logstart()
522
524
523 # find user editor so that it we don't have to look it up constantly
525 # find user editor so that it we don't have to look it up constantly
524 if IP_rc.editor.strip()=='0':
526 if IP_rc.editor.strip()=='0':
525 try:
527 try:
526 ed = os.environ['EDITOR']
528 ed = os.environ['EDITOR']
527 except KeyError:
529 except KeyError:
528 if os.name == 'posix':
530 if os.name == 'posix':
529 ed = 'vi' # the only one guaranteed to be there!
531 ed = 'vi' # the only one guaranteed to be there!
530 else:
532 else:
531 ed = 'notepad' # same in Windows!
533 ed = 'notepad' # same in Windows!
532 IP_rc.editor = ed
534 IP_rc.editor = ed
533
535
534 # Keep track of whether this is an embedded instance or not (useful for
536 # Keep track of whether this is an embedded instance or not (useful for
535 # post-mortems).
537 # post-mortems).
536 IP_rc.embedded = IP.embedded
538 IP_rc.embedded = IP.embedded
537
539
538 # Recursive reload
540 # Recursive reload
539 try:
541 try:
540 from IPython import deep_reload
542 from IPython import deep_reload
541 if IP_rc.deep_reload:
543 if IP_rc.deep_reload:
542 __builtin__.reload = deep_reload.reload
544 __builtin__.reload = deep_reload.reload
543 else:
545 else:
544 __builtin__.dreload = deep_reload.reload
546 __builtin__.dreload = deep_reload.reload
545 del deep_reload
547 del deep_reload
546 except ImportError:
548 except ImportError:
547 pass
549 pass
548
550
549 # Save the current state of our namespace so that the interactive shell
551 # Save the current state of our namespace so that the interactive shell
550 # can later know which variables have been created by us from config files
552 # can later know which variables have been created by us from config files
551 # and loading. This way, loading a file (in any way) is treated just like
553 # and loading. This way, loading a file (in any way) is treated just like
552 # defining things on the command line, and %who works as expected.
554 # defining things on the command line, and %who works as expected.
553
555
554 # DON'T do anything that affects the namespace beyond this point!
556 # DON'T do anything that affects the namespace beyond this point!
555 IP.internal_ns.update(__main__.__dict__)
557 IP.internal_ns.update(__main__.__dict__)
556
558
557 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
559 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
558
560
559 # Now run through the different sections of the users's config
561 # Now run through the different sections of the users's config
560 if IP_rc.debug:
562 if IP_rc.debug:
561 print 'Trying to execute the following configuration structure:'
563 print 'Trying to execute the following configuration structure:'
562 print '(Things listed first are deeper in the inclusion tree and get'
564 print '(Things listed first are deeper in the inclusion tree and get'
563 print 'loaded first).\n'
565 print 'loaded first).\n'
564 pprint(IP_rc.__dict__)
566 pprint(IP_rc.__dict__)
565
567
566 for mod in IP_rc.import_mod:
568 for mod in IP_rc.import_mod:
567 try:
569 try:
568 exec 'import '+mod in IP.user_ns
570 exec 'import '+mod in IP.user_ns
569 except :
571 except :
570 IP.InteractiveTB()
572 IP.InteractiveTB()
571 import_fail_info(mod)
573 import_fail_info(mod)
572
574
573 for mod_fn in IP_rc.import_some:
575 for mod_fn in IP_rc.import_some:
574 if mod_fn == []: break
576 if mod_fn == []: break
575 mod,fn = mod_fn[0],','.join(mod_fn[1:])
577 mod,fn = mod_fn[0],','.join(mod_fn[1:])
576 try:
578 try:
577 exec 'from '+mod+' import '+fn in IP.user_ns
579 exec 'from '+mod+' import '+fn in IP.user_ns
578 except :
580 except :
579 IP.InteractiveTB()
581 IP.InteractiveTB()
580 import_fail_info(mod,fn)
582 import_fail_info(mod,fn)
581
583
582 for mod in IP_rc.import_all:
584 for mod in IP_rc.import_all:
583 try:
585 try:
584 exec 'from '+mod+' import *' in IP.user_ns
586 exec 'from '+mod+' import *' in IP.user_ns
585 except :
587 except :
586 IP.InteractiveTB()
588 IP.InteractiveTB()
587 import_fail_info(mod)
589 import_fail_info(mod)
588
590
589 for code in IP_rc.execute:
591 for code in IP_rc.execute:
590 try:
592 try:
591 exec code in IP.user_ns
593 exec code in IP.user_ns
592 except:
594 except:
593 IP.InteractiveTB()
595 IP.InteractiveTB()
594 warn('Failure executing code: ' + `code`)
596 warn('Failure executing code: ' + `code`)
595
597
596 # Execute the files the user wants in ipythonrc
598 # Execute the files the user wants in ipythonrc
597 for file in IP_rc.execfile:
599 for file in IP_rc.execfile:
598 try:
600 try:
599 file = filefind(file,sys.path+[IPython_dir])
601 file = filefind(file,sys.path+[IPython_dir])
600 except IOError:
602 except IOError:
601 warn(itpl('File $file not found. Skipping it.'))
603 warn(itpl('File $file not found. Skipping it.'))
602 else:
604 else:
603 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
605 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
604
606
605 # release stdout and stderr and save config log into a global summary
607 # release stdout and stderr and save config log into a global summary
606 msg.config.release_all()
608 msg.config.release_all()
607 if IP_rc.messages:
609 if IP_rc.messages:
608 msg.summary += msg.config.summary_all()
610 msg.summary += msg.config.summary_all()
609
611
610 #------------------------------------------------------------------------
612 #------------------------------------------------------------------------
611 # Setup interactive session
613 # Setup interactive session
612
614
613 # Now we should be fully configured. We can then execute files or load
615 # Now we should be fully configured. We can then execute files or load
614 # things only needed for interactive use. Then we'll open the shell.
616 # things only needed for interactive use. Then we'll open the shell.
615
617
616 # Take a snapshot of the user namespace before opening the shell. That way
618 # Take a snapshot of the user namespace before opening the shell. That way
617 # we'll be able to identify which things were interactively defined and
619 # we'll be able to identify which things were interactively defined and
618 # which were defined through config files.
620 # which were defined through config files.
619 IP.user_config_ns = IP.user_ns.copy()
621 IP.user_config_ns = IP.user_ns.copy()
620
622
621 # Force reading a file as if it were a session log. Slower but safer.
623 # Force reading a file as if it were a session log. Slower but safer.
622 if load_logplay:
624 if load_logplay:
623 print 'Replaying log...'
625 print 'Replaying log...'
624 try:
626 try:
625 if IP_rc.debug:
627 if IP_rc.debug:
626 logplay_quiet = 0
628 logplay_quiet = 0
627 else:
629 else:
628 logplay_quiet = 1
630 logplay_quiet = 1
629
631
630 msg.logplay.trap_all()
632 msg.logplay.trap_all()
631 IP.safe_execfile(load_logplay,IP.user_ns,
633 IP.safe_execfile(load_logplay,IP.user_ns,
632 islog = 1, quiet = logplay_quiet)
634 islog = 1, quiet = logplay_quiet)
633 msg.logplay.release_all()
635 msg.logplay.release_all()
634 if IP_rc.messages:
636 if IP_rc.messages:
635 msg.summary += msg.logplay.summary_all()
637 msg.summary += msg.logplay.summary_all()
636 except:
638 except:
637 warn('Problems replaying logfile %s.' % load_logplay)
639 warn('Problems replaying logfile %s.' % load_logplay)
638 IP.InteractiveTB()
640 IP.InteractiveTB()
639
641
640 # Load remaining files in command line
642 # Load remaining files in command line
641 msg.user_exec.trap_all()
643 msg.user_exec.trap_all()
642
644
643 # Do NOT execute files named in the command line as scripts to be loaded
645 # Do NOT execute files named in the command line as scripts to be loaded
644 # by embedded instances. Doing so has the potential for an infinite
646 # by embedded instances. Doing so has the potential for an infinite
645 # recursion if there are exceptions thrown in the process.
647 # recursion if there are exceptions thrown in the process.
646
648
647 # XXX FIXME: the execution of user files should be moved out to after
649 # XXX FIXME: the execution of user files should be moved out to after
648 # ipython is fully initialized, just as if they were run via %run at the
650 # ipython is fully initialized, just as if they were run via %run at the
649 # ipython prompt. This would also give them the benefit of ipython's
651 # ipython prompt. This would also give them the benefit of ipython's
650 # nice tracebacks.
652 # nice tracebacks.
651
653
652 if not embedded and IP_rc.args:
654 if not embedded and IP_rc.args:
653 name_save = IP.user_ns['__name__']
655 name_save = IP.user_ns['__name__']
654 IP.user_ns['__name__'] = '__main__'
656 IP.user_ns['__name__'] = '__main__'
655 try:
657 try:
656 # Set our own excepthook in case the user code tries to call it
658 # Set our own excepthook in case the user code tries to call it
657 # directly. This prevents triggering the IPython crash handler.
659 # directly. This prevents triggering the IPython crash handler.
658 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
660 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
659 for run in args:
661 for run in args:
660 IP.safe_execfile(run,IP.user_ns)
662 IP.safe_execfile(run,IP.user_ns)
661 finally:
663 finally:
662 # Reset our crash handler in place
664 # Reset our crash handler in place
663 sys.excepthook = old_excepthook
665 sys.excepthook = old_excepthook
664
666
665 IP.user_ns['__name__'] = name_save
667 IP.user_ns['__name__'] = name_save
666
668
667 msg.user_exec.release_all()
669 msg.user_exec.release_all()
668 if IP_rc.messages:
670 if IP_rc.messages:
669 msg.summary += msg.user_exec.summary_all()
671 msg.summary += msg.user_exec.summary_all()
670
672
671 # since we can't specify a null string on the cmd line, 0 is the equivalent:
673 # since we can't specify a null string on the cmd line, 0 is the equivalent:
672 if IP_rc.nosep:
674 if IP_rc.nosep:
673 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
675 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
674 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
676 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
675 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
677 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
676 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
678 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
677 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
679 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
678 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
680 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
679 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
681 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
680
682
681 # Determine how many lines at the bottom of the screen are needed for
683 # Determine how many lines at the bottom of the screen are needed for
682 # showing prompts, so we can know wheter long strings are to be printed or
684 # showing prompts, so we can know wheter long strings are to be printed or
683 # paged:
685 # paged:
684 num_lines_bot = IP_rc.separate_in.count('\n')+1
686 num_lines_bot = IP_rc.separate_in.count('\n')+1
685 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
687 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
686 # Initialize cache, set in/out prompts and printing system
688 # Initialize cache, set in/out prompts and printing system
687 IP.outputcache = CachedOutput(IP_rc.cache_size,
689 IP.outputcache = CachedOutput(IP_rc.cache_size,
688 IP_rc.pprint,
690 IP_rc.pprint,
689 input_sep = IP_rc.separate_in,
691 input_sep = IP_rc.separate_in,
690 output_sep = IP_rc.separate_out,
692 output_sep = IP_rc.separate_out,
691 output_sep2 = IP_rc.separate_out2,
693 output_sep2 = IP_rc.separate_out2,
692 ps1 = IP_rc.prompt_in1,
694 ps1 = IP_rc.prompt_in1,
693 ps2 = IP_rc.prompt_in2,
695 ps2 = IP_rc.prompt_in2,
694 ps_out = IP_rc.prompt_out,
696 ps_out = IP_rc.prompt_out,
695 user_ns = IP.user_ns,
697 user_ns = IP.user_ns,
696 input_hist = IP.input_hist,
698 input_hist = IP.input_hist,
697 pad_left = IP_rc.prompts_pad_left)
699 pad_left = IP_rc.prompts_pad_left)
698
700
699 # user may have over-ridden the default print hook:
701 # user may have over-ridden the default print hook:
700 try:
702 try:
701 IP.outputcache.__class__.display = IP.hooks.display
703 IP.outputcache.__class__.display = IP.hooks.display
702 except AttributeError:
704 except AttributeError:
703 pass
705 pass
704
706
705 # Set calling of pdb on exceptions
707 # Set calling of pdb on exceptions
706 IP.InteractiveTB.call_pdb = IP_rc.pdb
708 IP.InteractiveTB.call_pdb = IP_rc.pdb
707
709
708 # I don't like assigning globally to sys, because it means when embedding
710 # I don't like assigning globally to sys, because it means when embedding
709 # instances, each embedded instance overrides the previous choice. But
711 # instances, each embedded instance overrides the previous choice. But
710 # sys.displayhook seems to be called internally by exec, so I don't see a
712 # sys.displayhook seems to be called internally by exec, so I don't see a
711 # way around it.
713 # way around it.
712 sys.displayhook = IP.outputcache
714 sys.displayhook = IP.outputcache
713
715
714 # we need to know globally if we're caching i/o or not
716 # we need to know globally if we're caching i/o or not
715 IP.do_full_cache = IP.outputcache.do_full_cache
717 IP.do_full_cache = IP.outputcache.do_full_cache
716
718
717 # configure startup banner
719 # configure startup banner
718 if IP_rc.c: # regular python doesn't print the banner with -c
720 if IP_rc.c: # regular python doesn't print the banner with -c
719 IP_rc.banner = 0
721 IP_rc.banner = 0
720 if IP_rc.banner:
722 if IP_rc.banner:
721 BANN_P = IP.BANNER_PARTS
723 BANN_P = IP.BANNER_PARTS
722 else:
724 else:
723 BANN_P = []
725 BANN_P = []
724
726
725 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
727 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
726
728
727 # add message log (possibly empty)
729 # add message log (possibly empty)
728 if msg.summary: BANN_P.append(msg.summary)
730 if msg.summary: BANN_P.append(msg.summary)
729 # Final banner is a string
731 # Final banner is a string
730 IP.BANNER = '\n'.join(BANN_P)
732 IP.BANNER = '\n'.join(BANN_P)
731
733
732 # Finalize the IPython instance. This assumes the rc structure is fully
734 # Finalize the IPython instance. This assumes the rc structure is fully
733 # in place.
735 # in place.
734 IP.post_config_initialization()
736 IP.post_config_initialization()
735
737
736 return IP
738 return IP
737 #************************ end of file <ipmaker.py> **************************
739 #************************ end of file <ipmaker.py> **************************
@@ -1,4586 +1,4587 b''
1 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
3 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
4 better hadnle backslashes in paths. See the thread 'More Windows
4 better hadnle backslashes in paths. See the thread 'More Windows
5 questions part 2 - \/ characters revisited' on the iypthon user
5 questions part 2 - \/ characters revisited' on the iypthon user
6 list:
6 list:
7 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
7 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
8 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
8
9
9 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
10 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
10 true by default, and add it to the shipped ipythonrc file. Since
11 true by default, and add it to the shipped ipythonrc file. Since
11 this asks the user before proceeding, I think it's OK to make it
12 this asks the user before proceeding, I think it's OK to make it
12 true by default.
13 true by default.
13
14
14 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
15 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
15 of the previous special-casing of input in the eval loop. I think
16 of the previous special-casing of input in the eval loop. I think
16 this is cleaner, as they really are commands and shouldn't have
17 this is cleaner, as they really are commands and shouldn't have
17 a special role in the middle of the core code.
18 a special role in the middle of the core code.
18
19
19 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
20 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
20
21
21 * IPython/iplib.py (edit_syntax_error): added support for
22 * IPython/iplib.py (edit_syntax_error): added support for
22 automatically reopening the editor if the file had a syntax error
23 automatically reopening the editor if the file had a syntax error
23 in it. Thanks to scottt who provided the patch at:
24 in it. Thanks to scottt who provided the patch at:
24 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
25 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
25 version committed).
26 version committed).
26
27
27 * IPython/iplib.py (handle_normal): add suport for multi-line
28 * IPython/iplib.py (handle_normal): add suport for multi-line
28 input with emtpy lines. This fixes
29 input with emtpy lines. This fixes
29 http://www.scipy.net/roundup/ipython/issue43 and a similar
30 http://www.scipy.net/roundup/ipython/issue43 and a similar
30 discussion on the user list.
31 discussion on the user list.
31
32
32 WARNING: a behavior change is necessarily introduced to support
33 WARNING: a behavior change is necessarily introduced to support
33 blank lines: now a single blank line with whitespace does NOT
34 blank lines: now a single blank line with whitespace does NOT
34 break the input loop, which means that when autoindent is on, by
35 break the input loop, which means that when autoindent is on, by
35 default hitting return on the next (indented) line does NOT exit.
36 default hitting return on the next (indented) line does NOT exit.
36
37
37 Instead, to exit a multiline input you can either have:
38 Instead, to exit a multiline input you can either have:
38
39
39 - TWO whitespace lines (just hit return again), or
40 - TWO whitespace lines (just hit return again), or
40 - a single whitespace line of a different length than provided
41 - a single whitespace line of a different length than provided
41 by the autoindent (add or remove a space).
42 by the autoindent (add or remove a space).
42
43
43 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
44 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
44 module to better organize all readline-related functionality.
45 module to better organize all readline-related functionality.
45 I've deleted FlexCompleter and put all completion clases here.
46 I've deleted FlexCompleter and put all completion clases here.
46
47
47 * IPython/iplib.py (raw_input): improve indentation management.
48 * IPython/iplib.py (raw_input): improve indentation management.
48 It is now possible to paste indented code with autoindent on, and
49 It is now possible to paste indented code with autoindent on, and
49 the code is interpreted correctly (though it still looks bad on
50 the code is interpreted correctly (though it still looks bad on
50 screen, due to the line-oriented nature of ipython).
51 screen, due to the line-oriented nature of ipython).
51 (MagicCompleter.complete): change behavior so that a TAB key on an
52 (MagicCompleter.complete): change behavior so that a TAB key on an
52 otherwise empty line actually inserts a tab, instead of completing
53 otherwise empty line actually inserts a tab, instead of completing
53 on the entire global namespace. This makes it easier to use the
54 on the entire global namespace. This makes it easier to use the
54 TAB key for indentation. After a request by Hans Meine
55 TAB key for indentation. After a request by Hans Meine
55 <hans_meine-AT-gmx.net>
56 <hans_meine-AT-gmx.net>
56 (_prefilter): add support so that typing plain 'exit' or 'quit'
57 (_prefilter): add support so that typing plain 'exit' or 'quit'
57 does a sensible thing. Originally I tried to deviate as little as
58 does a sensible thing. Originally I tried to deviate as little as
58 possible from the default python behavior, but even that one may
59 possible from the default python behavior, but even that one may
59 change in this direction (thread on python-dev to that effect).
60 change in this direction (thread on python-dev to that effect).
60 Regardless, ipython should do the right thing even if CPython's
61 Regardless, ipython should do the right thing even if CPython's
61 '>>>' prompt doesn't.
62 '>>>' prompt doesn't.
62 (InteractiveShell): removed subclassing code.InteractiveConsole
63 (InteractiveShell): removed subclassing code.InteractiveConsole
63 class. By now we'd overridden just about all of its methods: I've
64 class. By now we'd overridden just about all of its methods: I've
64 copied the remaining two over, and now ipython is a standalone
65 copied the remaining two over, and now ipython is a standalone
65 class. This will provide a clearer picture for the chainsaw
66 class. This will provide a clearer picture for the chainsaw
66 branch refactoring.
67 branch refactoring.
67
68
68 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
69 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
69
70
70 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
71 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
71 failures for objects which break when dir() is called on them.
72 failures for objects which break when dir() is called on them.
72
73
73 * IPython/FlexCompleter.py (Completer.__init__): Added support for
74 * IPython/FlexCompleter.py (Completer.__init__): Added support for
74 distinct local and global namespaces in the completer API. This
75 distinct local and global namespaces in the completer API. This
75 change allows us top properly handle completion with distinct
76 change allows us top properly handle completion with distinct
76 scopes, including in embedded instances (this had never really
77 scopes, including in embedded instances (this had never really
77 worked correctly).
78 worked correctly).
78
79
79 Note: this introduces a change in the constructor for
80 Note: this introduces a change in the constructor for
80 MagicCompleter, as a new global_namespace parameter is now the
81 MagicCompleter, as a new global_namespace parameter is now the
81 second argument (the others were bumped one position).
82 second argument (the others were bumped one position).
82
83
83 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
84 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
84
85
85 * IPython/iplib.py (embed_mainloop): fix tab-completion in
86 * IPython/iplib.py (embed_mainloop): fix tab-completion in
86 embedded instances (which can be done now thanks to Vivian's
87 embedded instances (which can be done now thanks to Vivian's
87 frame-handling fixes for pdb).
88 frame-handling fixes for pdb).
88 (InteractiveShell.__init__): Fix namespace handling problem in
89 (InteractiveShell.__init__): Fix namespace handling problem in
89 embedded instances. We were overwriting __main__ unconditionally,
90 embedded instances. We were overwriting __main__ unconditionally,
90 and this should only be done for 'full' (non-embedded) IPython;
91 and this should only be done for 'full' (non-embedded) IPython;
91 embedded instances must respect the caller's __main__. Thanks to
92 embedded instances must respect the caller's __main__. Thanks to
92 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
93 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
93
94
94 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
95 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
95
96
96 * setup.py: added download_url to setup(). This registers the
97 * setup.py: added download_url to setup(). This registers the
97 download address at PyPI, which is not only useful to humans
98 download address at PyPI, which is not only useful to humans
98 browsing the site, but is also picked up by setuptools (the Eggs
99 browsing the site, but is also picked up by setuptools (the Eggs
99 machinery). Thanks to Ville and R. Kern for the info/discussion
100 machinery). Thanks to Ville and R. Kern for the info/discussion
100 on this.
101 on this.
101
102
102 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
103 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
103
104
104 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
105 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
105 This brings a lot of nice functionality to the pdb mode, which now
106 This brings a lot of nice functionality to the pdb mode, which now
106 has tab-completion, syntax highlighting, and better stack handling
107 has tab-completion, syntax highlighting, and better stack handling
107 than before. Many thanks to Vivian De Smedt
108 than before. Many thanks to Vivian De Smedt
108 <vivian-AT-vdesmedt.com> for the original patches.
109 <vivian-AT-vdesmedt.com> for the original patches.
109
110
110 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
111 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
111
112
112 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
113 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
113 sequence to consistently accept the banner argument. The
114 sequence to consistently accept the banner argument. The
114 inconsistency was tripping SAGE, thanks to Gary Zablackis
115 inconsistency was tripping SAGE, thanks to Gary Zablackis
115 <gzabl-AT-yahoo.com> for the report.
116 <gzabl-AT-yahoo.com> for the report.
116
117
117 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
118 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
118
119
119 * IPython/iplib.py (InteractiveShell.post_config_initialization):
120 * IPython/iplib.py (InteractiveShell.post_config_initialization):
120 Fix bug where a naked 'alias' call in the ipythonrc file would
121 Fix bug where a naked 'alias' call in the ipythonrc file would
121 cause a crash. Bug reported by Jorgen Stenarson.
122 cause a crash. Bug reported by Jorgen Stenarson.
122
123
123 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
124 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
124
125
125 * IPython/ipmaker.py (make_IPython): cleanups which should improve
126 * IPython/ipmaker.py (make_IPython): cleanups which should improve
126 startup time.
127 startup time.
127
128
128 * IPython/iplib.py (runcode): my globals 'fix' for embedded
129 * IPython/iplib.py (runcode): my globals 'fix' for embedded
129 instances had introduced a bug with globals in normal code. Now
130 instances had introduced a bug with globals in normal code. Now
130 it's working in all cases.
131 it's working in all cases.
131
132
132 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
133 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
133 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
134 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
134 has been introduced to set the default case sensitivity of the
135 has been introduced to set the default case sensitivity of the
135 searches. Users can still select either mode at runtime on a
136 searches. Users can still select either mode at runtime on a
136 per-search basis.
137 per-search basis.
137
138
138 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
139 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
139
140
140 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
141 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
141 attributes in wildcard searches for subclasses. Modified version
142 attributes in wildcard searches for subclasses. Modified version
142 of a patch by Jorgen.
143 of a patch by Jorgen.
143
144
144 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
145 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
145
146
146 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
147 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
147 embedded instances. I added a user_global_ns attribute to the
148 embedded instances. I added a user_global_ns attribute to the
148 InteractiveShell class to handle this.
149 InteractiveShell class to handle this.
149
150
150 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
151 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
151
152
152 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
153 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
153 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
154 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
154 (reported under win32, but may happen also in other platforms).
155 (reported under win32, but may happen also in other platforms).
155 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
156 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
156
157
157 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
158 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
158
159
159 * IPython/Magic.py (magic_psearch): new support for wildcard
160 * IPython/Magic.py (magic_psearch): new support for wildcard
160 patterns. Now, typing ?a*b will list all names which begin with a
161 patterns. Now, typing ?a*b will list all names which begin with a
161 and end in b, for example. The %psearch magic has full
162 and end in b, for example. The %psearch magic has full
162 docstrings. Many thanks to JΓΆrgen Stenarson
163 docstrings. Many thanks to JΓΆrgen Stenarson
163 <jorgen.stenarson-AT-bostream.nu>, author of the patches
164 <jorgen.stenarson-AT-bostream.nu>, author of the patches
164 implementing this functionality.
165 implementing this functionality.
165
166
166 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
167 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
167
168
168 * Manual: fixed long-standing annoyance of double-dashes (as in
169 * Manual: fixed long-standing annoyance of double-dashes (as in
169 --prefix=~, for example) being stripped in the HTML version. This
170 --prefix=~, for example) being stripped in the HTML version. This
170 is a latex2html bug, but a workaround was provided. Many thanks
171 is a latex2html bug, but a workaround was provided. Many thanks
171 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
172 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
172 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
173 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
173 rolling. This seemingly small issue had tripped a number of users
174 rolling. This seemingly small issue had tripped a number of users
174 when first installing, so I'm glad to see it gone.
175 when first installing, so I'm glad to see it gone.
175
176
176 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
177 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
177
178
178 * IPython/Extensions/numeric_formats.py: fix missing import,
179 * IPython/Extensions/numeric_formats.py: fix missing import,
179 reported by Stephen Walton.
180 reported by Stephen Walton.
180
181
181 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
182 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
182
183
183 * IPython/demo.py: finish demo module, fully documented now.
184 * IPython/demo.py: finish demo module, fully documented now.
184
185
185 * IPython/genutils.py (file_read): simple little utility to read a
186 * IPython/genutils.py (file_read): simple little utility to read a
186 file and ensure it's closed afterwards.
187 file and ensure it's closed afterwards.
187
188
188 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
189 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
189
190
190 * IPython/demo.py (Demo.__init__): added support for individually
191 * IPython/demo.py (Demo.__init__): added support for individually
191 tagging blocks for automatic execution.
192 tagging blocks for automatic execution.
192
193
193 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
194 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
194 syntax-highlighted python sources, requested by John.
195 syntax-highlighted python sources, requested by John.
195
196
196 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
197 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
197
198
198 * IPython/demo.py (Demo.again): fix bug where again() blocks after
199 * IPython/demo.py (Demo.again): fix bug where again() blocks after
199 finishing.
200 finishing.
200
201
201 * IPython/genutils.py (shlex_split): moved from Magic to here,
202 * IPython/genutils.py (shlex_split): moved from Magic to here,
202 where all 2.2 compatibility stuff lives. I needed it for demo.py.
203 where all 2.2 compatibility stuff lives. I needed it for demo.py.
203
204
204 * IPython/demo.py (Demo.__init__): added support for silent
205 * IPython/demo.py (Demo.__init__): added support for silent
205 blocks, improved marks as regexps, docstrings written.
206 blocks, improved marks as regexps, docstrings written.
206 (Demo.__init__): better docstring, added support for sys.argv.
207 (Demo.__init__): better docstring, added support for sys.argv.
207
208
208 * IPython/genutils.py (marquee): little utility used by the demo
209 * IPython/genutils.py (marquee): little utility used by the demo
209 code, handy in general.
210 code, handy in general.
210
211
211 * IPython/demo.py (Demo.__init__): new class for interactive
212 * IPython/demo.py (Demo.__init__): new class for interactive
212 demos. Not documented yet, I just wrote it in a hurry for
213 demos. Not documented yet, I just wrote it in a hurry for
213 scipy'05. Will docstring later.
214 scipy'05. Will docstring later.
214
215
215 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
216 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
216
217
217 * IPython/Shell.py (sigint_handler): Drastic simplification which
218 * IPython/Shell.py (sigint_handler): Drastic simplification which
218 also seems to make Ctrl-C work correctly across threads! This is
219 also seems to make Ctrl-C work correctly across threads! This is
219 so simple, that I can't beleive I'd missed it before. Needs more
220 so simple, that I can't beleive I'd missed it before. Needs more
220 testing, though.
221 testing, though.
221 (KBINT): Never mind, revert changes. I'm sure I'd tried something
222 (KBINT): Never mind, revert changes. I'm sure I'd tried something
222 like this before...
223 like this before...
223
224
224 * IPython/genutils.py (get_home_dir): add protection against
225 * IPython/genutils.py (get_home_dir): add protection against
225 non-dirs in win32 registry.
226 non-dirs in win32 registry.
226
227
227 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
228 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
228 bug where dict was mutated while iterating (pysh crash).
229 bug where dict was mutated while iterating (pysh crash).
229
230
230 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
231 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
231
232
232 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
233 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
233 spurious newlines added by this routine. After a report by
234 spurious newlines added by this routine. After a report by
234 F. Mantegazza.
235 F. Mantegazza.
235
236
236 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
237 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
237
238
238 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
239 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
239 calls. These were a leftover from the GTK 1.x days, and can cause
240 calls. These were a leftover from the GTK 1.x days, and can cause
240 problems in certain cases (after a report by John Hunter).
241 problems in certain cases (after a report by John Hunter).
241
242
242 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
243 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
243 os.getcwd() fails at init time. Thanks to patch from David Remahl
244 os.getcwd() fails at init time. Thanks to patch from David Remahl
244 <chmod007-AT-mac.com>.
245 <chmod007-AT-mac.com>.
245 (InteractiveShell.__init__): prevent certain special magics from
246 (InteractiveShell.__init__): prevent certain special magics from
246 being shadowed by aliases. Closes
247 being shadowed by aliases. Closes
247 http://www.scipy.net/roundup/ipython/issue41.
248 http://www.scipy.net/roundup/ipython/issue41.
248
249
249 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
250 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
250
251
251 * IPython/iplib.py (InteractiveShell.complete): Added new
252 * IPython/iplib.py (InteractiveShell.complete): Added new
252 top-level completion method to expose the completion mechanism
253 top-level completion method to expose the completion mechanism
253 beyond readline-based environments.
254 beyond readline-based environments.
254
255
255 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
256 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
256
257
257 * tools/ipsvnc (svnversion): fix svnversion capture.
258 * tools/ipsvnc (svnversion): fix svnversion capture.
258
259
259 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
260 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
260 attribute to self, which was missing. Before, it was set by a
261 attribute to self, which was missing. Before, it was set by a
261 routine which in certain cases wasn't being called, so the
262 routine which in certain cases wasn't being called, so the
262 instance could end up missing the attribute. This caused a crash.
263 instance could end up missing the attribute. This caused a crash.
263 Closes http://www.scipy.net/roundup/ipython/issue40.
264 Closes http://www.scipy.net/roundup/ipython/issue40.
264
265
265 2005-08-16 Fernando Perez <fperez@colorado.edu>
266 2005-08-16 Fernando Perez <fperez@colorado.edu>
266
267
267 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
268 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
268 contains non-string attribute. Closes
269 contains non-string attribute. Closes
269 http://www.scipy.net/roundup/ipython/issue38.
270 http://www.scipy.net/roundup/ipython/issue38.
270
271
271 2005-08-14 Fernando Perez <fperez@colorado.edu>
272 2005-08-14 Fernando Perez <fperez@colorado.edu>
272
273
273 * tools/ipsvnc: Minor improvements, to add changeset info.
274 * tools/ipsvnc: Minor improvements, to add changeset info.
274
275
275 2005-08-12 Fernando Perez <fperez@colorado.edu>
276 2005-08-12 Fernando Perez <fperez@colorado.edu>
276
277
277 * IPython/iplib.py (runsource): remove self.code_to_run_src
278 * IPython/iplib.py (runsource): remove self.code_to_run_src
278 attribute. I realized this is nothing more than
279 attribute. I realized this is nothing more than
279 '\n'.join(self.buffer), and having the same data in two different
280 '\n'.join(self.buffer), and having the same data in two different
280 places is just asking for synchronization bugs. This may impact
281 places is just asking for synchronization bugs. This may impact
281 people who have custom exception handlers, so I need to warn
282 people who have custom exception handlers, so I need to warn
282 ipython-dev about it (F. Mantegazza may use them).
283 ipython-dev about it (F. Mantegazza may use them).
283
284
284 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
285 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
285
286
286 * IPython/genutils.py: fix 2.2 compatibility (generators)
287 * IPython/genutils.py: fix 2.2 compatibility (generators)
287
288
288 2005-07-18 Fernando Perez <fperez@colorado.edu>
289 2005-07-18 Fernando Perez <fperez@colorado.edu>
289
290
290 * IPython/genutils.py (get_home_dir): fix to help users with
291 * IPython/genutils.py (get_home_dir): fix to help users with
291 invalid $HOME under win32.
292 invalid $HOME under win32.
292
293
293 2005-07-17 Fernando Perez <fperez@colorado.edu>
294 2005-07-17 Fernando Perez <fperez@colorado.edu>
294
295
295 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
296 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
296 some old hacks and clean up a bit other routines; code should be
297 some old hacks and clean up a bit other routines; code should be
297 simpler and a bit faster.
298 simpler and a bit faster.
298
299
299 * IPython/iplib.py (interact): removed some last-resort attempts
300 * IPython/iplib.py (interact): removed some last-resort attempts
300 to survive broken stdout/stderr. That code was only making it
301 to survive broken stdout/stderr. That code was only making it
301 harder to abstract out the i/o (necessary for gui integration),
302 harder to abstract out the i/o (necessary for gui integration),
302 and the crashes it could prevent were extremely rare in practice
303 and the crashes it could prevent were extremely rare in practice
303 (besides being fully user-induced in a pretty violent manner).
304 (besides being fully user-induced in a pretty violent manner).
304
305
305 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
306 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
306 Nothing major yet, but the code is simpler to read; this should
307 Nothing major yet, but the code is simpler to read; this should
307 make it easier to do more serious modifications in the future.
308 make it easier to do more serious modifications in the future.
308
309
309 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
310 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
310 which broke in .15 (thanks to a report by Ville).
311 which broke in .15 (thanks to a report by Ville).
311
312
312 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
313 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
313 be quite correct, I know next to nothing about unicode). This
314 be quite correct, I know next to nothing about unicode). This
314 will allow unicode strings to be used in prompts, amongst other
315 will allow unicode strings to be used in prompts, amongst other
315 cases. It also will prevent ipython from crashing when unicode
316 cases. It also will prevent ipython from crashing when unicode
316 shows up unexpectedly in many places. If ascii encoding fails, we
317 shows up unexpectedly in many places. If ascii encoding fails, we
317 assume utf_8. Currently the encoding is not a user-visible
318 assume utf_8. Currently the encoding is not a user-visible
318 setting, though it could be made so if there is demand for it.
319 setting, though it could be made so if there is demand for it.
319
320
320 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
321 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
321
322
322 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
323 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
323
324
324 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
325 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
325
326
326 * IPython/genutils.py: Add 2.2 compatibility here, so all other
327 * IPython/genutils.py: Add 2.2 compatibility here, so all other
327 code can work transparently for 2.2/2.3.
328 code can work transparently for 2.2/2.3.
328
329
329 2005-07-16 Fernando Perez <fperez@colorado.edu>
330 2005-07-16 Fernando Perez <fperez@colorado.edu>
330
331
331 * IPython/ultraTB.py (ExceptionColors): Make a global variable
332 * IPython/ultraTB.py (ExceptionColors): Make a global variable
332 out of the color scheme table used for coloring exception
333 out of the color scheme table used for coloring exception
333 tracebacks. This allows user code to add new schemes at runtime.
334 tracebacks. This allows user code to add new schemes at runtime.
334 This is a minimally modified version of the patch at
335 This is a minimally modified version of the patch at
335 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
336 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
336 for the contribution.
337 for the contribution.
337
338
338 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
339 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
339 slightly modified version of the patch in
340 slightly modified version of the patch in
340 http://www.scipy.net/roundup/ipython/issue34, which also allows me
341 http://www.scipy.net/roundup/ipython/issue34, which also allows me
341 to remove the previous try/except solution (which was costlier).
342 to remove the previous try/except solution (which was costlier).
342 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
343 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
343
344
344 2005-06-08 Fernando Perez <fperez@colorado.edu>
345 2005-06-08 Fernando Perez <fperez@colorado.edu>
345
346
346 * IPython/iplib.py (write/write_err): Add methods to abstract all
347 * IPython/iplib.py (write/write_err): Add methods to abstract all
347 I/O a bit more.
348 I/O a bit more.
348
349
349 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
350 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
350 warning, reported by Aric Hagberg, fix by JD Hunter.
351 warning, reported by Aric Hagberg, fix by JD Hunter.
351
352
352 2005-06-02 *** Released version 0.6.15
353 2005-06-02 *** Released version 0.6.15
353
354
354 2005-06-01 Fernando Perez <fperez@colorado.edu>
355 2005-06-01 Fernando Perez <fperez@colorado.edu>
355
356
356 * IPython/iplib.py (MagicCompleter.file_matches): Fix
357 * IPython/iplib.py (MagicCompleter.file_matches): Fix
357 tab-completion of filenames within open-quoted strings. Note that
358 tab-completion of filenames within open-quoted strings. Note that
358 this requires that in ~/.ipython/ipythonrc, users change the
359 this requires that in ~/.ipython/ipythonrc, users change the
359 readline delimiters configuration to read:
360 readline delimiters configuration to read:
360
361
361 readline_remove_delims -/~
362 readline_remove_delims -/~
362
363
363
364
364 2005-05-31 *** Released version 0.6.14
365 2005-05-31 *** Released version 0.6.14
365
366
366 2005-05-29 Fernando Perez <fperez@colorado.edu>
367 2005-05-29 Fernando Perez <fperez@colorado.edu>
367
368
368 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
369 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
369 with files not on the filesystem. Reported by Eliyahu Sandler
370 with files not on the filesystem. Reported by Eliyahu Sandler
370 <eli@gondolin.net>
371 <eli@gondolin.net>
371
372
372 2005-05-22 Fernando Perez <fperez@colorado.edu>
373 2005-05-22 Fernando Perez <fperez@colorado.edu>
373
374
374 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
375 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
375 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
376 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
376
377
377 2005-05-19 Fernando Perez <fperez@colorado.edu>
378 2005-05-19 Fernando Perez <fperez@colorado.edu>
378
379
379 * IPython/iplib.py (safe_execfile): close a file which could be
380 * IPython/iplib.py (safe_execfile): close a file which could be
380 left open (causing problems in win32, which locks open files).
381 left open (causing problems in win32, which locks open files).
381 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
382 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
382
383
383 2005-05-18 Fernando Perez <fperez@colorado.edu>
384 2005-05-18 Fernando Perez <fperez@colorado.edu>
384
385
385 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
386 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
386 keyword arguments correctly to safe_execfile().
387 keyword arguments correctly to safe_execfile().
387
388
388 2005-05-13 Fernando Perez <fperez@colorado.edu>
389 2005-05-13 Fernando Perez <fperez@colorado.edu>
389
390
390 * ipython.1: Added info about Qt to manpage, and threads warning
391 * ipython.1: Added info about Qt to manpage, and threads warning
391 to usage page (invoked with --help).
392 to usage page (invoked with --help).
392
393
393 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
394 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
394 new matcher (it goes at the end of the priority list) to do
395 new matcher (it goes at the end of the priority list) to do
395 tab-completion on named function arguments. Submitted by George
396 tab-completion on named function arguments. Submitted by George
396 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
397 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
397 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
398 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
398 for more details.
399 for more details.
399
400
400 * IPython/Magic.py (magic_run): Added new -e flag to ignore
401 * IPython/Magic.py (magic_run): Added new -e flag to ignore
401 SystemExit exceptions in the script being run. Thanks to a report
402 SystemExit exceptions in the script being run. Thanks to a report
402 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
403 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
403 producing very annoying behavior when running unit tests.
404 producing very annoying behavior when running unit tests.
404
405
405 2005-05-12 Fernando Perez <fperez@colorado.edu>
406 2005-05-12 Fernando Perez <fperez@colorado.edu>
406
407
407 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
408 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
408 which I'd broken (again) due to a changed regexp. In the process,
409 which I'd broken (again) due to a changed regexp. In the process,
409 added ';' as an escape to auto-quote the whole line without
410 added ';' as an escape to auto-quote the whole line without
410 splitting its arguments. Thanks to a report by Jerry McRae
411 splitting its arguments. Thanks to a report by Jerry McRae
411 <qrs0xyc02-AT-sneakemail.com>.
412 <qrs0xyc02-AT-sneakemail.com>.
412
413
413 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
414 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
414 possible crashes caused by a TokenError. Reported by Ed Schofield
415 possible crashes caused by a TokenError. Reported by Ed Schofield
415 <schofield-AT-ftw.at>.
416 <schofield-AT-ftw.at>.
416
417
417 2005-05-06 Fernando Perez <fperez@colorado.edu>
418 2005-05-06 Fernando Perez <fperez@colorado.edu>
418
419
419 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
420 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
420
421
421 2005-04-29 Fernando Perez <fperez@colorado.edu>
422 2005-04-29 Fernando Perez <fperez@colorado.edu>
422
423
423 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
424 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
424 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
425 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
425 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
426 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
426 which provides support for Qt interactive usage (similar to the
427 which provides support for Qt interactive usage (similar to the
427 existing one for WX and GTK). This had been often requested.
428 existing one for WX and GTK). This had been often requested.
428
429
429 2005-04-14 *** Released version 0.6.13
430 2005-04-14 *** Released version 0.6.13
430
431
431 2005-04-08 Fernando Perez <fperez@colorado.edu>
432 2005-04-08 Fernando Perez <fperez@colorado.edu>
432
433
433 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
434 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
434 from _ofind, which gets called on almost every input line. Now,
435 from _ofind, which gets called on almost every input line. Now,
435 we only try to get docstrings if they are actually going to be
436 we only try to get docstrings if they are actually going to be
436 used (the overhead of fetching unnecessary docstrings can be
437 used (the overhead of fetching unnecessary docstrings can be
437 noticeable for certain objects, such as Pyro proxies).
438 noticeable for certain objects, such as Pyro proxies).
438
439
439 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
440 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
440 for completers. For some reason I had been passing them the state
441 for completers. For some reason I had been passing them the state
441 variable, which completers never actually need, and was in
442 variable, which completers never actually need, and was in
442 conflict with the rlcompleter API. Custom completers ONLY need to
443 conflict with the rlcompleter API. Custom completers ONLY need to
443 take the text parameter.
444 take the text parameter.
444
445
445 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
446 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
446 work correctly in pysh. I've also moved all the logic which used
447 work correctly in pysh. I've also moved all the logic which used
447 to be in pysh.py here, which will prevent problems with future
448 to be in pysh.py here, which will prevent problems with future
448 upgrades. However, this time I must warn users to update their
449 upgrades. However, this time I must warn users to update their
449 pysh profile to include the line
450 pysh profile to include the line
450
451
451 import_all IPython.Extensions.InterpreterExec
452 import_all IPython.Extensions.InterpreterExec
452
453
453 because otherwise things won't work for them. They MUST also
454 because otherwise things won't work for them. They MUST also
454 delete pysh.py and the line
455 delete pysh.py and the line
455
456
456 execfile pysh.py
457 execfile pysh.py
457
458
458 from their ipythonrc-pysh.
459 from their ipythonrc-pysh.
459
460
460 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
461 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
461 robust in the face of objects whose dir() returns non-strings
462 robust in the face of objects whose dir() returns non-strings
462 (which it shouldn't, but some broken libs like ITK do). Thanks to
463 (which it shouldn't, but some broken libs like ITK do). Thanks to
463 a patch by John Hunter (implemented differently, though). Also
464 a patch by John Hunter (implemented differently, though). Also
464 minor improvements by using .extend instead of + on lists.
465 minor improvements by using .extend instead of + on lists.
465
466
466 * pysh.py:
467 * pysh.py:
467
468
468 2005-04-06 Fernando Perez <fperez@colorado.edu>
469 2005-04-06 Fernando Perez <fperez@colorado.edu>
469
470
470 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
471 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
471 by default, so that all users benefit from it. Those who don't
472 by default, so that all users benefit from it. Those who don't
472 want it can still turn it off.
473 want it can still turn it off.
473
474
474 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
475 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
475 config file, I'd forgotten about this, so users were getting it
476 config file, I'd forgotten about this, so users were getting it
476 off by default.
477 off by default.
477
478
478 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
479 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
479 consistency. Now magics can be called in multiline statements,
480 consistency. Now magics can be called in multiline statements,
480 and python variables can be expanded in magic calls via $var.
481 and python variables can be expanded in magic calls via $var.
481 This makes the magic system behave just like aliases or !system
482 This makes the magic system behave just like aliases or !system
482 calls.
483 calls.
483
484
484 2005-03-28 Fernando Perez <fperez@colorado.edu>
485 2005-03-28 Fernando Perez <fperez@colorado.edu>
485
486
486 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
487 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
487 expensive string additions for building command. Add support for
488 expensive string additions for building command. Add support for
488 trailing ';' when autocall is used.
489 trailing ';' when autocall is used.
489
490
490 2005-03-26 Fernando Perez <fperez@colorado.edu>
491 2005-03-26 Fernando Perez <fperez@colorado.edu>
491
492
492 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
493 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
493 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
494 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
494 ipython.el robust against prompts with any number of spaces
495 ipython.el robust against prompts with any number of spaces
495 (including 0) after the ':' character.
496 (including 0) after the ':' character.
496
497
497 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
498 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
498 continuation prompt, which misled users to think the line was
499 continuation prompt, which misled users to think the line was
499 already indented. Closes debian Bug#300847, reported to me by
500 already indented. Closes debian Bug#300847, reported to me by
500 Norbert Tretkowski <tretkowski-AT-inittab.de>.
501 Norbert Tretkowski <tretkowski-AT-inittab.de>.
501
502
502 2005-03-23 Fernando Perez <fperez@colorado.edu>
503 2005-03-23 Fernando Perez <fperez@colorado.edu>
503
504
504 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
505 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
505 properly aligned if they have embedded newlines.
506 properly aligned if they have embedded newlines.
506
507
507 * IPython/iplib.py (runlines): Add a public method to expose
508 * IPython/iplib.py (runlines): Add a public method to expose
508 IPython's code execution machinery, so that users can run strings
509 IPython's code execution machinery, so that users can run strings
509 as if they had been typed at the prompt interactively.
510 as if they had been typed at the prompt interactively.
510 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
511 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
511 methods which can call the system shell, but with python variable
512 methods which can call the system shell, but with python variable
512 expansion. The three such methods are: __IPYTHON__.system,
513 expansion. The three such methods are: __IPYTHON__.system,
513 .getoutput and .getoutputerror. These need to be documented in a
514 .getoutput and .getoutputerror. These need to be documented in a
514 'public API' section (to be written) of the manual.
515 'public API' section (to be written) of the manual.
515
516
516 2005-03-20 Fernando Perez <fperez@colorado.edu>
517 2005-03-20 Fernando Perez <fperez@colorado.edu>
517
518
518 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
519 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
519 for custom exception handling. This is quite powerful, and it
520 for custom exception handling. This is quite powerful, and it
520 allows for user-installable exception handlers which can trap
521 allows for user-installable exception handlers which can trap
521 custom exceptions at runtime and treat them separately from
522 custom exceptions at runtime and treat them separately from
522 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
523 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
523 Mantegazza <mantegazza-AT-ill.fr>.
524 Mantegazza <mantegazza-AT-ill.fr>.
524 (InteractiveShell.set_custom_completer): public API function to
525 (InteractiveShell.set_custom_completer): public API function to
525 add new completers at runtime.
526 add new completers at runtime.
526
527
527 2005-03-19 Fernando Perez <fperez@colorado.edu>
528 2005-03-19 Fernando Perez <fperez@colorado.edu>
528
529
529 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
530 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
530 allow objects which provide their docstrings via non-standard
531 allow objects which provide their docstrings via non-standard
531 mechanisms (like Pyro proxies) to still be inspected by ipython's
532 mechanisms (like Pyro proxies) to still be inspected by ipython's
532 ? system.
533 ? system.
533
534
534 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
535 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
535 automatic capture system. I tried quite hard to make it work
536 automatic capture system. I tried quite hard to make it work
536 reliably, and simply failed. I tried many combinations with the
537 reliably, and simply failed. I tried many combinations with the
537 subprocess module, but eventually nothing worked in all needed
538 subprocess module, but eventually nothing worked in all needed
538 cases (not blocking stdin for the child, duplicating stdout
539 cases (not blocking stdin for the child, duplicating stdout
539 without blocking, etc). The new %sc/%sx still do capture to these
540 without blocking, etc). The new %sc/%sx still do capture to these
540 magical list/string objects which make shell use much more
541 magical list/string objects which make shell use much more
541 conveninent, so not all is lost.
542 conveninent, so not all is lost.
542
543
543 XXX - FIX MANUAL for the change above!
544 XXX - FIX MANUAL for the change above!
544
545
545 (runsource): I copied code.py's runsource() into ipython to modify
546 (runsource): I copied code.py's runsource() into ipython to modify
546 it a bit. Now the code object and source to be executed are
547 it a bit. Now the code object and source to be executed are
547 stored in ipython. This makes this info accessible to third-party
548 stored in ipython. This makes this info accessible to third-party
548 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
549 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
549 Mantegazza <mantegazza-AT-ill.fr>.
550 Mantegazza <mantegazza-AT-ill.fr>.
550
551
551 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
552 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
552 history-search via readline (like C-p/C-n). I'd wanted this for a
553 history-search via readline (like C-p/C-n). I'd wanted this for a
553 long time, but only recently found out how to do it. For users
554 long time, but only recently found out how to do it. For users
554 who already have their ipythonrc files made and want this, just
555 who already have their ipythonrc files made and want this, just
555 add:
556 add:
556
557
557 readline_parse_and_bind "\e[A": history-search-backward
558 readline_parse_and_bind "\e[A": history-search-backward
558 readline_parse_and_bind "\e[B": history-search-forward
559 readline_parse_and_bind "\e[B": history-search-forward
559
560
560 2005-03-18 Fernando Perez <fperez@colorado.edu>
561 2005-03-18 Fernando Perez <fperez@colorado.edu>
561
562
562 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
563 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
563 LSString and SList classes which allow transparent conversions
564 LSString and SList classes which allow transparent conversions
564 between list mode and whitespace-separated string.
565 between list mode and whitespace-separated string.
565 (magic_r): Fix recursion problem in %r.
566 (magic_r): Fix recursion problem in %r.
566
567
567 * IPython/genutils.py (LSString): New class to be used for
568 * IPython/genutils.py (LSString): New class to be used for
568 automatic storage of the results of all alias/system calls in _o
569 automatic storage of the results of all alias/system calls in _o
569 and _e (stdout/err). These provide a .l/.list attribute which
570 and _e (stdout/err). These provide a .l/.list attribute which
570 does automatic splitting on newlines. This means that for most
571 does automatic splitting on newlines. This means that for most
571 uses, you'll never need to do capturing of output with %sc/%sx
572 uses, you'll never need to do capturing of output with %sc/%sx
572 anymore, since ipython keeps this always done for you. Note that
573 anymore, since ipython keeps this always done for you. Note that
573 only the LAST results are stored, the _o/e variables are
574 only the LAST results are stored, the _o/e variables are
574 overwritten on each call. If you need to save their contents
575 overwritten on each call. If you need to save their contents
575 further, simply bind them to any other name.
576 further, simply bind them to any other name.
576
577
577 2005-03-17 Fernando Perez <fperez@colorado.edu>
578 2005-03-17 Fernando Perez <fperez@colorado.edu>
578
579
579 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
580 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
580 prompt namespace handling.
581 prompt namespace handling.
581
582
582 2005-03-16 Fernando Perez <fperez@colorado.edu>
583 2005-03-16 Fernando Perez <fperez@colorado.edu>
583
584
584 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
585 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
585 classic prompts to be '>>> ' (final space was missing, and it
586 classic prompts to be '>>> ' (final space was missing, and it
586 trips the emacs python mode).
587 trips the emacs python mode).
587 (BasePrompt.__str__): Added safe support for dynamic prompt
588 (BasePrompt.__str__): Added safe support for dynamic prompt
588 strings. Now you can set your prompt string to be '$x', and the
589 strings. Now you can set your prompt string to be '$x', and the
589 value of x will be printed from your interactive namespace. The
590 value of x will be printed from your interactive namespace. The
590 interpolation syntax includes the full Itpl support, so
591 interpolation syntax includes the full Itpl support, so
591 ${foo()+x+bar()} is a valid prompt string now, and the function
592 ${foo()+x+bar()} is a valid prompt string now, and the function
592 calls will be made at runtime.
593 calls will be made at runtime.
593
594
594 2005-03-15 Fernando Perez <fperez@colorado.edu>
595 2005-03-15 Fernando Perez <fperez@colorado.edu>
595
596
596 * IPython/Magic.py (magic_history): renamed %hist to %history, to
597 * IPython/Magic.py (magic_history): renamed %hist to %history, to
597 avoid name clashes in pylab. %hist still works, it just forwards
598 avoid name clashes in pylab. %hist still works, it just forwards
598 the call to %history.
599 the call to %history.
599
600
600 2005-03-02 *** Released version 0.6.12
601 2005-03-02 *** Released version 0.6.12
601
602
602 2005-03-02 Fernando Perez <fperez@colorado.edu>
603 2005-03-02 Fernando Perez <fperez@colorado.edu>
603
604
604 * IPython/iplib.py (handle_magic): log magic calls properly as
605 * IPython/iplib.py (handle_magic): log magic calls properly as
605 ipmagic() function calls.
606 ipmagic() function calls.
606
607
607 * IPython/Magic.py (magic_time): Improved %time to support
608 * IPython/Magic.py (magic_time): Improved %time to support
608 statements and provide wall-clock as well as CPU time.
609 statements and provide wall-clock as well as CPU time.
609
610
610 2005-02-27 Fernando Perez <fperez@colorado.edu>
611 2005-02-27 Fernando Perez <fperez@colorado.edu>
611
612
612 * IPython/hooks.py: New hooks module, to expose user-modifiable
613 * IPython/hooks.py: New hooks module, to expose user-modifiable
613 IPython functionality in a clean manner. For now only the editor
614 IPython functionality in a clean manner. For now only the editor
614 hook is actually written, and other thigns which I intend to turn
615 hook is actually written, and other thigns which I intend to turn
615 into proper hooks aren't yet there. The display and prefilter
616 into proper hooks aren't yet there. The display and prefilter
616 stuff, for example, should be hooks. But at least now the
617 stuff, for example, should be hooks. But at least now the
617 framework is in place, and the rest can be moved here with more
618 framework is in place, and the rest can be moved here with more
618 time later. IPython had had a .hooks variable for a long time for
619 time later. IPython had had a .hooks variable for a long time for
619 this purpose, but I'd never actually used it for anything.
620 this purpose, but I'd never actually used it for anything.
620
621
621 2005-02-26 Fernando Perez <fperez@colorado.edu>
622 2005-02-26 Fernando Perez <fperez@colorado.edu>
622
623
623 * IPython/ipmaker.py (make_IPython): make the default ipython
624 * IPython/ipmaker.py (make_IPython): make the default ipython
624 directory be called _ipython under win32, to follow more the
625 directory be called _ipython under win32, to follow more the
625 naming peculiarities of that platform (where buggy software like
626 naming peculiarities of that platform (where buggy software like
626 Visual Sourcesafe breaks with .named directories). Reported by
627 Visual Sourcesafe breaks with .named directories). Reported by
627 Ville Vainio.
628 Ville Vainio.
628
629
629 2005-02-23 Fernando Perez <fperez@colorado.edu>
630 2005-02-23 Fernando Perez <fperez@colorado.edu>
630
631
631 * IPython/iplib.py (InteractiveShell.__init__): removed a few
632 * IPython/iplib.py (InteractiveShell.__init__): removed a few
632 auto_aliases for win32 which were causing problems. Users can
633 auto_aliases for win32 which were causing problems. Users can
633 define the ones they personally like.
634 define the ones they personally like.
634
635
635 2005-02-21 Fernando Perez <fperez@colorado.edu>
636 2005-02-21 Fernando Perez <fperez@colorado.edu>
636
637
637 * IPython/Magic.py (magic_time): new magic to time execution of
638 * IPython/Magic.py (magic_time): new magic to time execution of
638 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
639 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
639
640
640 2005-02-19 Fernando Perez <fperez@colorado.edu>
641 2005-02-19 Fernando Perez <fperez@colorado.edu>
641
642
642 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
643 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
643 into keys (for prompts, for example).
644 into keys (for prompts, for example).
644
645
645 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
646 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
646 prompts in case users want them. This introduces a small behavior
647 prompts in case users want them. This introduces a small behavior
647 change: ipython does not automatically add a space to all prompts
648 change: ipython does not automatically add a space to all prompts
648 anymore. To get the old prompts with a space, users should add it
649 anymore. To get the old prompts with a space, users should add it
649 manually to their ipythonrc file, so for example prompt_in1 should
650 manually to their ipythonrc file, so for example prompt_in1 should
650 now read 'In [\#]: ' instead of 'In [\#]:'.
651 now read 'In [\#]: ' instead of 'In [\#]:'.
651 (BasePrompt.__init__): New option prompts_pad_left (only in rc
652 (BasePrompt.__init__): New option prompts_pad_left (only in rc
652 file) to control left-padding of secondary prompts.
653 file) to control left-padding of secondary prompts.
653
654
654 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
655 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
655 the profiler can't be imported. Fix for Debian, which removed
656 the profiler can't be imported. Fix for Debian, which removed
656 profile.py because of License issues. I applied a slightly
657 profile.py because of License issues. I applied a slightly
657 modified version of the original Debian patch at
658 modified version of the original Debian patch at
658 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
659 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
659
660
660 2005-02-17 Fernando Perez <fperez@colorado.edu>
661 2005-02-17 Fernando Perez <fperez@colorado.edu>
661
662
662 * IPython/genutils.py (native_line_ends): Fix bug which would
663 * IPython/genutils.py (native_line_ends): Fix bug which would
663 cause improper line-ends under win32 b/c I was not opening files
664 cause improper line-ends under win32 b/c I was not opening files
664 in binary mode. Bug report and fix thanks to Ville.
665 in binary mode. Bug report and fix thanks to Ville.
665
666
666 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
667 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
667 trying to catch spurious foo[1] autocalls. My fix actually broke
668 trying to catch spurious foo[1] autocalls. My fix actually broke
668 ',/' autoquote/call with explicit escape (bad regexp).
669 ',/' autoquote/call with explicit escape (bad regexp).
669
670
670 2005-02-15 *** Released version 0.6.11
671 2005-02-15 *** Released version 0.6.11
671
672
672 2005-02-14 Fernando Perez <fperez@colorado.edu>
673 2005-02-14 Fernando Perez <fperez@colorado.edu>
673
674
674 * IPython/background_jobs.py: New background job management
675 * IPython/background_jobs.py: New background job management
675 subsystem. This is implemented via a new set of classes, and
676 subsystem. This is implemented via a new set of classes, and
676 IPython now provides a builtin 'jobs' object for background job
677 IPython now provides a builtin 'jobs' object for background job
677 execution. A convenience %bg magic serves as a lightweight
678 execution. A convenience %bg magic serves as a lightweight
678 frontend for starting the more common type of calls. This was
679 frontend for starting the more common type of calls. This was
679 inspired by discussions with B. Granger and the BackgroundCommand
680 inspired by discussions with B. Granger and the BackgroundCommand
680 class described in the book Python Scripting for Computational
681 class described in the book Python Scripting for Computational
681 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
682 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
682 (although ultimately no code from this text was used, as IPython's
683 (although ultimately no code from this text was used, as IPython's
683 system is a separate implementation).
684 system is a separate implementation).
684
685
685 * IPython/iplib.py (MagicCompleter.python_matches): add new option
686 * IPython/iplib.py (MagicCompleter.python_matches): add new option
686 to control the completion of single/double underscore names
687 to control the completion of single/double underscore names
687 separately. As documented in the example ipytonrc file, the
688 separately. As documented in the example ipytonrc file, the
688 readline_omit__names variable can now be set to 2, to omit even
689 readline_omit__names variable can now be set to 2, to omit even
689 single underscore names. Thanks to a patch by Brian Wong
690 single underscore names. Thanks to a patch by Brian Wong
690 <BrianWong-AT-AirgoNetworks.Com>.
691 <BrianWong-AT-AirgoNetworks.Com>.
691 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
692 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
692 be autocalled as foo([1]) if foo were callable. A problem for
693 be autocalled as foo([1]) if foo were callable. A problem for
693 things which are both callable and implement __getitem__.
694 things which are both callable and implement __getitem__.
694 (init_readline): Fix autoindentation for win32. Thanks to a patch
695 (init_readline): Fix autoindentation for win32. Thanks to a patch
695 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
696 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
696
697
697 2005-02-12 Fernando Perez <fperez@colorado.edu>
698 2005-02-12 Fernando Perez <fperez@colorado.edu>
698
699
699 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
700 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
700 which I had written long ago to sort out user error messages which
701 which I had written long ago to sort out user error messages which
701 may occur during startup. This seemed like a good idea initially,
702 may occur during startup. This seemed like a good idea initially,
702 but it has proven a disaster in retrospect. I don't want to
703 but it has proven a disaster in retrospect. I don't want to
703 change much code for now, so my fix is to set the internal 'debug'
704 change much code for now, so my fix is to set the internal 'debug'
704 flag to true everywhere, whose only job was precisely to control
705 flag to true everywhere, whose only job was precisely to control
705 this subsystem. This closes issue 28 (as well as avoiding all
706 this subsystem. This closes issue 28 (as well as avoiding all
706 sorts of strange hangups which occur from time to time).
707 sorts of strange hangups which occur from time to time).
707
708
708 2005-02-07 Fernando Perez <fperez@colorado.edu>
709 2005-02-07 Fernando Perez <fperez@colorado.edu>
709
710
710 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
711 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
711 previous call produced a syntax error.
712 previous call produced a syntax error.
712
713
713 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
714 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
714 classes without constructor.
715 classes without constructor.
715
716
716 2005-02-06 Fernando Perez <fperez@colorado.edu>
717 2005-02-06 Fernando Perez <fperez@colorado.edu>
717
718
718 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
719 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
719 completions with the results of each matcher, so we return results
720 completions with the results of each matcher, so we return results
720 to the user from all namespaces. This breaks with ipython
721 to the user from all namespaces. This breaks with ipython
721 tradition, but I think it's a nicer behavior. Now you get all
722 tradition, but I think it's a nicer behavior. Now you get all
722 possible completions listed, from all possible namespaces (python,
723 possible completions listed, from all possible namespaces (python,
723 filesystem, magics...) After a request by John Hunter
724 filesystem, magics...) After a request by John Hunter
724 <jdhunter-AT-nitace.bsd.uchicago.edu>.
725 <jdhunter-AT-nitace.bsd.uchicago.edu>.
725
726
726 2005-02-05 Fernando Perez <fperez@colorado.edu>
727 2005-02-05 Fernando Perez <fperez@colorado.edu>
727
728
728 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
729 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
729 the call had quote characters in it (the quotes were stripped).
730 the call had quote characters in it (the quotes were stripped).
730
731
731 2005-01-31 Fernando Perez <fperez@colorado.edu>
732 2005-01-31 Fernando Perez <fperez@colorado.edu>
732
733
733 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
734 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
734 Itpl.itpl() to make the code more robust against psyco
735 Itpl.itpl() to make the code more robust against psyco
735 optimizations.
736 optimizations.
736
737
737 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
738 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
738 of causing an exception. Quicker, cleaner.
739 of causing an exception. Quicker, cleaner.
739
740
740 2005-01-28 Fernando Perez <fperez@colorado.edu>
741 2005-01-28 Fernando Perez <fperez@colorado.edu>
741
742
742 * scripts/ipython_win_post_install.py (install): hardcode
743 * scripts/ipython_win_post_install.py (install): hardcode
743 sys.prefix+'python.exe' as the executable path. It turns out that
744 sys.prefix+'python.exe' as the executable path. It turns out that
744 during the post-installation run, sys.executable resolves to the
745 during the post-installation run, sys.executable resolves to the
745 name of the binary installer! I should report this as a distutils
746 name of the binary installer! I should report this as a distutils
746 bug, I think. I updated the .10 release with this tiny fix, to
747 bug, I think. I updated the .10 release with this tiny fix, to
747 avoid annoying the lists further.
748 avoid annoying the lists further.
748
749
749 2005-01-27 *** Released version 0.6.10
750 2005-01-27 *** Released version 0.6.10
750
751
751 2005-01-27 Fernando Perez <fperez@colorado.edu>
752 2005-01-27 Fernando Perez <fperez@colorado.edu>
752
753
753 * IPython/numutils.py (norm): Added 'inf' as optional name for
754 * IPython/numutils.py (norm): Added 'inf' as optional name for
754 L-infinity norm, included references to mathworld.com for vector
755 L-infinity norm, included references to mathworld.com for vector
755 norm definitions.
756 norm definitions.
756 (amin/amax): added amin/amax for array min/max. Similar to what
757 (amin/amax): added amin/amax for array min/max. Similar to what
757 pylab ships with after the recent reorganization of names.
758 pylab ships with after the recent reorganization of names.
758 (spike/spike_odd): removed deprecated spike/spike_odd functions.
759 (spike/spike_odd): removed deprecated spike/spike_odd functions.
759
760
760 * ipython.el: committed Alex's recent fixes and improvements.
761 * ipython.el: committed Alex's recent fixes and improvements.
761 Tested with python-mode from CVS, and it looks excellent. Since
762 Tested with python-mode from CVS, and it looks excellent. Since
762 python-mode hasn't released anything in a while, I'm temporarily
763 python-mode hasn't released anything in a while, I'm temporarily
763 putting a copy of today's CVS (v 4.70) of python-mode in:
764 putting a copy of today's CVS (v 4.70) of python-mode in:
764 http://ipython.scipy.org/tmp/python-mode.el
765 http://ipython.scipy.org/tmp/python-mode.el
765
766
766 * scripts/ipython_win_post_install.py (install): Win32 fix to use
767 * scripts/ipython_win_post_install.py (install): Win32 fix to use
767 sys.executable for the executable name, instead of assuming it's
768 sys.executable for the executable name, instead of assuming it's
768 called 'python.exe' (the post-installer would have produced broken
769 called 'python.exe' (the post-installer would have produced broken
769 setups on systems with a differently named python binary).
770 setups on systems with a differently named python binary).
770
771
771 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
772 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
772 references to os.linesep, to make the code more
773 references to os.linesep, to make the code more
773 platform-independent. This is also part of the win32 coloring
774 platform-independent. This is also part of the win32 coloring
774 fixes.
775 fixes.
775
776
776 * IPython/genutils.py (page_dumb): Remove attempts to chop long
777 * IPython/genutils.py (page_dumb): Remove attempts to chop long
777 lines, which actually cause coloring bugs because the length of
778 lines, which actually cause coloring bugs because the length of
778 the line is very difficult to correctly compute with embedded
779 the line is very difficult to correctly compute with embedded
779 escapes. This was the source of all the coloring problems under
780 escapes. This was the source of all the coloring problems under
780 Win32. I think that _finally_, Win32 users have a properly
781 Win32. I think that _finally_, Win32 users have a properly
781 working ipython in all respects. This would never have happened
782 working ipython in all respects. This would never have happened
782 if not for Gary Bishop and Viktor Ransmayr's great help and work.
783 if not for Gary Bishop and Viktor Ransmayr's great help and work.
783
784
784 2005-01-26 *** Released version 0.6.9
785 2005-01-26 *** Released version 0.6.9
785
786
786 2005-01-25 Fernando Perez <fperez@colorado.edu>
787 2005-01-25 Fernando Perez <fperez@colorado.edu>
787
788
788 * setup.py: finally, we have a true Windows installer, thanks to
789 * setup.py: finally, we have a true Windows installer, thanks to
789 the excellent work of Viktor Ransmayr
790 the excellent work of Viktor Ransmayr
790 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
791 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
791 Windows users. The setup routine is quite a bit cleaner thanks to
792 Windows users. The setup routine is quite a bit cleaner thanks to
792 this, and the post-install script uses the proper functions to
793 this, and the post-install script uses the proper functions to
793 allow a clean de-installation using the standard Windows Control
794 allow a clean de-installation using the standard Windows Control
794 Panel.
795 Panel.
795
796
796 * IPython/genutils.py (get_home_dir): changed to use the $HOME
797 * IPython/genutils.py (get_home_dir): changed to use the $HOME
797 environment variable under all OSes (including win32) if
798 environment variable under all OSes (including win32) if
798 available. This will give consistency to win32 users who have set
799 available. This will give consistency to win32 users who have set
799 this variable for any reason. If os.environ['HOME'] fails, the
800 this variable for any reason. If os.environ['HOME'] fails, the
800 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
801 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
801
802
802 2005-01-24 Fernando Perez <fperez@colorado.edu>
803 2005-01-24 Fernando Perez <fperez@colorado.edu>
803
804
804 * IPython/numutils.py (empty_like): add empty_like(), similar to
805 * IPython/numutils.py (empty_like): add empty_like(), similar to
805 zeros_like() but taking advantage of the new empty() Numeric routine.
806 zeros_like() but taking advantage of the new empty() Numeric routine.
806
807
807 2005-01-23 *** Released version 0.6.8
808 2005-01-23 *** Released version 0.6.8
808
809
809 2005-01-22 Fernando Perez <fperez@colorado.edu>
810 2005-01-22 Fernando Perez <fperez@colorado.edu>
810
811
811 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
812 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
812 automatic show() calls. After discussing things with JDH, it
813 automatic show() calls. After discussing things with JDH, it
813 turns out there are too many corner cases where this can go wrong.
814 turns out there are too many corner cases where this can go wrong.
814 It's best not to try to be 'too smart', and simply have ipython
815 It's best not to try to be 'too smart', and simply have ipython
815 reproduce as much as possible the default behavior of a normal
816 reproduce as much as possible the default behavior of a normal
816 python shell.
817 python shell.
817
818
818 * IPython/iplib.py (InteractiveShell.__init__): Modified the
819 * IPython/iplib.py (InteractiveShell.__init__): Modified the
819 line-splitting regexp and _prefilter() to avoid calling getattr()
820 line-splitting regexp and _prefilter() to avoid calling getattr()
820 on assignments. This closes
821 on assignments. This closes
821 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
822 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
822 readline uses getattr(), so a simple <TAB> keypress is still
823 readline uses getattr(), so a simple <TAB> keypress is still
823 enough to trigger getattr() calls on an object.
824 enough to trigger getattr() calls on an object.
824
825
825 2005-01-21 Fernando Perez <fperez@colorado.edu>
826 2005-01-21 Fernando Perez <fperez@colorado.edu>
826
827
827 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
828 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
828 docstring under pylab so it doesn't mask the original.
829 docstring under pylab so it doesn't mask the original.
829
830
830 2005-01-21 *** Released version 0.6.7
831 2005-01-21 *** Released version 0.6.7
831
832
832 2005-01-21 Fernando Perez <fperez@colorado.edu>
833 2005-01-21 Fernando Perez <fperez@colorado.edu>
833
834
834 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
835 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
835 signal handling for win32 users in multithreaded mode.
836 signal handling for win32 users in multithreaded mode.
836
837
837 2005-01-17 Fernando Perez <fperez@colorado.edu>
838 2005-01-17 Fernando Perez <fperez@colorado.edu>
838
839
839 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
840 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
840 instances with no __init__. After a crash report by Norbert Nemec
841 instances with no __init__. After a crash report by Norbert Nemec
841 <Norbert-AT-nemec-online.de>.
842 <Norbert-AT-nemec-online.de>.
842
843
843 2005-01-14 Fernando Perez <fperez@colorado.edu>
844 2005-01-14 Fernando Perez <fperez@colorado.edu>
844
845
845 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
846 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
846 names for verbose exceptions, when multiple dotted names and the
847 names for verbose exceptions, when multiple dotted names and the
847 'parent' object were present on the same line.
848 'parent' object were present on the same line.
848
849
849 2005-01-11 Fernando Perez <fperez@colorado.edu>
850 2005-01-11 Fernando Perez <fperez@colorado.edu>
850
851
851 * IPython/genutils.py (flag_calls): new utility to trap and flag
852 * IPython/genutils.py (flag_calls): new utility to trap and flag
852 calls in functions. I need it to clean up matplotlib support.
853 calls in functions. I need it to clean up matplotlib support.
853 Also removed some deprecated code in genutils.
854 Also removed some deprecated code in genutils.
854
855
855 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
856 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
856 that matplotlib scripts called with %run, which don't call show()
857 that matplotlib scripts called with %run, which don't call show()
857 themselves, still have their plotting windows open.
858 themselves, still have their plotting windows open.
858
859
859 2005-01-05 Fernando Perez <fperez@colorado.edu>
860 2005-01-05 Fernando Perez <fperez@colorado.edu>
860
861
861 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
862 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
862 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
863 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
863
864
864 2004-12-19 Fernando Perez <fperez@colorado.edu>
865 2004-12-19 Fernando Perez <fperez@colorado.edu>
865
866
866 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
867 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
867 parent_runcode, which was an eyesore. The same result can be
868 parent_runcode, which was an eyesore. The same result can be
868 obtained with Python's regular superclass mechanisms.
869 obtained with Python's regular superclass mechanisms.
869
870
870 2004-12-17 Fernando Perez <fperez@colorado.edu>
871 2004-12-17 Fernando Perez <fperez@colorado.edu>
871
872
872 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
873 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
873 reported by Prabhu.
874 reported by Prabhu.
874 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
875 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
875 sys.stderr) instead of explicitly calling sys.stderr. This helps
876 sys.stderr) instead of explicitly calling sys.stderr. This helps
876 maintain our I/O abstractions clean, for future GUI embeddings.
877 maintain our I/O abstractions clean, for future GUI embeddings.
877
878
878 * IPython/genutils.py (info): added new utility for sys.stderr
879 * IPython/genutils.py (info): added new utility for sys.stderr
879 unified info message handling (thin wrapper around warn()).
880 unified info message handling (thin wrapper around warn()).
880
881
881 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
882 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
882 composite (dotted) names on verbose exceptions.
883 composite (dotted) names on verbose exceptions.
883 (VerboseTB.nullrepr): harden against another kind of errors which
884 (VerboseTB.nullrepr): harden against another kind of errors which
884 Python's inspect module can trigger, and which were crashing
885 Python's inspect module can trigger, and which were crashing
885 IPython. Thanks to a report by Marco Lombardi
886 IPython. Thanks to a report by Marco Lombardi
886 <mlombard-AT-ma010192.hq.eso.org>.
887 <mlombard-AT-ma010192.hq.eso.org>.
887
888
888 2004-12-13 *** Released version 0.6.6
889 2004-12-13 *** Released version 0.6.6
889
890
890 2004-12-12 Fernando Perez <fperez@colorado.edu>
891 2004-12-12 Fernando Perez <fperez@colorado.edu>
891
892
892 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
893 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
893 generated by pygtk upon initialization if it was built without
894 generated by pygtk upon initialization if it was built without
894 threads (for matplotlib users). After a crash reported by
895 threads (for matplotlib users). After a crash reported by
895 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
896 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
896
897
897 * IPython/ipmaker.py (make_IPython): fix small bug in the
898 * IPython/ipmaker.py (make_IPython): fix small bug in the
898 import_some parameter for multiple imports.
899 import_some parameter for multiple imports.
899
900
900 * IPython/iplib.py (ipmagic): simplified the interface of
901 * IPython/iplib.py (ipmagic): simplified the interface of
901 ipmagic() to take a single string argument, just as it would be
902 ipmagic() to take a single string argument, just as it would be
902 typed at the IPython cmd line.
903 typed at the IPython cmd line.
903 (ipalias): Added new ipalias() with an interface identical to
904 (ipalias): Added new ipalias() with an interface identical to
904 ipmagic(). This completes exposing a pure python interface to the
905 ipmagic(). This completes exposing a pure python interface to the
905 alias and magic system, which can be used in loops or more complex
906 alias and magic system, which can be used in loops or more complex
906 code where IPython's automatic line mangling is not active.
907 code where IPython's automatic line mangling is not active.
907
908
908 * IPython/genutils.py (timing): changed interface of timing to
909 * IPython/genutils.py (timing): changed interface of timing to
909 simply run code once, which is the most common case. timings()
910 simply run code once, which is the most common case. timings()
910 remains unchanged, for the cases where you want multiple runs.
911 remains unchanged, for the cases where you want multiple runs.
911
912
912 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
913 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
913 bug where Python2.2 crashes with exec'ing code which does not end
914 bug where Python2.2 crashes with exec'ing code which does not end
914 in a single newline. Python 2.3 is OK, so I hadn't noticed this
915 in a single newline. Python 2.3 is OK, so I hadn't noticed this
915 before.
916 before.
916
917
917 2004-12-10 Fernando Perez <fperez@colorado.edu>
918 2004-12-10 Fernando Perez <fperez@colorado.edu>
918
919
919 * IPython/Magic.py (Magic.magic_prun): changed name of option from
920 * IPython/Magic.py (Magic.magic_prun): changed name of option from
920 -t to -T, to accomodate the new -t flag in %run (the %run and
921 -t to -T, to accomodate the new -t flag in %run (the %run and
921 %prun options are kind of intermixed, and it's not easy to change
922 %prun options are kind of intermixed, and it's not easy to change
922 this with the limitations of python's getopt).
923 this with the limitations of python's getopt).
923
924
924 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
925 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
925 the execution of scripts. It's not as fine-tuned as timeit.py,
926 the execution of scripts. It's not as fine-tuned as timeit.py,
926 but it works from inside ipython (and under 2.2, which lacks
927 but it works from inside ipython (and under 2.2, which lacks
927 timeit.py). Optionally a number of runs > 1 can be given for
928 timeit.py). Optionally a number of runs > 1 can be given for
928 timing very short-running code.
929 timing very short-running code.
929
930
930 * IPython/genutils.py (uniq_stable): new routine which returns a
931 * IPython/genutils.py (uniq_stable): new routine which returns a
931 list of unique elements in any iterable, but in stable order of
932 list of unique elements in any iterable, but in stable order of
932 appearance. I needed this for the ultraTB fixes, and it's a handy
933 appearance. I needed this for the ultraTB fixes, and it's a handy
933 utility.
934 utility.
934
935
935 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
936 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
936 dotted names in Verbose exceptions. This had been broken since
937 dotted names in Verbose exceptions. This had been broken since
937 the very start, now x.y will properly be printed in a Verbose
938 the very start, now x.y will properly be printed in a Verbose
938 traceback, instead of x being shown and y appearing always as an
939 traceback, instead of x being shown and y appearing always as an
939 'undefined global'. Getting this to work was a bit tricky,
940 'undefined global'. Getting this to work was a bit tricky,
940 because by default python tokenizers are stateless. Saved by
941 because by default python tokenizers are stateless. Saved by
941 python's ability to easily add a bit of state to an arbitrary
942 python's ability to easily add a bit of state to an arbitrary
942 function (without needing to build a full-blown callable object).
943 function (without needing to build a full-blown callable object).
943
944
944 Also big cleanup of this code, which had horrendous runtime
945 Also big cleanup of this code, which had horrendous runtime
945 lookups of zillions of attributes for colorization. Moved all
946 lookups of zillions of attributes for colorization. Moved all
946 this code into a few templates, which make it cleaner and quicker.
947 this code into a few templates, which make it cleaner and quicker.
947
948
948 Printout quality was also improved for Verbose exceptions: one
949 Printout quality was also improved for Verbose exceptions: one
949 variable per line, and memory addresses are printed (this can be
950 variable per line, and memory addresses are printed (this can be
950 quite handy in nasty debugging situations, which is what Verbose
951 quite handy in nasty debugging situations, which is what Verbose
951 is for).
952 is for).
952
953
953 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
954 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
954 the command line as scripts to be loaded by embedded instances.
955 the command line as scripts to be loaded by embedded instances.
955 Doing so has the potential for an infinite recursion if there are
956 Doing so has the potential for an infinite recursion if there are
956 exceptions thrown in the process. This fixes a strange crash
957 exceptions thrown in the process. This fixes a strange crash
957 reported by Philippe MULLER <muller-AT-irit.fr>.
958 reported by Philippe MULLER <muller-AT-irit.fr>.
958
959
959 2004-12-09 Fernando Perez <fperez@colorado.edu>
960 2004-12-09 Fernando Perez <fperez@colorado.edu>
960
961
961 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
962 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
962 to reflect new names in matplotlib, which now expose the
963 to reflect new names in matplotlib, which now expose the
963 matlab-compatible interface via a pylab module instead of the
964 matlab-compatible interface via a pylab module instead of the
964 'matlab' name. The new code is backwards compatible, so users of
965 'matlab' name. The new code is backwards compatible, so users of
965 all matplotlib versions are OK. Patch by J. Hunter.
966 all matplotlib versions are OK. Patch by J. Hunter.
966
967
967 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
968 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
968 of __init__ docstrings for instances (class docstrings are already
969 of __init__ docstrings for instances (class docstrings are already
969 automatically printed). Instances with customized docstrings
970 automatically printed). Instances with customized docstrings
970 (indep. of the class) are also recognized and all 3 separate
971 (indep. of the class) are also recognized and all 3 separate
971 docstrings are printed (instance, class, constructor). After some
972 docstrings are printed (instance, class, constructor). After some
972 comments/suggestions by J. Hunter.
973 comments/suggestions by J. Hunter.
973
974
974 2004-12-05 Fernando Perez <fperez@colorado.edu>
975 2004-12-05 Fernando Perez <fperez@colorado.edu>
975
976
976 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
977 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
977 warnings when tab-completion fails and triggers an exception.
978 warnings when tab-completion fails and triggers an exception.
978
979
979 2004-12-03 Fernando Perez <fperez@colorado.edu>
980 2004-12-03 Fernando Perez <fperez@colorado.edu>
980
981
981 * IPython/Magic.py (magic_prun): Fix bug where an exception would
982 * IPython/Magic.py (magic_prun): Fix bug where an exception would
982 be triggered when using 'run -p'. An incorrect option flag was
983 be triggered when using 'run -p'. An incorrect option flag was
983 being set ('d' instead of 'D').
984 being set ('d' instead of 'D').
984 (manpage): fix missing escaped \- sign.
985 (manpage): fix missing escaped \- sign.
985
986
986 2004-11-30 *** Released version 0.6.5
987 2004-11-30 *** Released version 0.6.5
987
988
988 2004-11-30 Fernando Perez <fperez@colorado.edu>
989 2004-11-30 Fernando Perez <fperez@colorado.edu>
989
990
990 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
991 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
991 setting with -d option.
992 setting with -d option.
992
993
993 * setup.py (docfiles): Fix problem where the doc glob I was using
994 * setup.py (docfiles): Fix problem where the doc glob I was using
994 was COMPLETELY BROKEN. It was giving the right files by pure
995 was COMPLETELY BROKEN. It was giving the right files by pure
995 accident, but failed once I tried to include ipython.el. Note:
996 accident, but failed once I tried to include ipython.el. Note:
996 glob() does NOT allow you to do exclusion on multiple endings!
997 glob() does NOT allow you to do exclusion on multiple endings!
997
998
998 2004-11-29 Fernando Perez <fperez@colorado.edu>
999 2004-11-29 Fernando Perez <fperez@colorado.edu>
999
1000
1000 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1001 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1001 the manpage as the source. Better formatting & consistency.
1002 the manpage as the source. Better formatting & consistency.
1002
1003
1003 * IPython/Magic.py (magic_run): Added new -d option, to run
1004 * IPython/Magic.py (magic_run): Added new -d option, to run
1004 scripts under the control of the python pdb debugger. Note that
1005 scripts under the control of the python pdb debugger. Note that
1005 this required changing the %prun option -d to -D, to avoid a clash
1006 this required changing the %prun option -d to -D, to avoid a clash
1006 (since %run must pass options to %prun, and getopt is too dumb to
1007 (since %run must pass options to %prun, and getopt is too dumb to
1007 handle options with string values with embedded spaces). Thanks
1008 handle options with string values with embedded spaces). Thanks
1008 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1009 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1009 (magic_who_ls): added type matching to %who and %whos, so that one
1010 (magic_who_ls): added type matching to %who and %whos, so that one
1010 can filter their output to only include variables of certain
1011 can filter their output to only include variables of certain
1011 types. Another suggestion by Matthew.
1012 types. Another suggestion by Matthew.
1012 (magic_whos): Added memory summaries in kb and Mb for arrays.
1013 (magic_whos): Added memory summaries in kb and Mb for arrays.
1013 (magic_who): Improve formatting (break lines every 9 vars).
1014 (magic_who): Improve formatting (break lines every 9 vars).
1014
1015
1015 2004-11-28 Fernando Perez <fperez@colorado.edu>
1016 2004-11-28 Fernando Perez <fperez@colorado.edu>
1016
1017
1017 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1018 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1018 cache when empty lines were present.
1019 cache when empty lines were present.
1019
1020
1020 2004-11-24 Fernando Perez <fperez@colorado.edu>
1021 2004-11-24 Fernando Perez <fperez@colorado.edu>
1021
1022
1022 * IPython/usage.py (__doc__): document the re-activated threading
1023 * IPython/usage.py (__doc__): document the re-activated threading
1023 options for WX and GTK.
1024 options for WX and GTK.
1024
1025
1025 2004-11-23 Fernando Perez <fperez@colorado.edu>
1026 2004-11-23 Fernando Perez <fperez@colorado.edu>
1026
1027
1027 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1028 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1028 the -wthread and -gthread options, along with a new -tk one to try
1029 the -wthread and -gthread options, along with a new -tk one to try
1029 and coordinate Tk threading with wx/gtk. The tk support is very
1030 and coordinate Tk threading with wx/gtk. The tk support is very
1030 platform dependent, since it seems to require Tcl and Tk to be
1031 platform dependent, since it seems to require Tcl and Tk to be
1031 built with threads (Fedora1/2 appears NOT to have it, but in
1032 built with threads (Fedora1/2 appears NOT to have it, but in
1032 Prabhu's Debian boxes it works OK). But even with some Tk
1033 Prabhu's Debian boxes it works OK). But even with some Tk
1033 limitations, this is a great improvement.
1034 limitations, this is a great improvement.
1034
1035
1035 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1036 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1036 info in user prompts. Patch by Prabhu.
1037 info in user prompts. Patch by Prabhu.
1037
1038
1038 2004-11-18 Fernando Perez <fperez@colorado.edu>
1039 2004-11-18 Fernando Perez <fperez@colorado.edu>
1039
1040
1040 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1041 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1041 EOFErrors and bail, to avoid infinite loops if a non-terminating
1042 EOFErrors and bail, to avoid infinite loops if a non-terminating
1042 file is fed into ipython. Patch submitted in issue 19 by user,
1043 file is fed into ipython. Patch submitted in issue 19 by user,
1043 many thanks.
1044 many thanks.
1044
1045
1045 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1046 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1046 autoquote/parens in continuation prompts, which can cause lots of
1047 autoquote/parens in continuation prompts, which can cause lots of
1047 problems. Closes roundup issue 20.
1048 problems. Closes roundup issue 20.
1048
1049
1049 2004-11-17 Fernando Perez <fperez@colorado.edu>
1050 2004-11-17 Fernando Perez <fperez@colorado.edu>
1050
1051
1051 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1052 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1052 reported as debian bug #280505. I'm not sure my local changelog
1053 reported as debian bug #280505. I'm not sure my local changelog
1053 entry has the proper debian format (Jack?).
1054 entry has the proper debian format (Jack?).
1054
1055
1055 2004-11-08 *** Released version 0.6.4
1056 2004-11-08 *** Released version 0.6.4
1056
1057
1057 2004-11-08 Fernando Perez <fperez@colorado.edu>
1058 2004-11-08 Fernando Perez <fperez@colorado.edu>
1058
1059
1059 * IPython/iplib.py (init_readline): Fix exit message for Windows
1060 * IPython/iplib.py (init_readline): Fix exit message for Windows
1060 when readline is active. Thanks to a report by Eric Jones
1061 when readline is active. Thanks to a report by Eric Jones
1061 <eric-AT-enthought.com>.
1062 <eric-AT-enthought.com>.
1062
1063
1063 2004-11-07 Fernando Perez <fperez@colorado.edu>
1064 2004-11-07 Fernando Perez <fperez@colorado.edu>
1064
1065
1065 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1066 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1066 sometimes seen by win2k/cygwin users.
1067 sometimes seen by win2k/cygwin users.
1067
1068
1068 2004-11-06 Fernando Perez <fperez@colorado.edu>
1069 2004-11-06 Fernando Perez <fperez@colorado.edu>
1069
1070
1070 * IPython/iplib.py (interact): Change the handling of %Exit from
1071 * IPython/iplib.py (interact): Change the handling of %Exit from
1071 trying to propagate a SystemExit to an internal ipython flag.
1072 trying to propagate a SystemExit to an internal ipython flag.
1072 This is less elegant than using Python's exception mechanism, but
1073 This is less elegant than using Python's exception mechanism, but
1073 I can't get that to work reliably with threads, so under -pylab
1074 I can't get that to work reliably with threads, so under -pylab
1074 %Exit was hanging IPython. Cross-thread exception handling is
1075 %Exit was hanging IPython. Cross-thread exception handling is
1075 really a bitch. Thaks to a bug report by Stephen Walton
1076 really a bitch. Thaks to a bug report by Stephen Walton
1076 <stephen.walton-AT-csun.edu>.
1077 <stephen.walton-AT-csun.edu>.
1077
1078
1078 2004-11-04 Fernando Perez <fperez@colorado.edu>
1079 2004-11-04 Fernando Perez <fperez@colorado.edu>
1079
1080
1080 * IPython/iplib.py (raw_input_original): store a pointer to the
1081 * IPython/iplib.py (raw_input_original): store a pointer to the
1081 true raw_input to harden against code which can modify it
1082 true raw_input to harden against code which can modify it
1082 (wx.py.PyShell does this and would otherwise crash ipython).
1083 (wx.py.PyShell does this and would otherwise crash ipython).
1083 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1084 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1084
1085
1085 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1086 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1086 Ctrl-C problem, which does not mess up the input line.
1087 Ctrl-C problem, which does not mess up the input line.
1087
1088
1088 2004-11-03 Fernando Perez <fperez@colorado.edu>
1089 2004-11-03 Fernando Perez <fperez@colorado.edu>
1089
1090
1090 * IPython/Release.py: Changed licensing to BSD, in all files.
1091 * IPython/Release.py: Changed licensing to BSD, in all files.
1091 (name): lowercase name for tarball/RPM release.
1092 (name): lowercase name for tarball/RPM release.
1092
1093
1093 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1094 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1094 use throughout ipython.
1095 use throughout ipython.
1095
1096
1096 * IPython/Magic.py (Magic._ofind): Switch to using the new
1097 * IPython/Magic.py (Magic._ofind): Switch to using the new
1097 OInspect.getdoc() function.
1098 OInspect.getdoc() function.
1098
1099
1099 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1100 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1100 of the line currently being canceled via Ctrl-C. It's extremely
1101 of the line currently being canceled via Ctrl-C. It's extremely
1101 ugly, but I don't know how to do it better (the problem is one of
1102 ugly, but I don't know how to do it better (the problem is one of
1102 handling cross-thread exceptions).
1103 handling cross-thread exceptions).
1103
1104
1104 2004-10-28 Fernando Perez <fperez@colorado.edu>
1105 2004-10-28 Fernando Perez <fperez@colorado.edu>
1105
1106
1106 * IPython/Shell.py (signal_handler): add signal handlers to trap
1107 * IPython/Shell.py (signal_handler): add signal handlers to trap
1107 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1108 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1108 report by Francesc Alted.
1109 report by Francesc Alted.
1109
1110
1110 2004-10-21 Fernando Perez <fperez@colorado.edu>
1111 2004-10-21 Fernando Perez <fperez@colorado.edu>
1111
1112
1112 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1113 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1113 to % for pysh syntax extensions.
1114 to % for pysh syntax extensions.
1114
1115
1115 2004-10-09 Fernando Perez <fperez@colorado.edu>
1116 2004-10-09 Fernando Perez <fperez@colorado.edu>
1116
1117
1117 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1118 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1118 arrays to print a more useful summary, without calling str(arr).
1119 arrays to print a more useful summary, without calling str(arr).
1119 This avoids the problem of extremely lengthy computations which
1120 This avoids the problem of extremely lengthy computations which
1120 occur if arr is large, and appear to the user as a system lockup
1121 occur if arr is large, and appear to the user as a system lockup
1121 with 100% cpu activity. After a suggestion by Kristian Sandberg
1122 with 100% cpu activity. After a suggestion by Kristian Sandberg
1122 <Kristian.Sandberg@colorado.edu>.
1123 <Kristian.Sandberg@colorado.edu>.
1123 (Magic.__init__): fix bug in global magic escapes not being
1124 (Magic.__init__): fix bug in global magic escapes not being
1124 correctly set.
1125 correctly set.
1125
1126
1126 2004-10-08 Fernando Perez <fperez@colorado.edu>
1127 2004-10-08 Fernando Perez <fperez@colorado.edu>
1127
1128
1128 * IPython/Magic.py (__license__): change to absolute imports of
1129 * IPython/Magic.py (__license__): change to absolute imports of
1129 ipython's own internal packages, to start adapting to the absolute
1130 ipython's own internal packages, to start adapting to the absolute
1130 import requirement of PEP-328.
1131 import requirement of PEP-328.
1131
1132
1132 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1133 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1133 files, and standardize author/license marks through the Release
1134 files, and standardize author/license marks through the Release
1134 module instead of having per/file stuff (except for files with
1135 module instead of having per/file stuff (except for files with
1135 particular licenses, like the MIT/PSF-licensed codes).
1136 particular licenses, like the MIT/PSF-licensed codes).
1136
1137
1137 * IPython/Debugger.py: remove dead code for python 2.1
1138 * IPython/Debugger.py: remove dead code for python 2.1
1138
1139
1139 2004-10-04 Fernando Perez <fperez@colorado.edu>
1140 2004-10-04 Fernando Perez <fperez@colorado.edu>
1140
1141
1141 * IPython/iplib.py (ipmagic): New function for accessing magics
1142 * IPython/iplib.py (ipmagic): New function for accessing magics
1142 via a normal python function call.
1143 via a normal python function call.
1143
1144
1144 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1145 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1145 from '@' to '%', to accomodate the new @decorator syntax of python
1146 from '@' to '%', to accomodate the new @decorator syntax of python
1146 2.4.
1147 2.4.
1147
1148
1148 2004-09-29 Fernando Perez <fperez@colorado.edu>
1149 2004-09-29 Fernando Perez <fperez@colorado.edu>
1149
1150
1150 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1151 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1151 matplotlib.use to prevent running scripts which try to switch
1152 matplotlib.use to prevent running scripts which try to switch
1152 interactive backends from within ipython. This will just crash
1153 interactive backends from within ipython. This will just crash
1153 the python interpreter, so we can't allow it (but a detailed error
1154 the python interpreter, so we can't allow it (but a detailed error
1154 is given to the user).
1155 is given to the user).
1155
1156
1156 2004-09-28 Fernando Perez <fperez@colorado.edu>
1157 2004-09-28 Fernando Perez <fperez@colorado.edu>
1157
1158
1158 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1159 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1159 matplotlib-related fixes so that using @run with non-matplotlib
1160 matplotlib-related fixes so that using @run with non-matplotlib
1160 scripts doesn't pop up spurious plot windows. This requires
1161 scripts doesn't pop up spurious plot windows. This requires
1161 matplotlib >= 0.63, where I had to make some changes as well.
1162 matplotlib >= 0.63, where I had to make some changes as well.
1162
1163
1163 * IPython/ipmaker.py (make_IPython): update version requirement to
1164 * IPython/ipmaker.py (make_IPython): update version requirement to
1164 python 2.2.
1165 python 2.2.
1165
1166
1166 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1167 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1167 banner arg for embedded customization.
1168 banner arg for embedded customization.
1168
1169
1169 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1170 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1170 explicit uses of __IP as the IPython's instance name. Now things
1171 explicit uses of __IP as the IPython's instance name. Now things
1171 are properly handled via the shell.name value. The actual code
1172 are properly handled via the shell.name value. The actual code
1172 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1173 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1173 is much better than before. I'll clean things completely when the
1174 is much better than before. I'll clean things completely when the
1174 magic stuff gets a real overhaul.
1175 magic stuff gets a real overhaul.
1175
1176
1176 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1177 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1177 minor changes to debian dir.
1178 minor changes to debian dir.
1178
1179
1179 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1180 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1180 pointer to the shell itself in the interactive namespace even when
1181 pointer to the shell itself in the interactive namespace even when
1181 a user-supplied dict is provided. This is needed for embedding
1182 a user-supplied dict is provided. This is needed for embedding
1182 purposes (found by tests with Michel Sanner).
1183 purposes (found by tests with Michel Sanner).
1183
1184
1184 2004-09-27 Fernando Perez <fperez@colorado.edu>
1185 2004-09-27 Fernando Perez <fperez@colorado.edu>
1185
1186
1186 * IPython/UserConfig/ipythonrc: remove []{} from
1187 * IPython/UserConfig/ipythonrc: remove []{} from
1187 readline_remove_delims, so that things like [modname.<TAB> do
1188 readline_remove_delims, so that things like [modname.<TAB> do
1188 proper completion. This disables [].TAB, but that's a less common
1189 proper completion. This disables [].TAB, but that's a less common
1189 case than module names in list comprehensions, for example.
1190 case than module names in list comprehensions, for example.
1190 Thanks to a report by Andrea Riciputi.
1191 Thanks to a report by Andrea Riciputi.
1191
1192
1192 2004-09-09 Fernando Perez <fperez@colorado.edu>
1193 2004-09-09 Fernando Perez <fperez@colorado.edu>
1193
1194
1194 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1195 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1195 blocking problems in win32 and osx. Fix by John.
1196 blocking problems in win32 and osx. Fix by John.
1196
1197
1197 2004-09-08 Fernando Perez <fperez@colorado.edu>
1198 2004-09-08 Fernando Perez <fperez@colorado.edu>
1198
1199
1199 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1200 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1200 for Win32 and OSX. Fix by John Hunter.
1201 for Win32 and OSX. Fix by John Hunter.
1201
1202
1202 2004-08-30 *** Released version 0.6.3
1203 2004-08-30 *** Released version 0.6.3
1203
1204
1204 2004-08-30 Fernando Perez <fperez@colorado.edu>
1205 2004-08-30 Fernando Perez <fperez@colorado.edu>
1205
1206
1206 * setup.py (isfile): Add manpages to list of dependent files to be
1207 * setup.py (isfile): Add manpages to list of dependent files to be
1207 updated.
1208 updated.
1208
1209
1209 2004-08-27 Fernando Perez <fperez@colorado.edu>
1210 2004-08-27 Fernando Perez <fperez@colorado.edu>
1210
1211
1211 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1212 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1212 for now. They don't really work with standalone WX/GTK code
1213 for now. They don't really work with standalone WX/GTK code
1213 (though matplotlib IS working fine with both of those backends).
1214 (though matplotlib IS working fine with both of those backends).
1214 This will neeed much more testing. I disabled most things with
1215 This will neeed much more testing. I disabled most things with
1215 comments, so turning it back on later should be pretty easy.
1216 comments, so turning it back on later should be pretty easy.
1216
1217
1217 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1218 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1218 autocalling of expressions like r'foo', by modifying the line
1219 autocalling of expressions like r'foo', by modifying the line
1219 split regexp. Closes
1220 split regexp. Closes
1220 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1221 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1221 Riley <ipythonbugs-AT-sabi.net>.
1222 Riley <ipythonbugs-AT-sabi.net>.
1222 (InteractiveShell.mainloop): honor --nobanner with banner
1223 (InteractiveShell.mainloop): honor --nobanner with banner
1223 extensions.
1224 extensions.
1224
1225
1225 * IPython/Shell.py: Significant refactoring of all classes, so
1226 * IPython/Shell.py: Significant refactoring of all classes, so
1226 that we can really support ALL matplotlib backends and threading
1227 that we can really support ALL matplotlib backends and threading
1227 models (John spotted a bug with Tk which required this). Now we
1228 models (John spotted a bug with Tk which required this). Now we
1228 should support single-threaded, WX-threads and GTK-threads, both
1229 should support single-threaded, WX-threads and GTK-threads, both
1229 for generic code and for matplotlib.
1230 for generic code and for matplotlib.
1230
1231
1231 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1232 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1232 -pylab, to simplify things for users. Will also remove the pylab
1233 -pylab, to simplify things for users. Will also remove the pylab
1233 profile, since now all of matplotlib configuration is directly
1234 profile, since now all of matplotlib configuration is directly
1234 handled here. This also reduces startup time.
1235 handled here. This also reduces startup time.
1235
1236
1236 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1237 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1237 shell wasn't being correctly called. Also in IPShellWX.
1238 shell wasn't being correctly called. Also in IPShellWX.
1238
1239
1239 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1240 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1240 fine-tune banner.
1241 fine-tune banner.
1241
1242
1242 * IPython/numutils.py (spike): Deprecate these spike functions,
1243 * IPython/numutils.py (spike): Deprecate these spike functions,
1243 delete (long deprecated) gnuplot_exec handler.
1244 delete (long deprecated) gnuplot_exec handler.
1244
1245
1245 2004-08-26 Fernando Perez <fperez@colorado.edu>
1246 2004-08-26 Fernando Perez <fperez@colorado.edu>
1246
1247
1247 * ipython.1: Update for threading options, plus some others which
1248 * ipython.1: Update for threading options, plus some others which
1248 were missing.
1249 were missing.
1249
1250
1250 * IPython/ipmaker.py (__call__): Added -wthread option for
1251 * IPython/ipmaker.py (__call__): Added -wthread option for
1251 wxpython thread handling. Make sure threading options are only
1252 wxpython thread handling. Make sure threading options are only
1252 valid at the command line.
1253 valid at the command line.
1253
1254
1254 * scripts/ipython: moved shell selection into a factory function
1255 * scripts/ipython: moved shell selection into a factory function
1255 in Shell.py, to keep the starter script to a minimum.
1256 in Shell.py, to keep the starter script to a minimum.
1256
1257
1257 2004-08-25 Fernando Perez <fperez@colorado.edu>
1258 2004-08-25 Fernando Perez <fperez@colorado.edu>
1258
1259
1259 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1260 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1260 John. Along with some recent changes he made to matplotlib, the
1261 John. Along with some recent changes he made to matplotlib, the
1261 next versions of both systems should work very well together.
1262 next versions of both systems should work very well together.
1262
1263
1263 2004-08-24 Fernando Perez <fperez@colorado.edu>
1264 2004-08-24 Fernando Perez <fperez@colorado.edu>
1264
1265
1265 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1266 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1266 tried to switch the profiling to using hotshot, but I'm getting
1267 tried to switch the profiling to using hotshot, but I'm getting
1267 strange errors from prof.runctx() there. I may be misreading the
1268 strange errors from prof.runctx() there. I may be misreading the
1268 docs, but it looks weird. For now the profiling code will
1269 docs, but it looks weird. For now the profiling code will
1269 continue to use the standard profiler.
1270 continue to use the standard profiler.
1270
1271
1271 2004-08-23 Fernando Perez <fperez@colorado.edu>
1272 2004-08-23 Fernando Perez <fperez@colorado.edu>
1272
1273
1273 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1274 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1274 threaded shell, by John Hunter. It's not quite ready yet, but
1275 threaded shell, by John Hunter. It's not quite ready yet, but
1275 close.
1276 close.
1276
1277
1277 2004-08-22 Fernando Perez <fperez@colorado.edu>
1278 2004-08-22 Fernando Perez <fperez@colorado.edu>
1278
1279
1279 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1280 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1280 in Magic and ultraTB.
1281 in Magic and ultraTB.
1281
1282
1282 * ipython.1: document threading options in manpage.
1283 * ipython.1: document threading options in manpage.
1283
1284
1284 * scripts/ipython: Changed name of -thread option to -gthread,
1285 * scripts/ipython: Changed name of -thread option to -gthread,
1285 since this is GTK specific. I want to leave the door open for a
1286 since this is GTK specific. I want to leave the door open for a
1286 -wthread option for WX, which will most likely be necessary. This
1287 -wthread option for WX, which will most likely be necessary. This
1287 change affects usage and ipmaker as well.
1288 change affects usage and ipmaker as well.
1288
1289
1289 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1290 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1290 handle the matplotlib shell issues. Code by John Hunter
1291 handle the matplotlib shell issues. Code by John Hunter
1291 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1292 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1292 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1293 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1293 broken (and disabled for end users) for now, but it puts the
1294 broken (and disabled for end users) for now, but it puts the
1294 infrastructure in place.
1295 infrastructure in place.
1295
1296
1296 2004-08-21 Fernando Perez <fperez@colorado.edu>
1297 2004-08-21 Fernando Perez <fperez@colorado.edu>
1297
1298
1298 * ipythonrc-pylab: Add matplotlib support.
1299 * ipythonrc-pylab: Add matplotlib support.
1299
1300
1300 * matplotlib_config.py: new files for matplotlib support, part of
1301 * matplotlib_config.py: new files for matplotlib support, part of
1301 the pylab profile.
1302 the pylab profile.
1302
1303
1303 * IPython/usage.py (__doc__): documented the threading options.
1304 * IPython/usage.py (__doc__): documented the threading options.
1304
1305
1305 2004-08-20 Fernando Perez <fperez@colorado.edu>
1306 2004-08-20 Fernando Perez <fperez@colorado.edu>
1306
1307
1307 * ipython: Modified the main calling routine to handle the -thread
1308 * ipython: Modified the main calling routine to handle the -thread
1308 and -mpthread options. This needs to be done as a top-level hack,
1309 and -mpthread options. This needs to be done as a top-level hack,
1309 because it determines which class to instantiate for IPython
1310 because it determines which class to instantiate for IPython
1310 itself.
1311 itself.
1311
1312
1312 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1313 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1313 classes to support multithreaded GTK operation without blocking,
1314 classes to support multithreaded GTK operation without blocking,
1314 and matplotlib with all backends. This is a lot of still very
1315 and matplotlib with all backends. This is a lot of still very
1315 experimental code, and threads are tricky. So it may still have a
1316 experimental code, and threads are tricky. So it may still have a
1316 few rough edges... This code owes a lot to
1317 few rough edges... This code owes a lot to
1317 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1318 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1318 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1319 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1319 to John Hunter for all the matplotlib work.
1320 to John Hunter for all the matplotlib work.
1320
1321
1321 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1322 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1322 options for gtk thread and matplotlib support.
1323 options for gtk thread and matplotlib support.
1323
1324
1324 2004-08-16 Fernando Perez <fperez@colorado.edu>
1325 2004-08-16 Fernando Perez <fperez@colorado.edu>
1325
1326
1326 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1327 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1327 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1328 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1328 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1329 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1329
1330
1330 2004-08-11 Fernando Perez <fperez@colorado.edu>
1331 2004-08-11 Fernando Perez <fperez@colorado.edu>
1331
1332
1332 * setup.py (isfile): Fix build so documentation gets updated for
1333 * setup.py (isfile): Fix build so documentation gets updated for
1333 rpms (it was only done for .tgz builds).
1334 rpms (it was only done for .tgz builds).
1334
1335
1335 2004-08-10 Fernando Perez <fperez@colorado.edu>
1336 2004-08-10 Fernando Perez <fperez@colorado.edu>
1336
1337
1337 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1338 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1338
1339
1339 * iplib.py : Silence syntax error exceptions in tab-completion.
1340 * iplib.py : Silence syntax error exceptions in tab-completion.
1340
1341
1341 2004-08-05 Fernando Perez <fperez@colorado.edu>
1342 2004-08-05 Fernando Perez <fperez@colorado.edu>
1342
1343
1343 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1344 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1344 'color off' mark for continuation prompts. This was causing long
1345 'color off' mark for continuation prompts. This was causing long
1345 continuation lines to mis-wrap.
1346 continuation lines to mis-wrap.
1346
1347
1347 2004-08-01 Fernando Perez <fperez@colorado.edu>
1348 2004-08-01 Fernando Perez <fperez@colorado.edu>
1348
1349
1349 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1350 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1350 for building ipython to be a parameter. All this is necessary
1351 for building ipython to be a parameter. All this is necessary
1351 right now to have a multithreaded version, but this insane
1352 right now to have a multithreaded version, but this insane
1352 non-design will be cleaned up soon. For now, it's a hack that
1353 non-design will be cleaned up soon. For now, it's a hack that
1353 works.
1354 works.
1354
1355
1355 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1356 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1356 args in various places. No bugs so far, but it's a dangerous
1357 args in various places. No bugs so far, but it's a dangerous
1357 practice.
1358 practice.
1358
1359
1359 2004-07-31 Fernando Perez <fperez@colorado.edu>
1360 2004-07-31 Fernando Perez <fperez@colorado.edu>
1360
1361
1361 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1362 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1362 fix completion of files with dots in their names under most
1363 fix completion of files with dots in their names under most
1363 profiles (pysh was OK because the completion order is different).
1364 profiles (pysh was OK because the completion order is different).
1364
1365
1365 2004-07-27 Fernando Perez <fperez@colorado.edu>
1366 2004-07-27 Fernando Perez <fperez@colorado.edu>
1366
1367
1367 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1368 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1368 keywords manually, b/c the one in keyword.py was removed in python
1369 keywords manually, b/c the one in keyword.py was removed in python
1369 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1370 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1370 This is NOT a bug under python 2.3 and earlier.
1371 This is NOT a bug under python 2.3 and earlier.
1371
1372
1372 2004-07-26 Fernando Perez <fperez@colorado.edu>
1373 2004-07-26 Fernando Perez <fperez@colorado.edu>
1373
1374
1374 * IPython/ultraTB.py (VerboseTB.text): Add another
1375 * IPython/ultraTB.py (VerboseTB.text): Add another
1375 linecache.checkcache() call to try to prevent inspect.py from
1376 linecache.checkcache() call to try to prevent inspect.py from
1376 crashing under python 2.3. I think this fixes
1377 crashing under python 2.3. I think this fixes
1377 http://www.scipy.net/roundup/ipython/issue17.
1378 http://www.scipy.net/roundup/ipython/issue17.
1378
1379
1379 2004-07-26 *** Released version 0.6.2
1380 2004-07-26 *** Released version 0.6.2
1380
1381
1381 2004-07-26 Fernando Perez <fperez@colorado.edu>
1382 2004-07-26 Fernando Perez <fperez@colorado.edu>
1382
1383
1383 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1384 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1384 fail for any number.
1385 fail for any number.
1385 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1386 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1386 empty bookmarks.
1387 empty bookmarks.
1387
1388
1388 2004-07-26 *** Released version 0.6.1
1389 2004-07-26 *** Released version 0.6.1
1389
1390
1390 2004-07-26 Fernando Perez <fperez@colorado.edu>
1391 2004-07-26 Fernando Perez <fperez@colorado.edu>
1391
1392
1392 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1393 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1393
1394
1394 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1395 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1395 escaping '()[]{}' in filenames.
1396 escaping '()[]{}' in filenames.
1396
1397
1397 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1398 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1398 Python 2.2 users who lack a proper shlex.split.
1399 Python 2.2 users who lack a proper shlex.split.
1399
1400
1400 2004-07-19 Fernando Perez <fperez@colorado.edu>
1401 2004-07-19 Fernando Perez <fperez@colorado.edu>
1401
1402
1402 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1403 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1403 for reading readline's init file. I follow the normal chain:
1404 for reading readline's init file. I follow the normal chain:
1404 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1405 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1405 report by Mike Heeter. This closes
1406 report by Mike Heeter. This closes
1406 http://www.scipy.net/roundup/ipython/issue16.
1407 http://www.scipy.net/roundup/ipython/issue16.
1407
1408
1408 2004-07-18 Fernando Perez <fperez@colorado.edu>
1409 2004-07-18 Fernando Perez <fperez@colorado.edu>
1409
1410
1410 * IPython/iplib.py (__init__): Add better handling of '\' under
1411 * IPython/iplib.py (__init__): Add better handling of '\' under
1411 Win32 for filenames. After a patch by Ville.
1412 Win32 for filenames. After a patch by Ville.
1412
1413
1413 2004-07-17 Fernando Perez <fperez@colorado.edu>
1414 2004-07-17 Fernando Perez <fperez@colorado.edu>
1414
1415
1415 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1416 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1416 autocalling would be triggered for 'foo is bar' if foo is
1417 autocalling would be triggered for 'foo is bar' if foo is
1417 callable. I also cleaned up the autocall detection code to use a
1418 callable. I also cleaned up the autocall detection code to use a
1418 regexp, which is faster. Bug reported by Alexander Schmolck.
1419 regexp, which is faster. Bug reported by Alexander Schmolck.
1419
1420
1420 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1421 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1421 '?' in them would confuse the help system. Reported by Alex
1422 '?' in them would confuse the help system. Reported by Alex
1422 Schmolck.
1423 Schmolck.
1423
1424
1424 2004-07-16 Fernando Perez <fperez@colorado.edu>
1425 2004-07-16 Fernando Perez <fperez@colorado.edu>
1425
1426
1426 * IPython/GnuplotInteractive.py (__all__): added plot2.
1427 * IPython/GnuplotInteractive.py (__all__): added plot2.
1427
1428
1428 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1429 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1429 plotting dictionaries, lists or tuples of 1d arrays.
1430 plotting dictionaries, lists or tuples of 1d arrays.
1430
1431
1431 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1432 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1432 optimizations.
1433 optimizations.
1433
1434
1434 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1435 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1435 the information which was there from Janko's original IPP code:
1436 the information which was there from Janko's original IPP code:
1436
1437
1437 03.05.99 20:53 porto.ifm.uni-kiel.de
1438 03.05.99 20:53 porto.ifm.uni-kiel.de
1438 --Started changelog.
1439 --Started changelog.
1439 --make clear do what it say it does
1440 --make clear do what it say it does
1440 --added pretty output of lines from inputcache
1441 --added pretty output of lines from inputcache
1441 --Made Logger a mixin class, simplifies handling of switches
1442 --Made Logger a mixin class, simplifies handling of switches
1442 --Added own completer class. .string<TAB> expands to last history
1443 --Added own completer class. .string<TAB> expands to last history
1443 line which starts with string. The new expansion is also present
1444 line which starts with string. The new expansion is also present
1444 with Ctrl-r from the readline library. But this shows, who this
1445 with Ctrl-r from the readline library. But this shows, who this
1445 can be done for other cases.
1446 can be done for other cases.
1446 --Added convention that all shell functions should accept a
1447 --Added convention that all shell functions should accept a
1447 parameter_string This opens the door for different behaviour for
1448 parameter_string This opens the door for different behaviour for
1448 each function. @cd is a good example of this.
1449 each function. @cd is a good example of this.
1449
1450
1450 04.05.99 12:12 porto.ifm.uni-kiel.de
1451 04.05.99 12:12 porto.ifm.uni-kiel.de
1451 --added logfile rotation
1452 --added logfile rotation
1452 --added new mainloop method which freezes first the namespace
1453 --added new mainloop method which freezes first the namespace
1453
1454
1454 07.05.99 21:24 porto.ifm.uni-kiel.de
1455 07.05.99 21:24 porto.ifm.uni-kiel.de
1455 --added the docreader classes. Now there is a help system.
1456 --added the docreader classes. Now there is a help system.
1456 -This is only a first try. Currently it's not easy to put new
1457 -This is only a first try. Currently it's not easy to put new
1457 stuff in the indices. But this is the way to go. Info would be
1458 stuff in the indices. But this is the way to go. Info would be
1458 better, but HTML is every where and not everybody has an info
1459 better, but HTML is every where and not everybody has an info
1459 system installed and it's not so easy to change html-docs to info.
1460 system installed and it's not so easy to change html-docs to info.
1460 --added global logfile option
1461 --added global logfile option
1461 --there is now a hook for object inspection method pinfo needs to
1462 --there is now a hook for object inspection method pinfo needs to
1462 be provided for this. Can be reached by two '??'.
1463 be provided for this. Can be reached by two '??'.
1463
1464
1464 08.05.99 20:51 porto.ifm.uni-kiel.de
1465 08.05.99 20:51 porto.ifm.uni-kiel.de
1465 --added a README
1466 --added a README
1466 --bug in rc file. Something has changed so functions in the rc
1467 --bug in rc file. Something has changed so functions in the rc
1467 file need to reference the shell and not self. Not clear if it's a
1468 file need to reference the shell and not self. Not clear if it's a
1468 bug or feature.
1469 bug or feature.
1469 --changed rc file for new behavior
1470 --changed rc file for new behavior
1470
1471
1471 2004-07-15 Fernando Perez <fperez@colorado.edu>
1472 2004-07-15 Fernando Perez <fperez@colorado.edu>
1472
1473
1473 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1474 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1474 cache was falling out of sync in bizarre manners when multi-line
1475 cache was falling out of sync in bizarre manners when multi-line
1475 input was present. Minor optimizations and cleanup.
1476 input was present. Minor optimizations and cleanup.
1476
1477
1477 (Logger): Remove old Changelog info for cleanup. This is the
1478 (Logger): Remove old Changelog info for cleanup. This is the
1478 information which was there from Janko's original code:
1479 information which was there from Janko's original code:
1479
1480
1480 Changes to Logger: - made the default log filename a parameter
1481 Changes to Logger: - made the default log filename a parameter
1481
1482
1482 - put a check for lines beginning with !@? in log(). Needed
1483 - put a check for lines beginning with !@? in log(). Needed
1483 (even if the handlers properly log their lines) for mid-session
1484 (even if the handlers properly log their lines) for mid-session
1484 logging activation to work properly. Without this, lines logged
1485 logging activation to work properly. Without this, lines logged
1485 in mid session, which get read from the cache, would end up
1486 in mid session, which get read from the cache, would end up
1486 'bare' (with !@? in the open) in the log. Now they are caught
1487 'bare' (with !@? in the open) in the log. Now they are caught
1487 and prepended with a #.
1488 and prepended with a #.
1488
1489
1489 * IPython/iplib.py (InteractiveShell.init_readline): added check
1490 * IPython/iplib.py (InteractiveShell.init_readline): added check
1490 in case MagicCompleter fails to be defined, so we don't crash.
1491 in case MagicCompleter fails to be defined, so we don't crash.
1491
1492
1492 2004-07-13 Fernando Perez <fperez@colorado.edu>
1493 2004-07-13 Fernando Perez <fperez@colorado.edu>
1493
1494
1494 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1495 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1495 of EPS if the requested filename ends in '.eps'.
1496 of EPS if the requested filename ends in '.eps'.
1496
1497
1497 2004-07-04 Fernando Perez <fperez@colorado.edu>
1498 2004-07-04 Fernando Perez <fperez@colorado.edu>
1498
1499
1499 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1500 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1500 escaping of quotes when calling the shell.
1501 escaping of quotes when calling the shell.
1501
1502
1502 2004-07-02 Fernando Perez <fperez@colorado.edu>
1503 2004-07-02 Fernando Perez <fperez@colorado.edu>
1503
1504
1504 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1505 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1505 gettext not working because we were clobbering '_'. Fixes
1506 gettext not working because we were clobbering '_'. Fixes
1506 http://www.scipy.net/roundup/ipython/issue6.
1507 http://www.scipy.net/roundup/ipython/issue6.
1507
1508
1508 2004-07-01 Fernando Perez <fperez@colorado.edu>
1509 2004-07-01 Fernando Perez <fperez@colorado.edu>
1509
1510
1510 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1511 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1511 into @cd. Patch by Ville.
1512 into @cd. Patch by Ville.
1512
1513
1513 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1514 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1514 new function to store things after ipmaker runs. Patch by Ville.
1515 new function to store things after ipmaker runs. Patch by Ville.
1515 Eventually this will go away once ipmaker is removed and the class
1516 Eventually this will go away once ipmaker is removed and the class
1516 gets cleaned up, but for now it's ok. Key functionality here is
1517 gets cleaned up, but for now it's ok. Key functionality here is
1517 the addition of the persistent storage mechanism, a dict for
1518 the addition of the persistent storage mechanism, a dict for
1518 keeping data across sessions (for now just bookmarks, but more can
1519 keeping data across sessions (for now just bookmarks, but more can
1519 be implemented later).
1520 be implemented later).
1520
1521
1521 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1522 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1522 persistent across sections. Patch by Ville, I modified it
1523 persistent across sections. Patch by Ville, I modified it
1523 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1524 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1524 added a '-l' option to list all bookmarks.
1525 added a '-l' option to list all bookmarks.
1525
1526
1526 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1527 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1527 center for cleanup. Registered with atexit.register(). I moved
1528 center for cleanup. Registered with atexit.register(). I moved
1528 here the old exit_cleanup(). After a patch by Ville.
1529 here the old exit_cleanup(). After a patch by Ville.
1529
1530
1530 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1531 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1531 characters in the hacked shlex_split for python 2.2.
1532 characters in the hacked shlex_split for python 2.2.
1532
1533
1533 * IPython/iplib.py (file_matches): more fixes to filenames with
1534 * IPython/iplib.py (file_matches): more fixes to filenames with
1534 whitespace in them. It's not perfect, but limitations in python's
1535 whitespace in them. It's not perfect, but limitations in python's
1535 readline make it impossible to go further.
1536 readline make it impossible to go further.
1536
1537
1537 2004-06-29 Fernando Perez <fperez@colorado.edu>
1538 2004-06-29 Fernando Perez <fperez@colorado.edu>
1538
1539
1539 * IPython/iplib.py (file_matches): escape whitespace correctly in
1540 * IPython/iplib.py (file_matches): escape whitespace correctly in
1540 filename completions. Bug reported by Ville.
1541 filename completions. Bug reported by Ville.
1541
1542
1542 2004-06-28 Fernando Perez <fperez@colorado.edu>
1543 2004-06-28 Fernando Perez <fperez@colorado.edu>
1543
1544
1544 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1545 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1545 the history file will be called 'history-PROFNAME' (or just
1546 the history file will be called 'history-PROFNAME' (or just
1546 'history' if no profile is loaded). I was getting annoyed at
1547 'history' if no profile is loaded). I was getting annoyed at
1547 getting my Numerical work history clobbered by pysh sessions.
1548 getting my Numerical work history clobbered by pysh sessions.
1548
1549
1549 * IPython/iplib.py (InteractiveShell.__init__): Internal
1550 * IPython/iplib.py (InteractiveShell.__init__): Internal
1550 getoutputerror() function so that we can honor the system_verbose
1551 getoutputerror() function so that we can honor the system_verbose
1551 flag for _all_ system calls. I also added escaping of #
1552 flag for _all_ system calls. I also added escaping of #
1552 characters here to avoid confusing Itpl.
1553 characters here to avoid confusing Itpl.
1553
1554
1554 * IPython/Magic.py (shlex_split): removed call to shell in
1555 * IPython/Magic.py (shlex_split): removed call to shell in
1555 parse_options and replaced it with shlex.split(). The annoying
1556 parse_options and replaced it with shlex.split(). The annoying
1556 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1557 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1557 to backport it from 2.3, with several frail hacks (the shlex
1558 to backport it from 2.3, with several frail hacks (the shlex
1558 module is rather limited in 2.2). Thanks to a suggestion by Ville
1559 module is rather limited in 2.2). Thanks to a suggestion by Ville
1559 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1560 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1560 problem.
1561 problem.
1561
1562
1562 (Magic.magic_system_verbose): new toggle to print the actual
1563 (Magic.magic_system_verbose): new toggle to print the actual
1563 system calls made by ipython. Mainly for debugging purposes.
1564 system calls made by ipython. Mainly for debugging purposes.
1564
1565
1565 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1566 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1566 doesn't support persistence. Reported (and fix suggested) by
1567 doesn't support persistence. Reported (and fix suggested) by
1567 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1568 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1568
1569
1569 2004-06-26 Fernando Perez <fperez@colorado.edu>
1570 2004-06-26 Fernando Perez <fperez@colorado.edu>
1570
1571
1571 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1572 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1572 continue prompts.
1573 continue prompts.
1573
1574
1574 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1575 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1575 function (basically a big docstring) and a few more things here to
1576 function (basically a big docstring) and a few more things here to
1576 speedup startup. pysh.py is now very lightweight. We want because
1577 speedup startup. pysh.py is now very lightweight. We want because
1577 it gets execfile'd, while InterpreterExec gets imported, so
1578 it gets execfile'd, while InterpreterExec gets imported, so
1578 byte-compilation saves time.
1579 byte-compilation saves time.
1579
1580
1580 2004-06-25 Fernando Perez <fperez@colorado.edu>
1581 2004-06-25 Fernando Perez <fperez@colorado.edu>
1581
1582
1582 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1583 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1583 -NUM', which was recently broken.
1584 -NUM', which was recently broken.
1584
1585
1585 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1586 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1586 in multi-line input (but not !!, which doesn't make sense there).
1587 in multi-line input (but not !!, which doesn't make sense there).
1587
1588
1588 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1589 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1589 It's just too useful, and people can turn it off in the less
1590 It's just too useful, and people can turn it off in the less
1590 common cases where it's a problem.
1591 common cases where it's a problem.
1591
1592
1592 2004-06-24 Fernando Perez <fperez@colorado.edu>
1593 2004-06-24 Fernando Perez <fperez@colorado.edu>
1593
1594
1594 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1595 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1595 special syntaxes (like alias calling) is now allied in multi-line
1596 special syntaxes (like alias calling) is now allied in multi-line
1596 input. This is still _very_ experimental, but it's necessary for
1597 input. This is still _very_ experimental, but it's necessary for
1597 efficient shell usage combining python looping syntax with system
1598 efficient shell usage combining python looping syntax with system
1598 calls. For now it's restricted to aliases, I don't think it
1599 calls. For now it's restricted to aliases, I don't think it
1599 really even makes sense to have this for magics.
1600 really even makes sense to have this for magics.
1600
1601
1601 2004-06-23 Fernando Perez <fperez@colorado.edu>
1602 2004-06-23 Fernando Perez <fperez@colorado.edu>
1602
1603
1603 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1604 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1604 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1605 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1605
1606
1606 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1607 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1607 extensions under Windows (after code sent by Gary Bishop). The
1608 extensions under Windows (after code sent by Gary Bishop). The
1608 extensions considered 'executable' are stored in IPython's rc
1609 extensions considered 'executable' are stored in IPython's rc
1609 structure as win_exec_ext.
1610 structure as win_exec_ext.
1610
1611
1611 * IPython/genutils.py (shell): new function, like system() but
1612 * IPython/genutils.py (shell): new function, like system() but
1612 without return value. Very useful for interactive shell work.
1613 without return value. Very useful for interactive shell work.
1613
1614
1614 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1615 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1615 delete aliases.
1616 delete aliases.
1616
1617
1617 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1618 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1618 sure that the alias table doesn't contain python keywords.
1619 sure that the alias table doesn't contain python keywords.
1619
1620
1620 2004-06-21 Fernando Perez <fperez@colorado.edu>
1621 2004-06-21 Fernando Perez <fperez@colorado.edu>
1621
1622
1622 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1623 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1623 non-existent items are found in $PATH. Reported by Thorsten.
1624 non-existent items are found in $PATH. Reported by Thorsten.
1624
1625
1625 2004-06-20 Fernando Perez <fperez@colorado.edu>
1626 2004-06-20 Fernando Perez <fperez@colorado.edu>
1626
1627
1627 * IPython/iplib.py (complete): modified the completer so that the
1628 * IPython/iplib.py (complete): modified the completer so that the
1628 order of priorities can be easily changed at runtime.
1629 order of priorities can be easily changed at runtime.
1629
1630
1630 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1631 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1631 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1632 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1632
1633
1633 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1634 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1634 expand Python variables prepended with $ in all system calls. The
1635 expand Python variables prepended with $ in all system calls. The
1635 same was done to InteractiveShell.handle_shell_escape. Now all
1636 same was done to InteractiveShell.handle_shell_escape. Now all
1636 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1637 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1637 expansion of python variables and expressions according to the
1638 expansion of python variables and expressions according to the
1638 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1639 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1639
1640
1640 Though PEP-215 has been rejected, a similar (but simpler) one
1641 Though PEP-215 has been rejected, a similar (but simpler) one
1641 seems like it will go into Python 2.4, PEP-292 -
1642 seems like it will go into Python 2.4, PEP-292 -
1642 http://www.python.org/peps/pep-0292.html.
1643 http://www.python.org/peps/pep-0292.html.
1643
1644
1644 I'll keep the full syntax of PEP-215, since IPython has since the
1645 I'll keep the full syntax of PEP-215, since IPython has since the
1645 start used Ka-Ping Yee's reference implementation discussed there
1646 start used Ka-Ping Yee's reference implementation discussed there
1646 (Itpl), and I actually like the powerful semantics it offers.
1647 (Itpl), and I actually like the powerful semantics it offers.
1647
1648
1648 In order to access normal shell variables, the $ has to be escaped
1649 In order to access normal shell variables, the $ has to be escaped
1649 via an extra $. For example:
1650 via an extra $. For example:
1650
1651
1651 In [7]: PATH='a python variable'
1652 In [7]: PATH='a python variable'
1652
1653
1653 In [8]: !echo $PATH
1654 In [8]: !echo $PATH
1654 a python variable
1655 a python variable
1655
1656
1656 In [9]: !echo $$PATH
1657 In [9]: !echo $$PATH
1657 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1658 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1658
1659
1659 (Magic.parse_options): escape $ so the shell doesn't evaluate
1660 (Magic.parse_options): escape $ so the shell doesn't evaluate
1660 things prematurely.
1661 things prematurely.
1661
1662
1662 * IPython/iplib.py (InteractiveShell.call_alias): added the
1663 * IPython/iplib.py (InteractiveShell.call_alias): added the
1663 ability for aliases to expand python variables via $.
1664 ability for aliases to expand python variables via $.
1664
1665
1665 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1666 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1666 system, now there's a @rehash/@rehashx pair of magics. These work
1667 system, now there's a @rehash/@rehashx pair of magics. These work
1667 like the csh rehash command, and can be invoked at any time. They
1668 like the csh rehash command, and can be invoked at any time. They
1668 build a table of aliases to everything in the user's $PATH
1669 build a table of aliases to everything in the user's $PATH
1669 (@rehash uses everything, @rehashx is slower but only adds
1670 (@rehash uses everything, @rehashx is slower but only adds
1670 executable files). With this, the pysh.py-based shell profile can
1671 executable files). With this, the pysh.py-based shell profile can
1671 now simply call rehash upon startup, and full access to all
1672 now simply call rehash upon startup, and full access to all
1672 programs in the user's path is obtained.
1673 programs in the user's path is obtained.
1673
1674
1674 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1675 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1675 functionality is now fully in place. I removed the old dynamic
1676 functionality is now fully in place. I removed the old dynamic
1676 code generation based approach, in favor of a much lighter one
1677 code generation based approach, in favor of a much lighter one
1677 based on a simple dict. The advantage is that this allows me to
1678 based on a simple dict. The advantage is that this allows me to
1678 now have thousands of aliases with negligible cost (unthinkable
1679 now have thousands of aliases with negligible cost (unthinkable
1679 with the old system).
1680 with the old system).
1680
1681
1681 2004-06-19 Fernando Perez <fperez@colorado.edu>
1682 2004-06-19 Fernando Perez <fperez@colorado.edu>
1682
1683
1683 * IPython/iplib.py (__init__): extended MagicCompleter class to
1684 * IPython/iplib.py (__init__): extended MagicCompleter class to
1684 also complete (last in priority) on user aliases.
1685 also complete (last in priority) on user aliases.
1685
1686
1686 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1687 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1687 call to eval.
1688 call to eval.
1688 (ItplNS.__init__): Added a new class which functions like Itpl,
1689 (ItplNS.__init__): Added a new class which functions like Itpl,
1689 but allows configuring the namespace for the evaluation to occur
1690 but allows configuring the namespace for the evaluation to occur
1690 in.
1691 in.
1691
1692
1692 2004-06-18 Fernando Perez <fperez@colorado.edu>
1693 2004-06-18 Fernando Perez <fperez@colorado.edu>
1693
1694
1694 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1695 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1695 better message when 'exit' or 'quit' are typed (a common newbie
1696 better message when 'exit' or 'quit' are typed (a common newbie
1696 confusion).
1697 confusion).
1697
1698
1698 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1699 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1699 check for Windows users.
1700 check for Windows users.
1700
1701
1701 * IPython/iplib.py (InteractiveShell.user_setup): removed
1702 * IPython/iplib.py (InteractiveShell.user_setup): removed
1702 disabling of colors for Windows. I'll test at runtime and issue a
1703 disabling of colors for Windows. I'll test at runtime and issue a
1703 warning if Gary's readline isn't found, as to nudge users to
1704 warning if Gary's readline isn't found, as to nudge users to
1704 download it.
1705 download it.
1705
1706
1706 2004-06-16 Fernando Perez <fperez@colorado.edu>
1707 2004-06-16 Fernando Perez <fperez@colorado.edu>
1707
1708
1708 * IPython/genutils.py (Stream.__init__): changed to print errors
1709 * IPython/genutils.py (Stream.__init__): changed to print errors
1709 to sys.stderr. I had a circular dependency here. Now it's
1710 to sys.stderr. I had a circular dependency here. Now it's
1710 possible to run ipython as IDLE's shell (consider this pre-alpha,
1711 possible to run ipython as IDLE's shell (consider this pre-alpha,
1711 since true stdout things end up in the starting terminal instead
1712 since true stdout things end up in the starting terminal instead
1712 of IDLE's out).
1713 of IDLE's out).
1713
1714
1714 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1715 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1715 users who haven't # updated their prompt_in2 definitions. Remove
1716 users who haven't # updated their prompt_in2 definitions. Remove
1716 eventually.
1717 eventually.
1717 (multiple_replace): added credit to original ASPN recipe.
1718 (multiple_replace): added credit to original ASPN recipe.
1718
1719
1719 2004-06-15 Fernando Perez <fperez@colorado.edu>
1720 2004-06-15 Fernando Perez <fperez@colorado.edu>
1720
1721
1721 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1722 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1722 list of auto-defined aliases.
1723 list of auto-defined aliases.
1723
1724
1724 2004-06-13 Fernando Perez <fperez@colorado.edu>
1725 2004-06-13 Fernando Perez <fperez@colorado.edu>
1725
1726
1726 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1727 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1727 install was really requested (so setup.py can be used for other
1728 install was really requested (so setup.py can be used for other
1728 things under Windows).
1729 things under Windows).
1729
1730
1730 2004-06-10 Fernando Perez <fperez@colorado.edu>
1731 2004-06-10 Fernando Perez <fperez@colorado.edu>
1731
1732
1732 * IPython/Logger.py (Logger.create_log): Manually remove any old
1733 * IPython/Logger.py (Logger.create_log): Manually remove any old
1733 backup, since os.remove may fail under Windows. Fixes bug
1734 backup, since os.remove may fail under Windows. Fixes bug
1734 reported by Thorsten.
1735 reported by Thorsten.
1735
1736
1736 2004-06-09 Fernando Perez <fperez@colorado.edu>
1737 2004-06-09 Fernando Perez <fperez@colorado.edu>
1737
1738
1738 * examples/example-embed.py: fixed all references to %n (replaced
1739 * examples/example-embed.py: fixed all references to %n (replaced
1739 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1740 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1740 for all examples and the manual as well.
1741 for all examples and the manual as well.
1741
1742
1742 2004-06-08 Fernando Perez <fperez@colorado.edu>
1743 2004-06-08 Fernando Perez <fperez@colorado.edu>
1743
1744
1744 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1745 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1745 alignment and color management. All 3 prompt subsystems now
1746 alignment and color management. All 3 prompt subsystems now
1746 inherit from BasePrompt.
1747 inherit from BasePrompt.
1747
1748
1748 * tools/release: updates for windows installer build and tag rpms
1749 * tools/release: updates for windows installer build and tag rpms
1749 with python version (since paths are fixed).
1750 with python version (since paths are fixed).
1750
1751
1751 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1752 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1752 which will become eventually obsolete. Also fixed the default
1753 which will become eventually obsolete. Also fixed the default
1753 prompt_in2 to use \D, so at least new users start with the correct
1754 prompt_in2 to use \D, so at least new users start with the correct
1754 defaults.
1755 defaults.
1755 WARNING: Users with existing ipythonrc files will need to apply
1756 WARNING: Users with existing ipythonrc files will need to apply
1756 this fix manually!
1757 this fix manually!
1757
1758
1758 * setup.py: make windows installer (.exe). This is finally the
1759 * setup.py: make windows installer (.exe). This is finally the
1759 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1760 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1760 which I hadn't included because it required Python 2.3 (or recent
1761 which I hadn't included because it required Python 2.3 (or recent
1761 distutils).
1762 distutils).
1762
1763
1763 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1764 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1764 usage of new '\D' escape.
1765 usage of new '\D' escape.
1765
1766
1766 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1767 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1767 lacks os.getuid())
1768 lacks os.getuid())
1768 (CachedOutput.set_colors): Added the ability to turn coloring
1769 (CachedOutput.set_colors): Added the ability to turn coloring
1769 on/off with @colors even for manually defined prompt colors. It
1770 on/off with @colors even for manually defined prompt colors. It
1770 uses a nasty global, but it works safely and via the generic color
1771 uses a nasty global, but it works safely and via the generic color
1771 handling mechanism.
1772 handling mechanism.
1772 (Prompt2.__init__): Introduced new escape '\D' for continuation
1773 (Prompt2.__init__): Introduced new escape '\D' for continuation
1773 prompts. It represents the counter ('\#') as dots.
1774 prompts. It represents the counter ('\#') as dots.
1774 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1775 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1775 need to update their ipythonrc files and replace '%n' with '\D' in
1776 need to update their ipythonrc files and replace '%n' with '\D' in
1776 their prompt_in2 settings everywhere. Sorry, but there's
1777 their prompt_in2 settings everywhere. Sorry, but there's
1777 otherwise no clean way to get all prompts to properly align. The
1778 otherwise no clean way to get all prompts to properly align. The
1778 ipythonrc shipped with IPython has been updated.
1779 ipythonrc shipped with IPython has been updated.
1779
1780
1780 2004-06-07 Fernando Perez <fperez@colorado.edu>
1781 2004-06-07 Fernando Perez <fperez@colorado.edu>
1781
1782
1782 * setup.py (isfile): Pass local_icons option to latex2html, so the
1783 * setup.py (isfile): Pass local_icons option to latex2html, so the
1783 resulting HTML file is self-contained. Thanks to
1784 resulting HTML file is self-contained. Thanks to
1784 dryice-AT-liu.com.cn for the tip.
1785 dryice-AT-liu.com.cn for the tip.
1785
1786
1786 * pysh.py: I created a new profile 'shell', which implements a
1787 * pysh.py: I created a new profile 'shell', which implements a
1787 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1788 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1788 system shell, nor will it become one anytime soon. It's mainly
1789 system shell, nor will it become one anytime soon. It's mainly
1789 meant to illustrate the use of the new flexible bash-like prompts.
1790 meant to illustrate the use of the new flexible bash-like prompts.
1790 I guess it could be used by hardy souls for true shell management,
1791 I guess it could be used by hardy souls for true shell management,
1791 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1792 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1792 profile. This uses the InterpreterExec extension provided by
1793 profile. This uses the InterpreterExec extension provided by
1793 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1794 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1794
1795
1795 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1796 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1796 auto-align itself with the length of the previous input prompt
1797 auto-align itself with the length of the previous input prompt
1797 (taking into account the invisible color escapes).
1798 (taking into account the invisible color escapes).
1798 (CachedOutput.__init__): Large restructuring of this class. Now
1799 (CachedOutput.__init__): Large restructuring of this class. Now
1799 all three prompts (primary1, primary2, output) are proper objects,
1800 all three prompts (primary1, primary2, output) are proper objects,
1800 managed by the 'parent' CachedOutput class. The code is still a
1801 managed by the 'parent' CachedOutput class. The code is still a
1801 bit hackish (all prompts share state via a pointer to the cache),
1802 bit hackish (all prompts share state via a pointer to the cache),
1802 but it's overall far cleaner than before.
1803 but it's overall far cleaner than before.
1803
1804
1804 * IPython/genutils.py (getoutputerror): modified to add verbose,
1805 * IPython/genutils.py (getoutputerror): modified to add verbose,
1805 debug and header options. This makes the interface of all getout*
1806 debug and header options. This makes the interface of all getout*
1806 functions uniform.
1807 functions uniform.
1807 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1808 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1808
1809
1809 * IPython/Magic.py (Magic.default_option): added a function to
1810 * IPython/Magic.py (Magic.default_option): added a function to
1810 allow registering default options for any magic command. This
1811 allow registering default options for any magic command. This
1811 makes it easy to have profiles which customize the magics globally
1812 makes it easy to have profiles which customize the magics globally
1812 for a certain use. The values set through this function are
1813 for a certain use. The values set through this function are
1813 picked up by the parse_options() method, which all magics should
1814 picked up by the parse_options() method, which all magics should
1814 use to parse their options.
1815 use to parse their options.
1815
1816
1816 * IPython/genutils.py (warn): modified the warnings framework to
1817 * IPython/genutils.py (warn): modified the warnings framework to
1817 use the Term I/O class. I'm trying to slowly unify all of
1818 use the Term I/O class. I'm trying to slowly unify all of
1818 IPython's I/O operations to pass through Term.
1819 IPython's I/O operations to pass through Term.
1819
1820
1820 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1821 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1821 the secondary prompt to correctly match the length of the primary
1822 the secondary prompt to correctly match the length of the primary
1822 one for any prompt. Now multi-line code will properly line up
1823 one for any prompt. Now multi-line code will properly line up
1823 even for path dependent prompts, such as the new ones available
1824 even for path dependent prompts, such as the new ones available
1824 via the prompt_specials.
1825 via the prompt_specials.
1825
1826
1826 2004-06-06 Fernando Perez <fperez@colorado.edu>
1827 2004-06-06 Fernando Perez <fperez@colorado.edu>
1827
1828
1828 * IPython/Prompts.py (prompt_specials): Added the ability to have
1829 * IPython/Prompts.py (prompt_specials): Added the ability to have
1829 bash-like special sequences in the prompts, which get
1830 bash-like special sequences in the prompts, which get
1830 automatically expanded. Things like hostname, current working
1831 automatically expanded. Things like hostname, current working
1831 directory and username are implemented already, but it's easy to
1832 directory and username are implemented already, but it's easy to
1832 add more in the future. Thanks to a patch by W.J. van der Laan
1833 add more in the future. Thanks to a patch by W.J. van der Laan
1833 <gnufnork-AT-hetdigitalegat.nl>
1834 <gnufnork-AT-hetdigitalegat.nl>
1834 (prompt_specials): Added color support for prompt strings, so
1835 (prompt_specials): Added color support for prompt strings, so
1835 users can define arbitrary color setups for their prompts.
1836 users can define arbitrary color setups for their prompts.
1836
1837
1837 2004-06-05 Fernando Perez <fperez@colorado.edu>
1838 2004-06-05 Fernando Perez <fperez@colorado.edu>
1838
1839
1839 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1840 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1840 code to load Gary Bishop's readline and configure it
1841 code to load Gary Bishop's readline and configure it
1841 automatically. Thanks to Gary for help on this.
1842 automatically. Thanks to Gary for help on this.
1842
1843
1843 2004-06-01 Fernando Perez <fperez@colorado.edu>
1844 2004-06-01 Fernando Perez <fperez@colorado.edu>
1844
1845
1845 * IPython/Logger.py (Logger.create_log): fix bug for logging
1846 * IPython/Logger.py (Logger.create_log): fix bug for logging
1846 with no filename (previous fix was incomplete).
1847 with no filename (previous fix was incomplete).
1847
1848
1848 2004-05-25 Fernando Perez <fperez@colorado.edu>
1849 2004-05-25 Fernando Perez <fperez@colorado.edu>
1849
1850
1850 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1851 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1851 parens would get passed to the shell.
1852 parens would get passed to the shell.
1852
1853
1853 2004-05-20 Fernando Perez <fperez@colorado.edu>
1854 2004-05-20 Fernando Perez <fperez@colorado.edu>
1854
1855
1855 * IPython/Magic.py (Magic.magic_prun): changed default profile
1856 * IPython/Magic.py (Magic.magic_prun): changed default profile
1856 sort order to 'time' (the more common profiling need).
1857 sort order to 'time' (the more common profiling need).
1857
1858
1858 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1859 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1859 so that source code shown is guaranteed in sync with the file on
1860 so that source code shown is guaranteed in sync with the file on
1860 disk (also changed in psource). Similar fix to the one for
1861 disk (also changed in psource). Similar fix to the one for
1861 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1862 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1862 <yann.ledu-AT-noos.fr>.
1863 <yann.ledu-AT-noos.fr>.
1863
1864
1864 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1865 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1865 with a single option would not be correctly parsed. Closes
1866 with a single option would not be correctly parsed. Closes
1866 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1867 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1867 introduced in 0.6.0 (on 2004-05-06).
1868 introduced in 0.6.0 (on 2004-05-06).
1868
1869
1869 2004-05-13 *** Released version 0.6.0
1870 2004-05-13 *** Released version 0.6.0
1870
1871
1871 2004-05-13 Fernando Perez <fperez@colorado.edu>
1872 2004-05-13 Fernando Perez <fperez@colorado.edu>
1872
1873
1873 * debian/: Added debian/ directory to CVS, so that debian support
1874 * debian/: Added debian/ directory to CVS, so that debian support
1874 is publicly accessible. The debian package is maintained by Jack
1875 is publicly accessible. The debian package is maintained by Jack
1875 Moffit <jack-AT-xiph.org>.
1876 Moffit <jack-AT-xiph.org>.
1876
1877
1877 * Documentation: included the notes about an ipython-based system
1878 * Documentation: included the notes about an ipython-based system
1878 shell (the hypothetical 'pysh') into the new_design.pdf document,
1879 shell (the hypothetical 'pysh') into the new_design.pdf document,
1879 so that these ideas get distributed to users along with the
1880 so that these ideas get distributed to users along with the
1880 official documentation.
1881 official documentation.
1881
1882
1882 2004-05-10 Fernando Perez <fperez@colorado.edu>
1883 2004-05-10 Fernando Perez <fperez@colorado.edu>
1883
1884
1884 * IPython/Logger.py (Logger.create_log): fix recently introduced
1885 * IPython/Logger.py (Logger.create_log): fix recently introduced
1885 bug (misindented line) where logstart would fail when not given an
1886 bug (misindented line) where logstart would fail when not given an
1886 explicit filename.
1887 explicit filename.
1887
1888
1888 2004-05-09 Fernando Perez <fperez@colorado.edu>
1889 2004-05-09 Fernando Perez <fperez@colorado.edu>
1889
1890
1890 * IPython/Magic.py (Magic.parse_options): skip system call when
1891 * IPython/Magic.py (Magic.parse_options): skip system call when
1891 there are no options to look for. Faster, cleaner for the common
1892 there are no options to look for. Faster, cleaner for the common
1892 case.
1893 case.
1893
1894
1894 * Documentation: many updates to the manual: describing Windows
1895 * Documentation: many updates to the manual: describing Windows
1895 support better, Gnuplot updates, credits, misc small stuff. Also
1896 support better, Gnuplot updates, credits, misc small stuff. Also
1896 updated the new_design doc a bit.
1897 updated the new_design doc a bit.
1897
1898
1898 2004-05-06 *** Released version 0.6.0.rc1
1899 2004-05-06 *** Released version 0.6.0.rc1
1899
1900
1900 2004-05-06 Fernando Perez <fperez@colorado.edu>
1901 2004-05-06 Fernando Perez <fperez@colorado.edu>
1901
1902
1902 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1903 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1903 operations to use the vastly more efficient list/''.join() method.
1904 operations to use the vastly more efficient list/''.join() method.
1904 (FormattedTB.text): Fix
1905 (FormattedTB.text): Fix
1905 http://www.scipy.net/roundup/ipython/issue12 - exception source
1906 http://www.scipy.net/roundup/ipython/issue12 - exception source
1906 extract not updated after reload. Thanks to Mike Salib
1907 extract not updated after reload. Thanks to Mike Salib
1907 <msalib-AT-mit.edu> for pinning the source of the problem.
1908 <msalib-AT-mit.edu> for pinning the source of the problem.
1908 Fortunately, the solution works inside ipython and doesn't require
1909 Fortunately, the solution works inside ipython and doesn't require
1909 any changes to python proper.
1910 any changes to python proper.
1910
1911
1911 * IPython/Magic.py (Magic.parse_options): Improved to process the
1912 * IPython/Magic.py (Magic.parse_options): Improved to process the
1912 argument list as a true shell would (by actually using the
1913 argument list as a true shell would (by actually using the
1913 underlying system shell). This way, all @magics automatically get
1914 underlying system shell). This way, all @magics automatically get
1914 shell expansion for variables. Thanks to a comment by Alex
1915 shell expansion for variables. Thanks to a comment by Alex
1915 Schmolck.
1916 Schmolck.
1916
1917
1917 2004-04-04 Fernando Perez <fperez@colorado.edu>
1918 2004-04-04 Fernando Perez <fperez@colorado.edu>
1918
1919
1919 * IPython/iplib.py (InteractiveShell.interact): Added a special
1920 * IPython/iplib.py (InteractiveShell.interact): Added a special
1920 trap for a debugger quit exception, which is basically impossible
1921 trap for a debugger quit exception, which is basically impossible
1921 to handle by normal mechanisms, given what pdb does to the stack.
1922 to handle by normal mechanisms, given what pdb does to the stack.
1922 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1923 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1923
1924
1924 2004-04-03 Fernando Perez <fperez@colorado.edu>
1925 2004-04-03 Fernando Perez <fperez@colorado.edu>
1925
1926
1926 * IPython/genutils.py (Term): Standardized the names of the Term
1927 * IPython/genutils.py (Term): Standardized the names of the Term
1927 class streams to cin/cout/cerr, following C++ naming conventions
1928 class streams to cin/cout/cerr, following C++ naming conventions
1928 (I can't use in/out/err because 'in' is not a valid attribute
1929 (I can't use in/out/err because 'in' is not a valid attribute
1929 name).
1930 name).
1930
1931
1931 * IPython/iplib.py (InteractiveShell.interact): don't increment
1932 * IPython/iplib.py (InteractiveShell.interact): don't increment
1932 the prompt if there's no user input. By Daniel 'Dang' Griffith
1933 the prompt if there's no user input. By Daniel 'Dang' Griffith
1933 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1934 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1934 Francois Pinard.
1935 Francois Pinard.
1935
1936
1936 2004-04-02 Fernando Perez <fperez@colorado.edu>
1937 2004-04-02 Fernando Perez <fperez@colorado.edu>
1937
1938
1938 * IPython/genutils.py (Stream.__init__): Modified to survive at
1939 * IPython/genutils.py (Stream.__init__): Modified to survive at
1939 least importing in contexts where stdin/out/err aren't true file
1940 least importing in contexts where stdin/out/err aren't true file
1940 objects, such as PyCrust (they lack fileno() and mode). However,
1941 objects, such as PyCrust (they lack fileno() and mode). However,
1941 the recovery facilities which rely on these things existing will
1942 the recovery facilities which rely on these things existing will
1942 not work.
1943 not work.
1943
1944
1944 2004-04-01 Fernando Perez <fperez@colorado.edu>
1945 2004-04-01 Fernando Perez <fperez@colorado.edu>
1945
1946
1946 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1947 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1947 use the new getoutputerror() function, so it properly
1948 use the new getoutputerror() function, so it properly
1948 distinguishes stdout/err.
1949 distinguishes stdout/err.
1949
1950
1950 * IPython/genutils.py (getoutputerror): added a function to
1951 * IPython/genutils.py (getoutputerror): added a function to
1951 capture separately the standard output and error of a command.
1952 capture separately the standard output and error of a command.
1952 After a comment from dang on the mailing lists. This code is
1953 After a comment from dang on the mailing lists. This code is
1953 basically a modified version of commands.getstatusoutput(), from
1954 basically a modified version of commands.getstatusoutput(), from
1954 the standard library.
1955 the standard library.
1955
1956
1956 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1957 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
1957 '!!' as a special syntax (shorthand) to access @sx.
1958 '!!' as a special syntax (shorthand) to access @sx.
1958
1959
1959 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1960 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
1960 command and return its output as a list split on '\n'.
1961 command and return its output as a list split on '\n'.
1961
1962
1962 2004-03-31 Fernando Perez <fperez@colorado.edu>
1963 2004-03-31 Fernando Perez <fperez@colorado.edu>
1963
1964
1964 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1965 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
1965 method to dictionaries used as FakeModule instances if they lack
1966 method to dictionaries used as FakeModule instances if they lack
1966 it. At least pydoc in python2.3 breaks for runtime-defined
1967 it. At least pydoc in python2.3 breaks for runtime-defined
1967 functions without this hack. At some point I need to _really_
1968 functions without this hack. At some point I need to _really_
1968 understand what FakeModule is doing, because it's a gross hack.
1969 understand what FakeModule is doing, because it's a gross hack.
1969 But it solves Arnd's problem for now...
1970 But it solves Arnd's problem for now...
1970
1971
1971 2004-02-27 Fernando Perez <fperez@colorado.edu>
1972 2004-02-27 Fernando Perez <fperez@colorado.edu>
1972
1973
1973 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1974 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
1974 mode would behave erratically. Also increased the number of
1975 mode would behave erratically. Also increased the number of
1975 possible logs in rotate mod to 999. Thanks to Rod Holland
1976 possible logs in rotate mod to 999. Thanks to Rod Holland
1976 <rhh@StructureLABS.com> for the report and fixes.
1977 <rhh@StructureLABS.com> for the report and fixes.
1977
1978
1978 2004-02-26 Fernando Perez <fperez@colorado.edu>
1979 2004-02-26 Fernando Perez <fperez@colorado.edu>
1979
1980
1980 * IPython/genutils.py (page): Check that the curses module really
1981 * IPython/genutils.py (page): Check that the curses module really
1981 has the initscr attribute before trying to use it. For some
1982 has the initscr attribute before trying to use it. For some
1982 reason, the Solaris curses module is missing this. I think this
1983 reason, the Solaris curses module is missing this. I think this
1983 should be considered a Solaris python bug, but I'm not sure.
1984 should be considered a Solaris python bug, but I'm not sure.
1984
1985
1985 2004-01-17 Fernando Perez <fperez@colorado.edu>
1986 2004-01-17 Fernando Perez <fperez@colorado.edu>
1986
1987
1987 * IPython/genutils.py (Stream.__init__): Changes to try to make
1988 * IPython/genutils.py (Stream.__init__): Changes to try to make
1988 ipython robust against stdin/out/err being closed by the user.
1989 ipython robust against stdin/out/err being closed by the user.
1989 This is 'user error' (and blocks a normal python session, at least
1990 This is 'user error' (and blocks a normal python session, at least
1990 the stdout case). However, Ipython should be able to survive such
1991 the stdout case). However, Ipython should be able to survive such
1991 instances of abuse as gracefully as possible. To simplify the
1992 instances of abuse as gracefully as possible. To simplify the
1992 coding and maintain compatibility with Gary Bishop's Term
1993 coding and maintain compatibility with Gary Bishop's Term
1993 contributions, I've made use of classmethods for this. I think
1994 contributions, I've made use of classmethods for this. I think
1994 this introduces a dependency on python 2.2.
1995 this introduces a dependency on python 2.2.
1995
1996
1996 2004-01-13 Fernando Perez <fperez@colorado.edu>
1997 2004-01-13 Fernando Perez <fperez@colorado.edu>
1997
1998
1998 * IPython/numutils.py (exp_safe): simplified the code a bit and
1999 * IPython/numutils.py (exp_safe): simplified the code a bit and
1999 removed the need for importing the kinds module altogether.
2000 removed the need for importing the kinds module altogether.
2000
2001
2001 2004-01-06 Fernando Perez <fperez@colorado.edu>
2002 2004-01-06 Fernando Perez <fperez@colorado.edu>
2002
2003
2003 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2004 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2004 a magic function instead, after some community feedback. No
2005 a magic function instead, after some community feedback. No
2005 special syntax will exist for it, but its name is deliberately
2006 special syntax will exist for it, but its name is deliberately
2006 very short.
2007 very short.
2007
2008
2008 2003-12-20 Fernando Perez <fperez@colorado.edu>
2009 2003-12-20 Fernando Perez <fperez@colorado.edu>
2009
2010
2010 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2011 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2011 new functionality, to automagically assign the result of a shell
2012 new functionality, to automagically assign the result of a shell
2012 command to a variable. I'll solicit some community feedback on
2013 command to a variable. I'll solicit some community feedback on
2013 this before making it permanent.
2014 this before making it permanent.
2014
2015
2015 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2016 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2016 requested about callables for which inspect couldn't obtain a
2017 requested about callables for which inspect couldn't obtain a
2017 proper argspec. Thanks to a crash report sent by Etienne
2018 proper argspec. Thanks to a crash report sent by Etienne
2018 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2019 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2019
2020
2020 2003-12-09 Fernando Perez <fperez@colorado.edu>
2021 2003-12-09 Fernando Perez <fperez@colorado.edu>
2021
2022
2022 * IPython/genutils.py (page): patch for the pager to work across
2023 * IPython/genutils.py (page): patch for the pager to work across
2023 various versions of Windows. By Gary Bishop.
2024 various versions of Windows. By Gary Bishop.
2024
2025
2025 2003-12-04 Fernando Perez <fperez@colorado.edu>
2026 2003-12-04 Fernando Perez <fperez@colorado.edu>
2026
2027
2027 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2028 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2028 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2029 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2029 While I tested this and it looks ok, there may still be corner
2030 While I tested this and it looks ok, there may still be corner
2030 cases I've missed.
2031 cases I've missed.
2031
2032
2032 2003-12-01 Fernando Perez <fperez@colorado.edu>
2033 2003-12-01 Fernando Perez <fperez@colorado.edu>
2033
2034
2034 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2035 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2035 where a line like 'p,q=1,2' would fail because the automagic
2036 where a line like 'p,q=1,2' would fail because the automagic
2036 system would be triggered for @p.
2037 system would be triggered for @p.
2037
2038
2038 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2039 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2039 cleanups, code unmodified.
2040 cleanups, code unmodified.
2040
2041
2041 * IPython/genutils.py (Term): added a class for IPython to handle
2042 * IPython/genutils.py (Term): added a class for IPython to handle
2042 output. In most cases it will just be a proxy for stdout/err, but
2043 output. In most cases it will just be a proxy for stdout/err, but
2043 having this allows modifications to be made for some platforms,
2044 having this allows modifications to be made for some platforms,
2044 such as handling color escapes under Windows. All of this code
2045 such as handling color escapes under Windows. All of this code
2045 was contributed by Gary Bishop, with minor modifications by me.
2046 was contributed by Gary Bishop, with minor modifications by me.
2046 The actual changes affect many files.
2047 The actual changes affect many files.
2047
2048
2048 2003-11-30 Fernando Perez <fperez@colorado.edu>
2049 2003-11-30 Fernando Perez <fperez@colorado.edu>
2049
2050
2050 * IPython/iplib.py (file_matches): new completion code, courtesy
2051 * IPython/iplib.py (file_matches): new completion code, courtesy
2051 of Jeff Collins. This enables filename completion again under
2052 of Jeff Collins. This enables filename completion again under
2052 python 2.3, which disabled it at the C level.
2053 python 2.3, which disabled it at the C level.
2053
2054
2054 2003-11-11 Fernando Perez <fperez@colorado.edu>
2055 2003-11-11 Fernando Perez <fperez@colorado.edu>
2055
2056
2056 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2057 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2057 for Numeric.array(map(...)), but often convenient.
2058 for Numeric.array(map(...)), but often convenient.
2058
2059
2059 2003-11-05 Fernando Perez <fperez@colorado.edu>
2060 2003-11-05 Fernando Perez <fperez@colorado.edu>
2060
2061
2061 * IPython/numutils.py (frange): Changed a call from int() to
2062 * IPython/numutils.py (frange): Changed a call from int() to
2062 int(round()) to prevent a problem reported with arange() in the
2063 int(round()) to prevent a problem reported with arange() in the
2063 numpy list.
2064 numpy list.
2064
2065
2065 2003-10-06 Fernando Perez <fperez@colorado.edu>
2066 2003-10-06 Fernando Perez <fperez@colorado.edu>
2066
2067
2067 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2068 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2068 prevent crashes if sys lacks an argv attribute (it happens with
2069 prevent crashes if sys lacks an argv attribute (it happens with
2069 embedded interpreters which build a bare-bones sys module).
2070 embedded interpreters which build a bare-bones sys module).
2070 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2071 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2071
2072
2072 2003-09-24 Fernando Perez <fperez@colorado.edu>
2073 2003-09-24 Fernando Perez <fperez@colorado.edu>
2073
2074
2074 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2075 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2075 to protect against poorly written user objects where __getattr__
2076 to protect against poorly written user objects where __getattr__
2076 raises exceptions other than AttributeError. Thanks to a bug
2077 raises exceptions other than AttributeError. Thanks to a bug
2077 report by Oliver Sander <osander-AT-gmx.de>.
2078 report by Oliver Sander <osander-AT-gmx.de>.
2078
2079
2079 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2080 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2080 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2081 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2081
2082
2082 2003-09-09 Fernando Perez <fperez@colorado.edu>
2083 2003-09-09 Fernando Perez <fperez@colorado.edu>
2083
2084
2084 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2085 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2085 unpacking a list whith a callable as first element would
2086 unpacking a list whith a callable as first element would
2086 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2087 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2087 Collins.
2088 Collins.
2088
2089
2089 2003-08-25 *** Released version 0.5.0
2090 2003-08-25 *** Released version 0.5.0
2090
2091
2091 2003-08-22 Fernando Perez <fperez@colorado.edu>
2092 2003-08-22 Fernando Perez <fperez@colorado.edu>
2092
2093
2093 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2094 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2094 improperly defined user exceptions. Thanks to feedback from Mark
2095 improperly defined user exceptions. Thanks to feedback from Mark
2095 Russell <mrussell-AT-verio.net>.
2096 Russell <mrussell-AT-verio.net>.
2096
2097
2097 2003-08-20 Fernando Perez <fperez@colorado.edu>
2098 2003-08-20 Fernando Perez <fperez@colorado.edu>
2098
2099
2099 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2100 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2100 printing so that it would print multi-line string forms starting
2101 printing so that it would print multi-line string forms starting
2101 with a new line. This way the formatting is better respected for
2102 with a new line. This way the formatting is better respected for
2102 objects which work hard to make nice string forms.
2103 objects which work hard to make nice string forms.
2103
2104
2104 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2105 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2105 autocall would overtake data access for objects with both
2106 autocall would overtake data access for objects with both
2106 __getitem__ and __call__.
2107 __getitem__ and __call__.
2107
2108
2108 2003-08-19 *** Released version 0.5.0-rc1
2109 2003-08-19 *** Released version 0.5.0-rc1
2109
2110
2110 2003-08-19 Fernando Perez <fperez@colorado.edu>
2111 2003-08-19 Fernando Perez <fperez@colorado.edu>
2111
2112
2112 * IPython/deep_reload.py (load_tail): single tiny change here
2113 * IPython/deep_reload.py (load_tail): single tiny change here
2113 seems to fix the long-standing bug of dreload() failing to work
2114 seems to fix the long-standing bug of dreload() failing to work
2114 for dotted names. But this module is pretty tricky, so I may have
2115 for dotted names. But this module is pretty tricky, so I may have
2115 missed some subtlety. Needs more testing!.
2116 missed some subtlety. Needs more testing!.
2116
2117
2117 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2118 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2118 exceptions which have badly implemented __str__ methods.
2119 exceptions which have badly implemented __str__ methods.
2119 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2120 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2120 which I've been getting reports about from Python 2.3 users. I
2121 which I've been getting reports about from Python 2.3 users. I
2121 wish I had a simple test case to reproduce the problem, so I could
2122 wish I had a simple test case to reproduce the problem, so I could
2122 either write a cleaner workaround or file a bug report if
2123 either write a cleaner workaround or file a bug report if
2123 necessary.
2124 necessary.
2124
2125
2125 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2126 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2126 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2127 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2127 a bug report by Tjabo Kloppenburg.
2128 a bug report by Tjabo Kloppenburg.
2128
2129
2129 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2130 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2130 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2131 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2131 seems rather unstable. Thanks to a bug report by Tjabo
2132 seems rather unstable. Thanks to a bug report by Tjabo
2132 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2133 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2133
2134
2134 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2135 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2135 this out soon because of the critical fixes in the inner loop for
2136 this out soon because of the critical fixes in the inner loop for
2136 generators.
2137 generators.
2137
2138
2138 * IPython/Magic.py (Magic.getargspec): removed. This (and
2139 * IPython/Magic.py (Magic.getargspec): removed. This (and
2139 _get_def) have been obsoleted by OInspect for a long time, I
2140 _get_def) have been obsoleted by OInspect for a long time, I
2140 hadn't noticed that they were dead code.
2141 hadn't noticed that they were dead code.
2141 (Magic._ofind): restored _ofind functionality for a few literals
2142 (Magic._ofind): restored _ofind functionality for a few literals
2142 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2143 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2143 for things like "hello".capitalize?, since that would require a
2144 for things like "hello".capitalize?, since that would require a
2144 potentially dangerous eval() again.
2145 potentially dangerous eval() again.
2145
2146
2146 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2147 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2147 logic a bit more to clean up the escapes handling and minimize the
2148 logic a bit more to clean up the escapes handling and minimize the
2148 use of _ofind to only necessary cases. The interactive 'feel' of
2149 use of _ofind to only necessary cases. The interactive 'feel' of
2149 IPython should have improved quite a bit with the changes in
2150 IPython should have improved quite a bit with the changes in
2150 _prefilter and _ofind (besides being far safer than before).
2151 _prefilter and _ofind (besides being far safer than before).
2151
2152
2152 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2153 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2153 obscure, never reported). Edit would fail to find the object to
2154 obscure, never reported). Edit would fail to find the object to
2154 edit under some circumstances.
2155 edit under some circumstances.
2155 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2156 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2156 which were causing double-calling of generators. Those eval calls
2157 which were causing double-calling of generators. Those eval calls
2157 were _very_ dangerous, since code with side effects could be
2158 were _very_ dangerous, since code with side effects could be
2158 triggered. As they say, 'eval is evil'... These were the
2159 triggered. As they say, 'eval is evil'... These were the
2159 nastiest evals in IPython. Besides, _ofind is now far simpler,
2160 nastiest evals in IPython. Besides, _ofind is now far simpler,
2160 and it should also be quite a bit faster. Its use of inspect is
2161 and it should also be quite a bit faster. Its use of inspect is
2161 also safer, so perhaps some of the inspect-related crashes I've
2162 also safer, so perhaps some of the inspect-related crashes I've
2162 seen lately with Python 2.3 might be taken care of. That will
2163 seen lately with Python 2.3 might be taken care of. That will
2163 need more testing.
2164 need more testing.
2164
2165
2165 2003-08-17 Fernando Perez <fperez@colorado.edu>
2166 2003-08-17 Fernando Perez <fperez@colorado.edu>
2166
2167
2167 * IPython/iplib.py (InteractiveShell._prefilter): significant
2168 * IPython/iplib.py (InteractiveShell._prefilter): significant
2168 simplifications to the logic for handling user escapes. Faster
2169 simplifications to the logic for handling user escapes. Faster
2169 and simpler code.
2170 and simpler code.
2170
2171
2171 2003-08-14 Fernando Perez <fperez@colorado.edu>
2172 2003-08-14 Fernando Perez <fperez@colorado.edu>
2172
2173
2173 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2174 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2174 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2175 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2175 but it should be quite a bit faster. And the recursive version
2176 but it should be quite a bit faster. And the recursive version
2176 generated O(log N) intermediate storage for all rank>1 arrays,
2177 generated O(log N) intermediate storage for all rank>1 arrays,
2177 even if they were contiguous.
2178 even if they were contiguous.
2178 (l1norm): Added this function.
2179 (l1norm): Added this function.
2179 (norm): Added this function for arbitrary norms (including
2180 (norm): Added this function for arbitrary norms (including
2180 l-infinity). l1 and l2 are still special cases for convenience
2181 l-infinity). l1 and l2 are still special cases for convenience
2181 and speed.
2182 and speed.
2182
2183
2183 2003-08-03 Fernando Perez <fperez@colorado.edu>
2184 2003-08-03 Fernando Perez <fperez@colorado.edu>
2184
2185
2185 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2186 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2186 exceptions, which now raise PendingDeprecationWarnings in Python
2187 exceptions, which now raise PendingDeprecationWarnings in Python
2187 2.3. There were some in Magic and some in Gnuplot2.
2188 2.3. There were some in Magic and some in Gnuplot2.
2188
2189
2189 2003-06-30 Fernando Perez <fperez@colorado.edu>
2190 2003-06-30 Fernando Perez <fperez@colorado.edu>
2190
2191
2191 * IPython/genutils.py (page): modified to call curses only for
2192 * IPython/genutils.py (page): modified to call curses only for
2192 terminals where TERM=='xterm'. After problems under many other
2193 terminals where TERM=='xterm'. After problems under many other
2193 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2194 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2194
2195
2195 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2196 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2196 would be triggered when readline was absent. This was just an old
2197 would be triggered when readline was absent. This was just an old
2197 debugging statement I'd forgotten to take out.
2198 debugging statement I'd forgotten to take out.
2198
2199
2199 2003-06-20 Fernando Perez <fperez@colorado.edu>
2200 2003-06-20 Fernando Perez <fperez@colorado.edu>
2200
2201
2201 * IPython/genutils.py (clock): modified to return only user time
2202 * IPython/genutils.py (clock): modified to return only user time
2202 (not counting system time), after a discussion on scipy. While
2203 (not counting system time), after a discussion on scipy. While
2203 system time may be a useful quantity occasionally, it may much
2204 system time may be a useful quantity occasionally, it may much
2204 more easily be skewed by occasional swapping or other similar
2205 more easily be skewed by occasional swapping or other similar
2205 activity.
2206 activity.
2206
2207
2207 2003-06-05 Fernando Perez <fperez@colorado.edu>
2208 2003-06-05 Fernando Perez <fperez@colorado.edu>
2208
2209
2209 * IPython/numutils.py (identity): new function, for building
2210 * IPython/numutils.py (identity): new function, for building
2210 arbitrary rank Kronecker deltas (mostly backwards compatible with
2211 arbitrary rank Kronecker deltas (mostly backwards compatible with
2211 Numeric.identity)
2212 Numeric.identity)
2212
2213
2213 2003-06-03 Fernando Perez <fperez@colorado.edu>
2214 2003-06-03 Fernando Perez <fperez@colorado.edu>
2214
2215
2215 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2216 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2216 arguments passed to magics with spaces, to allow trailing '\' to
2217 arguments passed to magics with spaces, to allow trailing '\' to
2217 work normally (mainly for Windows users).
2218 work normally (mainly for Windows users).
2218
2219
2219 2003-05-29 Fernando Perez <fperez@colorado.edu>
2220 2003-05-29 Fernando Perez <fperez@colorado.edu>
2220
2221
2221 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2222 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2222 instead of pydoc.help. This fixes a bizarre behavior where
2223 instead of pydoc.help. This fixes a bizarre behavior where
2223 printing '%s' % locals() would trigger the help system. Now
2224 printing '%s' % locals() would trigger the help system. Now
2224 ipython behaves like normal python does.
2225 ipython behaves like normal python does.
2225
2226
2226 Note that if one does 'from pydoc import help', the bizarre
2227 Note that if one does 'from pydoc import help', the bizarre
2227 behavior returns, but this will also happen in normal python, so
2228 behavior returns, but this will also happen in normal python, so
2228 it's not an ipython bug anymore (it has to do with how pydoc.help
2229 it's not an ipython bug anymore (it has to do with how pydoc.help
2229 is implemented).
2230 is implemented).
2230
2231
2231 2003-05-22 Fernando Perez <fperez@colorado.edu>
2232 2003-05-22 Fernando Perez <fperez@colorado.edu>
2232
2233
2233 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2234 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2234 return [] instead of None when nothing matches, also match to end
2235 return [] instead of None when nothing matches, also match to end
2235 of line. Patch by Gary Bishop.
2236 of line. Patch by Gary Bishop.
2236
2237
2237 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2238 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2238 protection as before, for files passed on the command line. This
2239 protection as before, for files passed on the command line. This
2239 prevents the CrashHandler from kicking in if user files call into
2240 prevents the CrashHandler from kicking in if user files call into
2240 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2241 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2241 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2242 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2242
2243
2243 2003-05-20 *** Released version 0.4.0
2244 2003-05-20 *** Released version 0.4.0
2244
2245
2245 2003-05-20 Fernando Perez <fperez@colorado.edu>
2246 2003-05-20 Fernando Perez <fperez@colorado.edu>
2246
2247
2247 * setup.py: added support for manpages. It's a bit hackish b/c of
2248 * setup.py: added support for manpages. It's a bit hackish b/c of
2248 a bug in the way the bdist_rpm distutils target handles gzipped
2249 a bug in the way the bdist_rpm distutils target handles gzipped
2249 manpages, but it works. After a patch by Jack.
2250 manpages, but it works. After a patch by Jack.
2250
2251
2251 2003-05-19 Fernando Perez <fperez@colorado.edu>
2252 2003-05-19 Fernando Perez <fperez@colorado.edu>
2252
2253
2253 * IPython/numutils.py: added a mockup of the kinds module, since
2254 * IPython/numutils.py: added a mockup of the kinds module, since
2254 it was recently removed from Numeric. This way, numutils will
2255 it was recently removed from Numeric. This way, numutils will
2255 work for all users even if they are missing kinds.
2256 work for all users even if they are missing kinds.
2256
2257
2257 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2258 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2258 failure, which can occur with SWIG-wrapped extensions. After a
2259 failure, which can occur with SWIG-wrapped extensions. After a
2259 crash report from Prabhu.
2260 crash report from Prabhu.
2260
2261
2261 2003-05-16 Fernando Perez <fperez@colorado.edu>
2262 2003-05-16 Fernando Perez <fperez@colorado.edu>
2262
2263
2263 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2264 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2264 protect ipython from user code which may call directly
2265 protect ipython from user code which may call directly
2265 sys.excepthook (this looks like an ipython crash to the user, even
2266 sys.excepthook (this looks like an ipython crash to the user, even
2266 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2267 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2267 This is especially important to help users of WxWindows, but may
2268 This is especially important to help users of WxWindows, but may
2268 also be useful in other cases.
2269 also be useful in other cases.
2269
2270
2270 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2271 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2271 an optional tb_offset to be specified, and to preserve exception
2272 an optional tb_offset to be specified, and to preserve exception
2272 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2273 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2273
2274
2274 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2275 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2275
2276
2276 2003-05-15 Fernando Perez <fperez@colorado.edu>
2277 2003-05-15 Fernando Perez <fperez@colorado.edu>
2277
2278
2278 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2279 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2279 installing for a new user under Windows.
2280 installing for a new user under Windows.
2280
2281
2281 2003-05-12 Fernando Perez <fperez@colorado.edu>
2282 2003-05-12 Fernando Perez <fperez@colorado.edu>
2282
2283
2283 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2284 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2284 handler for Emacs comint-based lines. Currently it doesn't do
2285 handler for Emacs comint-based lines. Currently it doesn't do
2285 much (but importantly, it doesn't update the history cache). In
2286 much (but importantly, it doesn't update the history cache). In
2286 the future it may be expanded if Alex needs more functionality
2287 the future it may be expanded if Alex needs more functionality
2287 there.
2288 there.
2288
2289
2289 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2290 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2290 info to crash reports.
2291 info to crash reports.
2291
2292
2292 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2293 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2293 just like Python's -c. Also fixed crash with invalid -color
2294 just like Python's -c. Also fixed crash with invalid -color
2294 option value at startup. Thanks to Will French
2295 option value at startup. Thanks to Will French
2295 <wfrench-AT-bestweb.net> for the bug report.
2296 <wfrench-AT-bestweb.net> for the bug report.
2296
2297
2297 2003-05-09 Fernando Perez <fperez@colorado.edu>
2298 2003-05-09 Fernando Perez <fperez@colorado.edu>
2298
2299
2299 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2300 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2300 to EvalDict (it's a mapping, after all) and simplified its code
2301 to EvalDict (it's a mapping, after all) and simplified its code
2301 quite a bit, after a nice discussion on c.l.py where Gustavo
2302 quite a bit, after a nice discussion on c.l.py where Gustavo
2302 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2303 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2303
2304
2304 2003-04-30 Fernando Perez <fperez@colorado.edu>
2305 2003-04-30 Fernando Perez <fperez@colorado.edu>
2305
2306
2306 * IPython/genutils.py (timings_out): modified it to reduce its
2307 * IPython/genutils.py (timings_out): modified it to reduce its
2307 overhead in the common reps==1 case.
2308 overhead in the common reps==1 case.
2308
2309
2309 2003-04-29 Fernando Perez <fperez@colorado.edu>
2310 2003-04-29 Fernando Perez <fperez@colorado.edu>
2310
2311
2311 * IPython/genutils.py (timings_out): Modified to use the resource
2312 * IPython/genutils.py (timings_out): Modified to use the resource
2312 module, which avoids the wraparound problems of time.clock().
2313 module, which avoids the wraparound problems of time.clock().
2313
2314
2314 2003-04-17 *** Released version 0.2.15pre4
2315 2003-04-17 *** Released version 0.2.15pre4
2315
2316
2316 2003-04-17 Fernando Perez <fperez@colorado.edu>
2317 2003-04-17 Fernando Perez <fperez@colorado.edu>
2317
2318
2318 * setup.py (scriptfiles): Split windows-specific stuff over to a
2319 * setup.py (scriptfiles): Split windows-specific stuff over to a
2319 separate file, in an attempt to have a Windows GUI installer.
2320 separate file, in an attempt to have a Windows GUI installer.
2320 That didn't work, but part of the groundwork is done.
2321 That didn't work, but part of the groundwork is done.
2321
2322
2322 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2323 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2323 indent/unindent with 4 spaces. Particularly useful in combination
2324 indent/unindent with 4 spaces. Particularly useful in combination
2324 with the new auto-indent option.
2325 with the new auto-indent option.
2325
2326
2326 2003-04-16 Fernando Perez <fperez@colorado.edu>
2327 2003-04-16 Fernando Perez <fperez@colorado.edu>
2327
2328
2328 * IPython/Magic.py: various replacements of self.rc for
2329 * IPython/Magic.py: various replacements of self.rc for
2329 self.shell.rc. A lot more remains to be done to fully disentangle
2330 self.shell.rc. A lot more remains to be done to fully disentangle
2330 this class from the main Shell class.
2331 this class from the main Shell class.
2331
2332
2332 * IPython/GnuplotRuntime.py: added checks for mouse support so
2333 * IPython/GnuplotRuntime.py: added checks for mouse support so
2333 that we don't try to enable it if the current gnuplot doesn't
2334 that we don't try to enable it if the current gnuplot doesn't
2334 really support it. Also added checks so that we don't try to
2335 really support it. Also added checks so that we don't try to
2335 enable persist under Windows (where Gnuplot doesn't recognize the
2336 enable persist under Windows (where Gnuplot doesn't recognize the
2336 option).
2337 option).
2337
2338
2338 * IPython/iplib.py (InteractiveShell.interact): Added optional
2339 * IPython/iplib.py (InteractiveShell.interact): Added optional
2339 auto-indenting code, after a patch by King C. Shu
2340 auto-indenting code, after a patch by King C. Shu
2340 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2341 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2341 get along well with pasting indented code. If I ever figure out
2342 get along well with pasting indented code. If I ever figure out
2342 how to make that part go well, it will become on by default.
2343 how to make that part go well, it will become on by default.
2343
2344
2344 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2345 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2345 crash ipython if there was an unmatched '%' in the user's prompt
2346 crash ipython if there was an unmatched '%' in the user's prompt
2346 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2347 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2347
2348
2348 * IPython/iplib.py (InteractiveShell.interact): removed the
2349 * IPython/iplib.py (InteractiveShell.interact): removed the
2349 ability to ask the user whether he wants to crash or not at the
2350 ability to ask the user whether he wants to crash or not at the
2350 'last line' exception handler. Calling functions at that point
2351 'last line' exception handler. Calling functions at that point
2351 changes the stack, and the error reports would have incorrect
2352 changes the stack, and the error reports would have incorrect
2352 tracebacks.
2353 tracebacks.
2353
2354
2354 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2355 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2355 pass through a peger a pretty-printed form of any object. After a
2356 pass through a peger a pretty-printed form of any object. After a
2356 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2357 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2357
2358
2358 2003-04-14 Fernando Perez <fperez@colorado.edu>
2359 2003-04-14 Fernando Perez <fperez@colorado.edu>
2359
2360
2360 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2361 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2361 all files in ~ would be modified at first install (instead of
2362 all files in ~ would be modified at first install (instead of
2362 ~/.ipython). This could be potentially disastrous, as the
2363 ~/.ipython). This could be potentially disastrous, as the
2363 modification (make line-endings native) could damage binary files.
2364 modification (make line-endings native) could damage binary files.
2364
2365
2365 2003-04-10 Fernando Perez <fperez@colorado.edu>
2366 2003-04-10 Fernando Perez <fperez@colorado.edu>
2366
2367
2367 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2368 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2368 handle only lines which are invalid python. This now means that
2369 handle only lines which are invalid python. This now means that
2369 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2370 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2370 for the bug report.
2371 for the bug report.
2371
2372
2372 2003-04-01 Fernando Perez <fperez@colorado.edu>
2373 2003-04-01 Fernando Perez <fperez@colorado.edu>
2373
2374
2374 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2375 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2375 where failing to set sys.last_traceback would crash pdb.pm().
2376 where failing to set sys.last_traceback would crash pdb.pm().
2376 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2377 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2377 report.
2378 report.
2378
2379
2379 2003-03-25 Fernando Perez <fperez@colorado.edu>
2380 2003-03-25 Fernando Perez <fperez@colorado.edu>
2380
2381
2381 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2382 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2382 before printing it (it had a lot of spurious blank lines at the
2383 before printing it (it had a lot of spurious blank lines at the
2383 end).
2384 end).
2384
2385
2385 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2386 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2386 output would be sent 21 times! Obviously people don't use this
2387 output would be sent 21 times! Obviously people don't use this
2387 too often, or I would have heard about it.
2388 too often, or I would have heard about it.
2388
2389
2389 2003-03-24 Fernando Perez <fperez@colorado.edu>
2390 2003-03-24 Fernando Perez <fperez@colorado.edu>
2390
2391
2391 * setup.py (scriptfiles): renamed the data_files parameter from
2392 * setup.py (scriptfiles): renamed the data_files parameter from
2392 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2393 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2393 for the patch.
2394 for the patch.
2394
2395
2395 2003-03-20 Fernando Perez <fperez@colorado.edu>
2396 2003-03-20 Fernando Perez <fperez@colorado.edu>
2396
2397
2397 * IPython/genutils.py (error): added error() and fatal()
2398 * IPython/genutils.py (error): added error() and fatal()
2398 functions.
2399 functions.
2399
2400
2400 2003-03-18 *** Released version 0.2.15pre3
2401 2003-03-18 *** Released version 0.2.15pre3
2401
2402
2402 2003-03-18 Fernando Perez <fperez@colorado.edu>
2403 2003-03-18 Fernando Perez <fperez@colorado.edu>
2403
2404
2404 * setupext/install_data_ext.py
2405 * setupext/install_data_ext.py
2405 (install_data_ext.initialize_options): Class contributed by Jack
2406 (install_data_ext.initialize_options): Class contributed by Jack
2406 Moffit for fixing the old distutils hack. He is sending this to
2407 Moffit for fixing the old distutils hack. He is sending this to
2407 the distutils folks so in the future we may not need it as a
2408 the distutils folks so in the future we may not need it as a
2408 private fix.
2409 private fix.
2409
2410
2410 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2411 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2411 changes for Debian packaging. See his patch for full details.
2412 changes for Debian packaging. See his patch for full details.
2412 The old distutils hack of making the ipythonrc* files carry a
2413 The old distutils hack of making the ipythonrc* files carry a
2413 bogus .py extension is gone, at last. Examples were moved to a
2414 bogus .py extension is gone, at last. Examples were moved to a
2414 separate subdir under doc/, and the separate executable scripts
2415 separate subdir under doc/, and the separate executable scripts
2415 now live in their own directory. Overall a great cleanup. The
2416 now live in their own directory. Overall a great cleanup. The
2416 manual was updated to use the new files, and setup.py has been
2417 manual was updated to use the new files, and setup.py has been
2417 fixed for this setup.
2418 fixed for this setup.
2418
2419
2419 * IPython/PyColorize.py (Parser.usage): made non-executable and
2420 * IPython/PyColorize.py (Parser.usage): made non-executable and
2420 created a pycolor wrapper around it to be included as a script.
2421 created a pycolor wrapper around it to be included as a script.
2421
2422
2422 2003-03-12 *** Released version 0.2.15pre2
2423 2003-03-12 *** Released version 0.2.15pre2
2423
2424
2424 2003-03-12 Fernando Perez <fperez@colorado.edu>
2425 2003-03-12 Fernando Perez <fperez@colorado.edu>
2425
2426
2426 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2427 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2427 long-standing problem with garbage characters in some terminals.
2428 long-standing problem with garbage characters in some terminals.
2428 The issue was really that the \001 and \002 escapes must _only_ be
2429 The issue was really that the \001 and \002 escapes must _only_ be
2429 passed to input prompts (which call readline), but _never_ to
2430 passed to input prompts (which call readline), but _never_ to
2430 normal text to be printed on screen. I changed ColorANSI to have
2431 normal text to be printed on screen. I changed ColorANSI to have
2431 two classes: TermColors and InputTermColors, each with the
2432 two classes: TermColors and InputTermColors, each with the
2432 appropriate escapes for input prompts or normal text. The code in
2433 appropriate escapes for input prompts or normal text. The code in
2433 Prompts.py got slightly more complicated, but this very old and
2434 Prompts.py got slightly more complicated, but this very old and
2434 annoying bug is finally fixed.
2435 annoying bug is finally fixed.
2435
2436
2436 All the credit for nailing down the real origin of this problem
2437 All the credit for nailing down the real origin of this problem
2437 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2438 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2438 *Many* thanks to him for spending quite a bit of effort on this.
2439 *Many* thanks to him for spending quite a bit of effort on this.
2439
2440
2440 2003-03-05 *** Released version 0.2.15pre1
2441 2003-03-05 *** Released version 0.2.15pre1
2441
2442
2442 2003-03-03 Fernando Perez <fperez@colorado.edu>
2443 2003-03-03 Fernando Perez <fperez@colorado.edu>
2443
2444
2444 * IPython/FakeModule.py: Moved the former _FakeModule to a
2445 * IPython/FakeModule.py: Moved the former _FakeModule to a
2445 separate file, because it's also needed by Magic (to fix a similar
2446 separate file, because it's also needed by Magic (to fix a similar
2446 pickle-related issue in @run).
2447 pickle-related issue in @run).
2447
2448
2448 2003-03-02 Fernando Perez <fperez@colorado.edu>
2449 2003-03-02 Fernando Perez <fperez@colorado.edu>
2449
2450
2450 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2451 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2451 the autocall option at runtime.
2452 the autocall option at runtime.
2452 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2453 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2453 across Magic.py to start separating Magic from InteractiveShell.
2454 across Magic.py to start separating Magic from InteractiveShell.
2454 (Magic._ofind): Fixed to return proper namespace for dotted
2455 (Magic._ofind): Fixed to return proper namespace for dotted
2455 names. Before, a dotted name would always return 'not currently
2456 names. Before, a dotted name would always return 'not currently
2456 defined', because it would find the 'parent'. s.x would be found,
2457 defined', because it would find the 'parent'. s.x would be found,
2457 but since 'x' isn't defined by itself, it would get confused.
2458 but since 'x' isn't defined by itself, it would get confused.
2458 (Magic.magic_run): Fixed pickling problems reported by Ralf
2459 (Magic.magic_run): Fixed pickling problems reported by Ralf
2459 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2460 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2460 that I'd used when Mike Heeter reported similar issues at the
2461 that I'd used when Mike Heeter reported similar issues at the
2461 top-level, but now for @run. It boils down to injecting the
2462 top-level, but now for @run. It boils down to injecting the
2462 namespace where code is being executed with something that looks
2463 namespace where code is being executed with something that looks
2463 enough like a module to fool pickle.dump(). Since a pickle stores
2464 enough like a module to fool pickle.dump(). Since a pickle stores
2464 a named reference to the importing module, we need this for
2465 a named reference to the importing module, we need this for
2465 pickles to save something sensible.
2466 pickles to save something sensible.
2466
2467
2467 * IPython/ipmaker.py (make_IPython): added an autocall option.
2468 * IPython/ipmaker.py (make_IPython): added an autocall option.
2468
2469
2469 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2470 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2470 the auto-eval code. Now autocalling is an option, and the code is
2471 the auto-eval code. Now autocalling is an option, and the code is
2471 also vastly safer. There is no more eval() involved at all.
2472 also vastly safer. There is no more eval() involved at all.
2472
2473
2473 2003-03-01 Fernando Perez <fperez@colorado.edu>
2474 2003-03-01 Fernando Perez <fperez@colorado.edu>
2474
2475
2475 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2476 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2476 dict with named keys instead of a tuple.
2477 dict with named keys instead of a tuple.
2477
2478
2478 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2479 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2479
2480
2480 * setup.py (make_shortcut): Fixed message about directories
2481 * setup.py (make_shortcut): Fixed message about directories
2481 created during Windows installation (the directories were ok, just
2482 created during Windows installation (the directories were ok, just
2482 the printed message was misleading). Thanks to Chris Liechti
2483 the printed message was misleading). Thanks to Chris Liechti
2483 <cliechti-AT-gmx.net> for the heads up.
2484 <cliechti-AT-gmx.net> for the heads up.
2484
2485
2485 2003-02-21 Fernando Perez <fperez@colorado.edu>
2486 2003-02-21 Fernando Perez <fperez@colorado.edu>
2486
2487
2487 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2488 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2488 of ValueError exception when checking for auto-execution. This
2489 of ValueError exception when checking for auto-execution. This
2489 one is raised by things like Numeric arrays arr.flat when the
2490 one is raised by things like Numeric arrays arr.flat when the
2490 array is non-contiguous.
2491 array is non-contiguous.
2491
2492
2492 2003-01-31 Fernando Perez <fperez@colorado.edu>
2493 2003-01-31 Fernando Perez <fperez@colorado.edu>
2493
2494
2494 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2495 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2495 not return any value at all (even though the command would get
2496 not return any value at all (even though the command would get
2496 executed).
2497 executed).
2497 (xsys): Flush stdout right after printing the command to ensure
2498 (xsys): Flush stdout right after printing the command to ensure
2498 proper ordering of commands and command output in the total
2499 proper ordering of commands and command output in the total
2499 output.
2500 output.
2500 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2501 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2501 system/getoutput as defaults. The old ones are kept for
2502 system/getoutput as defaults. The old ones are kept for
2502 compatibility reasons, so no code which uses this library needs
2503 compatibility reasons, so no code which uses this library needs
2503 changing.
2504 changing.
2504
2505
2505 2003-01-27 *** Released version 0.2.14
2506 2003-01-27 *** Released version 0.2.14
2506
2507
2507 2003-01-25 Fernando Perez <fperez@colorado.edu>
2508 2003-01-25 Fernando Perez <fperez@colorado.edu>
2508
2509
2509 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2510 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2510 functions defined in previous edit sessions could not be re-edited
2511 functions defined in previous edit sessions could not be re-edited
2511 (because the temp files were immediately removed). Now temp files
2512 (because the temp files were immediately removed). Now temp files
2512 are removed only at IPython's exit.
2513 are removed only at IPython's exit.
2513 (Magic.magic_run): Improved @run to perform shell-like expansions
2514 (Magic.magic_run): Improved @run to perform shell-like expansions
2514 on its arguments (~users and $VARS). With this, @run becomes more
2515 on its arguments (~users and $VARS). With this, @run becomes more
2515 like a normal command-line.
2516 like a normal command-line.
2516
2517
2517 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2518 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2518 bugs related to embedding and cleaned up that code. A fairly
2519 bugs related to embedding and cleaned up that code. A fairly
2519 important one was the impossibility to access the global namespace
2520 important one was the impossibility to access the global namespace
2520 through the embedded IPython (only local variables were visible).
2521 through the embedded IPython (only local variables were visible).
2521
2522
2522 2003-01-14 Fernando Perez <fperez@colorado.edu>
2523 2003-01-14 Fernando Perez <fperez@colorado.edu>
2523
2524
2524 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2525 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2525 auto-calling to be a bit more conservative. Now it doesn't get
2526 auto-calling to be a bit more conservative. Now it doesn't get
2526 triggered if any of '!=()<>' are in the rest of the input line, to
2527 triggered if any of '!=()<>' are in the rest of the input line, to
2527 allow comparing callables. Thanks to Alex for the heads up.
2528 allow comparing callables. Thanks to Alex for the heads up.
2528
2529
2529 2003-01-07 Fernando Perez <fperez@colorado.edu>
2530 2003-01-07 Fernando Perez <fperez@colorado.edu>
2530
2531
2531 * IPython/genutils.py (page): fixed estimation of the number of
2532 * IPython/genutils.py (page): fixed estimation of the number of
2532 lines in a string to be paged to simply count newlines. This
2533 lines in a string to be paged to simply count newlines. This
2533 prevents over-guessing due to embedded escape sequences. A better
2534 prevents over-guessing due to embedded escape sequences. A better
2534 long-term solution would involve stripping out the control chars
2535 long-term solution would involve stripping out the control chars
2535 for the count, but it's potentially so expensive I just don't
2536 for the count, but it's potentially so expensive I just don't
2536 think it's worth doing.
2537 think it's worth doing.
2537
2538
2538 2002-12-19 *** Released version 0.2.14pre50
2539 2002-12-19 *** Released version 0.2.14pre50
2539
2540
2540 2002-12-19 Fernando Perez <fperez@colorado.edu>
2541 2002-12-19 Fernando Perez <fperez@colorado.edu>
2541
2542
2542 * tools/release (version): Changed release scripts to inform
2543 * tools/release (version): Changed release scripts to inform
2543 Andrea and build a NEWS file with a list of recent changes.
2544 Andrea and build a NEWS file with a list of recent changes.
2544
2545
2545 * IPython/ColorANSI.py (__all__): changed terminal detection
2546 * IPython/ColorANSI.py (__all__): changed terminal detection
2546 code. Seems to work better for xterms without breaking
2547 code. Seems to work better for xterms without breaking
2547 konsole. Will need more testing to determine if WinXP and Mac OSX
2548 konsole. Will need more testing to determine if WinXP and Mac OSX
2548 also work ok.
2549 also work ok.
2549
2550
2550 2002-12-18 *** Released version 0.2.14pre49
2551 2002-12-18 *** Released version 0.2.14pre49
2551
2552
2552 2002-12-18 Fernando Perez <fperez@colorado.edu>
2553 2002-12-18 Fernando Perez <fperez@colorado.edu>
2553
2554
2554 * Docs: added new info about Mac OSX, from Andrea.
2555 * Docs: added new info about Mac OSX, from Andrea.
2555
2556
2556 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2557 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2557 allow direct plotting of python strings whose format is the same
2558 allow direct plotting of python strings whose format is the same
2558 of gnuplot data files.
2559 of gnuplot data files.
2559
2560
2560 2002-12-16 Fernando Perez <fperez@colorado.edu>
2561 2002-12-16 Fernando Perez <fperez@colorado.edu>
2561
2562
2562 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2563 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2563 value of exit question to be acknowledged.
2564 value of exit question to be acknowledged.
2564
2565
2565 2002-12-03 Fernando Perez <fperez@colorado.edu>
2566 2002-12-03 Fernando Perez <fperez@colorado.edu>
2566
2567
2567 * IPython/ipmaker.py: removed generators, which had been added
2568 * IPython/ipmaker.py: removed generators, which had been added
2568 by mistake in an earlier debugging run. This was causing trouble
2569 by mistake in an earlier debugging run. This was causing trouble
2569 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2570 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2570 for pointing this out.
2571 for pointing this out.
2571
2572
2572 2002-11-17 Fernando Perez <fperez@colorado.edu>
2573 2002-11-17 Fernando Perez <fperez@colorado.edu>
2573
2574
2574 * Manual: updated the Gnuplot section.
2575 * Manual: updated the Gnuplot section.
2575
2576
2576 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2577 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2577 a much better split of what goes in Runtime and what goes in
2578 a much better split of what goes in Runtime and what goes in
2578 Interactive.
2579 Interactive.
2579
2580
2580 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2581 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2581 being imported from iplib.
2582 being imported from iplib.
2582
2583
2583 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2584 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2584 for command-passing. Now the global Gnuplot instance is called
2585 for command-passing. Now the global Gnuplot instance is called
2585 'gp' instead of 'g', which was really a far too fragile and
2586 'gp' instead of 'g', which was really a far too fragile and
2586 common name.
2587 common name.
2587
2588
2588 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2589 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2589 bounding boxes generated by Gnuplot for square plots.
2590 bounding boxes generated by Gnuplot for square plots.
2590
2591
2591 * IPython/genutils.py (popkey): new function added. I should
2592 * IPython/genutils.py (popkey): new function added. I should
2592 suggest this on c.l.py as a dict method, it seems useful.
2593 suggest this on c.l.py as a dict method, it seems useful.
2593
2594
2594 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2595 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2595 to transparently handle PostScript generation. MUCH better than
2596 to transparently handle PostScript generation. MUCH better than
2596 the previous plot_eps/replot_eps (which I removed now). The code
2597 the previous plot_eps/replot_eps (which I removed now). The code
2597 is also fairly clean and well documented now (including
2598 is also fairly clean and well documented now (including
2598 docstrings).
2599 docstrings).
2599
2600
2600 2002-11-13 Fernando Perez <fperez@colorado.edu>
2601 2002-11-13 Fernando Perez <fperez@colorado.edu>
2601
2602
2602 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2603 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2603 (inconsistent with options).
2604 (inconsistent with options).
2604
2605
2605 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2606 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2606 manually disabled, I don't know why. Fixed it.
2607 manually disabled, I don't know why. Fixed it.
2607 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2608 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2608 eps output.
2609 eps output.
2609
2610
2610 2002-11-12 Fernando Perez <fperez@colorado.edu>
2611 2002-11-12 Fernando Perez <fperez@colorado.edu>
2611
2612
2612 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2613 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2613 don't propagate up to caller. Fixes crash reported by François
2614 don't propagate up to caller. Fixes crash reported by François
2614 Pinard.
2615 Pinard.
2615
2616
2616 2002-11-09 Fernando Perez <fperez@colorado.edu>
2617 2002-11-09 Fernando Perez <fperez@colorado.edu>
2617
2618
2618 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2619 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2619 history file for new users.
2620 history file for new users.
2620 (make_IPython): fixed bug where initial install would leave the
2621 (make_IPython): fixed bug where initial install would leave the
2621 user running in the .ipython dir.
2622 user running in the .ipython dir.
2622 (make_IPython): fixed bug where config dir .ipython would be
2623 (make_IPython): fixed bug where config dir .ipython would be
2623 created regardless of the given -ipythondir option. Thanks to Cory
2624 created regardless of the given -ipythondir option. Thanks to Cory
2624 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2625 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2625
2626
2626 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2627 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2627 type confirmations. Will need to use it in all of IPython's code
2628 type confirmations. Will need to use it in all of IPython's code
2628 consistently.
2629 consistently.
2629
2630
2630 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2631 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2631 context to print 31 lines instead of the default 5. This will make
2632 context to print 31 lines instead of the default 5. This will make
2632 the crash reports extremely detailed in case the problem is in
2633 the crash reports extremely detailed in case the problem is in
2633 libraries I don't have access to.
2634 libraries I don't have access to.
2634
2635
2635 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2636 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2636 line of defense' code to still crash, but giving users fair
2637 line of defense' code to still crash, but giving users fair
2637 warning. I don't want internal errors to go unreported: if there's
2638 warning. I don't want internal errors to go unreported: if there's
2638 an internal problem, IPython should crash and generate a full
2639 an internal problem, IPython should crash and generate a full
2639 report.
2640 report.
2640
2641
2641 2002-11-08 Fernando Perez <fperez@colorado.edu>
2642 2002-11-08 Fernando Perez <fperez@colorado.edu>
2642
2643
2643 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2644 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2644 otherwise uncaught exceptions which can appear if people set
2645 otherwise uncaught exceptions which can appear if people set
2645 sys.stdout to something badly broken. Thanks to a crash report
2646 sys.stdout to something badly broken. Thanks to a crash report
2646 from henni-AT-mail.brainbot.com.
2647 from henni-AT-mail.brainbot.com.
2647
2648
2648 2002-11-04 Fernando Perez <fperez@colorado.edu>
2649 2002-11-04 Fernando Perez <fperez@colorado.edu>
2649
2650
2650 * IPython/iplib.py (InteractiveShell.interact): added
2651 * IPython/iplib.py (InteractiveShell.interact): added
2651 __IPYTHON__active to the builtins. It's a flag which goes on when
2652 __IPYTHON__active to the builtins. It's a flag which goes on when
2652 the interaction starts and goes off again when it stops. This
2653 the interaction starts and goes off again when it stops. This
2653 allows embedding code to detect being inside IPython. Before this
2654 allows embedding code to detect being inside IPython. Before this
2654 was done via __IPYTHON__, but that only shows that an IPython
2655 was done via __IPYTHON__, but that only shows that an IPython
2655 instance has been created.
2656 instance has been created.
2656
2657
2657 * IPython/Magic.py (Magic.magic_env): I realized that in a
2658 * IPython/Magic.py (Magic.magic_env): I realized that in a
2658 UserDict, instance.data holds the data as a normal dict. So I
2659 UserDict, instance.data holds the data as a normal dict. So I
2659 modified @env to return os.environ.data instead of rebuilding a
2660 modified @env to return os.environ.data instead of rebuilding a
2660 dict by hand.
2661 dict by hand.
2661
2662
2662 2002-11-02 Fernando Perez <fperez@colorado.edu>
2663 2002-11-02 Fernando Perez <fperez@colorado.edu>
2663
2664
2664 * IPython/genutils.py (warn): changed so that level 1 prints no
2665 * IPython/genutils.py (warn): changed so that level 1 prints no
2665 header. Level 2 is now the default (with 'WARNING' header, as
2666 header. Level 2 is now the default (with 'WARNING' header, as
2666 before). I think I tracked all places where changes were needed in
2667 before). I think I tracked all places where changes were needed in
2667 IPython, but outside code using the old level numbering may have
2668 IPython, but outside code using the old level numbering may have
2668 broken.
2669 broken.
2669
2670
2670 * IPython/iplib.py (InteractiveShell.runcode): added this to
2671 * IPython/iplib.py (InteractiveShell.runcode): added this to
2671 handle the tracebacks in SystemExit traps correctly. The previous
2672 handle the tracebacks in SystemExit traps correctly. The previous
2672 code (through interact) was printing more of the stack than
2673 code (through interact) was printing more of the stack than
2673 necessary, showing IPython internal code to the user.
2674 necessary, showing IPython internal code to the user.
2674
2675
2675 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2676 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2676 default. Now that the default at the confirmation prompt is yes,
2677 default. Now that the default at the confirmation prompt is yes,
2677 it's not so intrusive. François' argument that ipython sessions
2678 it's not so intrusive. François' argument that ipython sessions
2678 tend to be complex enough not to lose them from an accidental C-d,
2679 tend to be complex enough not to lose them from an accidental C-d,
2679 is a valid one.
2680 is a valid one.
2680
2681
2681 * IPython/iplib.py (InteractiveShell.interact): added a
2682 * IPython/iplib.py (InteractiveShell.interact): added a
2682 showtraceback() call to the SystemExit trap, and modified the exit
2683 showtraceback() call to the SystemExit trap, and modified the exit
2683 confirmation to have yes as the default.
2684 confirmation to have yes as the default.
2684
2685
2685 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2686 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2686 this file. It's been gone from the code for a long time, this was
2687 this file. It's been gone from the code for a long time, this was
2687 simply leftover junk.
2688 simply leftover junk.
2688
2689
2689 2002-11-01 Fernando Perez <fperez@colorado.edu>
2690 2002-11-01 Fernando Perez <fperez@colorado.edu>
2690
2691
2691 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2692 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2692 added. If set, IPython now traps EOF and asks for
2693 added. If set, IPython now traps EOF and asks for
2693 confirmation. After a request by François Pinard.
2694 confirmation. After a request by François Pinard.
2694
2695
2695 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2696 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2696 of @abort, and with a new (better) mechanism for handling the
2697 of @abort, and with a new (better) mechanism for handling the
2697 exceptions.
2698 exceptions.
2698
2699
2699 2002-10-27 Fernando Perez <fperez@colorado.edu>
2700 2002-10-27 Fernando Perez <fperez@colorado.edu>
2700
2701
2701 * IPython/usage.py (__doc__): updated the --help information and
2702 * IPython/usage.py (__doc__): updated the --help information and
2702 the ipythonrc file to indicate that -log generates
2703 the ipythonrc file to indicate that -log generates
2703 ./ipython.log. Also fixed the corresponding info in @logstart.
2704 ./ipython.log. Also fixed the corresponding info in @logstart.
2704 This and several other fixes in the manuals thanks to reports by
2705 This and several other fixes in the manuals thanks to reports by
2705 François Pinard <pinard-AT-iro.umontreal.ca>.
2706 François Pinard <pinard-AT-iro.umontreal.ca>.
2706
2707
2707 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2708 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2708 refer to @logstart (instead of @log, which doesn't exist).
2709 refer to @logstart (instead of @log, which doesn't exist).
2709
2710
2710 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2711 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2711 AttributeError crash. Thanks to Christopher Armstrong
2712 AttributeError crash. Thanks to Christopher Armstrong
2712 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2713 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2713 introduced recently (in 0.2.14pre37) with the fix to the eval
2714 introduced recently (in 0.2.14pre37) with the fix to the eval
2714 problem mentioned below.
2715 problem mentioned below.
2715
2716
2716 2002-10-17 Fernando Perez <fperez@colorado.edu>
2717 2002-10-17 Fernando Perez <fperez@colorado.edu>
2717
2718
2718 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2719 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2719 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2720 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2720
2721
2721 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2722 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2722 this function to fix a problem reported by Alex Schmolck. He saw
2723 this function to fix a problem reported by Alex Schmolck. He saw
2723 it with list comprehensions and generators, which were getting
2724 it with list comprehensions and generators, which were getting
2724 called twice. The real problem was an 'eval' call in testing for
2725 called twice. The real problem was an 'eval' call in testing for
2725 automagic which was evaluating the input line silently.
2726 automagic which was evaluating the input line silently.
2726
2727
2727 This is a potentially very nasty bug, if the input has side
2728 This is a potentially very nasty bug, if the input has side
2728 effects which must not be repeated. The code is much cleaner now,
2729 effects which must not be repeated. The code is much cleaner now,
2729 without any blanket 'except' left and with a regexp test for
2730 without any blanket 'except' left and with a regexp test for
2730 actual function names.
2731 actual function names.
2731
2732
2732 But an eval remains, which I'm not fully comfortable with. I just
2733 But an eval remains, which I'm not fully comfortable with. I just
2733 don't know how to find out if an expression could be a callable in
2734 don't know how to find out if an expression could be a callable in
2734 the user's namespace without doing an eval on the string. However
2735 the user's namespace without doing an eval on the string. However
2735 that string is now much more strictly checked so that no code
2736 that string is now much more strictly checked so that no code
2736 slips by, so the eval should only happen for things that can
2737 slips by, so the eval should only happen for things that can
2737 really be only function/method names.
2738 really be only function/method names.
2738
2739
2739 2002-10-15 Fernando Perez <fperez@colorado.edu>
2740 2002-10-15 Fernando Perez <fperez@colorado.edu>
2740
2741
2741 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2742 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2742 OSX information to main manual, removed README_Mac_OSX file from
2743 OSX information to main manual, removed README_Mac_OSX file from
2743 distribution. Also updated credits for recent additions.
2744 distribution. Also updated credits for recent additions.
2744
2745
2745 2002-10-10 Fernando Perez <fperez@colorado.edu>
2746 2002-10-10 Fernando Perez <fperez@colorado.edu>
2746
2747
2747 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2748 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2748 terminal-related issues. Many thanks to Andrea Riciputi
2749 terminal-related issues. Many thanks to Andrea Riciputi
2749 <andrea.riciputi-AT-libero.it> for writing it.
2750 <andrea.riciputi-AT-libero.it> for writing it.
2750
2751
2751 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2752 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2752 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2753 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2753
2754
2754 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2755 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2755 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2756 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2756 <syver-en-AT-online.no> who both submitted patches for this problem.
2757 <syver-en-AT-online.no> who both submitted patches for this problem.
2757
2758
2758 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2759 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2759 global embedding to make sure that things don't overwrite user
2760 global embedding to make sure that things don't overwrite user
2760 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2761 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2761
2762
2762 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2763 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2763 compatibility. Thanks to Hayden Callow
2764 compatibility. Thanks to Hayden Callow
2764 <h.callow-AT-elec.canterbury.ac.nz>
2765 <h.callow-AT-elec.canterbury.ac.nz>
2765
2766
2766 2002-10-04 Fernando Perez <fperez@colorado.edu>
2767 2002-10-04 Fernando Perez <fperez@colorado.edu>
2767
2768
2768 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2769 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2769 Gnuplot.File objects.
2770 Gnuplot.File objects.
2770
2771
2771 2002-07-23 Fernando Perez <fperez@colorado.edu>
2772 2002-07-23 Fernando Perez <fperez@colorado.edu>
2772
2773
2773 * IPython/genutils.py (timing): Added timings() and timing() for
2774 * IPython/genutils.py (timing): Added timings() and timing() for
2774 quick access to the most commonly needed data, the execution
2775 quick access to the most commonly needed data, the execution
2775 times. Old timing() renamed to timings_out().
2776 times. Old timing() renamed to timings_out().
2776
2777
2777 2002-07-18 Fernando Perez <fperez@colorado.edu>
2778 2002-07-18 Fernando Perez <fperez@colorado.edu>
2778
2779
2779 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2780 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2780 bug with nested instances disrupting the parent's tab completion.
2781 bug with nested instances disrupting the parent's tab completion.
2781
2782
2782 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2783 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2783 all_completions code to begin the emacs integration.
2784 all_completions code to begin the emacs integration.
2784
2785
2785 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2786 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2786 argument to allow titling individual arrays when plotting.
2787 argument to allow titling individual arrays when plotting.
2787
2788
2788 2002-07-15 Fernando Perez <fperez@colorado.edu>
2789 2002-07-15 Fernando Perez <fperez@colorado.edu>
2789
2790
2790 * setup.py (make_shortcut): changed to retrieve the value of
2791 * setup.py (make_shortcut): changed to retrieve the value of
2791 'Program Files' directory from the registry (this value changes in
2792 'Program Files' directory from the registry (this value changes in
2792 non-english versions of Windows). Thanks to Thomas Fanslau
2793 non-english versions of Windows). Thanks to Thomas Fanslau
2793 <tfanslau-AT-gmx.de> for the report.
2794 <tfanslau-AT-gmx.de> for the report.
2794
2795
2795 2002-07-10 Fernando Perez <fperez@colorado.edu>
2796 2002-07-10 Fernando Perez <fperez@colorado.edu>
2796
2797
2797 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2798 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2798 a bug in pdb, which crashes if a line with only whitespace is
2799 a bug in pdb, which crashes if a line with only whitespace is
2799 entered. Bug report submitted to sourceforge.
2800 entered. Bug report submitted to sourceforge.
2800
2801
2801 2002-07-09 Fernando Perez <fperez@colorado.edu>
2802 2002-07-09 Fernando Perez <fperez@colorado.edu>
2802
2803
2803 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2804 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2804 reporting exceptions (it's a bug in inspect.py, I just set a
2805 reporting exceptions (it's a bug in inspect.py, I just set a
2805 workaround).
2806 workaround).
2806
2807
2807 2002-07-08 Fernando Perez <fperez@colorado.edu>
2808 2002-07-08 Fernando Perez <fperez@colorado.edu>
2808
2809
2809 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2810 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2810 __IPYTHON__ in __builtins__ to show up in user_ns.
2811 __IPYTHON__ in __builtins__ to show up in user_ns.
2811
2812
2812 2002-07-03 Fernando Perez <fperez@colorado.edu>
2813 2002-07-03 Fernando Perez <fperez@colorado.edu>
2813
2814
2814 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2815 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2815 name from @gp_set_instance to @gp_set_default.
2816 name from @gp_set_instance to @gp_set_default.
2816
2817
2817 * IPython/ipmaker.py (make_IPython): default editor value set to
2818 * IPython/ipmaker.py (make_IPython): default editor value set to
2818 '0' (a string), to match the rc file. Otherwise will crash when
2819 '0' (a string), to match the rc file. Otherwise will crash when
2819 .strip() is called on it.
2820 .strip() is called on it.
2820
2821
2821
2822
2822 2002-06-28 Fernando Perez <fperez@colorado.edu>
2823 2002-06-28 Fernando Perez <fperez@colorado.edu>
2823
2824
2824 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2825 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2825 of files in current directory when a file is executed via
2826 of files in current directory when a file is executed via
2826 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2827 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2827
2828
2828 * setup.py (manfiles): fix for rpm builds, submitted by RA
2829 * setup.py (manfiles): fix for rpm builds, submitted by RA
2829 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2830 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2830
2831
2831 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2832 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2832 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2833 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2833 string!). A. Schmolck caught this one.
2834 string!). A. Schmolck caught this one.
2834
2835
2835 2002-06-27 Fernando Perez <fperez@colorado.edu>
2836 2002-06-27 Fernando Perez <fperez@colorado.edu>
2836
2837
2837 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2838 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2838 defined files at the cmd line. __name__ wasn't being set to
2839 defined files at the cmd line. __name__ wasn't being set to
2839 __main__.
2840 __main__.
2840
2841
2841 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2842 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2842 regular lists and tuples besides Numeric arrays.
2843 regular lists and tuples besides Numeric arrays.
2843
2844
2844 * IPython/Prompts.py (CachedOutput.__call__): Added output
2845 * IPython/Prompts.py (CachedOutput.__call__): Added output
2845 supression for input ending with ';'. Similar to Mathematica and
2846 supression for input ending with ';'. Similar to Mathematica and
2846 Matlab. The _* vars and Out[] list are still updated, just like
2847 Matlab. The _* vars and Out[] list are still updated, just like
2847 Mathematica behaves.
2848 Mathematica behaves.
2848
2849
2849 2002-06-25 Fernando Perez <fperez@colorado.edu>
2850 2002-06-25 Fernando Perez <fperez@colorado.edu>
2850
2851
2851 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2852 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2852 .ini extensions for profiels under Windows.
2853 .ini extensions for profiels under Windows.
2853
2854
2854 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2855 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2855 string form. Fix contributed by Alexander Schmolck
2856 string form. Fix contributed by Alexander Schmolck
2856 <a.schmolck-AT-gmx.net>
2857 <a.schmolck-AT-gmx.net>
2857
2858
2858 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2859 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2859 pre-configured Gnuplot instance.
2860 pre-configured Gnuplot instance.
2860
2861
2861 2002-06-21 Fernando Perez <fperez@colorado.edu>
2862 2002-06-21 Fernando Perez <fperez@colorado.edu>
2862
2863
2863 * IPython/numutils.py (exp_safe): new function, works around the
2864 * IPython/numutils.py (exp_safe): new function, works around the
2864 underflow problems in Numeric.
2865 underflow problems in Numeric.
2865 (log2): New fn. Safe log in base 2: returns exact integer answer
2866 (log2): New fn. Safe log in base 2: returns exact integer answer
2866 for exact integer powers of 2.
2867 for exact integer powers of 2.
2867
2868
2868 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2869 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2869 properly.
2870 properly.
2870
2871
2871 2002-06-20 Fernando Perez <fperez@colorado.edu>
2872 2002-06-20 Fernando Perez <fperez@colorado.edu>
2872
2873
2873 * IPython/genutils.py (timing): new function like
2874 * IPython/genutils.py (timing): new function like
2874 Mathematica's. Similar to time_test, but returns more info.
2875 Mathematica's. Similar to time_test, but returns more info.
2875
2876
2876 2002-06-18 Fernando Perez <fperez@colorado.edu>
2877 2002-06-18 Fernando Perez <fperez@colorado.edu>
2877
2878
2878 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2879 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2879 according to Mike Heeter's suggestions.
2880 according to Mike Heeter's suggestions.
2880
2881
2881 2002-06-16 Fernando Perez <fperez@colorado.edu>
2882 2002-06-16 Fernando Perez <fperez@colorado.edu>
2882
2883
2883 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2884 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2884 system. GnuplotMagic is gone as a user-directory option. New files
2885 system. GnuplotMagic is gone as a user-directory option. New files
2885 make it easier to use all the gnuplot stuff both from external
2886 make it easier to use all the gnuplot stuff both from external
2886 programs as well as from IPython. Had to rewrite part of
2887 programs as well as from IPython. Had to rewrite part of
2887 hardcopy() b/c of a strange bug: often the ps files simply don't
2888 hardcopy() b/c of a strange bug: often the ps files simply don't
2888 get created, and require a repeat of the command (often several
2889 get created, and require a repeat of the command (often several
2889 times).
2890 times).
2890
2891
2891 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2892 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2892 resolve output channel at call time, so that if sys.stderr has
2893 resolve output channel at call time, so that if sys.stderr has
2893 been redirected by user this gets honored.
2894 been redirected by user this gets honored.
2894
2895
2895 2002-06-13 Fernando Perez <fperez@colorado.edu>
2896 2002-06-13 Fernando Perez <fperez@colorado.edu>
2896
2897
2897 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2898 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2898 IPShell. Kept a copy with the old names to avoid breaking people's
2899 IPShell. Kept a copy with the old names to avoid breaking people's
2899 embedded code.
2900 embedded code.
2900
2901
2901 * IPython/ipython: simplified it to the bare minimum after
2902 * IPython/ipython: simplified it to the bare minimum after
2902 Holger's suggestions. Added info about how to use it in
2903 Holger's suggestions. Added info about how to use it in
2903 PYTHONSTARTUP.
2904 PYTHONSTARTUP.
2904
2905
2905 * IPython/Shell.py (IPythonShell): changed the options passing
2906 * IPython/Shell.py (IPythonShell): changed the options passing
2906 from a string with funky %s replacements to a straight list. Maybe
2907 from a string with funky %s replacements to a straight list. Maybe
2907 a bit more typing, but it follows sys.argv conventions, so there's
2908 a bit more typing, but it follows sys.argv conventions, so there's
2908 less special-casing to remember.
2909 less special-casing to remember.
2909
2910
2910 2002-06-12 Fernando Perez <fperez@colorado.edu>
2911 2002-06-12 Fernando Perez <fperez@colorado.edu>
2911
2912
2912 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2913 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2913 command. Thanks to a suggestion by Mike Heeter.
2914 command. Thanks to a suggestion by Mike Heeter.
2914 (Magic.magic_pfile): added behavior to look at filenames if given
2915 (Magic.magic_pfile): added behavior to look at filenames if given
2915 arg is not a defined object.
2916 arg is not a defined object.
2916 (Magic.magic_save): New @save function to save code snippets. Also
2917 (Magic.magic_save): New @save function to save code snippets. Also
2917 a Mike Heeter idea.
2918 a Mike Heeter idea.
2918
2919
2919 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2920 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2920 plot() and replot(). Much more convenient now, especially for
2921 plot() and replot(). Much more convenient now, especially for
2921 interactive use.
2922 interactive use.
2922
2923
2923 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2924 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2924 filenames.
2925 filenames.
2925
2926
2926 2002-06-02 Fernando Perez <fperez@colorado.edu>
2927 2002-06-02 Fernando Perez <fperez@colorado.edu>
2927
2928
2928 * IPython/Struct.py (Struct.__init__): modified to admit
2929 * IPython/Struct.py (Struct.__init__): modified to admit
2929 initialization via another struct.
2930 initialization via another struct.
2930
2931
2931 * IPython/genutils.py (SystemExec.__init__): New stateful
2932 * IPython/genutils.py (SystemExec.__init__): New stateful
2932 interface to xsys and bq. Useful for writing system scripts.
2933 interface to xsys and bq. Useful for writing system scripts.
2933
2934
2934 2002-05-30 Fernando Perez <fperez@colorado.edu>
2935 2002-05-30 Fernando Perez <fperez@colorado.edu>
2935
2936
2936 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2937 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2937 documents. This will make the user download smaller (it's getting
2938 documents. This will make the user download smaller (it's getting
2938 too big).
2939 too big).
2939
2940
2940 2002-05-29 Fernando Perez <fperez@colorado.edu>
2941 2002-05-29 Fernando Perez <fperez@colorado.edu>
2941
2942
2942 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2943 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2943 fix problems with shelve and pickle. Seems to work, but I don't
2944 fix problems with shelve and pickle. Seems to work, but I don't
2944 know if corner cases break it. Thanks to Mike Heeter
2945 know if corner cases break it. Thanks to Mike Heeter
2945 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2946 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2946
2947
2947 2002-05-24 Fernando Perez <fperez@colorado.edu>
2948 2002-05-24 Fernando Perez <fperez@colorado.edu>
2948
2949
2949 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2950 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2950 macros having broken.
2951 macros having broken.
2951
2952
2952 2002-05-21 Fernando Perez <fperez@colorado.edu>
2953 2002-05-21 Fernando Perez <fperez@colorado.edu>
2953
2954
2954 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2955 * IPython/Magic.py (Magic.magic_logstart): fixed recently
2955 introduced logging bug: all history before logging started was
2956 introduced logging bug: all history before logging started was
2956 being written one character per line! This came from the redesign
2957 being written one character per line! This came from the redesign
2957 of the input history as a special list which slices to strings,
2958 of the input history as a special list which slices to strings,
2958 not to lists.
2959 not to lists.
2959
2960
2960 2002-05-20 Fernando Perez <fperez@colorado.edu>
2961 2002-05-20 Fernando Perez <fperez@colorado.edu>
2961
2962
2962 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2963 * IPython/Prompts.py (CachedOutput.__init__): made the color table
2963 be an attribute of all classes in this module. The design of these
2964 be an attribute of all classes in this module. The design of these
2964 classes needs some serious overhauling.
2965 classes needs some serious overhauling.
2965
2966
2966 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2967 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
2967 which was ignoring '_' in option names.
2968 which was ignoring '_' in option names.
2968
2969
2969 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2970 * IPython/ultraTB.py (FormattedTB.__init__): Changed
2970 'Verbose_novars' to 'Context' and made it the new default. It's a
2971 'Verbose_novars' to 'Context' and made it the new default. It's a
2971 bit more readable and also safer than verbose.
2972 bit more readable and also safer than verbose.
2972
2973
2973 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2974 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
2974 triple-quoted strings.
2975 triple-quoted strings.
2975
2976
2976 * IPython/OInspect.py (__all__): new module exposing the object
2977 * IPython/OInspect.py (__all__): new module exposing the object
2977 introspection facilities. Now the corresponding magics are dummy
2978 introspection facilities. Now the corresponding magics are dummy
2978 wrappers around this. Having this module will make it much easier
2979 wrappers around this. Having this module will make it much easier
2979 to put these functions into our modified pdb.
2980 to put these functions into our modified pdb.
2980 This new object inspector system uses the new colorizing module,
2981 This new object inspector system uses the new colorizing module,
2981 so source code and other things are nicely syntax highlighted.
2982 so source code and other things are nicely syntax highlighted.
2982
2983
2983 2002-05-18 Fernando Perez <fperez@colorado.edu>
2984 2002-05-18 Fernando Perez <fperez@colorado.edu>
2984
2985
2985 * IPython/ColorANSI.py: Split the coloring tools into a separate
2986 * IPython/ColorANSI.py: Split the coloring tools into a separate
2986 module so I can use them in other code easier (they were part of
2987 module so I can use them in other code easier (they were part of
2987 ultraTB).
2988 ultraTB).
2988
2989
2989 2002-05-17 Fernando Perez <fperez@colorado.edu>
2990 2002-05-17 Fernando Perez <fperez@colorado.edu>
2990
2991
2991 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2992 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
2992 fixed it to set the global 'g' also to the called instance, as
2993 fixed it to set the global 'g' also to the called instance, as
2993 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2994 long as 'g' was still a gnuplot instance (so it doesn't overwrite
2994 user's 'g' variables).
2995 user's 'g' variables).
2995
2996
2996 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2997 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
2997 global variables (aliases to _ih,_oh) so that users which expect
2998 global variables (aliases to _ih,_oh) so that users which expect
2998 In[5] or Out[7] to work aren't unpleasantly surprised.
2999 In[5] or Out[7] to work aren't unpleasantly surprised.
2999 (InputList.__getslice__): new class to allow executing slices of
3000 (InputList.__getslice__): new class to allow executing slices of
3000 input history directly. Very simple class, complements the use of
3001 input history directly. Very simple class, complements the use of
3001 macros.
3002 macros.
3002
3003
3003 2002-05-16 Fernando Perez <fperez@colorado.edu>
3004 2002-05-16 Fernando Perez <fperez@colorado.edu>
3004
3005
3005 * setup.py (docdirbase): make doc directory be just doc/IPython
3006 * setup.py (docdirbase): make doc directory be just doc/IPython
3006 without version numbers, it will reduce clutter for users.
3007 without version numbers, it will reduce clutter for users.
3007
3008
3008 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3009 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3009 execfile call to prevent possible memory leak. See for details:
3010 execfile call to prevent possible memory leak. See for details:
3010 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3011 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3011
3012
3012 2002-05-15 Fernando Perez <fperez@colorado.edu>
3013 2002-05-15 Fernando Perez <fperez@colorado.edu>
3013
3014
3014 * IPython/Magic.py (Magic.magic_psource): made the object
3015 * IPython/Magic.py (Magic.magic_psource): made the object
3015 introspection names be more standard: pdoc, pdef, pfile and
3016 introspection names be more standard: pdoc, pdef, pfile and
3016 psource. They all print/page their output, and it makes
3017 psource. They all print/page their output, and it makes
3017 remembering them easier. Kept old names for compatibility as
3018 remembering them easier. Kept old names for compatibility as
3018 aliases.
3019 aliases.
3019
3020
3020 2002-05-14 Fernando Perez <fperez@colorado.edu>
3021 2002-05-14 Fernando Perez <fperez@colorado.edu>
3021
3022
3022 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3023 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3023 what the mouse problem was. The trick is to use gnuplot with temp
3024 what the mouse problem was. The trick is to use gnuplot with temp
3024 files and NOT with pipes (for data communication), because having
3025 files and NOT with pipes (for data communication), because having
3025 both pipes and the mouse on is bad news.
3026 both pipes and the mouse on is bad news.
3026
3027
3027 2002-05-13 Fernando Perez <fperez@colorado.edu>
3028 2002-05-13 Fernando Perez <fperez@colorado.edu>
3028
3029
3029 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3030 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3030 bug. Information would be reported about builtins even when
3031 bug. Information would be reported about builtins even when
3031 user-defined functions overrode them.
3032 user-defined functions overrode them.
3032
3033
3033 2002-05-11 Fernando Perez <fperez@colorado.edu>
3034 2002-05-11 Fernando Perez <fperez@colorado.edu>
3034
3035
3035 * IPython/__init__.py (__all__): removed FlexCompleter from
3036 * IPython/__init__.py (__all__): removed FlexCompleter from
3036 __all__ so that things don't fail in platforms without readline.
3037 __all__ so that things don't fail in platforms without readline.
3037
3038
3038 2002-05-10 Fernando Perez <fperez@colorado.edu>
3039 2002-05-10 Fernando Perez <fperez@colorado.edu>
3039
3040
3040 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3041 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3041 it requires Numeric, effectively making Numeric a dependency for
3042 it requires Numeric, effectively making Numeric a dependency for
3042 IPython.
3043 IPython.
3043
3044
3044 * Released 0.2.13
3045 * Released 0.2.13
3045
3046
3046 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3047 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3047 profiler interface. Now all the major options from the profiler
3048 profiler interface. Now all the major options from the profiler
3048 module are directly supported in IPython, both for single
3049 module are directly supported in IPython, both for single
3049 expressions (@prun) and for full programs (@run -p).
3050 expressions (@prun) and for full programs (@run -p).
3050
3051
3051 2002-05-09 Fernando Perez <fperez@colorado.edu>
3052 2002-05-09 Fernando Perez <fperez@colorado.edu>
3052
3053
3053 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3054 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3054 magic properly formatted for screen.
3055 magic properly formatted for screen.
3055
3056
3056 * setup.py (make_shortcut): Changed things to put pdf version in
3057 * setup.py (make_shortcut): Changed things to put pdf version in
3057 doc/ instead of doc/manual (had to change lyxport a bit).
3058 doc/ instead of doc/manual (had to change lyxport a bit).
3058
3059
3059 * IPython/Magic.py (Profile.string_stats): made profile runs go
3060 * IPython/Magic.py (Profile.string_stats): made profile runs go
3060 through pager (they are long and a pager allows searching, saving,
3061 through pager (they are long and a pager allows searching, saving,
3061 etc.)
3062 etc.)
3062
3063
3063 2002-05-08 Fernando Perez <fperez@colorado.edu>
3064 2002-05-08 Fernando Perez <fperez@colorado.edu>
3064
3065
3065 * Released 0.2.12
3066 * Released 0.2.12
3066
3067
3067 2002-05-06 Fernando Perez <fperez@colorado.edu>
3068 2002-05-06 Fernando Perez <fperez@colorado.edu>
3068
3069
3069 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3070 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3070 introduced); 'hist n1 n2' was broken.
3071 introduced); 'hist n1 n2' was broken.
3071 (Magic.magic_pdb): added optional on/off arguments to @pdb
3072 (Magic.magic_pdb): added optional on/off arguments to @pdb
3072 (Magic.magic_run): added option -i to @run, which executes code in
3073 (Magic.magic_run): added option -i to @run, which executes code in
3073 the IPython namespace instead of a clean one. Also added @irun as
3074 the IPython namespace instead of a clean one. Also added @irun as
3074 an alias to @run -i.
3075 an alias to @run -i.
3075
3076
3076 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3077 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3077 fixed (it didn't really do anything, the namespaces were wrong).
3078 fixed (it didn't really do anything, the namespaces were wrong).
3078
3079
3079 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3080 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3080
3081
3081 * IPython/__init__.py (__all__): Fixed package namespace, now
3082 * IPython/__init__.py (__all__): Fixed package namespace, now
3082 'import IPython' does give access to IPython.<all> as
3083 'import IPython' does give access to IPython.<all> as
3083 expected. Also renamed __release__ to Release.
3084 expected. Also renamed __release__ to Release.
3084
3085
3085 * IPython/Debugger.py (__license__): created new Pdb class which
3086 * IPython/Debugger.py (__license__): created new Pdb class which
3086 functions like a drop-in for the normal pdb.Pdb but does NOT
3087 functions like a drop-in for the normal pdb.Pdb but does NOT
3087 import readline by default. This way it doesn't muck up IPython's
3088 import readline by default. This way it doesn't muck up IPython's
3088 readline handling, and now tab-completion finally works in the
3089 readline handling, and now tab-completion finally works in the
3089 debugger -- sort of. It completes things globally visible, but the
3090 debugger -- sort of. It completes things globally visible, but the
3090 completer doesn't track the stack as pdb walks it. That's a bit
3091 completer doesn't track the stack as pdb walks it. That's a bit
3091 tricky, and I'll have to implement it later.
3092 tricky, and I'll have to implement it later.
3092
3093
3093 2002-05-05 Fernando Perez <fperez@colorado.edu>
3094 2002-05-05 Fernando Perez <fperez@colorado.edu>
3094
3095
3095 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3096 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3096 magic docstrings when printed via ? (explicit \'s were being
3097 magic docstrings when printed via ? (explicit \'s were being
3097 printed).
3098 printed).
3098
3099
3099 * IPython/ipmaker.py (make_IPython): fixed namespace
3100 * IPython/ipmaker.py (make_IPython): fixed namespace
3100 identification bug. Now variables loaded via logs or command-line
3101 identification bug. Now variables loaded via logs or command-line
3101 files are recognized in the interactive namespace by @who.
3102 files are recognized in the interactive namespace by @who.
3102
3103
3103 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3104 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3104 log replay system stemming from the string form of Structs.
3105 log replay system stemming from the string form of Structs.
3105
3106
3106 * IPython/Magic.py (Macro.__init__): improved macros to properly
3107 * IPython/Magic.py (Macro.__init__): improved macros to properly
3107 handle magic commands in them.
3108 handle magic commands in them.
3108 (Magic.magic_logstart): usernames are now expanded so 'logstart
3109 (Magic.magic_logstart): usernames are now expanded so 'logstart
3109 ~/mylog' now works.
3110 ~/mylog' now works.
3110
3111
3111 * IPython/iplib.py (complete): fixed bug where paths starting with
3112 * IPython/iplib.py (complete): fixed bug where paths starting with
3112 '/' would be completed as magic names.
3113 '/' would be completed as magic names.
3113
3114
3114 2002-05-04 Fernando Perez <fperez@colorado.edu>
3115 2002-05-04 Fernando Perez <fperez@colorado.edu>
3115
3116
3116 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3117 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3117 allow running full programs under the profiler's control.
3118 allow running full programs under the profiler's control.
3118
3119
3119 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3120 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3120 mode to report exceptions verbosely but without formatting
3121 mode to report exceptions verbosely but without formatting
3121 variables. This addresses the issue of ipython 'freezing' (it's
3122 variables. This addresses the issue of ipython 'freezing' (it's
3122 not frozen, but caught in an expensive formatting loop) when huge
3123 not frozen, but caught in an expensive formatting loop) when huge
3123 variables are in the context of an exception.
3124 variables are in the context of an exception.
3124 (VerboseTB.text): Added '--->' markers at line where exception was
3125 (VerboseTB.text): Added '--->' markers at line where exception was
3125 triggered. Much clearer to read, especially in NoColor modes.
3126 triggered. Much clearer to read, especially in NoColor modes.
3126
3127
3127 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3128 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3128 implemented in reverse when changing to the new parse_options().
3129 implemented in reverse when changing to the new parse_options().
3129
3130
3130 2002-05-03 Fernando Perez <fperez@colorado.edu>
3131 2002-05-03 Fernando Perez <fperez@colorado.edu>
3131
3132
3132 * IPython/Magic.py (Magic.parse_options): new function so that
3133 * IPython/Magic.py (Magic.parse_options): new function so that
3133 magics can parse options easier.
3134 magics can parse options easier.
3134 (Magic.magic_prun): new function similar to profile.run(),
3135 (Magic.magic_prun): new function similar to profile.run(),
3135 suggested by Chris Hart.
3136 suggested by Chris Hart.
3136 (Magic.magic_cd): fixed behavior so that it only changes if
3137 (Magic.magic_cd): fixed behavior so that it only changes if
3137 directory actually is in history.
3138 directory actually is in history.
3138
3139
3139 * IPython/usage.py (__doc__): added information about potential
3140 * IPython/usage.py (__doc__): added information about potential
3140 slowness of Verbose exception mode when there are huge data
3141 slowness of Verbose exception mode when there are huge data
3141 structures to be formatted (thanks to Archie Paulson).
3142 structures to be formatted (thanks to Archie Paulson).
3142
3143
3143 * IPython/ipmaker.py (make_IPython): Changed default logging
3144 * IPython/ipmaker.py (make_IPython): Changed default logging
3144 (when simply called with -log) to use curr_dir/ipython.log in
3145 (when simply called with -log) to use curr_dir/ipython.log in
3145 rotate mode. Fixed crash which was occuring with -log before
3146 rotate mode. Fixed crash which was occuring with -log before
3146 (thanks to Jim Boyle).
3147 (thanks to Jim Boyle).
3147
3148
3148 2002-05-01 Fernando Perez <fperez@colorado.edu>
3149 2002-05-01 Fernando Perez <fperez@colorado.edu>
3149
3150
3150 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3151 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3151 was nasty -- though somewhat of a corner case).
3152 was nasty -- though somewhat of a corner case).
3152
3153
3153 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3154 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3154 text (was a bug).
3155 text (was a bug).
3155
3156
3156 2002-04-30 Fernando Perez <fperez@colorado.edu>
3157 2002-04-30 Fernando Perez <fperez@colorado.edu>
3157
3158
3158 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3159 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3159 a print after ^D or ^C from the user so that the In[] prompt
3160 a print after ^D or ^C from the user so that the In[] prompt
3160 doesn't over-run the gnuplot one.
3161 doesn't over-run the gnuplot one.
3161
3162
3162 2002-04-29 Fernando Perez <fperez@colorado.edu>
3163 2002-04-29 Fernando Perez <fperez@colorado.edu>
3163
3164
3164 * Released 0.2.10
3165 * Released 0.2.10
3165
3166
3166 * IPython/__release__.py (version): get date dynamically.
3167 * IPython/__release__.py (version): get date dynamically.
3167
3168
3168 * Misc. documentation updates thanks to Arnd's comments. Also ran
3169 * Misc. documentation updates thanks to Arnd's comments. Also ran
3169 a full spellcheck on the manual (hadn't been done in a while).
3170 a full spellcheck on the manual (hadn't been done in a while).
3170
3171
3171 2002-04-27 Fernando Perez <fperez@colorado.edu>
3172 2002-04-27 Fernando Perez <fperez@colorado.edu>
3172
3173
3173 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3174 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3174 starting a log in mid-session would reset the input history list.
3175 starting a log in mid-session would reset the input history list.
3175
3176
3176 2002-04-26 Fernando Perez <fperez@colorado.edu>
3177 2002-04-26 Fernando Perez <fperez@colorado.edu>
3177
3178
3178 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3179 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3179 all files were being included in an update. Now anything in
3180 all files were being included in an update. Now anything in
3180 UserConfig that matches [A-Za-z]*.py will go (this excludes
3181 UserConfig that matches [A-Za-z]*.py will go (this excludes
3181 __init__.py)
3182 __init__.py)
3182
3183
3183 2002-04-25 Fernando Perez <fperez@colorado.edu>
3184 2002-04-25 Fernando Perez <fperez@colorado.edu>
3184
3185
3185 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3186 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3186 to __builtins__ so that any form of embedded or imported code can
3187 to __builtins__ so that any form of embedded or imported code can
3187 test for being inside IPython.
3188 test for being inside IPython.
3188
3189
3189 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3190 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3190 changed to GnuplotMagic because it's now an importable module,
3191 changed to GnuplotMagic because it's now an importable module,
3191 this makes the name follow that of the standard Gnuplot module.
3192 this makes the name follow that of the standard Gnuplot module.
3192 GnuplotMagic can now be loaded at any time in mid-session.
3193 GnuplotMagic can now be loaded at any time in mid-session.
3193
3194
3194 2002-04-24 Fernando Perez <fperez@colorado.edu>
3195 2002-04-24 Fernando Perez <fperez@colorado.edu>
3195
3196
3196 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3197 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3197 the globals (IPython has its own namespace) and the
3198 the globals (IPython has its own namespace) and the
3198 PhysicalQuantity stuff is much better anyway.
3199 PhysicalQuantity stuff is much better anyway.
3199
3200
3200 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3201 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3201 embedding example to standard user directory for
3202 embedding example to standard user directory for
3202 distribution. Also put it in the manual.
3203 distribution. Also put it in the manual.
3203
3204
3204 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3205 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3205 instance as first argument (so it doesn't rely on some obscure
3206 instance as first argument (so it doesn't rely on some obscure
3206 hidden global).
3207 hidden global).
3207
3208
3208 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3209 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3209 delimiters. While it prevents ().TAB from working, it allows
3210 delimiters. While it prevents ().TAB from working, it allows
3210 completions in open (... expressions. This is by far a more common
3211 completions in open (... expressions. This is by far a more common
3211 case.
3212 case.
3212
3213
3213 2002-04-23 Fernando Perez <fperez@colorado.edu>
3214 2002-04-23 Fernando Perez <fperez@colorado.edu>
3214
3215
3215 * IPython/Extensions/InterpreterPasteInput.py: new
3216 * IPython/Extensions/InterpreterPasteInput.py: new
3216 syntax-processing module for pasting lines with >>> or ... at the
3217 syntax-processing module for pasting lines with >>> or ... at the
3217 start.
3218 start.
3218
3219
3219 * IPython/Extensions/PhysicalQ_Interactive.py
3220 * IPython/Extensions/PhysicalQ_Interactive.py
3220 (PhysicalQuantityInteractive.__int__): fixed to work with either
3221 (PhysicalQuantityInteractive.__int__): fixed to work with either
3221 Numeric or math.
3222 Numeric or math.
3222
3223
3223 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3224 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3224 provided profiles. Now we have:
3225 provided profiles. Now we have:
3225 -math -> math module as * and cmath with its own namespace.
3226 -math -> math module as * and cmath with its own namespace.
3226 -numeric -> Numeric as *, plus gnuplot & grace
3227 -numeric -> Numeric as *, plus gnuplot & grace
3227 -physics -> same as before
3228 -physics -> same as before
3228
3229
3229 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3230 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3230 user-defined magics wouldn't be found by @magic if they were
3231 user-defined magics wouldn't be found by @magic if they were
3231 defined as class methods. Also cleaned up the namespace search
3232 defined as class methods. Also cleaned up the namespace search
3232 logic and the string building (to use %s instead of many repeated
3233 logic and the string building (to use %s instead of many repeated
3233 string adds).
3234 string adds).
3234
3235
3235 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3236 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3236 of user-defined magics to operate with class methods (cleaner, in
3237 of user-defined magics to operate with class methods (cleaner, in
3237 line with the gnuplot code).
3238 line with the gnuplot code).
3238
3239
3239 2002-04-22 Fernando Perez <fperez@colorado.edu>
3240 2002-04-22 Fernando Perez <fperez@colorado.edu>
3240
3241
3241 * setup.py: updated dependency list so that manual is updated when
3242 * setup.py: updated dependency list so that manual is updated when
3242 all included files change.
3243 all included files change.
3243
3244
3244 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3245 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3245 the delimiter removal option (the fix is ugly right now).
3246 the delimiter removal option (the fix is ugly right now).
3246
3247
3247 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3248 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3248 all of the math profile (quicker loading, no conflict between
3249 all of the math profile (quicker loading, no conflict between
3249 g-9.8 and g-gnuplot).
3250 g-9.8 and g-gnuplot).
3250
3251
3251 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3252 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3252 name of post-mortem files to IPython_crash_report.txt.
3253 name of post-mortem files to IPython_crash_report.txt.
3253
3254
3254 * Cleanup/update of the docs. Added all the new readline info and
3255 * Cleanup/update of the docs. Added all the new readline info and
3255 formatted all lists as 'real lists'.
3256 formatted all lists as 'real lists'.
3256
3257
3257 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3258 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3258 tab-completion options, since the full readline parse_and_bind is
3259 tab-completion options, since the full readline parse_and_bind is
3259 now accessible.
3260 now accessible.
3260
3261
3261 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3262 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3262 handling of readline options. Now users can specify any string to
3263 handling of readline options. Now users can specify any string to
3263 be passed to parse_and_bind(), as well as the delimiters to be
3264 be passed to parse_and_bind(), as well as the delimiters to be
3264 removed.
3265 removed.
3265 (InteractiveShell.__init__): Added __name__ to the global
3266 (InteractiveShell.__init__): Added __name__ to the global
3266 namespace so that things like Itpl which rely on its existence
3267 namespace so that things like Itpl which rely on its existence
3267 don't crash.
3268 don't crash.
3268 (InteractiveShell._prefilter): Defined the default with a _ so
3269 (InteractiveShell._prefilter): Defined the default with a _ so
3269 that prefilter() is easier to override, while the default one
3270 that prefilter() is easier to override, while the default one
3270 remains available.
3271 remains available.
3271
3272
3272 2002-04-18 Fernando Perez <fperez@colorado.edu>
3273 2002-04-18 Fernando Perez <fperez@colorado.edu>
3273
3274
3274 * Added information about pdb in the docs.
3275 * Added information about pdb in the docs.
3275
3276
3276 2002-04-17 Fernando Perez <fperez@colorado.edu>
3277 2002-04-17 Fernando Perez <fperez@colorado.edu>
3277
3278
3278 * IPython/ipmaker.py (make_IPython): added rc_override option to
3279 * IPython/ipmaker.py (make_IPython): added rc_override option to
3279 allow passing config options at creation time which may override
3280 allow passing config options at creation time which may override
3280 anything set in the config files or command line. This is
3281 anything set in the config files or command line. This is
3281 particularly useful for configuring embedded instances.
3282 particularly useful for configuring embedded instances.
3282
3283
3283 2002-04-15 Fernando Perez <fperez@colorado.edu>
3284 2002-04-15 Fernando Perez <fperez@colorado.edu>
3284
3285
3285 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3286 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3286 crash embedded instances because of the input cache falling out of
3287 crash embedded instances because of the input cache falling out of
3287 sync with the output counter.
3288 sync with the output counter.
3288
3289
3289 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3290 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3290 mode which calls pdb after an uncaught exception in IPython itself.
3291 mode which calls pdb after an uncaught exception in IPython itself.
3291
3292
3292 2002-04-14 Fernando Perez <fperez@colorado.edu>
3293 2002-04-14 Fernando Perez <fperez@colorado.edu>
3293
3294
3294 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3295 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3295 readline, fix it back after each call.
3296 readline, fix it back after each call.
3296
3297
3297 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3298 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3298 method to force all access via __call__(), which guarantees that
3299 method to force all access via __call__(), which guarantees that
3299 traceback references are properly deleted.
3300 traceback references are properly deleted.
3300
3301
3301 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3302 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3302 improve printing when pprint is in use.
3303 improve printing when pprint is in use.
3303
3304
3304 2002-04-13 Fernando Perez <fperez@colorado.edu>
3305 2002-04-13 Fernando Perez <fperez@colorado.edu>
3305
3306
3306 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3307 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3307 exceptions aren't caught anymore. If the user triggers one, he
3308 exceptions aren't caught anymore. If the user triggers one, he
3308 should know why he's doing it and it should go all the way up,
3309 should know why he's doing it and it should go all the way up,
3309 just like any other exception. So now @abort will fully kill the
3310 just like any other exception. So now @abort will fully kill the
3310 embedded interpreter and the embedding code (unless that happens
3311 embedded interpreter and the embedding code (unless that happens
3311 to catch SystemExit).
3312 to catch SystemExit).
3312
3313
3313 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3314 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3314 and a debugger() method to invoke the interactive pdb debugger
3315 and a debugger() method to invoke the interactive pdb debugger
3315 after printing exception information. Also added the corresponding
3316 after printing exception information. Also added the corresponding
3316 -pdb option and @pdb magic to control this feature, and updated
3317 -pdb option and @pdb magic to control this feature, and updated
3317 the docs. After a suggestion from Christopher Hart
3318 the docs. After a suggestion from Christopher Hart
3318 (hart-AT-caltech.edu).
3319 (hart-AT-caltech.edu).
3319
3320
3320 2002-04-12 Fernando Perez <fperez@colorado.edu>
3321 2002-04-12 Fernando Perez <fperez@colorado.edu>
3321
3322
3322 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3323 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3323 the exception handlers defined by the user (not the CrashHandler)
3324 the exception handlers defined by the user (not the CrashHandler)
3324 so that user exceptions don't trigger an ipython bug report.
3325 so that user exceptions don't trigger an ipython bug report.
3325
3326
3326 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3327 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3327 configurable (it should have always been so).
3328 configurable (it should have always been so).
3328
3329
3329 2002-03-26 Fernando Perez <fperez@colorado.edu>
3330 2002-03-26 Fernando Perez <fperez@colorado.edu>
3330
3331
3331 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3332 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3332 and there to fix embedding namespace issues. This should all be
3333 and there to fix embedding namespace issues. This should all be
3333 done in a more elegant way.
3334 done in a more elegant way.
3334
3335
3335 2002-03-25 Fernando Perez <fperez@colorado.edu>
3336 2002-03-25 Fernando Perez <fperez@colorado.edu>
3336
3337
3337 * IPython/genutils.py (get_home_dir): Try to make it work under
3338 * IPython/genutils.py (get_home_dir): Try to make it work under
3338 win9x also.
3339 win9x also.
3339
3340
3340 2002-03-20 Fernando Perez <fperez@colorado.edu>
3341 2002-03-20 Fernando Perez <fperez@colorado.edu>
3341
3342
3342 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3343 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3343 sys.displayhook untouched upon __init__.
3344 sys.displayhook untouched upon __init__.
3344
3345
3345 2002-03-19 Fernando Perez <fperez@colorado.edu>
3346 2002-03-19 Fernando Perez <fperez@colorado.edu>
3346
3347
3347 * Released 0.2.9 (for embedding bug, basically).
3348 * Released 0.2.9 (for embedding bug, basically).
3348
3349
3349 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3350 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3350 exceptions so that enclosing shell's state can be restored.
3351 exceptions so that enclosing shell's state can be restored.
3351
3352
3352 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3353 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3353 naming conventions in the .ipython/ dir.
3354 naming conventions in the .ipython/ dir.
3354
3355
3355 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3356 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3356 from delimiters list so filenames with - in them get expanded.
3357 from delimiters list so filenames with - in them get expanded.
3357
3358
3358 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3359 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3359 sys.displayhook not being properly restored after an embedded call.
3360 sys.displayhook not being properly restored after an embedded call.
3360
3361
3361 2002-03-18 Fernando Perez <fperez@colorado.edu>
3362 2002-03-18 Fernando Perez <fperez@colorado.edu>
3362
3363
3363 * Released 0.2.8
3364 * Released 0.2.8
3364
3365
3365 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3366 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3366 some files weren't being included in a -upgrade.
3367 some files weren't being included in a -upgrade.
3367 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3368 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3368 on' so that the first tab completes.
3369 on' so that the first tab completes.
3369 (InteractiveShell.handle_magic): fixed bug with spaces around
3370 (InteractiveShell.handle_magic): fixed bug with spaces around
3370 quotes breaking many magic commands.
3371 quotes breaking many magic commands.
3371
3372
3372 * setup.py: added note about ignoring the syntax error messages at
3373 * setup.py: added note about ignoring the syntax error messages at
3373 installation.
3374 installation.
3374
3375
3375 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3376 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3376 streamlining the gnuplot interface, now there's only one magic @gp.
3377 streamlining the gnuplot interface, now there's only one magic @gp.
3377
3378
3378 2002-03-17 Fernando Perez <fperez@colorado.edu>
3379 2002-03-17 Fernando Perez <fperez@colorado.edu>
3379
3380
3380 * IPython/UserConfig/magic_gnuplot.py: new name for the
3381 * IPython/UserConfig/magic_gnuplot.py: new name for the
3381 example-magic_pm.py file. Much enhanced system, now with a shell
3382 example-magic_pm.py file. Much enhanced system, now with a shell
3382 for communicating directly with gnuplot, one command at a time.
3383 for communicating directly with gnuplot, one command at a time.
3383
3384
3384 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3385 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3385 setting __name__=='__main__'.
3386 setting __name__=='__main__'.
3386
3387
3387 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3388 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3388 mini-shell for accessing gnuplot from inside ipython. Should
3389 mini-shell for accessing gnuplot from inside ipython. Should
3389 extend it later for grace access too. Inspired by Arnd's
3390 extend it later for grace access too. Inspired by Arnd's
3390 suggestion.
3391 suggestion.
3391
3392
3392 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3393 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3393 calling magic functions with () in their arguments. Thanks to Arnd
3394 calling magic functions with () in their arguments. Thanks to Arnd
3394 Baecker for pointing this to me.
3395 Baecker for pointing this to me.
3395
3396
3396 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3397 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3397 infinitely for integer or complex arrays (only worked with floats).
3398 infinitely for integer or complex arrays (only worked with floats).
3398
3399
3399 2002-03-16 Fernando Perez <fperez@colorado.edu>
3400 2002-03-16 Fernando Perez <fperez@colorado.edu>
3400
3401
3401 * setup.py: Merged setup and setup_windows into a single script
3402 * setup.py: Merged setup and setup_windows into a single script
3402 which properly handles things for windows users.
3403 which properly handles things for windows users.
3403
3404
3404 2002-03-15 Fernando Perez <fperez@colorado.edu>
3405 2002-03-15 Fernando Perez <fperez@colorado.edu>
3405
3406
3406 * Big change to the manual: now the magics are all automatically
3407 * Big change to the manual: now the magics are all automatically
3407 documented. This information is generated from their docstrings
3408 documented. This information is generated from their docstrings
3408 and put in a latex file included by the manual lyx file. This way
3409 and put in a latex file included by the manual lyx file. This way
3409 we get always up to date information for the magics. The manual
3410 we get always up to date information for the magics. The manual
3410 now also has proper version information, also auto-synced.
3411 now also has proper version information, also auto-synced.
3411
3412
3412 For this to work, an undocumented --magic_docstrings option was added.
3413 For this to work, an undocumented --magic_docstrings option was added.
3413
3414
3414 2002-03-13 Fernando Perez <fperez@colorado.edu>
3415 2002-03-13 Fernando Perez <fperez@colorado.edu>
3415
3416
3416 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3417 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3417 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3418 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3418
3419
3419 2002-03-12 Fernando Perez <fperez@colorado.edu>
3420 2002-03-12 Fernando Perez <fperez@colorado.edu>
3420
3421
3421 * IPython/ultraTB.py (TermColors): changed color escapes again to
3422 * IPython/ultraTB.py (TermColors): changed color escapes again to
3422 fix the (old, reintroduced) line-wrapping bug. Basically, if
3423 fix the (old, reintroduced) line-wrapping bug. Basically, if
3423 \001..\002 aren't given in the color escapes, lines get wrapped
3424 \001..\002 aren't given in the color escapes, lines get wrapped
3424 weirdly. But giving those screws up old xterms and emacs terms. So
3425 weirdly. But giving those screws up old xterms and emacs terms. So
3425 I added some logic for emacs terms to be ok, but I can't identify old
3426 I added some logic for emacs terms to be ok, but I can't identify old
3426 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3427 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3427
3428
3428 2002-03-10 Fernando Perez <fperez@colorado.edu>
3429 2002-03-10 Fernando Perez <fperez@colorado.edu>
3429
3430
3430 * IPython/usage.py (__doc__): Various documentation cleanups and
3431 * IPython/usage.py (__doc__): Various documentation cleanups and
3431 updates, both in usage docstrings and in the manual.
3432 updates, both in usage docstrings and in the manual.
3432
3433
3433 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3434 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3434 handling of caching. Set minimum acceptabe value for having a
3435 handling of caching. Set minimum acceptabe value for having a
3435 cache at 20 values.
3436 cache at 20 values.
3436
3437
3437 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3438 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3438 install_first_time function to a method, renamed it and added an
3439 install_first_time function to a method, renamed it and added an
3439 'upgrade' mode. Now people can update their config directory with
3440 'upgrade' mode. Now people can update their config directory with
3440 a simple command line switch (-upgrade, also new).
3441 a simple command line switch (-upgrade, also new).
3441
3442
3442 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3443 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3443 @file (convenient for automagic users under Python >= 2.2).
3444 @file (convenient for automagic users under Python >= 2.2).
3444 Removed @files (it seemed more like a plural than an abbrev. of
3445 Removed @files (it seemed more like a plural than an abbrev. of
3445 'file show').
3446 'file show').
3446
3447
3447 * IPython/iplib.py (install_first_time): Fixed crash if there were
3448 * IPython/iplib.py (install_first_time): Fixed crash if there were
3448 backup files ('~') in .ipython/ install directory.
3449 backup files ('~') in .ipython/ install directory.
3449
3450
3450 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3451 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3451 system. Things look fine, but these changes are fairly
3452 system. Things look fine, but these changes are fairly
3452 intrusive. Test them for a few days.
3453 intrusive. Test them for a few days.
3453
3454
3454 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3455 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3455 the prompts system. Now all in/out prompt strings are user
3456 the prompts system. Now all in/out prompt strings are user
3456 controllable. This is particularly useful for embedding, as one
3457 controllable. This is particularly useful for embedding, as one
3457 can tag embedded instances with particular prompts.
3458 can tag embedded instances with particular prompts.
3458
3459
3459 Also removed global use of sys.ps1/2, which now allows nested
3460 Also removed global use of sys.ps1/2, which now allows nested
3460 embeddings without any problems. Added command-line options for
3461 embeddings without any problems. Added command-line options for
3461 the prompt strings.
3462 the prompt strings.
3462
3463
3463 2002-03-08 Fernando Perez <fperez@colorado.edu>
3464 2002-03-08 Fernando Perez <fperez@colorado.edu>
3464
3465
3465 * IPython/UserConfig/example-embed-short.py (ipshell): added
3466 * IPython/UserConfig/example-embed-short.py (ipshell): added
3466 example file with the bare minimum code for embedding.
3467 example file with the bare minimum code for embedding.
3467
3468
3468 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3469 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3469 functionality for the embeddable shell to be activated/deactivated
3470 functionality for the embeddable shell to be activated/deactivated
3470 either globally or at each call.
3471 either globally or at each call.
3471
3472
3472 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3473 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3473 rewriting the prompt with '--->' for auto-inputs with proper
3474 rewriting the prompt with '--->' for auto-inputs with proper
3474 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3475 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3475 this is handled by the prompts class itself, as it should.
3476 this is handled by the prompts class itself, as it should.
3476
3477
3477 2002-03-05 Fernando Perez <fperez@colorado.edu>
3478 2002-03-05 Fernando Perez <fperez@colorado.edu>
3478
3479
3479 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3480 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3480 @logstart to avoid name clashes with the math log function.
3481 @logstart to avoid name clashes with the math log function.
3481
3482
3482 * Big updates to X/Emacs section of the manual.
3483 * Big updates to X/Emacs section of the manual.
3483
3484
3484 * Removed ipython_emacs. Milan explained to me how to pass
3485 * Removed ipython_emacs. Milan explained to me how to pass
3485 arguments to ipython through Emacs. Some day I'm going to end up
3486 arguments to ipython through Emacs. Some day I'm going to end up
3486 learning some lisp...
3487 learning some lisp...
3487
3488
3488 2002-03-04 Fernando Perez <fperez@colorado.edu>
3489 2002-03-04 Fernando Perez <fperez@colorado.edu>
3489
3490
3490 * IPython/ipython_emacs: Created script to be used as the
3491 * IPython/ipython_emacs: Created script to be used as the
3491 py-python-command Emacs variable so we can pass IPython
3492 py-python-command Emacs variable so we can pass IPython
3492 parameters. I can't figure out how to tell Emacs directly to pass
3493 parameters. I can't figure out how to tell Emacs directly to pass
3493 parameters to IPython, so a dummy shell script will do it.
3494 parameters to IPython, so a dummy shell script will do it.
3494
3495
3495 Other enhancements made for things to work better under Emacs'
3496 Other enhancements made for things to work better under Emacs'
3496 various types of terminals. Many thanks to Milan Zamazal
3497 various types of terminals. Many thanks to Milan Zamazal
3497 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3498 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3498
3499
3499 2002-03-01 Fernando Perez <fperez@colorado.edu>
3500 2002-03-01 Fernando Perez <fperez@colorado.edu>
3500
3501
3501 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3502 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3502 that loading of readline is now optional. This gives better
3503 that loading of readline is now optional. This gives better
3503 control to emacs users.
3504 control to emacs users.
3504
3505
3505 * IPython/ultraTB.py (__date__): Modified color escape sequences
3506 * IPython/ultraTB.py (__date__): Modified color escape sequences
3506 and now things work fine under xterm and in Emacs' term buffers
3507 and now things work fine under xterm and in Emacs' term buffers
3507 (though not shell ones). Well, in emacs you get colors, but all
3508 (though not shell ones). Well, in emacs you get colors, but all
3508 seem to be 'light' colors (no difference between dark and light
3509 seem to be 'light' colors (no difference between dark and light
3509 ones). But the garbage chars are gone, and also in xterms. It
3510 ones). But the garbage chars are gone, and also in xterms. It
3510 seems that now I'm using 'cleaner' ansi sequences.
3511 seems that now I'm using 'cleaner' ansi sequences.
3511
3512
3512 2002-02-21 Fernando Perez <fperez@colorado.edu>
3513 2002-02-21 Fernando Perez <fperez@colorado.edu>
3513
3514
3514 * Released 0.2.7 (mainly to publish the scoping fix).
3515 * Released 0.2.7 (mainly to publish the scoping fix).
3515
3516
3516 * IPython/Logger.py (Logger.logstate): added. A corresponding
3517 * IPython/Logger.py (Logger.logstate): added. A corresponding
3517 @logstate magic was created.
3518 @logstate magic was created.
3518
3519
3519 * IPython/Magic.py: fixed nested scoping problem under Python
3520 * IPython/Magic.py: fixed nested scoping problem under Python
3520 2.1.x (automagic wasn't working).
3521 2.1.x (automagic wasn't working).
3521
3522
3522 2002-02-20 Fernando Perez <fperez@colorado.edu>
3523 2002-02-20 Fernando Perez <fperez@colorado.edu>
3523
3524
3524 * Released 0.2.6.
3525 * Released 0.2.6.
3525
3526
3526 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3527 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3527 option so that logs can come out without any headers at all.
3528 option so that logs can come out without any headers at all.
3528
3529
3529 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3530 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3530 SciPy.
3531 SciPy.
3531
3532
3532 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3533 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3533 that embedded IPython calls don't require vars() to be explicitly
3534 that embedded IPython calls don't require vars() to be explicitly
3534 passed. Now they are extracted from the caller's frame (code
3535 passed. Now they are extracted from the caller's frame (code
3535 snatched from Eric Jones' weave). Added better documentation to
3536 snatched from Eric Jones' weave). Added better documentation to
3536 the section on embedding and the example file.
3537 the section on embedding and the example file.
3537
3538
3538 * IPython/genutils.py (page): Changed so that under emacs, it just
3539 * IPython/genutils.py (page): Changed so that under emacs, it just
3539 prints the string. You can then page up and down in the emacs
3540 prints the string. You can then page up and down in the emacs
3540 buffer itself. This is how the builtin help() works.
3541 buffer itself. This is how the builtin help() works.
3541
3542
3542 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3543 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3543 macro scoping: macros need to be executed in the user's namespace
3544 macro scoping: macros need to be executed in the user's namespace
3544 to work as if they had been typed by the user.
3545 to work as if they had been typed by the user.
3545
3546
3546 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3547 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3547 execute automatically (no need to type 'exec...'). They then
3548 execute automatically (no need to type 'exec...'). They then
3548 behave like 'true macros'. The printing system was also modified
3549 behave like 'true macros'. The printing system was also modified
3549 for this to work.
3550 for this to work.
3550
3551
3551 2002-02-19 Fernando Perez <fperez@colorado.edu>
3552 2002-02-19 Fernando Perez <fperez@colorado.edu>
3552
3553
3553 * IPython/genutils.py (page_file): new function for paging files
3554 * IPython/genutils.py (page_file): new function for paging files
3554 in an OS-independent way. Also necessary for file viewing to work
3555 in an OS-independent way. Also necessary for file viewing to work
3555 well inside Emacs buffers.
3556 well inside Emacs buffers.
3556 (page): Added checks for being in an emacs buffer.
3557 (page): Added checks for being in an emacs buffer.
3557 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3558 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3558 same bug in iplib.
3559 same bug in iplib.
3559
3560
3560 2002-02-18 Fernando Perez <fperez@colorado.edu>
3561 2002-02-18 Fernando Perez <fperez@colorado.edu>
3561
3562
3562 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3563 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3563 of readline so that IPython can work inside an Emacs buffer.
3564 of readline so that IPython can work inside an Emacs buffer.
3564
3565
3565 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3566 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3566 method signatures (they weren't really bugs, but it looks cleaner
3567 method signatures (they weren't really bugs, but it looks cleaner
3567 and keeps PyChecker happy).
3568 and keeps PyChecker happy).
3568
3569
3569 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3570 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3570 for implementing various user-defined hooks. Currently only
3571 for implementing various user-defined hooks. Currently only
3571 display is done.
3572 display is done.
3572
3573
3573 * IPython/Prompts.py (CachedOutput._display): changed display
3574 * IPython/Prompts.py (CachedOutput._display): changed display
3574 functions so that they can be dynamically changed by users easily.
3575 functions so that they can be dynamically changed by users easily.
3575
3576
3576 * IPython/Extensions/numeric_formats.py (num_display): added an
3577 * IPython/Extensions/numeric_formats.py (num_display): added an
3577 extension for printing NumPy arrays in flexible manners. It
3578 extension for printing NumPy arrays in flexible manners. It
3578 doesn't do anything yet, but all the structure is in
3579 doesn't do anything yet, but all the structure is in
3579 place. Ultimately the plan is to implement output format control
3580 place. Ultimately the plan is to implement output format control
3580 like in Octave.
3581 like in Octave.
3581
3582
3582 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3583 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3583 methods are found at run-time by all the automatic machinery.
3584 methods are found at run-time by all the automatic machinery.
3584
3585
3585 2002-02-17 Fernando Perez <fperez@colorado.edu>
3586 2002-02-17 Fernando Perez <fperez@colorado.edu>
3586
3587
3587 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3588 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3588 whole file a little.
3589 whole file a little.
3589
3590
3590 * ToDo: closed this document. Now there's a new_design.lyx
3591 * ToDo: closed this document. Now there's a new_design.lyx
3591 document for all new ideas. Added making a pdf of it for the
3592 document for all new ideas. Added making a pdf of it for the
3592 end-user distro.
3593 end-user distro.
3593
3594
3594 * IPython/Logger.py (Logger.switch_log): Created this to replace
3595 * IPython/Logger.py (Logger.switch_log): Created this to replace
3595 logon() and logoff(). It also fixes a nasty crash reported by
3596 logon() and logoff(). It also fixes a nasty crash reported by
3596 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3597 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3597
3598
3598 * IPython/iplib.py (complete): got auto-completion to work with
3599 * IPython/iplib.py (complete): got auto-completion to work with
3599 automagic (I had wanted this for a long time).
3600 automagic (I had wanted this for a long time).
3600
3601
3601 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3602 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3602 to @file, since file() is now a builtin and clashes with automagic
3603 to @file, since file() is now a builtin and clashes with automagic
3603 for @file.
3604 for @file.
3604
3605
3605 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3606 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3606 of this was previously in iplib, which had grown to more than 2000
3607 of this was previously in iplib, which had grown to more than 2000
3607 lines, way too long. No new functionality, but it makes managing
3608 lines, way too long. No new functionality, but it makes managing
3608 the code a bit easier.
3609 the code a bit easier.
3609
3610
3610 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3611 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3611 information to crash reports.
3612 information to crash reports.
3612
3613
3613 2002-02-12 Fernando Perez <fperez@colorado.edu>
3614 2002-02-12 Fernando Perez <fperez@colorado.edu>
3614
3615
3615 * Released 0.2.5.
3616 * Released 0.2.5.
3616
3617
3617 2002-02-11 Fernando Perez <fperez@colorado.edu>
3618 2002-02-11 Fernando Perez <fperez@colorado.edu>
3618
3619
3619 * Wrote a relatively complete Windows installer. It puts
3620 * Wrote a relatively complete Windows installer. It puts
3620 everything in place, creates Start Menu entries and fixes the
3621 everything in place, creates Start Menu entries and fixes the
3621 color issues. Nothing fancy, but it works.
3622 color issues. Nothing fancy, but it works.
3622
3623
3623 2002-02-10 Fernando Perez <fperez@colorado.edu>
3624 2002-02-10 Fernando Perez <fperez@colorado.edu>
3624
3625
3625 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3626 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3626 os.path.expanduser() call so that we can type @run ~/myfile.py and
3627 os.path.expanduser() call so that we can type @run ~/myfile.py and
3627 have thigs work as expected.
3628 have thigs work as expected.
3628
3629
3629 * IPython/genutils.py (page): fixed exception handling so things
3630 * IPython/genutils.py (page): fixed exception handling so things
3630 work both in Unix and Windows correctly. Quitting a pager triggers
3631 work both in Unix and Windows correctly. Quitting a pager triggers
3631 an IOError/broken pipe in Unix, and in windows not finding a pager
3632 an IOError/broken pipe in Unix, and in windows not finding a pager
3632 is also an IOError, so I had to actually look at the return value
3633 is also an IOError, so I had to actually look at the return value
3633 of the exception, not just the exception itself. Should be ok now.
3634 of the exception, not just the exception itself. Should be ok now.
3634
3635
3635 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3636 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3636 modified to allow case-insensitive color scheme changes.
3637 modified to allow case-insensitive color scheme changes.
3637
3638
3638 2002-02-09 Fernando Perez <fperez@colorado.edu>
3639 2002-02-09 Fernando Perez <fperez@colorado.edu>
3639
3640
3640 * IPython/genutils.py (native_line_ends): new function to leave
3641 * IPython/genutils.py (native_line_ends): new function to leave
3641 user config files with os-native line-endings.
3642 user config files with os-native line-endings.
3642
3643
3643 * README and manual updates.
3644 * README and manual updates.
3644
3645
3645 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3646 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3646 instead of StringType to catch Unicode strings.
3647 instead of StringType to catch Unicode strings.
3647
3648
3648 * IPython/genutils.py (filefind): fixed bug for paths with
3649 * IPython/genutils.py (filefind): fixed bug for paths with
3649 embedded spaces (very common in Windows).
3650 embedded spaces (very common in Windows).
3650
3651
3651 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3652 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3652 files under Windows, so that they get automatically associated
3653 files under Windows, so that they get automatically associated
3653 with a text editor. Windows makes it a pain to handle
3654 with a text editor. Windows makes it a pain to handle
3654 extension-less files.
3655 extension-less files.
3655
3656
3656 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3657 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3657 warning about readline only occur for Posix. In Windows there's no
3658 warning about readline only occur for Posix. In Windows there's no
3658 way to get readline, so why bother with the warning.
3659 way to get readline, so why bother with the warning.
3659
3660
3660 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3661 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3661 for __str__ instead of dir(self), since dir() changed in 2.2.
3662 for __str__ instead of dir(self), since dir() changed in 2.2.
3662
3663
3663 * Ported to Windows! Tested on XP, I suspect it should work fine
3664 * Ported to Windows! Tested on XP, I suspect it should work fine
3664 on NT/2000, but I don't think it will work on 98 et al. That
3665 on NT/2000, but I don't think it will work on 98 et al. That
3665 series of Windows is such a piece of junk anyway that I won't try
3666 series of Windows is such a piece of junk anyway that I won't try
3666 porting it there. The XP port was straightforward, showed a few
3667 porting it there. The XP port was straightforward, showed a few
3667 bugs here and there (fixed all), in particular some string
3668 bugs here and there (fixed all), in particular some string
3668 handling stuff which required considering Unicode strings (which
3669 handling stuff which required considering Unicode strings (which
3669 Windows uses). This is good, but hasn't been too tested :) No
3670 Windows uses). This is good, but hasn't been too tested :) No
3670 fancy installer yet, I'll put a note in the manual so people at
3671 fancy installer yet, I'll put a note in the manual so people at
3671 least make manually a shortcut.
3672 least make manually a shortcut.
3672
3673
3673 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3674 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3674 into a single one, "colors". This now controls both prompt and
3675 into a single one, "colors". This now controls both prompt and
3675 exception color schemes, and can be changed both at startup
3676 exception color schemes, and can be changed both at startup
3676 (either via command-line switches or via ipythonrc files) and at
3677 (either via command-line switches or via ipythonrc files) and at
3677 runtime, with @colors.
3678 runtime, with @colors.
3678 (Magic.magic_run): renamed @prun to @run and removed the old
3679 (Magic.magic_run): renamed @prun to @run and removed the old
3679 @run. The two were too similar to warrant keeping both.
3680 @run. The two were too similar to warrant keeping both.
3680
3681
3681 2002-02-03 Fernando Perez <fperez@colorado.edu>
3682 2002-02-03 Fernando Perez <fperez@colorado.edu>
3682
3683
3683 * IPython/iplib.py (install_first_time): Added comment on how to
3684 * IPython/iplib.py (install_first_time): Added comment on how to
3684 configure the color options for first-time users. Put a <return>
3685 configure the color options for first-time users. Put a <return>
3685 request at the end so that small-terminal users get a chance to
3686 request at the end so that small-terminal users get a chance to
3686 read the startup info.
3687 read the startup info.
3687
3688
3688 2002-01-23 Fernando Perez <fperez@colorado.edu>
3689 2002-01-23 Fernando Perez <fperez@colorado.edu>
3689
3690
3690 * IPython/iplib.py (CachedOutput.update): Changed output memory
3691 * IPython/iplib.py (CachedOutput.update): Changed output memory
3691 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3692 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3692 input history we still use _i. Did this b/c these variable are
3693 input history we still use _i. Did this b/c these variable are
3693 very commonly used in interactive work, so the less we need to
3694 very commonly used in interactive work, so the less we need to
3694 type the better off we are.
3695 type the better off we are.
3695 (Magic.magic_prun): updated @prun to better handle the namespaces
3696 (Magic.magic_prun): updated @prun to better handle the namespaces
3696 the file will run in, including a fix for __name__ not being set
3697 the file will run in, including a fix for __name__ not being set
3697 before.
3698 before.
3698
3699
3699 2002-01-20 Fernando Perez <fperez@colorado.edu>
3700 2002-01-20 Fernando Perez <fperez@colorado.edu>
3700
3701
3701 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3702 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3702 extra garbage for Python 2.2. Need to look more carefully into
3703 extra garbage for Python 2.2. Need to look more carefully into
3703 this later.
3704 this later.
3704
3705
3705 2002-01-19 Fernando Perez <fperez@colorado.edu>
3706 2002-01-19 Fernando Perez <fperez@colorado.edu>
3706
3707
3707 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3708 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3708 display SyntaxError exceptions properly formatted when they occur
3709 display SyntaxError exceptions properly formatted when they occur
3709 (they can be triggered by imported code).
3710 (they can be triggered by imported code).
3710
3711
3711 2002-01-18 Fernando Perez <fperez@colorado.edu>
3712 2002-01-18 Fernando Perez <fperez@colorado.edu>
3712
3713
3713 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3714 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3714 SyntaxError exceptions are reported nicely formatted, instead of
3715 SyntaxError exceptions are reported nicely formatted, instead of
3715 spitting out only offset information as before.
3716 spitting out only offset information as before.
3716 (Magic.magic_prun): Added the @prun function for executing
3717 (Magic.magic_prun): Added the @prun function for executing
3717 programs with command line args inside IPython.
3718 programs with command line args inside IPython.
3718
3719
3719 2002-01-16 Fernando Perez <fperez@colorado.edu>
3720 2002-01-16 Fernando Perez <fperez@colorado.edu>
3720
3721
3721 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3722 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3722 to *not* include the last item given in a range. This brings their
3723 to *not* include the last item given in a range. This brings their
3723 behavior in line with Python's slicing:
3724 behavior in line with Python's slicing:
3724 a[n1:n2] -> a[n1]...a[n2-1]
3725 a[n1:n2] -> a[n1]...a[n2-1]
3725 It may be a bit less convenient, but I prefer to stick to Python's
3726 It may be a bit less convenient, but I prefer to stick to Python's
3726 conventions *everywhere*, so users never have to wonder.
3727 conventions *everywhere*, so users never have to wonder.
3727 (Magic.magic_macro): Added @macro function to ease the creation of
3728 (Magic.magic_macro): Added @macro function to ease the creation of
3728 macros.
3729 macros.
3729
3730
3730 2002-01-05 Fernando Perez <fperez@colorado.edu>
3731 2002-01-05 Fernando Perez <fperez@colorado.edu>
3731
3732
3732 * Released 0.2.4.
3733 * Released 0.2.4.
3733
3734
3734 * IPython/iplib.py (Magic.magic_pdef):
3735 * IPython/iplib.py (Magic.magic_pdef):
3735 (InteractiveShell.safe_execfile): report magic lines and error
3736 (InteractiveShell.safe_execfile): report magic lines and error
3736 lines without line numbers so one can easily copy/paste them for
3737 lines without line numbers so one can easily copy/paste them for
3737 re-execution.
3738 re-execution.
3738
3739
3739 * Updated manual with recent changes.
3740 * Updated manual with recent changes.
3740
3741
3741 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3742 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3742 docstring printing when class? is called. Very handy for knowing
3743 docstring printing when class? is called. Very handy for knowing
3743 how to create class instances (as long as __init__ is well
3744 how to create class instances (as long as __init__ is well
3744 documented, of course :)
3745 documented, of course :)
3745 (Magic.magic_doc): print both class and constructor docstrings.
3746 (Magic.magic_doc): print both class and constructor docstrings.
3746 (Magic.magic_pdef): give constructor info if passed a class and
3747 (Magic.magic_pdef): give constructor info if passed a class and
3747 __call__ info for callable object instances.
3748 __call__ info for callable object instances.
3748
3749
3749 2002-01-04 Fernando Perez <fperez@colorado.edu>
3750 2002-01-04 Fernando Perez <fperez@colorado.edu>
3750
3751
3751 * Made deep_reload() off by default. It doesn't always work
3752 * Made deep_reload() off by default. It doesn't always work
3752 exactly as intended, so it's probably safer to have it off. It's
3753 exactly as intended, so it's probably safer to have it off. It's
3753 still available as dreload() anyway, so nothing is lost.
3754 still available as dreload() anyway, so nothing is lost.
3754
3755
3755 2002-01-02 Fernando Perez <fperez@colorado.edu>
3756 2002-01-02 Fernando Perez <fperez@colorado.edu>
3756
3757
3757 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3758 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3758 so I wanted an updated release).
3759 so I wanted an updated release).
3759
3760
3760 2001-12-27 Fernando Perez <fperez@colorado.edu>
3761 2001-12-27 Fernando Perez <fperez@colorado.edu>
3761
3762
3762 * IPython/iplib.py (InteractiveShell.interact): Added the original
3763 * IPython/iplib.py (InteractiveShell.interact): Added the original
3763 code from 'code.py' for this module in order to change the
3764 code from 'code.py' for this module in order to change the
3764 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3765 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3765 the history cache would break when the user hit Ctrl-C, and
3766 the history cache would break when the user hit Ctrl-C, and
3766 interact() offers no way to add any hooks to it.
3767 interact() offers no way to add any hooks to it.
3767
3768
3768 2001-12-23 Fernando Perez <fperez@colorado.edu>
3769 2001-12-23 Fernando Perez <fperez@colorado.edu>
3769
3770
3770 * setup.py: added check for 'MANIFEST' before trying to remove
3771 * setup.py: added check for 'MANIFEST' before trying to remove
3771 it. Thanks to Sean Reifschneider.
3772 it. Thanks to Sean Reifschneider.
3772
3773
3773 2001-12-22 Fernando Perez <fperez@colorado.edu>
3774 2001-12-22 Fernando Perez <fperez@colorado.edu>
3774
3775
3775 * Released 0.2.2.
3776 * Released 0.2.2.
3776
3777
3777 * Finished (reasonably) writing the manual. Later will add the
3778 * Finished (reasonably) writing the manual. Later will add the
3778 python-standard navigation stylesheets, but for the time being
3779 python-standard navigation stylesheets, but for the time being
3779 it's fairly complete. Distribution will include html and pdf
3780 it's fairly complete. Distribution will include html and pdf
3780 versions.
3781 versions.
3781
3782
3782 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3783 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3783 (MayaVi author).
3784 (MayaVi author).
3784
3785
3785 2001-12-21 Fernando Perez <fperez@colorado.edu>
3786 2001-12-21 Fernando Perez <fperez@colorado.edu>
3786
3787
3787 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3788 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3788 good public release, I think (with the manual and the distutils
3789 good public release, I think (with the manual and the distutils
3789 installer). The manual can use some work, but that can go
3790 installer). The manual can use some work, but that can go
3790 slowly. Otherwise I think it's quite nice for end users. Next
3791 slowly. Otherwise I think it's quite nice for end users. Next
3791 summer, rewrite the guts of it...
3792 summer, rewrite the guts of it...
3792
3793
3793 * Changed format of ipythonrc files to use whitespace as the
3794 * Changed format of ipythonrc files to use whitespace as the
3794 separator instead of an explicit '='. Cleaner.
3795 separator instead of an explicit '='. Cleaner.
3795
3796
3796 2001-12-20 Fernando Perez <fperez@colorado.edu>
3797 2001-12-20 Fernando Perez <fperez@colorado.edu>
3797
3798
3798 * Started a manual in LyX. For now it's just a quick merge of the
3799 * Started a manual in LyX. For now it's just a quick merge of the
3799 various internal docstrings and READMEs. Later it may grow into a
3800 various internal docstrings and READMEs. Later it may grow into a
3800 nice, full-blown manual.
3801 nice, full-blown manual.
3801
3802
3802 * Set up a distutils based installer. Installation should now be
3803 * Set up a distutils based installer. Installation should now be
3803 trivially simple for end-users.
3804 trivially simple for end-users.
3804
3805
3805 2001-12-11 Fernando Perez <fperez@colorado.edu>
3806 2001-12-11 Fernando Perez <fperez@colorado.edu>
3806
3807
3807 * Released 0.2.0. First public release, announced it at
3808 * Released 0.2.0. First public release, announced it at
3808 comp.lang.python. From now on, just bugfixes...
3809 comp.lang.python. From now on, just bugfixes...
3809
3810
3810 * Went through all the files, set copyright/license notices and
3811 * Went through all the files, set copyright/license notices and
3811 cleaned up things. Ready for release.
3812 cleaned up things. Ready for release.
3812
3813
3813 2001-12-10 Fernando Perez <fperez@colorado.edu>
3814 2001-12-10 Fernando Perez <fperez@colorado.edu>
3814
3815
3815 * Changed the first-time installer not to use tarfiles. It's more
3816 * Changed the first-time installer not to use tarfiles. It's more
3816 robust now and less unix-dependent. Also makes it easier for
3817 robust now and less unix-dependent. Also makes it easier for
3817 people to later upgrade versions.
3818 people to later upgrade versions.
3818
3819
3819 * Changed @exit to @abort to reflect the fact that it's pretty
3820 * Changed @exit to @abort to reflect the fact that it's pretty
3820 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3821 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3821 becomes significant only when IPyhton is embedded: in that case,
3822 becomes significant only when IPyhton is embedded: in that case,
3822 C-D closes IPython only, but @abort kills the enclosing program
3823 C-D closes IPython only, but @abort kills the enclosing program
3823 too (unless it had called IPython inside a try catching
3824 too (unless it had called IPython inside a try catching
3824 SystemExit).
3825 SystemExit).
3825
3826
3826 * Created Shell module which exposes the actuall IPython Shell
3827 * Created Shell module which exposes the actuall IPython Shell
3827 classes, currently the normal and the embeddable one. This at
3828 classes, currently the normal and the embeddable one. This at
3828 least offers a stable interface we won't need to change when
3829 least offers a stable interface we won't need to change when
3829 (later) the internals are rewritten. That rewrite will be confined
3830 (later) the internals are rewritten. That rewrite will be confined
3830 to iplib and ipmaker, but the Shell interface should remain as is.
3831 to iplib and ipmaker, but the Shell interface should remain as is.
3831
3832
3832 * Added embed module which offers an embeddable IPShell object,
3833 * Added embed module which offers an embeddable IPShell object,
3833 useful to fire up IPython *inside* a running program. Great for
3834 useful to fire up IPython *inside* a running program. Great for
3834 debugging or dynamical data analysis.
3835 debugging or dynamical data analysis.
3835
3836
3836 2001-12-08 Fernando Perez <fperez@colorado.edu>
3837 2001-12-08 Fernando Perez <fperez@colorado.edu>
3837
3838
3838 * Fixed small bug preventing seeing info from methods of defined
3839 * Fixed small bug preventing seeing info from methods of defined
3839 objects (incorrect namespace in _ofind()).
3840 objects (incorrect namespace in _ofind()).
3840
3841
3841 * Documentation cleanup. Moved the main usage docstrings to a
3842 * Documentation cleanup. Moved the main usage docstrings to a
3842 separate file, usage.py (cleaner to maintain, and hopefully in the
3843 separate file, usage.py (cleaner to maintain, and hopefully in the
3843 future some perlpod-like way of producing interactive, man and
3844 future some perlpod-like way of producing interactive, man and
3844 html docs out of it will be found).
3845 html docs out of it will be found).
3845
3846
3846 * Added @profile to see your profile at any time.
3847 * Added @profile to see your profile at any time.
3847
3848
3848 * Added @p as an alias for 'print'. It's especially convenient if
3849 * Added @p as an alias for 'print'. It's especially convenient if
3849 using automagic ('p x' prints x).
3850 using automagic ('p x' prints x).
3850
3851
3851 * Small cleanups and fixes after a pychecker run.
3852 * Small cleanups and fixes after a pychecker run.
3852
3853
3853 * Changed the @cd command to handle @cd - and @cd -<n> for
3854 * Changed the @cd command to handle @cd - and @cd -<n> for
3854 visiting any directory in _dh.
3855 visiting any directory in _dh.
3855
3856
3856 * Introduced _dh, a history of visited directories. @dhist prints
3857 * Introduced _dh, a history of visited directories. @dhist prints
3857 it out with numbers.
3858 it out with numbers.
3858
3859
3859 2001-12-07 Fernando Perez <fperez@colorado.edu>
3860 2001-12-07 Fernando Perez <fperez@colorado.edu>
3860
3861
3861 * Released 0.1.22
3862 * Released 0.1.22
3862
3863
3863 * Made initialization a bit more robust against invalid color
3864 * Made initialization a bit more robust against invalid color
3864 options in user input (exit, not traceback-crash).
3865 options in user input (exit, not traceback-crash).
3865
3866
3866 * Changed the bug crash reporter to write the report only in the
3867 * Changed the bug crash reporter to write the report only in the
3867 user's .ipython directory. That way IPython won't litter people's
3868 user's .ipython directory. That way IPython won't litter people's
3868 hard disks with crash files all over the place. Also print on
3869 hard disks with crash files all over the place. Also print on
3869 screen the necessary mail command.
3870 screen the necessary mail command.
3870
3871
3871 * With the new ultraTB, implemented LightBG color scheme for light
3872 * With the new ultraTB, implemented LightBG color scheme for light
3872 background terminals. A lot of people like white backgrounds, so I
3873 background terminals. A lot of people like white backgrounds, so I
3873 guess we should at least give them something readable.
3874 guess we should at least give them something readable.
3874
3875
3875 2001-12-06 Fernando Perez <fperez@colorado.edu>
3876 2001-12-06 Fernando Perez <fperez@colorado.edu>
3876
3877
3877 * Modified the structure of ultraTB. Now there's a proper class
3878 * Modified the structure of ultraTB. Now there's a proper class
3878 for tables of color schemes which allow adding schemes easily and
3879 for tables of color schemes which allow adding schemes easily and
3879 switching the active scheme without creating a new instance every
3880 switching the active scheme without creating a new instance every
3880 time (which was ridiculous). The syntax for creating new schemes
3881 time (which was ridiculous). The syntax for creating new schemes
3881 is also cleaner. I think ultraTB is finally done, with a clean
3882 is also cleaner. I think ultraTB is finally done, with a clean
3882 class structure. Names are also much cleaner (now there's proper
3883 class structure. Names are also much cleaner (now there's proper
3883 color tables, no need for every variable to also have 'color' in
3884 color tables, no need for every variable to also have 'color' in
3884 its name).
3885 its name).
3885
3886
3886 * Broke down genutils into separate files. Now genutils only
3887 * Broke down genutils into separate files. Now genutils only
3887 contains utility functions, and classes have been moved to their
3888 contains utility functions, and classes have been moved to their
3888 own files (they had enough independent functionality to warrant
3889 own files (they had enough independent functionality to warrant
3889 it): ConfigLoader, OutputTrap, Struct.
3890 it): ConfigLoader, OutputTrap, Struct.
3890
3891
3891 2001-12-05 Fernando Perez <fperez@colorado.edu>
3892 2001-12-05 Fernando Perez <fperez@colorado.edu>
3892
3893
3893 * IPython turns 21! Released version 0.1.21, as a candidate for
3894 * IPython turns 21! Released version 0.1.21, as a candidate for
3894 public consumption. If all goes well, release in a few days.
3895 public consumption. If all goes well, release in a few days.
3895
3896
3896 * Fixed path bug (files in Extensions/ directory wouldn't be found
3897 * Fixed path bug (files in Extensions/ directory wouldn't be found
3897 unless IPython/ was explicitly in sys.path).
3898 unless IPython/ was explicitly in sys.path).
3898
3899
3899 * Extended the FlexCompleter class as MagicCompleter to allow
3900 * Extended the FlexCompleter class as MagicCompleter to allow
3900 completion of @-starting lines.
3901 completion of @-starting lines.
3901
3902
3902 * Created __release__.py file as a central repository for release
3903 * Created __release__.py file as a central repository for release
3903 info that other files can read from.
3904 info that other files can read from.
3904
3905
3905 * Fixed small bug in logging: when logging was turned on in
3906 * Fixed small bug in logging: when logging was turned on in
3906 mid-session, old lines with special meanings (!@?) were being
3907 mid-session, old lines with special meanings (!@?) were being
3907 logged without the prepended comment, which is necessary since
3908 logged without the prepended comment, which is necessary since
3908 they are not truly valid python syntax. This should make session
3909 they are not truly valid python syntax. This should make session
3909 restores produce less errors.
3910 restores produce less errors.
3910
3911
3911 * The namespace cleanup forced me to make a FlexCompleter class
3912 * The namespace cleanup forced me to make a FlexCompleter class
3912 which is nothing but a ripoff of rlcompleter, but with selectable
3913 which is nothing but a ripoff of rlcompleter, but with selectable
3913 namespace (rlcompleter only works in __main__.__dict__). I'll try
3914 namespace (rlcompleter only works in __main__.__dict__). I'll try
3914 to submit a note to the authors to see if this change can be
3915 to submit a note to the authors to see if this change can be
3915 incorporated in future rlcompleter releases (Dec.6: done)
3916 incorporated in future rlcompleter releases (Dec.6: done)
3916
3917
3917 * More fixes to namespace handling. It was a mess! Now all
3918 * More fixes to namespace handling. It was a mess! Now all
3918 explicit references to __main__.__dict__ are gone (except when
3919 explicit references to __main__.__dict__ are gone (except when
3919 really needed) and everything is handled through the namespace
3920 really needed) and everything is handled through the namespace
3920 dicts in the IPython instance. We seem to be getting somewhere
3921 dicts in the IPython instance. We seem to be getting somewhere
3921 with this, finally...
3922 with this, finally...
3922
3923
3923 * Small documentation updates.
3924 * Small documentation updates.
3924
3925
3925 * Created the Extensions directory under IPython (with an
3926 * Created the Extensions directory under IPython (with an
3926 __init__.py). Put the PhysicalQ stuff there. This directory should
3927 __init__.py). Put the PhysicalQ stuff there. This directory should
3927 be used for all special-purpose extensions.
3928 be used for all special-purpose extensions.
3928
3929
3929 * File renaming:
3930 * File renaming:
3930 ipythonlib --> ipmaker
3931 ipythonlib --> ipmaker
3931 ipplib --> iplib
3932 ipplib --> iplib
3932 This makes a bit more sense in terms of what these files actually do.
3933 This makes a bit more sense in terms of what these files actually do.
3933
3934
3934 * Moved all the classes and functions in ipythonlib to ipplib, so
3935 * Moved all the classes and functions in ipythonlib to ipplib, so
3935 now ipythonlib only has make_IPython(). This will ease up its
3936 now ipythonlib only has make_IPython(). This will ease up its
3936 splitting in smaller functional chunks later.
3937 splitting in smaller functional chunks later.
3937
3938
3938 * Cleaned up (done, I think) output of @whos. Better column
3939 * Cleaned up (done, I think) output of @whos. Better column
3939 formatting, and now shows str(var) for as much as it can, which is
3940 formatting, and now shows str(var) for as much as it can, which is
3940 typically what one gets with a 'print var'.
3941 typically what one gets with a 'print var'.
3941
3942
3942 2001-12-04 Fernando Perez <fperez@colorado.edu>
3943 2001-12-04 Fernando Perez <fperez@colorado.edu>
3943
3944
3944 * Fixed namespace problems. Now builtin/IPyhton/user names get
3945 * Fixed namespace problems. Now builtin/IPyhton/user names get
3945 properly reported in their namespace. Internal namespace handling
3946 properly reported in their namespace. Internal namespace handling
3946 is finally getting decent (not perfect yet, but much better than
3947 is finally getting decent (not perfect yet, but much better than
3947 the ad-hoc mess we had).
3948 the ad-hoc mess we had).
3948
3949
3949 * Removed -exit option. If people just want to run a python
3950 * Removed -exit option. If people just want to run a python
3950 script, that's what the normal interpreter is for. Less
3951 script, that's what the normal interpreter is for. Less
3951 unnecessary options, less chances for bugs.
3952 unnecessary options, less chances for bugs.
3952
3953
3953 * Added a crash handler which generates a complete post-mortem if
3954 * Added a crash handler which generates a complete post-mortem if
3954 IPython crashes. This will help a lot in tracking bugs down the
3955 IPython crashes. This will help a lot in tracking bugs down the
3955 road.
3956 road.
3956
3957
3957 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3958 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
3958 which were boud to functions being reassigned would bypass the
3959 which were boud to functions being reassigned would bypass the
3959 logger, breaking the sync of _il with the prompt counter. This
3960 logger, breaking the sync of _il with the prompt counter. This
3960 would then crash IPython later when a new line was logged.
3961 would then crash IPython later when a new line was logged.
3961
3962
3962 2001-12-02 Fernando Perez <fperez@colorado.edu>
3963 2001-12-02 Fernando Perez <fperez@colorado.edu>
3963
3964
3964 * Made IPython a package. This means people don't have to clutter
3965 * Made IPython a package. This means people don't have to clutter
3965 their sys.path with yet another directory. Changed the INSTALL
3966 their sys.path with yet another directory. Changed the INSTALL
3966 file accordingly.
3967 file accordingly.
3967
3968
3968 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3969 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
3969 sorts its output (so @who shows it sorted) and @whos formats the
3970 sorts its output (so @who shows it sorted) and @whos formats the
3970 table according to the width of the first column. Nicer, easier to
3971 table according to the width of the first column. Nicer, easier to
3971 read. Todo: write a generic table_format() which takes a list of
3972 read. Todo: write a generic table_format() which takes a list of
3972 lists and prints it nicely formatted, with optional row/column
3973 lists and prints it nicely formatted, with optional row/column
3973 separators and proper padding and justification.
3974 separators and proper padding and justification.
3974
3975
3975 * Released 0.1.20
3976 * Released 0.1.20
3976
3977
3977 * Fixed bug in @log which would reverse the inputcache list (a
3978 * Fixed bug in @log which would reverse the inputcache list (a
3978 copy operation was missing).
3979 copy operation was missing).
3979
3980
3980 * Code cleanup. @config was changed to use page(). Better, since
3981 * Code cleanup. @config was changed to use page(). Better, since
3981 its output is always quite long.
3982 its output is always quite long.
3982
3983
3983 * Itpl is back as a dependency. I was having too many problems
3984 * Itpl is back as a dependency. I was having too many problems
3984 getting the parametric aliases to work reliably, and it's just
3985 getting the parametric aliases to work reliably, and it's just
3985 easier to code weird string operations with it than playing %()s
3986 easier to code weird string operations with it than playing %()s
3986 games. It's only ~6k, so I don't think it's too big a deal.
3987 games. It's only ~6k, so I don't think it's too big a deal.
3987
3988
3988 * Found (and fixed) a very nasty bug with history. !lines weren't
3989 * Found (and fixed) a very nasty bug with history. !lines weren't
3989 getting cached, and the out of sync caches would crash
3990 getting cached, and the out of sync caches would crash
3990 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3991 IPython. Fixed it by reorganizing the prefilter/handlers/logger
3991 division of labor a bit better. Bug fixed, cleaner structure.
3992 division of labor a bit better. Bug fixed, cleaner structure.
3992
3993
3993 2001-12-01 Fernando Perez <fperez@colorado.edu>
3994 2001-12-01 Fernando Perez <fperez@colorado.edu>
3994
3995
3995 * Released 0.1.19
3996 * Released 0.1.19
3996
3997
3997 * Added option -n to @hist to prevent line number printing. Much
3998 * Added option -n to @hist to prevent line number printing. Much
3998 easier to copy/paste code this way.
3999 easier to copy/paste code this way.
3999
4000
4000 * Created global _il to hold the input list. Allows easy
4001 * Created global _il to hold the input list. Allows easy
4001 re-execution of blocks of code by slicing it (inspired by Janko's
4002 re-execution of blocks of code by slicing it (inspired by Janko's
4002 comment on 'macros').
4003 comment on 'macros').
4003
4004
4004 * Small fixes and doc updates.
4005 * Small fixes and doc updates.
4005
4006
4006 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4007 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4007 much too fragile with automagic. Handles properly multi-line
4008 much too fragile with automagic. Handles properly multi-line
4008 statements and takes parameters.
4009 statements and takes parameters.
4009
4010
4010 2001-11-30 Fernando Perez <fperez@colorado.edu>
4011 2001-11-30 Fernando Perez <fperez@colorado.edu>
4011
4012
4012 * Version 0.1.18 released.
4013 * Version 0.1.18 released.
4013
4014
4014 * Fixed nasty namespace bug in initial module imports.
4015 * Fixed nasty namespace bug in initial module imports.
4015
4016
4016 * Added copyright/license notes to all code files (except
4017 * Added copyright/license notes to all code files (except
4017 DPyGetOpt). For the time being, LGPL. That could change.
4018 DPyGetOpt). For the time being, LGPL. That could change.
4018
4019
4019 * Rewrote a much nicer README, updated INSTALL, cleaned up
4020 * Rewrote a much nicer README, updated INSTALL, cleaned up
4020 ipythonrc-* samples.
4021 ipythonrc-* samples.
4021
4022
4022 * Overall code/documentation cleanup. Basically ready for
4023 * Overall code/documentation cleanup. Basically ready for
4023 release. Only remaining thing: licence decision (LGPL?).
4024 release. Only remaining thing: licence decision (LGPL?).
4024
4025
4025 * Converted load_config to a class, ConfigLoader. Now recursion
4026 * Converted load_config to a class, ConfigLoader. Now recursion
4026 control is better organized. Doesn't include the same file twice.
4027 control is better organized. Doesn't include the same file twice.
4027
4028
4028 2001-11-29 Fernando Perez <fperez@colorado.edu>
4029 2001-11-29 Fernando Perez <fperez@colorado.edu>
4029
4030
4030 * Got input history working. Changed output history variables from
4031 * Got input history working. Changed output history variables from
4031 _p to _o so that _i is for input and _o for output. Just cleaner
4032 _p to _o so that _i is for input and _o for output. Just cleaner
4032 convention.
4033 convention.
4033
4034
4034 * Implemented parametric aliases. This pretty much allows the
4035 * Implemented parametric aliases. This pretty much allows the
4035 alias system to offer full-blown shell convenience, I think.
4036 alias system to offer full-blown shell convenience, I think.
4036
4037
4037 * Version 0.1.17 released, 0.1.18 opened.
4038 * Version 0.1.17 released, 0.1.18 opened.
4038
4039
4039 * dot_ipython/ipythonrc (alias): added documentation.
4040 * dot_ipython/ipythonrc (alias): added documentation.
4040 (xcolor): Fixed small bug (xcolors -> xcolor)
4041 (xcolor): Fixed small bug (xcolors -> xcolor)
4041
4042
4042 * Changed the alias system. Now alias is a magic command to define
4043 * Changed the alias system. Now alias is a magic command to define
4043 aliases just like the shell. Rationale: the builtin magics should
4044 aliases just like the shell. Rationale: the builtin magics should
4044 be there for things deeply connected to IPython's
4045 be there for things deeply connected to IPython's
4045 architecture. And this is a much lighter system for what I think
4046 architecture. And this is a much lighter system for what I think
4046 is the really important feature: allowing users to define quickly
4047 is the really important feature: allowing users to define quickly
4047 magics that will do shell things for them, so they can customize
4048 magics that will do shell things for them, so they can customize
4048 IPython easily to match their work habits. If someone is really
4049 IPython easily to match their work habits. If someone is really
4049 desperate to have another name for a builtin alias, they can
4050 desperate to have another name for a builtin alias, they can
4050 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4051 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4051 works.
4052 works.
4052
4053
4053 2001-11-28 Fernando Perez <fperez@colorado.edu>
4054 2001-11-28 Fernando Perez <fperez@colorado.edu>
4054
4055
4055 * Changed @file so that it opens the source file at the proper
4056 * Changed @file so that it opens the source file at the proper
4056 line. Since it uses less, if your EDITOR environment is
4057 line. Since it uses less, if your EDITOR environment is
4057 configured, typing v will immediately open your editor of choice
4058 configured, typing v will immediately open your editor of choice
4058 right at the line where the object is defined. Not as quick as
4059 right at the line where the object is defined. Not as quick as
4059 having a direct @edit command, but for all intents and purposes it
4060 having a direct @edit command, but for all intents and purposes it
4060 works. And I don't have to worry about writing @edit to deal with
4061 works. And I don't have to worry about writing @edit to deal with
4061 all the editors, less does that.
4062 all the editors, less does that.
4062
4063
4063 * Version 0.1.16 released, 0.1.17 opened.
4064 * Version 0.1.16 released, 0.1.17 opened.
4064
4065
4065 * Fixed some nasty bugs in the page/page_dumb combo that could
4066 * Fixed some nasty bugs in the page/page_dumb combo that could
4066 crash IPython.
4067 crash IPython.
4067
4068
4068 2001-11-27 Fernando Perez <fperez@colorado.edu>
4069 2001-11-27 Fernando Perez <fperez@colorado.edu>
4069
4070
4070 * Version 0.1.15 released, 0.1.16 opened.
4071 * Version 0.1.15 released, 0.1.16 opened.
4071
4072
4072 * Finally got ? and ?? to work for undefined things: now it's
4073 * Finally got ? and ?? to work for undefined things: now it's
4073 possible to type {}.get? and get information about the get method
4074 possible to type {}.get? and get information about the get method
4074 of dicts, or os.path? even if only os is defined (so technically
4075 of dicts, or os.path? even if only os is defined (so technically
4075 os.path isn't). Works at any level. For example, after import os,
4076 os.path isn't). Works at any level. For example, after import os,
4076 os?, os.path?, os.path.abspath? all work. This is great, took some
4077 os?, os.path?, os.path.abspath? all work. This is great, took some
4077 work in _ofind.
4078 work in _ofind.
4078
4079
4079 * Fixed more bugs with logging. The sanest way to do it was to add
4080 * Fixed more bugs with logging. The sanest way to do it was to add
4080 to @log a 'mode' parameter. Killed two in one shot (this mode
4081 to @log a 'mode' parameter. Killed two in one shot (this mode
4081 option was a request of Janko's). I think it's finally clean
4082 option was a request of Janko's). I think it's finally clean
4082 (famous last words).
4083 (famous last words).
4083
4084
4084 * Added a page_dumb() pager which does a decent job of paging on
4085 * Added a page_dumb() pager which does a decent job of paging on
4085 screen, if better things (like less) aren't available. One less
4086 screen, if better things (like less) aren't available. One less
4086 unix dependency (someday maybe somebody will port this to
4087 unix dependency (someday maybe somebody will port this to
4087 windows).
4088 windows).
4088
4089
4089 * Fixed problem in magic_log: would lock of logging out if log
4090 * Fixed problem in magic_log: would lock of logging out if log
4090 creation failed (because it would still think it had succeeded).
4091 creation failed (because it would still think it had succeeded).
4091
4092
4092 * Improved the page() function using curses to auto-detect screen
4093 * Improved the page() function using curses to auto-detect screen
4093 size. Now it can make a much better decision on whether to print
4094 size. Now it can make a much better decision on whether to print
4094 or page a string. Option screen_length was modified: a value 0
4095 or page a string. Option screen_length was modified: a value 0
4095 means auto-detect, and that's the default now.
4096 means auto-detect, and that's the default now.
4096
4097
4097 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4098 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4098 go out. I'll test it for a few days, then talk to Janko about
4099 go out. I'll test it for a few days, then talk to Janko about
4099 licences and announce it.
4100 licences and announce it.
4100
4101
4101 * Fixed the length of the auto-generated ---> prompt which appears
4102 * Fixed the length of the auto-generated ---> prompt which appears
4102 for auto-parens and auto-quotes. Getting this right isn't trivial,
4103 for auto-parens and auto-quotes. Getting this right isn't trivial,
4103 with all the color escapes, different prompt types and optional
4104 with all the color escapes, different prompt types and optional
4104 separators. But it seems to be working in all the combinations.
4105 separators. But it seems to be working in all the combinations.
4105
4106
4106 2001-11-26 Fernando Perez <fperez@colorado.edu>
4107 2001-11-26 Fernando Perez <fperez@colorado.edu>
4107
4108
4108 * Wrote a regexp filter to get option types from the option names
4109 * Wrote a regexp filter to get option types from the option names
4109 string. This eliminates the need to manually keep two duplicate
4110 string. This eliminates the need to manually keep two duplicate
4110 lists.
4111 lists.
4111
4112
4112 * Removed the unneeded check_option_names. Now options are handled
4113 * Removed the unneeded check_option_names. Now options are handled
4113 in a much saner manner and it's easy to visually check that things
4114 in a much saner manner and it's easy to visually check that things
4114 are ok.
4115 are ok.
4115
4116
4116 * Updated version numbers on all files I modified to carry a
4117 * Updated version numbers on all files I modified to carry a
4117 notice so Janko and Nathan have clear version markers.
4118 notice so Janko and Nathan have clear version markers.
4118
4119
4119 * Updated docstring for ultraTB with my changes. I should send
4120 * Updated docstring for ultraTB with my changes. I should send
4120 this to Nathan.
4121 this to Nathan.
4121
4122
4122 * Lots of small fixes. Ran everything through pychecker again.
4123 * Lots of small fixes. Ran everything through pychecker again.
4123
4124
4124 * Made loading of deep_reload an cmd line option. If it's not too
4125 * Made loading of deep_reload an cmd line option. If it's not too
4125 kosher, now people can just disable it. With -nodeep_reload it's
4126 kosher, now people can just disable it. With -nodeep_reload it's
4126 still available as dreload(), it just won't overwrite reload().
4127 still available as dreload(), it just won't overwrite reload().
4127
4128
4128 * Moved many options to the no| form (-opt and -noopt
4129 * Moved many options to the no| form (-opt and -noopt
4129 accepted). Cleaner.
4130 accepted). Cleaner.
4130
4131
4131 * Changed magic_log so that if called with no parameters, it uses
4132 * Changed magic_log so that if called with no parameters, it uses
4132 'rotate' mode. That way auto-generated logs aren't automatically
4133 'rotate' mode. That way auto-generated logs aren't automatically
4133 over-written. For normal logs, now a backup is made if it exists
4134 over-written. For normal logs, now a backup is made if it exists
4134 (only 1 level of backups). A new 'backup' mode was added to the
4135 (only 1 level of backups). A new 'backup' mode was added to the
4135 Logger class to support this. This was a request by Janko.
4136 Logger class to support this. This was a request by Janko.
4136
4137
4137 * Added @logoff/@logon to stop/restart an active log.
4138 * Added @logoff/@logon to stop/restart an active log.
4138
4139
4139 * Fixed a lot of bugs in log saving/replay. It was pretty
4140 * Fixed a lot of bugs in log saving/replay. It was pretty
4140 broken. Now special lines (!@,/) appear properly in the command
4141 broken. Now special lines (!@,/) appear properly in the command
4141 history after a log replay.
4142 history after a log replay.
4142
4143
4143 * Tried and failed to implement full session saving via pickle. My
4144 * Tried and failed to implement full session saving via pickle. My
4144 idea was to pickle __main__.__dict__, but modules can't be
4145 idea was to pickle __main__.__dict__, but modules can't be
4145 pickled. This would be a better alternative to replaying logs, but
4146 pickled. This would be a better alternative to replaying logs, but
4146 seems quite tricky to get to work. Changed -session to be called
4147 seems quite tricky to get to work. Changed -session to be called
4147 -logplay, which more accurately reflects what it does. And if we
4148 -logplay, which more accurately reflects what it does. And if we
4148 ever get real session saving working, -session is now available.
4149 ever get real session saving working, -session is now available.
4149
4150
4150 * Implemented color schemes for prompts also. As for tracebacks,
4151 * Implemented color schemes for prompts also. As for tracebacks,
4151 currently only NoColor and Linux are supported. But now the
4152 currently only NoColor and Linux are supported. But now the
4152 infrastructure is in place, based on a generic ColorScheme
4153 infrastructure is in place, based on a generic ColorScheme
4153 class. So writing and activating new schemes both for the prompts
4154 class. So writing and activating new schemes both for the prompts
4154 and the tracebacks should be straightforward.
4155 and the tracebacks should be straightforward.
4155
4156
4156 * Version 0.1.13 released, 0.1.14 opened.
4157 * Version 0.1.13 released, 0.1.14 opened.
4157
4158
4158 * Changed handling of options for output cache. Now counter is
4159 * Changed handling of options for output cache. Now counter is
4159 hardwired starting at 1 and one specifies the maximum number of
4160 hardwired starting at 1 and one specifies the maximum number of
4160 entries *in the outcache* (not the max prompt counter). This is
4161 entries *in the outcache* (not the max prompt counter). This is
4161 much better, since many statements won't increase the cache
4162 much better, since many statements won't increase the cache
4162 count. It also eliminated some confusing options, now there's only
4163 count. It also eliminated some confusing options, now there's only
4163 one: cache_size.
4164 one: cache_size.
4164
4165
4165 * Added 'alias' magic function and magic_alias option in the
4166 * Added 'alias' magic function and magic_alias option in the
4166 ipythonrc file. Now the user can easily define whatever names he
4167 ipythonrc file. Now the user can easily define whatever names he
4167 wants for the magic functions without having to play weird
4168 wants for the magic functions without having to play weird
4168 namespace games. This gives IPython a real shell-like feel.
4169 namespace games. This gives IPython a real shell-like feel.
4169
4170
4170 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4171 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4171 @ or not).
4172 @ or not).
4172
4173
4173 This was one of the last remaining 'visible' bugs (that I know
4174 This was one of the last remaining 'visible' bugs (that I know
4174 of). I think if I can clean up the session loading so it works
4175 of). I think if I can clean up the session loading so it works
4175 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4176 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4176 about licensing).
4177 about licensing).
4177
4178
4178 2001-11-25 Fernando Perez <fperez@colorado.edu>
4179 2001-11-25 Fernando Perez <fperez@colorado.edu>
4179
4180
4180 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4181 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4181 there's a cleaner distinction between what ? and ?? show.
4182 there's a cleaner distinction between what ? and ?? show.
4182
4183
4183 * Added screen_length option. Now the user can define his own
4184 * Added screen_length option. Now the user can define his own
4184 screen size for page() operations.
4185 screen size for page() operations.
4185
4186
4186 * Implemented magic shell-like functions with automatic code
4187 * Implemented magic shell-like functions with automatic code
4187 generation. Now adding another function is just a matter of adding
4188 generation. Now adding another function is just a matter of adding
4188 an entry to a dict, and the function is dynamically generated at
4189 an entry to a dict, and the function is dynamically generated at
4189 run-time. Python has some really cool features!
4190 run-time. Python has some really cool features!
4190
4191
4191 * Renamed many options to cleanup conventions a little. Now all
4192 * Renamed many options to cleanup conventions a little. Now all
4192 are lowercase, and only underscores where needed. Also in the code
4193 are lowercase, and only underscores where needed. Also in the code
4193 option name tables are clearer.
4194 option name tables are clearer.
4194
4195
4195 * Changed prompts a little. Now input is 'In [n]:' instead of
4196 * Changed prompts a little. Now input is 'In [n]:' instead of
4196 'In[n]:='. This allows it the numbers to be aligned with the
4197 'In[n]:='. This allows it the numbers to be aligned with the
4197 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4198 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4198 Python (it was a Mathematica thing). The '...' continuation prompt
4199 Python (it was a Mathematica thing). The '...' continuation prompt
4199 was also changed a little to align better.
4200 was also changed a little to align better.
4200
4201
4201 * Fixed bug when flushing output cache. Not all _p<n> variables
4202 * Fixed bug when flushing output cache. Not all _p<n> variables
4202 exist, so their deletion needs to be wrapped in a try:
4203 exist, so their deletion needs to be wrapped in a try:
4203
4204
4204 * Figured out how to properly use inspect.formatargspec() (it
4205 * Figured out how to properly use inspect.formatargspec() (it
4205 requires the args preceded by *). So I removed all the code from
4206 requires the args preceded by *). So I removed all the code from
4206 _get_pdef in Magic, which was just replicating that.
4207 _get_pdef in Magic, which was just replicating that.
4207
4208
4208 * Added test to prefilter to allow redefining magic function names
4209 * Added test to prefilter to allow redefining magic function names
4209 as variables. This is ok, since the @ form is always available,
4210 as variables. This is ok, since the @ form is always available,
4210 but whe should allow the user to define a variable called 'ls' if
4211 but whe should allow the user to define a variable called 'ls' if
4211 he needs it.
4212 he needs it.
4212
4213
4213 * Moved the ToDo information from README into a separate ToDo.
4214 * Moved the ToDo information from README into a separate ToDo.
4214
4215
4215 * General code cleanup and small bugfixes. I think it's close to a
4216 * General code cleanup and small bugfixes. I think it's close to a
4216 state where it can be released, obviously with a big 'beta'
4217 state where it can be released, obviously with a big 'beta'
4217 warning on it.
4218 warning on it.
4218
4219
4219 * Got the magic function split to work. Now all magics are defined
4220 * Got the magic function split to work. Now all magics are defined
4220 in a separate class. It just organizes things a bit, and now
4221 in a separate class. It just organizes things a bit, and now
4221 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4222 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4222 was too long).
4223 was too long).
4223
4224
4224 * Changed @clear to @reset to avoid potential confusions with
4225 * Changed @clear to @reset to avoid potential confusions with
4225 the shell command clear. Also renamed @cl to @clear, which does
4226 the shell command clear. Also renamed @cl to @clear, which does
4226 exactly what people expect it to from their shell experience.
4227 exactly what people expect it to from their shell experience.
4227
4228
4228 Added a check to the @reset command (since it's so
4229 Added a check to the @reset command (since it's so
4229 destructive, it's probably a good idea to ask for confirmation).
4230 destructive, it's probably a good idea to ask for confirmation).
4230 But now reset only works for full namespace resetting. Since the
4231 But now reset only works for full namespace resetting. Since the
4231 del keyword is already there for deleting a few specific
4232 del keyword is already there for deleting a few specific
4232 variables, I don't see the point of having a redundant magic
4233 variables, I don't see the point of having a redundant magic
4233 function for the same task.
4234 function for the same task.
4234
4235
4235 2001-11-24 Fernando Perez <fperez@colorado.edu>
4236 2001-11-24 Fernando Perez <fperez@colorado.edu>
4236
4237
4237 * Updated the builtin docs (esp. the ? ones).
4238 * Updated the builtin docs (esp. the ? ones).
4238
4239
4239 * Ran all the code through pychecker. Not terribly impressed with
4240 * Ran all the code through pychecker. Not terribly impressed with
4240 it: lots of spurious warnings and didn't really find anything of
4241 it: lots of spurious warnings and didn't really find anything of
4241 substance (just a few modules being imported and not used).
4242 substance (just a few modules being imported and not used).
4242
4243
4243 * Implemented the new ultraTB functionality into IPython. New
4244 * Implemented the new ultraTB functionality into IPython. New
4244 option: xcolors. This chooses color scheme. xmode now only selects
4245 option: xcolors. This chooses color scheme. xmode now only selects
4245 between Plain and Verbose. Better orthogonality.
4246 between Plain and Verbose. Better orthogonality.
4246
4247
4247 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4248 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4248 mode and color scheme for the exception handlers. Now it's
4249 mode and color scheme for the exception handlers. Now it's
4249 possible to have the verbose traceback with no coloring.
4250 possible to have the verbose traceback with no coloring.
4250
4251
4251 2001-11-23 Fernando Perez <fperez@colorado.edu>
4252 2001-11-23 Fernando Perez <fperez@colorado.edu>
4252
4253
4253 * Version 0.1.12 released, 0.1.13 opened.
4254 * Version 0.1.12 released, 0.1.13 opened.
4254
4255
4255 * Removed option to set auto-quote and auto-paren escapes by
4256 * Removed option to set auto-quote and auto-paren escapes by
4256 user. The chances of breaking valid syntax are just too high. If
4257 user. The chances of breaking valid syntax are just too high. If
4257 someone *really* wants, they can always dig into the code.
4258 someone *really* wants, they can always dig into the code.
4258
4259
4259 * Made prompt separators configurable.
4260 * Made prompt separators configurable.
4260
4261
4261 2001-11-22 Fernando Perez <fperez@colorado.edu>
4262 2001-11-22 Fernando Perez <fperez@colorado.edu>
4262
4263
4263 * Small bugfixes in many places.
4264 * Small bugfixes in many places.
4264
4265
4265 * Removed the MyCompleter class from ipplib. It seemed redundant
4266 * Removed the MyCompleter class from ipplib. It seemed redundant
4266 with the C-p,C-n history search functionality. Less code to
4267 with the C-p,C-n history search functionality. Less code to
4267 maintain.
4268 maintain.
4268
4269
4269 * Moved all the original ipython.py code into ipythonlib.py. Right
4270 * Moved all the original ipython.py code into ipythonlib.py. Right
4270 now it's just one big dump into a function called make_IPython, so
4271 now it's just one big dump into a function called make_IPython, so
4271 no real modularity has been gained. But at least it makes the
4272 no real modularity has been gained. But at least it makes the
4272 wrapper script tiny, and since ipythonlib is a module, it gets
4273 wrapper script tiny, and since ipythonlib is a module, it gets
4273 compiled and startup is much faster.
4274 compiled and startup is much faster.
4274
4275
4275 This is a reasobably 'deep' change, so we should test it for a
4276 This is a reasobably 'deep' change, so we should test it for a
4276 while without messing too much more with the code.
4277 while without messing too much more with the code.
4277
4278
4278 2001-11-21 Fernando Perez <fperez@colorado.edu>
4279 2001-11-21 Fernando Perez <fperez@colorado.edu>
4279
4280
4280 * Version 0.1.11 released, 0.1.12 opened for further work.
4281 * Version 0.1.11 released, 0.1.12 opened for further work.
4281
4282
4282 * Removed dependency on Itpl. It was only needed in one place. It
4283 * Removed dependency on Itpl. It was only needed in one place. It
4283 would be nice if this became part of python, though. It makes life
4284 would be nice if this became part of python, though. It makes life
4284 *a lot* easier in some cases.
4285 *a lot* easier in some cases.
4285
4286
4286 * Simplified the prefilter code a bit. Now all handlers are
4287 * Simplified the prefilter code a bit. Now all handlers are
4287 expected to explicitly return a value (at least a blank string).
4288 expected to explicitly return a value (at least a blank string).
4288
4289
4289 * Heavy edits in ipplib. Removed the help system altogether. Now
4290 * Heavy edits in ipplib. Removed the help system altogether. Now
4290 obj?/?? is used for inspecting objects, a magic @doc prints
4291 obj?/?? is used for inspecting objects, a magic @doc prints
4291 docstrings, and full-blown Python help is accessed via the 'help'
4292 docstrings, and full-blown Python help is accessed via the 'help'
4292 keyword. This cleans up a lot of code (less to maintain) and does
4293 keyword. This cleans up a lot of code (less to maintain) and does
4293 the job. Since 'help' is now a standard Python component, might as
4294 the job. Since 'help' is now a standard Python component, might as
4294 well use it and remove duplicate functionality.
4295 well use it and remove duplicate functionality.
4295
4296
4296 Also removed the option to use ipplib as a standalone program. By
4297 Also removed the option to use ipplib as a standalone program. By
4297 now it's too dependent on other parts of IPython to function alone.
4298 now it's too dependent on other parts of IPython to function alone.
4298
4299
4299 * Fixed bug in genutils.pager. It would crash if the pager was
4300 * Fixed bug in genutils.pager. It would crash if the pager was
4300 exited immediately after opening (broken pipe).
4301 exited immediately after opening (broken pipe).
4301
4302
4302 * Trimmed down the VerboseTB reporting a little. The header is
4303 * Trimmed down the VerboseTB reporting a little. The header is
4303 much shorter now and the repeated exception arguments at the end
4304 much shorter now and the repeated exception arguments at the end
4304 have been removed. For interactive use the old header seemed a bit
4305 have been removed. For interactive use the old header seemed a bit
4305 excessive.
4306 excessive.
4306
4307
4307 * Fixed small bug in output of @whos for variables with multi-word
4308 * Fixed small bug in output of @whos for variables with multi-word
4308 types (only first word was displayed).
4309 types (only first word was displayed).
4309
4310
4310 2001-11-17 Fernando Perez <fperez@colorado.edu>
4311 2001-11-17 Fernando Perez <fperez@colorado.edu>
4311
4312
4312 * Version 0.1.10 released, 0.1.11 opened for further work.
4313 * Version 0.1.10 released, 0.1.11 opened for further work.
4313
4314
4314 * Modified dirs and friends. dirs now *returns* the stack (not
4315 * Modified dirs and friends. dirs now *returns* the stack (not
4315 prints), so one can manipulate it as a variable. Convenient to
4316 prints), so one can manipulate it as a variable. Convenient to
4316 travel along many directories.
4317 travel along many directories.
4317
4318
4318 * Fixed bug in magic_pdef: would only work with functions with
4319 * Fixed bug in magic_pdef: would only work with functions with
4319 arguments with default values.
4320 arguments with default values.
4320
4321
4321 2001-11-14 Fernando Perez <fperez@colorado.edu>
4322 2001-11-14 Fernando Perez <fperez@colorado.edu>
4322
4323
4323 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4324 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4324 example with IPython. Various other minor fixes and cleanups.
4325 example with IPython. Various other minor fixes and cleanups.
4325
4326
4326 * Version 0.1.9 released, 0.1.10 opened for further work.
4327 * Version 0.1.9 released, 0.1.10 opened for further work.
4327
4328
4328 * Added sys.path to the list of directories searched in the
4329 * Added sys.path to the list of directories searched in the
4329 execfile= option. It used to be the current directory and the
4330 execfile= option. It used to be the current directory and the
4330 user's IPYTHONDIR only.
4331 user's IPYTHONDIR only.
4331
4332
4332 2001-11-13 Fernando Perez <fperez@colorado.edu>
4333 2001-11-13 Fernando Perez <fperez@colorado.edu>
4333
4334
4334 * Reinstated the raw_input/prefilter separation that Janko had
4335 * Reinstated the raw_input/prefilter separation that Janko had
4335 initially. This gives a more convenient setup for extending the
4336 initially. This gives a more convenient setup for extending the
4336 pre-processor from the outside: raw_input always gets a string,
4337 pre-processor from the outside: raw_input always gets a string,
4337 and prefilter has to process it. We can then redefine prefilter
4338 and prefilter has to process it. We can then redefine prefilter
4338 from the outside and implement extensions for special
4339 from the outside and implement extensions for special
4339 purposes.
4340 purposes.
4340
4341
4341 Today I got one for inputting PhysicalQuantity objects
4342 Today I got one for inputting PhysicalQuantity objects
4342 (from Scientific) without needing any function calls at
4343 (from Scientific) without needing any function calls at
4343 all. Extremely convenient, and it's all done as a user-level
4344 all. Extremely convenient, and it's all done as a user-level
4344 extension (no IPython code was touched). Now instead of:
4345 extension (no IPython code was touched). Now instead of:
4345 a = PhysicalQuantity(4.2,'m/s**2')
4346 a = PhysicalQuantity(4.2,'m/s**2')
4346 one can simply say
4347 one can simply say
4347 a = 4.2 m/s**2
4348 a = 4.2 m/s**2
4348 or even
4349 or even
4349 a = 4.2 m/s^2
4350 a = 4.2 m/s^2
4350
4351
4351 I use this, but it's also a proof of concept: IPython really is
4352 I use this, but it's also a proof of concept: IPython really is
4352 fully user-extensible, even at the level of the parsing of the
4353 fully user-extensible, even at the level of the parsing of the
4353 command line. It's not trivial, but it's perfectly doable.
4354 command line. It's not trivial, but it's perfectly doable.
4354
4355
4355 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4356 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4356 the problem of modules being loaded in the inverse order in which
4357 the problem of modules being loaded in the inverse order in which
4357 they were defined in
4358 they were defined in
4358
4359
4359 * Version 0.1.8 released, 0.1.9 opened for further work.
4360 * Version 0.1.8 released, 0.1.9 opened for further work.
4360
4361
4361 * Added magics pdef, source and file. They respectively show the
4362 * Added magics pdef, source and file. They respectively show the
4362 definition line ('prototype' in C), source code and full python
4363 definition line ('prototype' in C), source code and full python
4363 file for any callable object. The object inspector oinfo uses
4364 file for any callable object. The object inspector oinfo uses
4364 these to show the same information.
4365 these to show the same information.
4365
4366
4366 * Version 0.1.7 released, 0.1.8 opened for further work.
4367 * Version 0.1.7 released, 0.1.8 opened for further work.
4367
4368
4368 * Separated all the magic functions into a class called Magic. The
4369 * Separated all the magic functions into a class called Magic. The
4369 InteractiveShell class was becoming too big for Xemacs to handle
4370 InteractiveShell class was becoming too big for Xemacs to handle
4370 (de-indenting a line would lock it up for 10 seconds while it
4371 (de-indenting a line would lock it up for 10 seconds while it
4371 backtracked on the whole class!)
4372 backtracked on the whole class!)
4372
4373
4373 FIXME: didn't work. It can be done, but right now namespaces are
4374 FIXME: didn't work. It can be done, but right now namespaces are
4374 all messed up. Do it later (reverted it for now, so at least
4375 all messed up. Do it later (reverted it for now, so at least
4375 everything works as before).
4376 everything works as before).
4376
4377
4377 * Got the object introspection system (magic_oinfo) working! I
4378 * Got the object introspection system (magic_oinfo) working! I
4378 think this is pretty much ready for release to Janko, so he can
4379 think this is pretty much ready for release to Janko, so he can
4379 test it for a while and then announce it. Pretty much 100% of what
4380 test it for a while and then announce it. Pretty much 100% of what
4380 I wanted for the 'phase 1' release is ready. Happy, tired.
4381 I wanted for the 'phase 1' release is ready. Happy, tired.
4381
4382
4382 2001-11-12 Fernando Perez <fperez@colorado.edu>
4383 2001-11-12 Fernando Perez <fperez@colorado.edu>
4383
4384
4384 * Version 0.1.6 released, 0.1.7 opened for further work.
4385 * Version 0.1.6 released, 0.1.7 opened for further work.
4385
4386
4386 * Fixed bug in printing: it used to test for truth before
4387 * Fixed bug in printing: it used to test for truth before
4387 printing, so 0 wouldn't print. Now checks for None.
4388 printing, so 0 wouldn't print. Now checks for None.
4388
4389
4389 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4390 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4390 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4391 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4391 reaches by hand into the outputcache. Think of a better way to do
4392 reaches by hand into the outputcache. Think of a better way to do
4392 this later.
4393 this later.
4393
4394
4394 * Various small fixes thanks to Nathan's comments.
4395 * Various small fixes thanks to Nathan's comments.
4395
4396
4396 * Changed magic_pprint to magic_Pprint. This way it doesn't
4397 * Changed magic_pprint to magic_Pprint. This way it doesn't
4397 collide with pprint() and the name is consistent with the command
4398 collide with pprint() and the name is consistent with the command
4398 line option.
4399 line option.
4399
4400
4400 * Changed prompt counter behavior to be fully like
4401 * Changed prompt counter behavior to be fully like
4401 Mathematica's. That is, even input that doesn't return a result
4402 Mathematica's. That is, even input that doesn't return a result
4402 raises the prompt counter. The old behavior was kind of confusing
4403 raises the prompt counter. The old behavior was kind of confusing
4403 (getting the same prompt number several times if the operation
4404 (getting the same prompt number several times if the operation
4404 didn't return a result).
4405 didn't return a result).
4405
4406
4406 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4407 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4407
4408
4408 * Fixed -Classic mode (wasn't working anymore).
4409 * Fixed -Classic mode (wasn't working anymore).
4409
4410
4410 * Added colored prompts using Nathan's new code. Colors are
4411 * Added colored prompts using Nathan's new code. Colors are
4411 currently hardwired, they can be user-configurable. For
4412 currently hardwired, they can be user-configurable. For
4412 developers, they can be chosen in file ipythonlib.py, at the
4413 developers, they can be chosen in file ipythonlib.py, at the
4413 beginning of the CachedOutput class def.
4414 beginning of the CachedOutput class def.
4414
4415
4415 2001-11-11 Fernando Perez <fperez@colorado.edu>
4416 2001-11-11 Fernando Perez <fperez@colorado.edu>
4416
4417
4417 * Version 0.1.5 released, 0.1.6 opened for further work.
4418 * Version 0.1.5 released, 0.1.6 opened for further work.
4418
4419
4419 * Changed magic_env to *return* the environment as a dict (not to
4420 * Changed magic_env to *return* the environment as a dict (not to
4420 print it). This way it prints, but it can also be processed.
4421 print it). This way it prints, but it can also be processed.
4421
4422
4422 * Added Verbose exception reporting to interactive
4423 * Added Verbose exception reporting to interactive
4423 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4424 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4424 traceback. Had to make some changes to the ultraTB file. This is
4425 traceback. Had to make some changes to the ultraTB file. This is
4425 probably the last 'big' thing in my mental todo list. This ties
4426 probably the last 'big' thing in my mental todo list. This ties
4426 in with the next entry:
4427 in with the next entry:
4427
4428
4428 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4429 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4429 has to specify is Plain, Color or Verbose for all exception
4430 has to specify is Plain, Color or Verbose for all exception
4430 handling.
4431 handling.
4431
4432
4432 * Removed ShellServices option. All this can really be done via
4433 * Removed ShellServices option. All this can really be done via
4433 the magic system. It's easier to extend, cleaner and has automatic
4434 the magic system. It's easier to extend, cleaner and has automatic
4434 namespace protection and documentation.
4435 namespace protection and documentation.
4435
4436
4436 2001-11-09 Fernando Perez <fperez@colorado.edu>
4437 2001-11-09 Fernando Perez <fperez@colorado.edu>
4437
4438
4438 * Fixed bug in output cache flushing (missing parameter to
4439 * Fixed bug in output cache flushing (missing parameter to
4439 __init__). Other small bugs fixed (found using pychecker).
4440 __init__). Other small bugs fixed (found using pychecker).
4440
4441
4441 * Version 0.1.4 opened for bugfixing.
4442 * Version 0.1.4 opened for bugfixing.
4442
4443
4443 2001-11-07 Fernando Perez <fperez@colorado.edu>
4444 2001-11-07 Fernando Perez <fperez@colorado.edu>
4444
4445
4445 * Version 0.1.3 released, mainly because of the raw_input bug.
4446 * Version 0.1.3 released, mainly because of the raw_input bug.
4446
4447
4447 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4448 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4448 and when testing for whether things were callable, a call could
4449 and when testing for whether things were callable, a call could
4449 actually be made to certain functions. They would get called again
4450 actually be made to certain functions. They would get called again
4450 once 'really' executed, with a resulting double call. A disaster
4451 once 'really' executed, with a resulting double call. A disaster
4451 in many cases (list.reverse() would never work!).
4452 in many cases (list.reverse() would never work!).
4452
4453
4453 * Removed prefilter() function, moved its code to raw_input (which
4454 * Removed prefilter() function, moved its code to raw_input (which
4454 after all was just a near-empty caller for prefilter). This saves
4455 after all was just a near-empty caller for prefilter). This saves
4455 a function call on every prompt, and simplifies the class a tiny bit.
4456 a function call on every prompt, and simplifies the class a tiny bit.
4456
4457
4457 * Fix _ip to __ip name in magic example file.
4458 * Fix _ip to __ip name in magic example file.
4458
4459
4459 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4460 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4460 work with non-gnu versions of tar.
4461 work with non-gnu versions of tar.
4461
4462
4462 2001-11-06 Fernando Perez <fperez@colorado.edu>
4463 2001-11-06 Fernando Perez <fperez@colorado.edu>
4463
4464
4464 * Version 0.1.2. Just to keep track of the recent changes.
4465 * Version 0.1.2. Just to keep track of the recent changes.
4465
4466
4466 * Fixed nasty bug in output prompt routine. It used to check 'if
4467 * Fixed nasty bug in output prompt routine. It used to check 'if
4467 arg != None...'. Problem is, this fails if arg implements a
4468 arg != None...'. Problem is, this fails if arg implements a
4468 special comparison (__cmp__) which disallows comparing to
4469 special comparison (__cmp__) which disallows comparing to
4469 None. Found it when trying to use the PhysicalQuantity module from
4470 None. Found it when trying to use the PhysicalQuantity module from
4470 ScientificPython.
4471 ScientificPython.
4471
4472
4472 2001-11-05 Fernando Perez <fperez@colorado.edu>
4473 2001-11-05 Fernando Perez <fperez@colorado.edu>
4473
4474
4474 * Also added dirs. Now the pushd/popd/dirs family functions
4475 * Also added dirs. Now the pushd/popd/dirs family functions
4475 basically like the shell, with the added convenience of going home
4476 basically like the shell, with the added convenience of going home
4476 when called with no args.
4477 when called with no args.
4477
4478
4478 * pushd/popd slightly modified to mimic shell behavior more
4479 * pushd/popd slightly modified to mimic shell behavior more
4479 closely.
4480 closely.
4480
4481
4481 * Added env,pushd,popd from ShellServices as magic functions. I
4482 * Added env,pushd,popd from ShellServices as magic functions. I
4482 think the cleanest will be to port all desired functions from
4483 think the cleanest will be to port all desired functions from
4483 ShellServices as magics and remove ShellServices altogether. This
4484 ShellServices as magics and remove ShellServices altogether. This
4484 will provide a single, clean way of adding functionality
4485 will provide a single, clean way of adding functionality
4485 (shell-type or otherwise) to IP.
4486 (shell-type or otherwise) to IP.
4486
4487
4487 2001-11-04 Fernando Perez <fperez@colorado.edu>
4488 2001-11-04 Fernando Perez <fperez@colorado.edu>
4488
4489
4489 * Added .ipython/ directory to sys.path. This way users can keep
4490 * Added .ipython/ directory to sys.path. This way users can keep
4490 customizations there and access them via import.
4491 customizations there and access them via import.
4491
4492
4492 2001-11-03 Fernando Perez <fperez@colorado.edu>
4493 2001-11-03 Fernando Perez <fperez@colorado.edu>
4493
4494
4494 * Opened version 0.1.1 for new changes.
4495 * Opened version 0.1.1 for new changes.
4495
4496
4496 * Changed version number to 0.1.0: first 'public' release, sent to
4497 * Changed version number to 0.1.0: first 'public' release, sent to
4497 Nathan and Janko.
4498 Nathan and Janko.
4498
4499
4499 * Lots of small fixes and tweaks.
4500 * Lots of small fixes and tweaks.
4500
4501
4501 * Minor changes to whos format. Now strings are shown, snipped if
4502 * Minor changes to whos format. Now strings are shown, snipped if
4502 too long.
4503 too long.
4503
4504
4504 * Changed ShellServices to work on __main__ so they show up in @who
4505 * Changed ShellServices to work on __main__ so they show up in @who
4505
4506
4506 * Help also works with ? at the end of a line:
4507 * Help also works with ? at the end of a line:
4507 ?sin and sin?
4508 ?sin and sin?
4508 both produce the same effect. This is nice, as often I use the
4509 both produce the same effect. This is nice, as often I use the
4509 tab-complete to find the name of a method, but I used to then have
4510 tab-complete to find the name of a method, but I used to then have
4510 to go to the beginning of the line to put a ? if I wanted more
4511 to go to the beginning of the line to put a ? if I wanted more
4511 info. Now I can just add the ? and hit return. Convenient.
4512 info. Now I can just add the ? and hit return. Convenient.
4512
4513
4513 2001-11-02 Fernando Perez <fperez@colorado.edu>
4514 2001-11-02 Fernando Perez <fperez@colorado.edu>
4514
4515
4515 * Python version check (>=2.1) added.
4516 * Python version check (>=2.1) added.
4516
4517
4517 * Added LazyPython documentation. At this point the docs are quite
4518 * Added LazyPython documentation. At this point the docs are quite
4518 a mess. A cleanup is in order.
4519 a mess. A cleanup is in order.
4519
4520
4520 * Auto-installer created. For some bizarre reason, the zipfiles
4521 * Auto-installer created. For some bizarre reason, the zipfiles
4521 module isn't working on my system. So I made a tar version
4522 module isn't working on my system. So I made a tar version
4522 (hopefully the command line options in various systems won't kill
4523 (hopefully the command line options in various systems won't kill
4523 me).
4524 me).
4524
4525
4525 * Fixes to Struct in genutils. Now all dictionary-like methods are
4526 * Fixes to Struct in genutils. Now all dictionary-like methods are
4526 protected (reasonably).
4527 protected (reasonably).
4527
4528
4528 * Added pager function to genutils and changed ? to print usage
4529 * Added pager function to genutils and changed ? to print usage
4529 note through it (it was too long).
4530 note through it (it was too long).
4530
4531
4531 * Added the LazyPython functionality. Works great! I changed the
4532 * Added the LazyPython functionality. Works great! I changed the
4532 auto-quote escape to ';', it's on home row and next to '. But
4533 auto-quote escape to ';', it's on home row and next to '. But
4533 both auto-quote and auto-paren (still /) escapes are command-line
4534 both auto-quote and auto-paren (still /) escapes are command-line
4534 parameters.
4535 parameters.
4535
4536
4536
4537
4537 2001-11-01 Fernando Perez <fperez@colorado.edu>
4538 2001-11-01 Fernando Perez <fperez@colorado.edu>
4538
4539
4539 * Version changed to 0.0.7. Fairly large change: configuration now
4540 * Version changed to 0.0.7. Fairly large change: configuration now
4540 is all stored in a directory, by default .ipython. There, all
4541 is all stored in a directory, by default .ipython. There, all
4541 config files have normal looking names (not .names)
4542 config files have normal looking names (not .names)
4542
4543
4543 * Version 0.0.6 Released first to Lucas and Archie as a test
4544 * Version 0.0.6 Released first to Lucas and Archie as a test
4544 run. Since it's the first 'semi-public' release, change version to
4545 run. Since it's the first 'semi-public' release, change version to
4545 > 0.0.6 for any changes now.
4546 > 0.0.6 for any changes now.
4546
4547
4547 * Stuff I had put in the ipplib.py changelog:
4548 * Stuff I had put in the ipplib.py changelog:
4548
4549
4549 Changes to InteractiveShell:
4550 Changes to InteractiveShell:
4550
4551
4551 - Made the usage message a parameter.
4552 - Made the usage message a parameter.
4552
4553
4553 - Require the name of the shell variable to be given. It's a bit
4554 - Require the name of the shell variable to be given. It's a bit
4554 of a hack, but allows the name 'shell' not to be hardwire in the
4555 of a hack, but allows the name 'shell' not to be hardwire in the
4555 magic (@) handler, which is problematic b/c it requires
4556 magic (@) handler, which is problematic b/c it requires
4556 polluting the global namespace with 'shell'. This in turn is
4557 polluting the global namespace with 'shell'. This in turn is
4557 fragile: if a user redefines a variable called shell, things
4558 fragile: if a user redefines a variable called shell, things
4558 break.
4559 break.
4559
4560
4560 - magic @: all functions available through @ need to be defined
4561 - magic @: all functions available through @ need to be defined
4561 as magic_<name>, even though they can be called simply as
4562 as magic_<name>, even though they can be called simply as
4562 @<name>. This allows the special command @magic to gather
4563 @<name>. This allows the special command @magic to gather
4563 information automatically about all existing magic functions,
4564 information automatically about all existing magic functions,
4564 even if they are run-time user extensions, by parsing the shell
4565 even if they are run-time user extensions, by parsing the shell
4565 instance __dict__ looking for special magic_ names.
4566 instance __dict__ looking for special magic_ names.
4566
4567
4567 - mainloop: added *two* local namespace parameters. This allows
4568 - mainloop: added *two* local namespace parameters. This allows
4568 the class to differentiate between parameters which were there
4569 the class to differentiate between parameters which were there
4569 before and after command line initialization was processed. This
4570 before and after command line initialization was processed. This
4570 way, later @who can show things loaded at startup by the
4571 way, later @who can show things loaded at startup by the
4571 user. This trick was necessary to make session saving/reloading
4572 user. This trick was necessary to make session saving/reloading
4572 really work: ideally after saving/exiting/reloading a session,
4573 really work: ideally after saving/exiting/reloading a session,
4573 *everythin* should look the same, including the output of @who. I
4574 *everythin* should look the same, including the output of @who. I
4574 was only able to make this work with this double namespace
4575 was only able to make this work with this double namespace
4575 trick.
4576 trick.
4576
4577
4577 - added a header to the logfile which allows (almost) full
4578 - added a header to the logfile which allows (almost) full
4578 session restoring.
4579 session restoring.
4579
4580
4580 - prepend lines beginning with @ or !, with a and log
4581 - prepend lines beginning with @ or !, with a and log
4581 them. Why? !lines: may be useful to know what you did @lines:
4582 them. Why? !lines: may be useful to know what you did @lines:
4582 they may affect session state. So when restoring a session, at
4583 they may affect session state. So when restoring a session, at
4583 least inform the user of their presence. I couldn't quite get
4584 least inform the user of their presence. I couldn't quite get
4584 them to properly re-execute, but at least the user is warned.
4585 them to properly re-execute, but at least the user is warned.
4585
4586
4586 * Started ChangeLog.
4587 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now