Show More
@@ -1,887 +1,886 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 |
|
7 | $Id: Shell.py 703 2005-08-16 17:34:44Z 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 sys |
|
23 | import sys | |
24 | import os |
|
24 | import os | |
25 | import code |
|
25 | import code | |
26 | import threading |
|
26 | import threading | |
27 | import signal |
|
27 | import signal | |
28 |
|
28 | |||
29 | import IPython |
|
29 | import IPython | |
30 | from IPython.iplib import InteractiveShell |
|
30 | from IPython.iplib import InteractiveShell | |
31 | from IPython.ipmaker import make_IPython |
|
31 | from IPython.ipmaker import make_IPython | |
32 | from IPython.genutils import Term,warn,error,flag_calls |
|
32 | from IPython.genutils import Term,warn,error,flag_calls | |
33 | from IPython.Struct import Struct |
|
33 | from IPython.Struct import Struct | |
34 | from IPython.Magic import Magic |
|
34 | from IPython.Magic import Magic | |
35 | from IPython import ultraTB |
|
35 | from IPython import ultraTB | |
36 |
|
36 | |||
37 | # global flag to pass around information about Ctrl-C without exceptions |
|
37 | # global flag to pass around information about Ctrl-C without exceptions | |
38 | KBINT = False |
|
38 | KBINT = False | |
39 |
|
39 | |||
40 | # global flag to turn on/off Tk support. |
|
40 | # global flag to turn on/off Tk support. | |
41 | USE_TK = False |
|
41 | USE_TK = False | |
42 |
|
42 | |||
43 | #----------------------------------------------------------------------------- |
|
43 | #----------------------------------------------------------------------------- | |
44 | # This class is trivial now, but I want to have it in to publish a clean |
|
44 | # This class is trivial now, but I want to have it in to publish a clean | |
45 | # interface. Later when the internals are reorganized, code that uses this |
|
45 | # interface. Later when the internals are reorganized, code that uses this | |
46 | # shouldn't have to change. |
|
46 | # shouldn't have to change. | |
47 |
|
47 | |||
48 | class IPShell: |
|
48 | class IPShell: | |
49 | """Create an IPython instance.""" |
|
49 | """Create an IPython instance.""" | |
50 |
|
50 | |||
51 | def __init__(self,argv=None,user_ns=None,debug=1, |
|
51 | def __init__(self,argv=None,user_ns=None,debug=1, | |
52 | shell_class=InteractiveShell): |
|
52 | shell_class=InteractiveShell): | |
53 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, |
|
53 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, | |
54 | shell_class=shell_class) |
|
54 | shell_class=shell_class) | |
55 |
|
55 | |||
56 | def mainloop(self,sys_exit=0,banner=None): |
|
56 | def mainloop(self,sys_exit=0,banner=None): | |
57 | self.IP.mainloop(banner) |
|
57 | self.IP.mainloop(banner) | |
58 | if sys_exit: |
|
58 | if sys_exit: | |
59 | sys.exit() |
|
59 | sys.exit() | |
60 |
|
60 | |||
61 | #----------------------------------------------------------------------------- |
|
61 | #----------------------------------------------------------------------------- | |
62 | class IPShellEmbed: |
|
62 | class IPShellEmbed: | |
63 | """Allow embedding an IPython shell into a running program. |
|
63 | """Allow embedding an IPython shell into a running program. | |
64 |
|
64 | |||
65 | Instances of this class are callable, with the __call__ method being an |
|
65 | Instances of this class are callable, with the __call__ method being an | |
66 | alias to the embed() method of an InteractiveShell instance. |
|
66 | alias to the embed() method of an InteractiveShell instance. | |
67 |
|
67 | |||
68 | Usage (see also the example-embed.py file for a running example): |
|
68 | Usage (see also the example-embed.py file for a running example): | |
69 |
|
69 | |||
70 | ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override]) |
|
70 | ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override]) | |
71 |
|
71 | |||
72 | - argv: list containing valid command-line options for IPython, as they |
|
72 | - argv: list containing valid command-line options for IPython, as they | |
73 | would appear in sys.argv[1:]. |
|
73 | would appear in sys.argv[1:]. | |
74 |
|
74 | |||
75 | For example, the following command-line options: |
|
75 | For example, the following command-line options: | |
76 |
|
76 | |||
77 | $ ipython -prompt_in1 'Input <\\#>' -colors LightBG |
|
77 | $ ipython -prompt_in1 'Input <\\#>' -colors LightBG | |
78 |
|
78 | |||
79 | would be passed in the argv list as: |
|
79 | would be passed in the argv list as: | |
80 |
|
80 | |||
81 | ['-prompt_in1','Input <\\#>','-colors','LightBG'] |
|
81 | ['-prompt_in1','Input <\\#>','-colors','LightBG'] | |
82 |
|
82 | |||
83 | - banner: string which gets printed every time the interpreter starts. |
|
83 | - banner: string which gets printed every time the interpreter starts. | |
84 |
|
84 | |||
85 | - exit_msg: string which gets printed every time the interpreter exits. |
|
85 | - exit_msg: string which gets printed every time the interpreter exits. | |
86 |
|
86 | |||
87 | - rc_override: a dict or Struct of configuration options such as those |
|
87 | - rc_override: a dict or Struct of configuration options such as those | |
88 | used by IPython. These options are read from your ~/.ipython/ipythonrc |
|
88 | used by IPython. These options are read from your ~/.ipython/ipythonrc | |
89 | file when the Shell object is created. Passing an explicit rc_override |
|
89 | file when the Shell object is created. Passing an explicit rc_override | |
90 | dict with any options you want allows you to override those values at |
|
90 | dict with any options you want allows you to override those values at | |
91 | creation time without having to modify the file. This way you can create |
|
91 | creation time without having to modify the file. This way you can create | |
92 | embeddable instances configured in any way you want without editing any |
|
92 | embeddable instances configured in any way you want without editing any | |
93 | global files (thus keeping your interactive IPython configuration |
|
93 | global files (thus keeping your interactive IPython configuration | |
94 | unchanged). |
|
94 | unchanged). | |
95 |
|
95 | |||
96 | Then the ipshell instance can be called anywhere inside your code: |
|
96 | Then the ipshell instance can be called anywhere inside your code: | |
97 |
|
97 | |||
98 | ipshell(header='') -> Opens up an IPython shell. |
|
98 | ipshell(header='') -> Opens up an IPython shell. | |
99 |
|
99 | |||
100 | - header: string printed by the IPython shell upon startup. This can let |
|
100 | - header: string printed by the IPython shell upon startup. This can let | |
101 | you know where in your code you are when dropping into the shell. Note |
|
101 | you know where in your code you are when dropping into the shell. Note | |
102 | that 'banner' gets prepended to all calls, so header is used for |
|
102 | that 'banner' gets prepended to all calls, so header is used for | |
103 | location-specific information. |
|
103 | location-specific information. | |
104 |
|
104 | |||
105 | For more details, see the __call__ method below. |
|
105 | For more details, see the __call__ method below. | |
106 |
|
106 | |||
107 | When the IPython shell is exited with Ctrl-D, normal program execution |
|
107 | When the IPython shell is exited with Ctrl-D, normal program execution | |
108 | resumes. |
|
108 | resumes. | |
109 |
|
109 | |||
110 | This functionality was inspired by a posting on comp.lang.python by cmkl |
|
110 | This functionality was inspired by a posting on comp.lang.python by cmkl | |
111 | <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and |
|
111 | <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and | |
112 | by the IDL stop/continue commands.""" |
|
112 | by the IDL stop/continue commands.""" | |
113 |
|
113 | |||
114 | def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None): |
|
114 | def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None): | |
115 | """Note that argv here is a string, NOT a list.""" |
|
115 | """Note that argv here is a string, NOT a list.""" | |
116 | self.set_banner(banner) |
|
116 | self.set_banner(banner) | |
117 | self.set_exit_msg(exit_msg) |
|
117 | self.set_exit_msg(exit_msg) | |
118 | self.set_dummy_mode(0) |
|
118 | self.set_dummy_mode(0) | |
119 |
|
119 | |||
120 | # sys.displayhook is a global, we need to save the user's original |
|
120 | # sys.displayhook is a global, we need to save the user's original | |
121 | # Don't rely on __displayhook__, as the user may have changed that. |
|
121 | # Don't rely on __displayhook__, as the user may have changed that. | |
122 | self.sys_displayhook_ori = sys.displayhook |
|
122 | self.sys_displayhook_ori = sys.displayhook | |
123 |
|
123 | |||
124 | # save readline completer status |
|
124 | # save readline completer status | |
125 | try: |
|
125 | try: | |
126 | #print 'Save completer',sys.ipcompleter # dbg |
|
126 | #print 'Save completer',sys.ipcompleter # dbg | |
127 | self.sys_ipcompleter_ori = sys.ipcompleter |
|
127 | self.sys_ipcompleter_ori = sys.ipcompleter | |
128 | except: |
|
128 | except: | |
129 | pass # not nested with IPython |
|
129 | pass # not nested with IPython | |
130 |
|
130 | |||
131 | # FIXME. Passing user_ns breaks namespace handling. |
|
131 | # FIXME. Passing user_ns breaks namespace handling. | |
132 | #self.IP = make_IPython(argv,user_ns=__main__.__dict__) |
|
132 | #self.IP = make_IPython(argv,user_ns=__main__.__dict__) | |
133 | self.IP = make_IPython(argv,rc_override=rc_override,embedded=True) |
|
133 | self.IP = make_IPython(argv,rc_override=rc_override,embedded=True) | |
134 |
|
134 | |||
135 | self.IP.name_space_init() |
|
135 | self.IP.name_space_init() | |
136 | # mark this as an embedded instance so we know if we get a crash |
|
136 | # mark this as an embedded instance so we know if we get a crash | |
137 | # post-mortem |
|
137 | # post-mortem | |
138 | self.IP.rc.embedded = 1 |
|
138 | self.IP.rc.embedded = 1 | |
139 | # copy our own displayhook also |
|
139 | # copy our own displayhook also | |
140 | self.sys_displayhook_embed = sys.displayhook |
|
140 | self.sys_displayhook_embed = sys.displayhook | |
141 | # and leave the system's display hook clean |
|
141 | # and leave the system's display hook clean | |
142 | sys.displayhook = self.sys_displayhook_ori |
|
142 | sys.displayhook = self.sys_displayhook_ori | |
143 | # don't use the ipython crash handler so that user exceptions aren't |
|
143 | # don't use the ipython crash handler so that user exceptions aren't | |
144 | # trapped |
|
144 | # trapped | |
145 | sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, |
|
145 | sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, | |
146 | mode = self.IP.rc.xmode, |
|
146 | mode = self.IP.rc.xmode, | |
147 | call_pdb = self.IP.rc.pdb) |
|
147 | call_pdb = self.IP.rc.pdb) | |
148 | self.restore_system_completer() |
|
148 | self.restore_system_completer() | |
149 |
|
149 | |||
150 | def restore_system_completer(self): |
|
150 | def restore_system_completer(self): | |
151 | """Restores the readline completer which was in place. |
|
151 | """Restores the readline completer which was in place. | |
152 |
|
152 | |||
153 | This allows embedded IPython within IPython not to disrupt the |
|
153 | This allows embedded IPython within IPython not to disrupt the | |
154 | parent's completion. |
|
154 | parent's completion. | |
155 | """ |
|
155 | """ | |
156 |
|
156 | |||
157 | try: |
|
157 | try: | |
158 | self.IP.readline.set_completer(self.sys_ipcompleter_ori) |
|
158 | self.IP.readline.set_completer(self.sys_ipcompleter_ori) | |
159 | sys.ipcompleter = self.sys_ipcompleter_ori |
|
159 | sys.ipcompleter = self.sys_ipcompleter_ori | |
160 | except: |
|
160 | except: | |
161 | pass |
|
161 | pass | |
162 |
|
162 | |||
163 | def __call__(self,header='',local_ns=None,global_ns=None,dummy=None): |
|
163 | def __call__(self,header='',local_ns=None,global_ns=None,dummy=None): | |
164 | """Activate the interactive interpreter. |
|
164 | """Activate the interactive interpreter. | |
165 |
|
165 | |||
166 | __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start |
|
166 | __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start | |
167 | the interpreter shell with the given local and global namespaces, and |
|
167 | the interpreter shell with the given local and global namespaces, and | |
168 | optionally print a header string at startup. |
|
168 | optionally print a header string at startup. | |
169 |
|
169 | |||
170 | The shell can be globally activated/deactivated using the |
|
170 | The shell can be globally activated/deactivated using the | |
171 | set/get_dummy_mode methods. This allows you to turn off a shell used |
|
171 | set/get_dummy_mode methods. This allows you to turn off a shell used | |
172 | for debugging globally. |
|
172 | for debugging globally. | |
173 |
|
173 | |||
174 | However, *each* time you call the shell you can override the current |
|
174 | However, *each* time you call the shell you can override the current | |
175 | state of dummy_mode with the optional keyword parameter 'dummy'. For |
|
175 | state of dummy_mode with the optional keyword parameter 'dummy'. For | |
176 | example, if you set dummy mode on with IPShell.set_dummy_mode(1), you |
|
176 | example, if you set dummy mode on with IPShell.set_dummy_mode(1), you | |
177 | can still have a specific call work by making it as IPShell(dummy=0). |
|
177 | can still have a specific call work by making it as IPShell(dummy=0). | |
178 |
|
178 | |||
179 | The optional keyword parameter dummy controls whether the call |
|
179 | The optional keyword parameter dummy controls whether the call | |
180 | actually does anything. """ |
|
180 | actually does anything. """ | |
181 |
|
181 | |||
182 | # Allow the dummy parameter to override the global __dummy_mode |
|
182 | # Allow the dummy parameter to override the global __dummy_mode | |
183 | if dummy or (dummy != 0 and self.__dummy_mode): |
|
183 | if dummy or (dummy != 0 and self.__dummy_mode): | |
184 | return |
|
184 | return | |
185 |
|
185 | |||
186 | # Set global subsystems (display,completions) to our values |
|
186 | # Set global subsystems (display,completions) to our values | |
187 | sys.displayhook = self.sys_displayhook_embed |
|
187 | sys.displayhook = self.sys_displayhook_embed | |
188 | if self.IP.has_readline: |
|
188 | if self.IP.has_readline: | |
189 | self.IP.readline.set_completer(self.IP.Completer.complete) |
|
189 | self.IP.readline.set_completer(self.IP.Completer.complete) | |
190 |
|
190 | |||
191 | if self.banner and header: |
|
191 | if self.banner and header: | |
192 | format = '%s\n%s\n' |
|
192 | format = '%s\n%s\n' | |
193 | else: |
|
193 | else: | |
194 | format = '%s%s\n' |
|
194 | format = '%s%s\n' | |
195 | banner = format % (self.banner,header) |
|
195 | banner = format % (self.banner,header) | |
196 |
|
196 | |||
197 | # Call the embedding code with a stack depth of 1 so it can skip over |
|
197 | # Call the embedding code with a stack depth of 1 so it can skip over | |
198 | # our call and get the original caller's namespaces. |
|
198 | # our call and get the original caller's namespaces. | |
199 | self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1) |
|
199 | self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1) | |
200 |
|
200 | |||
201 | if self.exit_msg: |
|
201 | if self.exit_msg: | |
202 | print self.exit_msg |
|
202 | print self.exit_msg | |
203 |
|
203 | |||
204 | # Restore global systems (display, completion) |
|
204 | # Restore global systems (display, completion) | |
205 | sys.displayhook = self.sys_displayhook_ori |
|
205 | sys.displayhook = self.sys_displayhook_ori | |
206 | self.restore_system_completer() |
|
206 | self.restore_system_completer() | |
207 |
|
207 | |||
208 | def set_dummy_mode(self,dummy): |
|
208 | def set_dummy_mode(self,dummy): | |
209 | """Sets the embeddable shell's dummy mode parameter. |
|
209 | """Sets the embeddable shell's dummy mode parameter. | |
210 |
|
210 | |||
211 | set_dummy_mode(dummy): dummy = 0 or 1. |
|
211 | set_dummy_mode(dummy): dummy = 0 or 1. | |
212 |
|
212 | |||
213 | This parameter is persistent and makes calls to the embeddable shell |
|
213 | This parameter is persistent and makes calls to the embeddable shell | |
214 | silently return without performing any action. This allows you to |
|
214 | silently return without performing any action. This allows you to | |
215 | globally activate or deactivate a shell you're using with a single call. |
|
215 | globally activate or deactivate a shell you're using with a single call. | |
216 |
|
216 | |||
217 | If you need to manually""" |
|
217 | If you need to manually""" | |
218 |
|
218 | |||
219 | if dummy not in [0,1]: |
|
219 | if dummy not in [0,1]: | |
220 | raise ValueError,'dummy parameter must be 0 or 1' |
|
220 | raise ValueError,'dummy parameter must be 0 or 1' | |
221 | self.__dummy_mode = dummy |
|
221 | self.__dummy_mode = dummy | |
222 |
|
222 | |||
223 | def get_dummy_mode(self): |
|
223 | def get_dummy_mode(self): | |
224 | """Return the current value of the dummy mode parameter. |
|
224 | """Return the current value of the dummy mode parameter. | |
225 | """ |
|
225 | """ | |
226 | return self.__dummy_mode |
|
226 | return self.__dummy_mode | |
227 |
|
227 | |||
228 | def set_banner(self,banner): |
|
228 | def set_banner(self,banner): | |
229 | """Sets the global banner. |
|
229 | """Sets the global banner. | |
230 |
|
230 | |||
231 | This banner gets prepended to every header printed when the shell |
|
231 | This banner gets prepended to every header printed when the shell | |
232 | instance is called.""" |
|
232 | instance is called.""" | |
233 |
|
233 | |||
234 | self.banner = banner |
|
234 | self.banner = banner | |
235 |
|
235 | |||
236 | def set_exit_msg(self,exit_msg): |
|
236 | def set_exit_msg(self,exit_msg): | |
237 | """Sets the global exit_msg. |
|
237 | """Sets the global exit_msg. | |
238 |
|
238 | |||
239 | This exit message gets printed upon exiting every time the embedded |
|
239 | This exit message gets printed upon exiting every time the embedded | |
240 | shell is called. It is None by default. """ |
|
240 | shell is called. It is None by default. """ | |
241 |
|
241 | |||
242 | self.exit_msg = exit_msg |
|
242 | self.exit_msg = exit_msg | |
243 |
|
243 | |||
244 | #----------------------------------------------------------------------------- |
|
244 | #----------------------------------------------------------------------------- | |
245 | def sigint_handler (signum,stack_frame): |
|
245 | def sigint_handler (signum,stack_frame): | |
246 | """Sigint handler for threaded apps. |
|
246 | """Sigint handler for threaded apps. | |
247 |
|
247 | |||
248 | This is a horrible hack to pass information about SIGINT _without_ using |
|
248 | This is a horrible hack to pass information about SIGINT _without_ using | |
249 | exceptions, since I haven't been able to properly manage cross-thread |
|
249 | exceptions, since I haven't been able to properly manage cross-thread | |
250 | exceptions in GTK/WX. In fact, I don't think it can be done (or at least |
|
250 | exceptions in GTK/WX. In fact, I don't think it can be done (or at least | |
251 | that's my understanding from a c.l.py thread where this was discussed).""" |
|
251 | that's my understanding from a c.l.py thread where this was discussed).""" | |
252 |
|
252 | |||
253 | global KBINT |
|
253 | global KBINT | |
254 |
|
254 | |||
255 | print '\nKeyboardInterrupt - Press <Enter> to continue.', |
|
255 | print '\nKeyboardInterrupt - Press <Enter> to continue.', | |
256 | Term.cout.flush() |
|
256 | Term.cout.flush() | |
257 | # Set global flag so that runsource can know that Ctrl-C was hit |
|
257 | # Set global flag so that runsource can know that Ctrl-C was hit | |
258 | KBINT = True |
|
258 | KBINT = True | |
259 |
|
259 | |||
260 | class MTInteractiveShell(InteractiveShell): |
|
260 | class MTInteractiveShell(InteractiveShell): | |
261 | """Simple multi-threaded shell.""" |
|
261 | """Simple multi-threaded shell.""" | |
262 |
|
262 | |||
263 | # Threading strategy taken from: |
|
263 | # Threading strategy taken from: | |
264 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian |
|
264 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian | |
265 | # McErlean and John Finlay. Modified with corrections by Antoon Pardon, |
|
265 | # McErlean and John Finlay. Modified with corrections by Antoon Pardon, | |
266 | # from the pygtk mailing list, to avoid lockups with system calls. |
|
266 | # from the pygtk mailing list, to avoid lockups with system calls. | |
267 |
|
267 | |||
268 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
268 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
269 | user_ns = None, banner2='',**kw): |
|
269 | user_ns = None, banner2='',**kw): | |
270 | """Similar to the normal InteractiveShell, but with threading control""" |
|
270 | """Similar to the normal InteractiveShell, but with threading control""" | |
271 |
|
271 | |||
272 | IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2) |
|
272 | IPython.iplib.InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2) | |
273 |
|
273 | |||
274 | # Locking control variable |
|
274 | # Locking control variable | |
275 | self.thread_ready = threading.Condition() |
|
275 | self.thread_ready = threading.Condition() | |
276 |
|
276 | |||
277 | # Stuff to do at closing time |
|
277 | # Stuff to do at closing time | |
278 | self._kill = False |
|
278 | self._kill = False | |
279 | on_kill = kw.get('on_kill') |
|
279 | on_kill = kw.get('on_kill') | |
280 | if on_kill is None: |
|
280 | if on_kill is None: | |
281 | on_kill = [] |
|
281 | on_kill = [] | |
282 | # Check that all things to kill are callable: |
|
282 | # Check that all things to kill are callable: | |
283 | for t in on_kill: |
|
283 | for t in on_kill: | |
284 | if not callable(t): |
|
284 | if not callable(t): | |
285 | raise TypeError,'on_kill must be a list of callables' |
|
285 | raise TypeError,'on_kill must be a list of callables' | |
286 | self.on_kill = on_kill |
|
286 | self.on_kill = on_kill | |
287 |
|
287 | |||
288 | def runsource(self, source, filename="<input>", symbol="single"): |
|
288 | def runsource(self, source, filename="<input>", symbol="single"): | |
289 | """Compile and run some source in the interpreter. |
|
289 | """Compile and run some source in the interpreter. | |
290 |
|
290 | |||
291 | Modified version of code.py's runsource(), to handle threading issues. |
|
291 | Modified version of code.py's runsource(), to handle threading issues. | |
292 | See the original for full docstring details.""" |
|
292 | See the original for full docstring details.""" | |
293 |
|
293 | |||
294 | global KBINT |
|
294 | global KBINT | |
295 |
|
295 | |||
296 | # If Ctrl-C was typed, we reset the flag and return right away |
|
296 | # If Ctrl-C was typed, we reset the flag and return right away | |
297 | if KBINT: |
|
297 | if KBINT: | |
298 | KBINT = False |
|
298 | KBINT = False | |
299 | return False |
|
299 | return False | |
300 |
|
300 | |||
301 | try: |
|
301 | try: | |
302 | code = self.compile(source, filename, symbol) |
|
302 | code = self.compile(source, filename, symbol) | |
303 | except (OverflowError, SyntaxError, ValueError): |
|
303 | except (OverflowError, SyntaxError, ValueError): | |
304 | # Case 1 |
|
304 | # Case 1 | |
305 | self.showsyntaxerror(filename) |
|
305 | self.showsyntaxerror(filename) | |
306 | return False |
|
306 | return False | |
307 |
|
307 | |||
308 | if code is None: |
|
308 | if code is None: | |
309 | # Case 2 |
|
309 | # Case 2 | |
310 | return True |
|
310 | return True | |
311 |
|
311 | |||
312 | # Case 3 |
|
312 | # Case 3 | |
313 | # Store code in self, so the execution thread can handle it |
|
313 | # Store code in self, so the execution thread can handle it | |
314 | self.thread_ready.acquire() |
|
314 | self.thread_ready.acquire() | |
315 | self.code_to_run_src = source |
|
|||
316 | self.code_to_run = code |
|
315 | self.code_to_run = code | |
317 | self.thread_ready.wait() # Wait until processed in timeout interval |
|
316 | self.thread_ready.wait() # Wait until processed in timeout interval | |
318 | self.thread_ready.release() |
|
317 | self.thread_ready.release() | |
319 |
|
318 | |||
320 | return False |
|
319 | return False | |
321 |
|
320 | |||
322 | def runcode(self): |
|
321 | def runcode(self): | |
323 | """Execute a code object. |
|
322 | """Execute a code object. | |
324 |
|
323 | |||
325 | Multithreaded wrapper around IPython's runcode().""" |
|
324 | Multithreaded wrapper around IPython's runcode().""" | |
326 |
|
325 | |||
327 | # lock thread-protected stuff |
|
326 | # lock thread-protected stuff | |
328 | self.thread_ready.acquire() |
|
327 | self.thread_ready.acquire() | |
329 |
|
328 | |||
330 | # Install sigint handler |
|
329 | # Install sigint handler | |
331 | try: |
|
330 | try: | |
332 | signal.signal(signal.SIGINT, sigint_handler) |
|
331 | signal.signal(signal.SIGINT, sigint_handler) | |
333 | except SystemError: |
|
332 | except SystemError: | |
334 | # This happens under Windows, which seems to have all sorts |
|
333 | # This happens under Windows, which seems to have all sorts | |
335 | # of problems with signal handling. Oh well... |
|
334 | # of problems with signal handling. Oh well... | |
336 | pass |
|
335 | pass | |
337 |
|
336 | |||
338 | if self._kill: |
|
337 | if self._kill: | |
339 | print >>Term.cout, 'Closing threads...', |
|
338 | print >>Term.cout, 'Closing threads...', | |
340 | Term.cout.flush() |
|
339 | Term.cout.flush() | |
341 | for tokill in self.on_kill: |
|
340 | for tokill in self.on_kill: | |
342 | tokill() |
|
341 | tokill() | |
343 | print >>Term.cout, 'Done.' |
|
342 | print >>Term.cout, 'Done.' | |
344 |
|
343 | |||
345 | # Run pending code by calling parent class |
|
344 | # Run pending code by calling parent class | |
346 | if self.code_to_run is not None: |
|
345 | if self.code_to_run is not None: | |
347 | self.thread_ready.notify() |
|
346 | self.thread_ready.notify() | |
348 | InteractiveShell.runcode(self,self.code_to_run) |
|
347 | InteractiveShell.runcode(self,self.code_to_run) | |
349 |
|
348 | |||
350 | # We're done with thread-protected variables |
|
349 | # We're done with thread-protected variables | |
351 | self.thread_ready.release() |
|
350 | self.thread_ready.release() | |
352 | # This MUST return true for gtk threading to work |
|
351 | # This MUST return true for gtk threading to work | |
353 | return True |
|
352 | return True | |
354 |
|
353 | |||
355 | def kill (self): |
|
354 | def kill (self): | |
356 | """Kill the thread, returning when it has been shut down.""" |
|
355 | """Kill the thread, returning when it has been shut down.""" | |
357 | self.thread_ready.acquire() |
|
356 | self.thread_ready.acquire() | |
358 | self._kill = True |
|
357 | self._kill = True | |
359 | self.thread_ready.release() |
|
358 | self.thread_ready.release() | |
360 |
|
359 | |||
361 | class MatplotlibShellBase: |
|
360 | class MatplotlibShellBase: | |
362 | """Mixin class to provide the necessary modifications to regular IPython |
|
361 | """Mixin class to provide the necessary modifications to regular IPython | |
363 | shell classes for matplotlib support. |
|
362 | shell classes for matplotlib support. | |
364 |
|
363 | |||
365 | Given Python's MRO, this should be used as the FIRST class in the |
|
364 | Given Python's MRO, this should be used as the FIRST class in the | |
366 | inheritance hierarchy, so that it overrides the relevant methods.""" |
|
365 | inheritance hierarchy, so that it overrides the relevant methods.""" | |
367 |
|
366 | |||
368 | def _matplotlib_config(self,name): |
|
367 | def _matplotlib_config(self,name): | |
369 | """Return various items needed to setup the user's shell with matplotlib""" |
|
368 | """Return various items needed to setup the user's shell with matplotlib""" | |
370 |
|
369 | |||
371 | # Initialize matplotlib to interactive mode always |
|
370 | # Initialize matplotlib to interactive mode always | |
372 | import matplotlib |
|
371 | import matplotlib | |
373 | from matplotlib import backends |
|
372 | from matplotlib import backends | |
374 | matplotlib.interactive(True) |
|
373 | matplotlib.interactive(True) | |
375 |
|
374 | |||
376 | def use(arg): |
|
375 | def use(arg): | |
377 | """IPython wrapper for matplotlib's backend switcher. |
|
376 | """IPython wrapper for matplotlib's backend switcher. | |
378 |
|
377 | |||
379 | In interactive use, we can not allow switching to a different |
|
378 | In interactive use, we can not allow switching to a different | |
380 | interactive backend, since thread conflicts will most likely crash |
|
379 | interactive backend, since thread conflicts will most likely crash | |
381 | the python interpreter. This routine does a safety check first, |
|
380 | the python interpreter. This routine does a safety check first, | |
382 | and refuses to perform a dangerous switch. It still allows |
|
381 | and refuses to perform a dangerous switch. It still allows | |
383 | switching to non-interactive backends.""" |
|
382 | switching to non-interactive backends.""" | |
384 |
|
383 | |||
385 | if arg in backends.interactive_bk and arg != self.mpl_backend: |
|
384 | if arg in backends.interactive_bk and arg != self.mpl_backend: | |
386 | m=('invalid matplotlib backend switch.\n' |
|
385 | m=('invalid matplotlib backend switch.\n' | |
387 | 'This script attempted to switch to the interactive ' |
|
386 | 'This script attempted to switch to the interactive ' | |
388 | 'backend: `%s`\n' |
|
387 | 'backend: `%s`\n' | |
389 | 'Your current choice of interactive backend is: `%s`\n\n' |
|
388 | 'Your current choice of interactive backend is: `%s`\n\n' | |
390 | 'Switching interactive matplotlib backends at runtime\n' |
|
389 | 'Switching interactive matplotlib backends at runtime\n' | |
391 | 'would crash the python interpreter, ' |
|
390 | 'would crash the python interpreter, ' | |
392 | 'and IPython has blocked it.\n\n' |
|
391 | 'and IPython has blocked it.\n\n' | |
393 | 'You need to either change your choice of matplotlib backend\n' |
|
392 | 'You need to either change your choice of matplotlib backend\n' | |
394 | 'by editing your .matplotlibrc file, or run this script as a \n' |
|
393 | 'by editing your .matplotlibrc file, or run this script as a \n' | |
395 | 'standalone file from the command line, not using IPython.\n' % |
|
394 | 'standalone file from the command line, not using IPython.\n' % | |
396 | (arg,self.mpl_backend) ) |
|
395 | (arg,self.mpl_backend) ) | |
397 | raise RuntimeError, m |
|
396 | raise RuntimeError, m | |
398 | else: |
|
397 | else: | |
399 | self.mpl_use(arg) |
|
398 | self.mpl_use(arg) | |
400 | self.mpl_use._called = True |
|
399 | self.mpl_use._called = True | |
401 |
|
400 | |||
402 | self.matplotlib = matplotlib |
|
401 | self.matplotlib = matplotlib | |
403 | self.mpl_backend = matplotlib.rcParams['backend'] |
|
402 | self.mpl_backend = matplotlib.rcParams['backend'] | |
404 |
|
403 | |||
405 | # we also need to block switching of interactive backends by use() |
|
404 | # we also need to block switching of interactive backends by use() | |
406 | self.mpl_use = matplotlib.use |
|
405 | self.mpl_use = matplotlib.use | |
407 | self.mpl_use._called = False |
|
406 | self.mpl_use._called = False | |
408 | # overwrite the original matplotlib.use with our wrapper |
|
407 | # overwrite the original matplotlib.use with our wrapper | |
409 | matplotlib.use = use |
|
408 | matplotlib.use = use | |
410 |
|
409 | |||
411 |
|
410 | |||
412 | # This must be imported last in the matplotlib series, after |
|
411 | # This must be imported last in the matplotlib series, after | |
413 | # backend/interactivity choices have been made |
|
412 | # backend/interactivity choices have been made | |
414 | try: |
|
413 | try: | |
415 | import matplotlib.pylab as pylab |
|
414 | import matplotlib.pylab as pylab | |
416 | self.pylab = pylab |
|
415 | self.pylab = pylab | |
417 | self.pylab_name = 'pylab' |
|
416 | self.pylab_name = 'pylab' | |
418 | except ImportError: |
|
417 | except ImportError: | |
419 | import matplotlib.matlab as matlab |
|
418 | import matplotlib.matlab as matlab | |
420 | self.pylab = matlab |
|
419 | self.pylab = matlab | |
421 | self.pylab_name = 'matlab' |
|
420 | self.pylab_name = 'matlab' | |
422 |
|
421 | |||
423 | self.pylab.show._needmain = False |
|
422 | self.pylab.show._needmain = False | |
424 | # We need to detect at runtime whether show() is called by the user. |
|
423 | # We need to detect at runtime whether show() is called by the user. | |
425 | # For this, we wrap it into a decorator which adds a 'called' flag. |
|
424 | # For this, we wrap it into a decorator which adds a 'called' flag. | |
426 | self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive) |
|
425 | self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive) | |
427 |
|
426 | |||
428 | # Build a user namespace initialized with matplotlib/matlab features. |
|
427 | # Build a user namespace initialized with matplotlib/matlab features. | |
429 | user_ns = {'__name__':'__main__', |
|
428 | user_ns = {'__name__':'__main__', | |
430 | '__builtins__' : __builtin__ } |
|
429 | '__builtins__' : __builtin__ } | |
431 |
|
430 | |||
432 | # Be careful not to remove the final \n in the code string below, or |
|
431 | # Be careful not to remove the final \n in the code string below, or | |
433 | # things will break badly with py22 (I think it's a python bug, 2.3 is |
|
432 | # things will break badly with py22 (I think it's a python bug, 2.3 is | |
434 | # OK). |
|
433 | # OK). | |
435 | pname = self.pylab_name # Python can't interpolate dotted var names |
|
434 | pname = self.pylab_name # Python can't interpolate dotted var names | |
436 | exec ("import matplotlib\n" |
|
435 | exec ("import matplotlib\n" | |
437 | "import matplotlib.%(pname)s as %(pname)s\n" |
|
436 | "import matplotlib.%(pname)s as %(pname)s\n" | |
438 | "from matplotlib.%(pname)s import *\n" % locals()) in user_ns |
|
437 | "from matplotlib.%(pname)s import *\n" % locals()) in user_ns | |
439 |
|
438 | |||
440 | # Build matplotlib info banner |
|
439 | # Build matplotlib info banner | |
441 | b=""" |
|
440 | b=""" | |
442 | Welcome to pylab, a matplotlib-based Python environment. |
|
441 | Welcome to pylab, a matplotlib-based Python environment. | |
443 | For more information, type 'help(pylab)'. |
|
442 | For more information, type 'help(pylab)'. | |
444 | """ |
|
443 | """ | |
445 | return user_ns,b |
|
444 | return user_ns,b | |
446 |
|
445 | |||
447 | def mplot_exec(self,fname,*where,**kw): |
|
446 | def mplot_exec(self,fname,*where,**kw): | |
448 | """Execute a matplotlib script. |
|
447 | """Execute a matplotlib script. | |
449 |
|
448 | |||
450 | This is a call to execfile(), but wrapped in safeties to properly |
|
449 | This is a call to execfile(), but wrapped in safeties to properly | |
451 | handle interactive rendering and backend switching.""" |
|
450 | handle interactive rendering and backend switching.""" | |
452 |
|
451 | |||
453 | #print '*** Matplotlib runner ***' # dbg |
|
452 | #print '*** Matplotlib runner ***' # dbg | |
454 | # turn off rendering until end of script |
|
453 | # turn off rendering until end of script | |
455 | isInteractive = self.matplotlib.rcParams['interactive'] |
|
454 | isInteractive = self.matplotlib.rcParams['interactive'] | |
456 | self.matplotlib.interactive(False) |
|
455 | self.matplotlib.interactive(False) | |
457 | self.safe_execfile(fname,*where,**kw) |
|
456 | self.safe_execfile(fname,*where,**kw) | |
458 | self.matplotlib.interactive(isInteractive) |
|
457 | self.matplotlib.interactive(isInteractive) | |
459 | # make rendering call now, if the user tried to do it |
|
458 | # make rendering call now, if the user tried to do it | |
460 | if self.pylab.draw_if_interactive.called: |
|
459 | if self.pylab.draw_if_interactive.called: | |
461 | self.pylab.draw() |
|
460 | self.pylab.draw() | |
462 | self.pylab.draw_if_interactive.called = False |
|
461 | self.pylab.draw_if_interactive.called = False | |
463 |
|
462 | |||
464 | # if a backend switch was performed, reverse it now |
|
463 | # if a backend switch was performed, reverse it now | |
465 | if self.mpl_use._called: |
|
464 | if self.mpl_use._called: | |
466 | self.matplotlib.rcParams['backend'] = self.mpl_backend |
|
465 | self.matplotlib.rcParams['backend'] = self.mpl_backend | |
467 |
|
466 | |||
468 | def magic_run(self,parameter_s=''): |
|
467 | def magic_run(self,parameter_s=''): | |
469 | Magic.magic_run(self,parameter_s,runner=self.mplot_exec) |
|
468 | Magic.magic_run(self,parameter_s,runner=self.mplot_exec) | |
470 |
|
469 | |||
471 | # Fix the docstring so users see the original as well |
|
470 | # Fix the docstring so users see the original as well | |
472 | magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__, |
|
471 | magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__, | |
473 | "\n *** Modified %run for Matplotlib," |
|
472 | "\n *** Modified %run for Matplotlib," | |
474 | " with proper interactive handling ***") |
|
473 | " with proper interactive handling ***") | |
475 |
|
474 | |||
476 | # Now we provide 2 versions of a matplotlib-aware IPython base shells, single |
|
475 | # Now we provide 2 versions of a matplotlib-aware IPython base shells, single | |
477 | # and multithreaded. Note that these are meant for internal use, the IPShell* |
|
476 | # and multithreaded. Note that these are meant for internal use, the IPShell* | |
478 | # classes below are the ones meant for public consumption. |
|
477 | # classes below are the ones meant for public consumption. | |
479 |
|
478 | |||
480 | class MatplotlibShell(MatplotlibShellBase,InteractiveShell): |
|
479 | class MatplotlibShell(MatplotlibShellBase,InteractiveShell): | |
481 | """Single-threaded shell with matplotlib support.""" |
|
480 | """Single-threaded shell with matplotlib support.""" | |
482 |
|
481 | |||
483 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
482 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
484 | user_ns = None, **kw): |
|
483 | user_ns = None, **kw): | |
485 | user_ns,b2 = self._matplotlib_config(name) |
|
484 | user_ns,b2 = self._matplotlib_config(name) | |
486 | InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw) |
|
485 | InteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw) | |
487 |
|
486 | |||
488 | class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell): |
|
487 | class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell): | |
489 | """Multi-threaded shell with matplotlib support.""" |
|
488 | """Multi-threaded shell with matplotlib support.""" | |
490 |
|
489 | |||
491 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
490 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
492 | user_ns = None, **kw): |
|
491 | user_ns = None, **kw): | |
493 | user_ns,b2 = self._matplotlib_config(name) |
|
492 | user_ns,b2 = self._matplotlib_config(name) | |
494 | MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw) |
|
493 | MTInteractiveShell.__init__(self,name,usage,rc,user_ns,banner2=b2,**kw) | |
495 |
|
494 | |||
496 | #----------------------------------------------------------------------------- |
|
495 | #----------------------------------------------------------------------------- | |
497 | # Utility functions for the different GUI enabled IPShell* classes. |
|
496 | # Utility functions for the different GUI enabled IPShell* classes. | |
498 |
|
497 | |||
499 | def get_tk(): |
|
498 | def get_tk(): | |
500 | """Tries to import Tkinter and returns a withdrawn Tkinter root |
|
499 | """Tries to import Tkinter and returns a withdrawn Tkinter root | |
501 | window. If Tkinter is already imported or not available, this |
|
500 | window. If Tkinter is already imported or not available, this | |
502 | returns None. This function calls `hijack_tk` underneath. |
|
501 | returns None. This function calls `hijack_tk` underneath. | |
503 | """ |
|
502 | """ | |
504 | if not USE_TK or sys.modules.has_key('Tkinter'): |
|
503 | if not USE_TK or sys.modules.has_key('Tkinter'): | |
505 | return None |
|
504 | return None | |
506 | else: |
|
505 | else: | |
507 | try: |
|
506 | try: | |
508 | import Tkinter |
|
507 | import Tkinter | |
509 | except ImportError: |
|
508 | except ImportError: | |
510 | return None |
|
509 | return None | |
511 | else: |
|
510 | else: | |
512 | hijack_tk() |
|
511 | hijack_tk() | |
513 | r = Tkinter.Tk() |
|
512 | r = Tkinter.Tk() | |
514 | r.withdraw() |
|
513 | r.withdraw() | |
515 | return r |
|
514 | return r | |
516 |
|
515 | |||
517 | def hijack_tk(): |
|
516 | def hijack_tk(): | |
518 | """Modifies Tkinter's mainloop with a dummy so when a module calls |
|
517 | """Modifies Tkinter's mainloop with a dummy so when a module calls | |
519 | mainloop, it does not block. |
|
518 | mainloop, it does not block. | |
520 |
|
519 | |||
521 | """ |
|
520 | """ | |
522 | def misc_mainloop(self, n=0): |
|
521 | def misc_mainloop(self, n=0): | |
523 | pass |
|
522 | pass | |
524 | def tkinter_mainloop(n=0): |
|
523 | def tkinter_mainloop(n=0): | |
525 | pass |
|
524 | pass | |
526 |
|
525 | |||
527 | import Tkinter |
|
526 | import Tkinter | |
528 | Tkinter.Misc.mainloop = misc_mainloop |
|
527 | Tkinter.Misc.mainloop = misc_mainloop | |
529 | Tkinter.mainloop = tkinter_mainloop |
|
528 | Tkinter.mainloop = tkinter_mainloop | |
530 |
|
529 | |||
531 | def update_tk(tk): |
|
530 | def update_tk(tk): | |
532 | """Updates the Tkinter event loop. This is typically called from |
|
531 | """Updates the Tkinter event loop. This is typically called from | |
533 | the respective WX or GTK mainloops. |
|
532 | the respective WX or GTK mainloops. | |
534 | """ |
|
533 | """ | |
535 | if tk: |
|
534 | if tk: | |
536 | tk.update() |
|
535 | tk.update() | |
537 |
|
536 | |||
538 | def hijack_wx(): |
|
537 | def hijack_wx(): | |
539 | """Modifies wxPython's MainLoop with a dummy so user code does not |
|
538 | """Modifies wxPython's MainLoop with a dummy so user code does not | |
540 | block IPython. The hijacked mainloop function is returned. |
|
539 | block IPython. The hijacked mainloop function is returned. | |
541 | """ |
|
540 | """ | |
542 | def dummy_mainloop(*args, **kw): |
|
541 | def dummy_mainloop(*args, **kw): | |
543 | pass |
|
542 | pass | |
544 | import wxPython |
|
543 | import wxPython | |
545 | ver = wxPython.__version__ |
|
544 | ver = wxPython.__version__ | |
546 | orig_mainloop = None |
|
545 | orig_mainloop = None | |
547 | if ver[:3] >= '2.5': |
|
546 | if ver[:3] >= '2.5': | |
548 | import wx |
|
547 | import wx | |
549 | if hasattr(wx, '_core_'): core = getattr(wx, '_core_') |
|
548 | if hasattr(wx, '_core_'): core = getattr(wx, '_core_') | |
550 | elif hasattr(wx, '_core'): core = getattr(wx, '_core') |
|
549 | elif hasattr(wx, '_core'): core = getattr(wx, '_core') | |
551 | else: raise AttributeError('Could not find wx core module') |
|
550 | else: raise AttributeError('Could not find wx core module') | |
552 | orig_mainloop = core.PyApp_MainLoop |
|
551 | orig_mainloop = core.PyApp_MainLoop | |
553 | core.PyApp_MainLoop = dummy_mainloop |
|
552 | core.PyApp_MainLoop = dummy_mainloop | |
554 | elif ver[:3] == '2.4': |
|
553 | elif ver[:3] == '2.4': | |
555 | orig_mainloop = wxPython.wxc.wxPyApp_MainLoop |
|
554 | orig_mainloop = wxPython.wxc.wxPyApp_MainLoop | |
556 | wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop |
|
555 | wxPython.wxc.wxPyApp_MainLoop = dummy_mainloop | |
557 | else: |
|
556 | else: | |
558 | warn("Unable to find either wxPython version 2.4 or >= 2.5.") |
|
557 | warn("Unable to find either wxPython version 2.4 or >= 2.5.") | |
559 | return orig_mainloop |
|
558 | return orig_mainloop | |
560 |
|
559 | |||
561 | def hijack_gtk(): |
|
560 | def hijack_gtk(): | |
562 | """Modifies pyGTK's mainloop with a dummy so user code does not |
|
561 | """Modifies pyGTK's mainloop with a dummy so user code does not | |
563 | block IPython. This function returns the original `gtk.mainloop` |
|
562 | block IPython. This function returns the original `gtk.mainloop` | |
564 | function that has been hijacked. |
|
563 | function that has been hijacked. | |
565 |
|
564 | |||
566 | NOTE: Make sure you import this *AFTER* you call |
|
565 | NOTE: Make sure you import this *AFTER* you call | |
567 | pygtk.require(...). |
|
566 | pygtk.require(...). | |
568 | """ |
|
567 | """ | |
569 | def dummy_mainloop(*args, **kw): |
|
568 | def dummy_mainloop(*args, **kw): | |
570 | pass |
|
569 | pass | |
571 | import gtk |
|
570 | import gtk | |
572 | if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main |
|
571 | if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main | |
573 | else: orig_mainloop = gtk.mainloop |
|
572 | else: orig_mainloop = gtk.mainloop | |
574 | gtk.mainloop = dummy_mainloop |
|
573 | gtk.mainloop = dummy_mainloop | |
575 | gtk.main = dummy_mainloop |
|
574 | gtk.main = dummy_mainloop | |
576 | return orig_mainloop |
|
575 | return orig_mainloop | |
577 |
|
576 | |||
578 | #----------------------------------------------------------------------------- |
|
577 | #----------------------------------------------------------------------------- | |
579 | # The IPShell* classes below are the ones meant to be run by external code as |
|
578 | # The IPShell* classes below are the ones meant to be run by external code as | |
580 | # IPython instances. Note that unless a specific threading strategy is |
|
579 | # IPython instances. Note that unless a specific threading strategy is | |
581 | # desired, the factory function start() below should be used instead (it |
|
580 | # desired, the factory function start() below should be used instead (it | |
582 | # selects the proper threaded class). |
|
581 | # selects the proper threaded class). | |
583 |
|
582 | |||
584 | class IPShellGTK(threading.Thread): |
|
583 | class IPShellGTK(threading.Thread): | |
585 | """Run a gtk mainloop() in a separate thread. |
|
584 | """Run a gtk mainloop() in a separate thread. | |
586 |
|
585 | |||
587 | Python commands can be passed to the thread where they will be executed. |
|
586 | Python commands can be passed to the thread where they will be executed. | |
588 | This is implemented by periodically checking for passed code using a |
|
587 | This is implemented by periodically checking for passed code using a | |
589 | GTK timeout callback.""" |
|
588 | GTK timeout callback.""" | |
590 |
|
589 | |||
591 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
590 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
592 |
|
591 | |||
593 | def __init__(self,argv=None,user_ns=None,debug=1, |
|
592 | def __init__(self,argv=None,user_ns=None,debug=1, | |
594 | shell_class=MTInteractiveShell): |
|
593 | shell_class=MTInteractiveShell): | |
595 |
|
594 | |||
596 | import pygtk |
|
595 | import pygtk | |
597 | pygtk.require("2.0") |
|
596 | pygtk.require("2.0") | |
598 | import gtk |
|
597 | import gtk | |
599 |
|
598 | |||
600 | self.gtk = gtk |
|
599 | self.gtk = gtk | |
601 | self.gtk_mainloop = hijack_gtk() |
|
600 | self.gtk_mainloop = hijack_gtk() | |
602 |
|
601 | |||
603 | # Allows us to use both Tk and GTK. |
|
602 | # Allows us to use both Tk and GTK. | |
604 | self.tk = get_tk() |
|
603 | self.tk = get_tk() | |
605 |
|
604 | |||
606 | if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit |
|
605 | if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit | |
607 | else: mainquit = self.gtk.mainquit |
|
606 | else: mainquit = self.gtk.mainquit | |
608 |
|
607 | |||
609 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, |
|
608 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, | |
610 | shell_class=shell_class, |
|
609 | shell_class=shell_class, | |
611 | on_kill=[mainquit]) |
|
610 | on_kill=[mainquit]) | |
612 | threading.Thread.__init__(self) |
|
611 | threading.Thread.__init__(self) | |
613 |
|
612 | |||
614 | def run(self): |
|
613 | def run(self): | |
615 | self.IP.mainloop() |
|
614 | self.IP.mainloop() | |
616 | self.IP.kill() |
|
615 | self.IP.kill() | |
617 |
|
616 | |||
618 | def mainloop(self): |
|
617 | def mainloop(self): | |
619 |
|
618 | |||
620 | if self.gtk.pygtk_version >= (2,4,0): |
|
619 | if self.gtk.pygtk_version >= (2,4,0): | |
621 | import gobject |
|
620 | import gobject | |
622 | gobject.timeout_add(self.TIMEOUT, self.on_timer) |
|
621 | gobject.timeout_add(self.TIMEOUT, self.on_timer) | |
623 | else: |
|
622 | else: | |
624 | self.gtk.timeout_add(self.TIMEOUT, self.on_timer) |
|
623 | self.gtk.timeout_add(self.TIMEOUT, self.on_timer) | |
625 |
|
624 | |||
626 | if sys.platform != 'win32': |
|
625 | if sys.platform != 'win32': | |
627 | try: |
|
626 | try: | |
628 | if self.gtk.gtk_version[0] >= 2: |
|
627 | if self.gtk.gtk_version[0] >= 2: | |
629 | self.gtk.threads_init() |
|
628 | self.gtk.threads_init() | |
630 | except AttributeError: |
|
629 | except AttributeError: | |
631 | pass |
|
630 | pass | |
632 | except RuntimeError: |
|
631 | except RuntimeError: | |
633 | error('Your pyGTK likely has not been compiled with ' |
|
632 | error('Your pyGTK likely has not been compiled with ' | |
634 | 'threading support.\n' |
|
633 | 'threading support.\n' | |
635 | 'The exception printout is below.\n' |
|
634 | 'The exception printout is below.\n' | |
636 | 'You can either rebuild pyGTK with threads, or ' |
|
635 | 'You can either rebuild pyGTK with threads, or ' | |
637 | 'try using \n' |
|
636 | 'try using \n' | |
638 | 'matplotlib with a different backend (like Tk or WX).\n' |
|
637 | 'matplotlib with a different backend (like Tk or WX).\n' | |
639 | 'Note that matplotlib will most likely not work in its ' |
|
638 | 'Note that matplotlib will most likely not work in its ' | |
640 | 'current state!') |
|
639 | 'current state!') | |
641 | self.IP.InteractiveTB() |
|
640 | self.IP.InteractiveTB() | |
642 | self.start() |
|
641 | self.start() | |
643 | self.gtk.threads_enter() |
|
642 | self.gtk.threads_enter() | |
644 | self.gtk_mainloop() |
|
643 | self.gtk_mainloop() | |
645 | self.gtk.threads_leave() |
|
644 | self.gtk.threads_leave() | |
646 | self.join() |
|
645 | self.join() | |
647 |
|
646 | |||
648 | def on_timer(self): |
|
647 | def on_timer(self): | |
649 | update_tk(self.tk) |
|
648 | update_tk(self.tk) | |
650 | return self.IP.runcode() |
|
649 | return self.IP.runcode() | |
651 |
|
650 | |||
652 |
|
651 | |||
653 | class IPShellWX(threading.Thread): |
|
652 | class IPShellWX(threading.Thread): | |
654 | """Run a wx mainloop() in a separate thread. |
|
653 | """Run a wx mainloop() in a separate thread. | |
655 |
|
654 | |||
656 | Python commands can be passed to the thread where they will be executed. |
|
655 | Python commands can be passed to the thread where they will be executed. | |
657 | This is implemented by periodically checking for passed code using a |
|
656 | This is implemented by periodically checking for passed code using a | |
658 | GTK timeout callback.""" |
|
657 | GTK timeout callback.""" | |
659 |
|
658 | |||
660 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
659 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
661 |
|
660 | |||
662 | def __init__(self,argv=None,user_ns=None,debug=1, |
|
661 | def __init__(self,argv=None,user_ns=None,debug=1, | |
663 | shell_class=MTInteractiveShell): |
|
662 | shell_class=MTInteractiveShell): | |
664 |
|
663 | |||
665 | import wxPython.wx as wx |
|
664 | import wxPython.wx as wx | |
666 |
|
665 | |||
667 | threading.Thread.__init__(self) |
|
666 | threading.Thread.__init__(self) | |
668 | self.wx = wx |
|
667 | self.wx = wx | |
669 | self.wx_mainloop = hijack_wx() |
|
668 | self.wx_mainloop = hijack_wx() | |
670 |
|
669 | |||
671 | # Allows us to use both Tk and GTK. |
|
670 | # Allows us to use both Tk and GTK. | |
672 | self.tk = get_tk() |
|
671 | self.tk = get_tk() | |
673 |
|
672 | |||
674 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, |
|
673 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, | |
675 | shell_class=shell_class, |
|
674 | shell_class=shell_class, | |
676 | on_kill=[self.wxexit]) |
|
675 | on_kill=[self.wxexit]) | |
677 | self.app = None |
|
676 | self.app = None | |
678 |
|
677 | |||
679 | def wxexit(self, *args): |
|
678 | def wxexit(self, *args): | |
680 | if self.app is not None: |
|
679 | if self.app is not None: | |
681 | self.app.agent.timer.Stop() |
|
680 | self.app.agent.timer.Stop() | |
682 | self.app.ExitMainLoop() |
|
681 | self.app.ExitMainLoop() | |
683 |
|
682 | |||
684 | def run(self): |
|
683 | def run(self): | |
685 | self.IP.mainloop() |
|
684 | self.IP.mainloop() | |
686 | self.IP.kill() |
|
685 | self.IP.kill() | |
687 |
|
686 | |||
688 | def mainloop(self): |
|
687 | def mainloop(self): | |
689 |
|
688 | |||
690 | self.start() |
|
689 | self.start() | |
691 |
|
690 | |||
692 | class TimerAgent(self.wx.wxMiniFrame): |
|
691 | class TimerAgent(self.wx.wxMiniFrame): | |
693 | wx = self.wx |
|
692 | wx = self.wx | |
694 | IP = self.IP |
|
693 | IP = self.IP | |
695 | tk = self.tk |
|
694 | tk = self.tk | |
696 | def __init__(self, parent, interval): |
|
695 | def __init__(self, parent, interval): | |
697 | style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ |
|
696 | style = self.wx.wxDEFAULT_FRAME_STYLE | self.wx.wxTINY_CAPTION_HORIZ | |
698 | self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200), |
|
697 | self.wx.wxMiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200), | |
699 | size=(100, 100),style=style) |
|
698 | size=(100, 100),style=style) | |
700 | self.Show(False) |
|
699 | self.Show(False) | |
701 | self.interval = interval |
|
700 | self.interval = interval | |
702 | self.timerId = self.wx.wxNewId() |
|
701 | self.timerId = self.wx.wxNewId() | |
703 |
|
702 | |||
704 | def StartWork(self): |
|
703 | def StartWork(self): | |
705 | self.timer = self.wx.wxTimer(self, self.timerId) |
|
704 | self.timer = self.wx.wxTimer(self, self.timerId) | |
706 | self.wx.EVT_TIMER(self, self.timerId, self.OnTimer) |
|
705 | self.wx.EVT_TIMER(self, self.timerId, self.OnTimer) | |
707 | self.timer.Start(self.interval) |
|
706 | self.timer.Start(self.interval) | |
708 |
|
707 | |||
709 | def OnTimer(self, event): |
|
708 | def OnTimer(self, event): | |
710 | update_tk(self.tk) |
|
709 | update_tk(self.tk) | |
711 | self.IP.runcode() |
|
710 | self.IP.runcode() | |
712 |
|
711 | |||
713 | class App(self.wx.wxApp): |
|
712 | class App(self.wx.wxApp): | |
714 | wx = self.wx |
|
713 | wx = self.wx | |
715 | TIMEOUT = self.TIMEOUT |
|
714 | TIMEOUT = self.TIMEOUT | |
716 | def OnInit(self): |
|
715 | def OnInit(self): | |
717 | 'Create the main window and insert the custom frame' |
|
716 | 'Create the main window and insert the custom frame' | |
718 | self.agent = TimerAgent(None, self.TIMEOUT) |
|
717 | self.agent = TimerAgent(None, self.TIMEOUT) | |
719 | self.agent.Show(self.wx.false) |
|
718 | self.agent.Show(self.wx.false) | |
720 | self.agent.StartWork() |
|
719 | self.agent.StartWork() | |
721 | return self.wx.true |
|
720 | return self.wx.true | |
722 |
|
721 | |||
723 | self.app = App(redirect=False) |
|
722 | self.app = App(redirect=False) | |
724 | self.wx_mainloop(self.app) |
|
723 | self.wx_mainloop(self.app) | |
725 | self.join() |
|
724 | self.join() | |
726 |
|
725 | |||
727 |
|
726 | |||
728 | class IPShellQt(threading.Thread): |
|
727 | class IPShellQt(threading.Thread): | |
729 | """Run a Qt event loop in a separate thread. |
|
728 | """Run a Qt event loop in a separate thread. | |
730 |
|
729 | |||
731 | Python commands can be passed to the thread where they will be executed. |
|
730 | Python commands can be passed to the thread where they will be executed. | |
732 | This is implemented by periodically checking for passed code using a |
|
731 | This is implemented by periodically checking for passed code using a | |
733 | Qt timer / slot.""" |
|
732 | Qt timer / slot.""" | |
734 |
|
733 | |||
735 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
734 | TIMEOUT = 100 # Millisecond interval between timeouts. | |
736 |
|
735 | |||
737 | def __init__(self,argv=None,user_ns=None,debug=0, |
|
736 | def __init__(self,argv=None,user_ns=None,debug=0, | |
738 | shell_class=MTInteractiveShell): |
|
737 | shell_class=MTInteractiveShell): | |
739 |
|
738 | |||
740 | import qt |
|
739 | import qt | |
741 |
|
740 | |||
742 | class newQApplication: |
|
741 | class newQApplication: | |
743 | def __init__( self ): |
|
742 | def __init__( self ): | |
744 | self.QApplication = qt.QApplication |
|
743 | self.QApplication = qt.QApplication | |
745 |
|
744 | |||
746 | def __call__( *args, **kwargs ): |
|
745 | def __call__( *args, **kwargs ): | |
747 | return qt.qApp |
|
746 | return qt.qApp | |
748 |
|
747 | |||
749 | def exec_loop( *args, **kwargs ): |
|
748 | def exec_loop( *args, **kwargs ): | |
750 | pass |
|
749 | pass | |
751 |
|
750 | |||
752 | def __getattr__( self, name ): |
|
751 | def __getattr__( self, name ): | |
753 | return getattr( self.QApplication, name ) |
|
752 | return getattr( self.QApplication, name ) | |
754 |
|
753 | |||
755 | qt.QApplication = newQApplication() |
|
754 | qt.QApplication = newQApplication() | |
756 |
|
755 | |||
757 | # Allows us to use both Tk and QT. |
|
756 | # Allows us to use both Tk and QT. | |
758 | self.tk = get_tk() |
|
757 | self.tk = get_tk() | |
759 |
|
758 | |||
760 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, |
|
759 | self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, | |
761 | shell_class=shell_class, |
|
760 | shell_class=shell_class, | |
762 | on_kill=[qt.qApp.exit]) |
|
761 | on_kill=[qt.qApp.exit]) | |
763 |
|
762 | |||
764 | threading.Thread.__init__(self) |
|
763 | threading.Thread.__init__(self) | |
765 |
|
764 | |||
766 | def run(self): |
|
765 | def run(self): | |
767 | #sys.excepthook = self.IP.excepthook # dbg |
|
766 | #sys.excepthook = self.IP.excepthook # dbg | |
768 | self.IP.mainloop() |
|
767 | self.IP.mainloop() | |
769 | self.IP.kill() |
|
768 | self.IP.kill() | |
770 |
|
769 | |||
771 | def mainloop(self): |
|
770 | def mainloop(self): | |
772 | import qt, sys |
|
771 | import qt, sys | |
773 | if qt.QApplication.startingUp(): |
|
772 | if qt.QApplication.startingUp(): | |
774 | a = qt.QApplication.QApplication( sys.argv ) |
|
773 | a = qt.QApplication.QApplication( sys.argv ) | |
775 | self.timer = qt.QTimer() |
|
774 | self.timer = qt.QTimer() | |
776 | qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer ) |
|
775 | qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer ) | |
777 |
|
776 | |||
778 | self.start() |
|
777 | self.start() | |
779 | self.timer.start( self.TIMEOUT, True ) |
|
778 | self.timer.start( self.TIMEOUT, True ) | |
780 | while True: |
|
779 | while True: | |
781 | if self.IP._kill: break |
|
780 | if self.IP._kill: break | |
782 | qt.qApp.exec_loop() |
|
781 | qt.qApp.exec_loop() | |
783 | self.join() |
|
782 | self.join() | |
784 |
|
783 | |||
785 | def on_timer(self): |
|
784 | def on_timer(self): | |
786 | update_tk(self.tk) |
|
785 | update_tk(self.tk) | |
787 | result = self.IP.runcode() |
|
786 | result = self.IP.runcode() | |
788 | self.timer.start( self.TIMEOUT, True ) |
|
787 | self.timer.start( self.TIMEOUT, True ) | |
789 | return result |
|
788 | return result | |
790 |
|
789 | |||
791 | # A set of matplotlib public IPython shell classes, for single-threaded |
|
790 | # A set of matplotlib public IPython shell classes, for single-threaded | |
792 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. |
|
791 | # (Tk* and FLTK* backends) and multithreaded (GTK* and WX* backends) use. | |
793 | class IPShellMatplotlib(IPShell): |
|
792 | class IPShellMatplotlib(IPShell): | |
794 | """Subclass IPShell with MatplotlibShell as the internal shell. |
|
793 | """Subclass IPShell with MatplotlibShell as the internal shell. | |
795 |
|
794 | |||
796 | Single-threaded class, meant for the Tk* and FLTK* backends. |
|
795 | Single-threaded class, meant for the Tk* and FLTK* backends. | |
797 |
|
796 | |||
798 | Having this on a separate class simplifies the external driver code.""" |
|
797 | Having this on a separate class simplifies the external driver code.""" | |
799 |
|
798 | |||
800 | def __init__(self,argv=None,user_ns=None,debug=1): |
|
799 | def __init__(self,argv=None,user_ns=None,debug=1): | |
801 | IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell) |
|
800 | IPShell.__init__(self,argv,user_ns,debug,shell_class=MatplotlibShell) | |
802 |
|
801 | |||
803 | class IPShellMatplotlibGTK(IPShellGTK): |
|
802 | class IPShellMatplotlibGTK(IPShellGTK): | |
804 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. |
|
803 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. | |
805 |
|
804 | |||
806 | Multi-threaded class, meant for the GTK* backends.""" |
|
805 | Multi-threaded class, meant for the GTK* backends.""" | |
807 |
|
806 | |||
808 | def __init__(self,argv=None,user_ns=None,debug=1): |
|
807 | def __init__(self,argv=None,user_ns=None,debug=1): | |
809 | IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) |
|
808 | IPShellGTK.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) | |
810 |
|
809 | |||
811 | class IPShellMatplotlibWX(IPShellWX): |
|
810 | class IPShellMatplotlibWX(IPShellWX): | |
812 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. |
|
811 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. | |
813 |
|
812 | |||
814 | Multi-threaded class, meant for the WX* backends.""" |
|
813 | Multi-threaded class, meant for the WX* backends.""" | |
815 |
|
814 | |||
816 | def __init__(self,argv=None,user_ns=None,debug=1): |
|
815 | def __init__(self,argv=None,user_ns=None,debug=1): | |
817 | IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) |
|
816 | IPShellWX.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) | |
818 |
|
817 | |||
819 | class IPShellMatplotlibQt(IPShellQt): |
|
818 | class IPShellMatplotlibQt(IPShellQt): | |
820 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. |
|
819 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. | |
821 |
|
820 | |||
822 | Multi-threaded class, meant for the Qt* backends.""" |
|
821 | Multi-threaded class, meant for the Qt* backends.""" | |
823 |
|
822 | |||
824 | def __init__(self,argv=None,user_ns=None,debug=1): |
|
823 | def __init__(self,argv=None,user_ns=None,debug=1): | |
825 | IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) |
|
824 | IPShellQt.__init__(self,argv,user_ns,debug,shell_class=MatplotlibMTShell) | |
826 |
|
825 | |||
827 | #----------------------------------------------------------------------------- |
|
826 | #----------------------------------------------------------------------------- | |
828 | # Factory functions to actually start the proper thread-aware shell |
|
827 | # Factory functions to actually start the proper thread-aware shell | |
829 |
|
828 | |||
830 | def _matplotlib_shell_class(): |
|
829 | def _matplotlib_shell_class(): | |
831 | """Factory function to handle shell class selection for matplotlib. |
|
830 | """Factory function to handle shell class selection for matplotlib. | |
832 |
|
831 | |||
833 | The proper shell class to use depends on the matplotlib backend, since |
|
832 | The proper shell class to use depends on the matplotlib backend, since | |
834 | each backend requires a different threading strategy.""" |
|
833 | each backend requires a different threading strategy.""" | |
835 |
|
834 | |||
836 | try: |
|
835 | try: | |
837 | import matplotlib |
|
836 | import matplotlib | |
838 | except ImportError: |
|
837 | except ImportError: | |
839 | error('matplotlib could NOT be imported! Starting normal IPython.') |
|
838 | error('matplotlib could NOT be imported! Starting normal IPython.') | |
840 | sh_class = IPShell |
|
839 | sh_class = IPShell | |
841 | else: |
|
840 | else: | |
842 | backend = matplotlib.rcParams['backend'] |
|
841 | backend = matplotlib.rcParams['backend'] | |
843 | if backend.startswith('GTK'): |
|
842 | if backend.startswith('GTK'): | |
844 | sh_class = IPShellMatplotlibGTK |
|
843 | sh_class = IPShellMatplotlibGTK | |
845 | elif backend.startswith('WX'): |
|
844 | elif backend.startswith('WX'): | |
846 | sh_class = IPShellMatplotlibWX |
|
845 | sh_class = IPShellMatplotlibWX | |
847 | elif backend.startswith('Qt'): |
|
846 | elif backend.startswith('Qt'): | |
848 | sh_class = IPShellMatplotlibQt |
|
847 | sh_class = IPShellMatplotlibQt | |
849 | else: |
|
848 | else: | |
850 | sh_class = IPShellMatplotlib |
|
849 | sh_class = IPShellMatplotlib | |
851 | #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg |
|
850 | #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg | |
852 | return sh_class |
|
851 | return sh_class | |
853 |
|
852 | |||
854 | # This is the one which should be called by external code. |
|
853 | # This is the one which should be called by external code. | |
855 | def start(): |
|
854 | def start(): | |
856 | """Return a running shell instance, dealing with threading options. |
|
855 | """Return a running shell instance, dealing with threading options. | |
857 |
|
856 | |||
858 | This is a factory function which will instantiate the proper IPython shell |
|
857 | This is a factory function which will instantiate the proper IPython shell | |
859 | based on the user's threading choice. Such a selector is needed because |
|
858 | based on the user's threading choice. Such a selector is needed because | |
860 | different GUI toolkits require different thread handling details.""" |
|
859 | different GUI toolkits require different thread handling details.""" | |
861 |
|
860 | |||
862 | global USE_TK |
|
861 | global USE_TK | |
863 | # Crude sys.argv hack to extract the threading options. |
|
862 | # Crude sys.argv hack to extract the threading options. | |
864 | if len(sys.argv) > 1: |
|
863 | if len(sys.argv) > 1: | |
865 | if len(sys.argv) > 2: |
|
864 | if len(sys.argv) > 2: | |
866 | arg2 = sys.argv[2] |
|
865 | arg2 = sys.argv[2] | |
867 | if arg2.endswith('-tk'): |
|
866 | if arg2.endswith('-tk'): | |
868 | USE_TK = True |
|
867 | USE_TK = True | |
869 | arg1 = sys.argv[1] |
|
868 | arg1 = sys.argv[1] | |
870 | if arg1.endswith('-gthread'): |
|
869 | if arg1.endswith('-gthread'): | |
871 | shell = IPShellGTK |
|
870 | shell = IPShellGTK | |
872 | elif arg1.endswith( '-qthread' ): |
|
871 | elif arg1.endswith( '-qthread' ): | |
873 | shell = IPShellQt |
|
872 | shell = IPShellQt | |
874 | elif arg1.endswith('-wthread'): |
|
873 | elif arg1.endswith('-wthread'): | |
875 | shell = IPShellWX |
|
874 | shell = IPShellWX | |
876 | elif arg1.endswith('-pylab'): |
|
875 | elif arg1.endswith('-pylab'): | |
877 | shell = _matplotlib_shell_class() |
|
876 | shell = _matplotlib_shell_class() | |
878 | else: |
|
877 | else: | |
879 | shell = IPShell |
|
878 | shell = IPShell | |
880 | else: |
|
879 | else: | |
881 | shell = IPShell |
|
880 | shell = IPShell | |
882 | return shell() |
|
881 | return shell() | |
883 |
|
882 | |||
884 | # Some aliases for backwards compatibility |
|
883 | # Some aliases for backwards compatibility | |
885 | IPythonShell = IPShell |
|
884 | IPythonShell = IPShell | |
886 | IPythonShellEmbed = IPShellEmbed |
|
885 | IPythonShellEmbed = IPShellEmbed | |
887 | #************************ End of file <Shell.py> *************************** |
|
886 | #************************ End of file <Shell.py> *************************** |
@@ -1,1520 +1,1521 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | General purpose utilities. |
|
3 | General purpose utilities. | |
4 |
|
4 | |||
5 | This is a grab-bag of stuff I find useful in most programs I write. Some of |
|
5 | This is a grab-bag of stuff I find useful in most programs I write. Some of | |
6 | these things are also convenient when working at the command line. |
|
6 | these things are also convenient when working at the command line. | |
7 |
|
7 | |||
8 |
$Id: genutils.py |
|
8 | $Id: genutils.py 703 2005-08-16 17:34:44Z fperez $""" | |
9 |
|
9 | |||
10 | #***************************************************************************** |
|
10 | #***************************************************************************** | |
11 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> |
|
11 | # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu> | |
12 | # |
|
12 | # | |
13 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | # Distributed under the terms of the BSD License. The full license is in | |
14 | # the file COPYING, distributed as part of this software. |
|
14 | # the file COPYING, distributed as part of this software. | |
15 | #***************************************************************************** |
|
15 | #***************************************************************************** | |
16 |
|
16 | |||
|
17 | from __future__ import generators # 2.2 compatibility | |||
|
18 | ||||
17 | from IPython import Release |
|
19 | from IPython import Release | |
18 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
20 | __author__ = '%s <%s>' % Release.authors['Fernando'] | |
19 | __license__ = Release.license |
|
21 | __license__ = Release.license | |
20 |
|
22 | |||
21 | #**************************************************************************** |
|
23 | #**************************************************************************** | |
22 | # required modules |
|
24 | # required modules | |
23 | import __main__ |
|
25 | import __main__ | |
24 | import types,commands,time,sys,os,re,shutil |
|
26 | import types,commands,time,sys,os,re,shutil | |
25 | import tempfile |
|
27 | import tempfile | |
26 | import codecs |
|
|||
27 | from IPython.Itpl import Itpl,itpl,printpl |
|
28 | from IPython.Itpl import Itpl,itpl,printpl | |
28 | from IPython import DPyGetOpt |
|
29 | from IPython import DPyGetOpt | |
29 |
|
30 | |||
30 | # Build objects which appeared in Python 2.3 for 2.2, to make ipython |
|
31 | # Build objects which appeared in Python 2.3 for 2.2, to make ipython | |
31 | # 2.2-friendly |
|
32 | # 2.2-friendly | |
32 | try: |
|
33 | try: | |
33 | basestring |
|
34 | basestring | |
34 | except NameError: |
|
35 | except NameError: | |
35 | import types |
|
36 | import types | |
36 | basestring = (types.StringType, types.UnicodeType) |
|
37 | basestring = (types.StringType, types.UnicodeType) | |
37 | True = 1==1 |
|
38 | True = 1==1 | |
38 | False = 1==0 |
|
39 | False = 1==0 | |
39 |
|
40 | |||
40 | def enumerate(obj): |
|
41 | def enumerate(obj): | |
41 | i = -1 |
|
42 | i = -1 | |
42 | for item in obj: |
|
43 | for item in obj: | |
43 | i += 1 |
|
44 | i += 1 | |
44 | yield i, item |
|
45 | yield i, item | |
45 |
|
46 | |||
46 | # add these to the builtin namespace, so that all modules find them |
|
47 | # add these to the builtin namespace, so that all modules find them | |
47 | import __builtin__ |
|
48 | import __builtin__ | |
48 | __builtin__.basestring = basestring |
|
49 | __builtin__.basestring = basestring | |
49 | __builtin__.True = True |
|
50 | __builtin__.True = True | |
50 | __builtin__.False = False |
|
51 | __builtin__.False = False | |
51 | __builtin__.enumerate = enumerate |
|
52 | __builtin__.enumerate = enumerate | |
52 |
|
53 | |||
53 | #**************************************************************************** |
|
54 | #**************************************************************************** | |
54 | # Exceptions |
|
55 | # Exceptions | |
55 | class Error(Exception): |
|
56 | class Error(Exception): | |
56 | """Base class for exceptions in this module.""" |
|
57 | """Base class for exceptions in this module.""" | |
57 | pass |
|
58 | pass | |
58 |
|
59 | |||
59 | #---------------------------------------------------------------------------- |
|
60 | #---------------------------------------------------------------------------- | |
60 | class IOStream: |
|
61 | class IOStream: | |
61 | def __init__(self,stream,fallback): |
|
62 | def __init__(self,stream,fallback): | |
62 | if not hasattr(stream,'write') or not hasattr(stream,'flush'): |
|
63 | if not hasattr(stream,'write') or not hasattr(stream,'flush'): | |
63 | stream = fallback |
|
64 | stream = fallback | |
64 | self.stream = stream |
|
65 | self.stream = stream | |
65 | self._swrite = stream.write |
|
66 | self._swrite = stream.write | |
66 | self.flush = stream.flush |
|
67 | self.flush = stream.flush | |
67 |
|
68 | |||
68 | def write(self,data): |
|
69 | def write(self,data): | |
69 | try: |
|
70 | try: | |
70 | self._swrite(data) |
|
71 | self._swrite(data) | |
71 | except: |
|
72 | except: | |
72 | try: |
|
73 | try: | |
73 | # print handles some unicode issues which may trip a plain |
|
74 | # print handles some unicode issues which may trip a plain | |
74 | # write() call. Attempt to emulate write() by using a |
|
75 | # write() call. Attempt to emulate write() by using a | |
75 | # trailing comma |
|
76 | # trailing comma | |
76 | print >> self.stream, data, |
|
77 | print >> self.stream, data, | |
77 | except: |
|
78 | except: | |
78 | # if we get here, something is seriously broken. |
|
79 | # if we get here, something is seriously broken. | |
79 | print >> sys.stderr, \ |
|
80 | print >> sys.stderr, \ | |
80 | 'ERROR - failed to write data to stream:', stream |
|
81 | 'ERROR - failed to write data to stream:', stream | |
81 |
|
82 | |||
82 | class IOTerm: |
|
83 | class IOTerm: | |
83 | """ Term holds the file or file-like objects for handling I/O operations. |
|
84 | """ Term holds the file or file-like objects for handling I/O operations. | |
84 |
|
85 | |||
85 | These are normally just sys.stdin, sys.stdout and sys.stderr but for |
|
86 | These are normally just sys.stdin, sys.stdout and sys.stderr but for | |
86 | Windows they can can replaced to allow editing the strings before they are |
|
87 | Windows they can can replaced to allow editing the strings before they are | |
87 | displayed.""" |
|
88 | displayed.""" | |
88 |
|
89 | |||
89 | # In the future, having IPython channel all its I/O operations through |
|
90 | # In the future, having IPython channel all its I/O operations through | |
90 | # this class will make it easier to embed it into other environments which |
|
91 | # this class will make it easier to embed it into other environments which | |
91 | # are not a normal terminal (such as a GUI-based shell) |
|
92 | # are not a normal terminal (such as a GUI-based shell) | |
92 | def __init__(self,cin=None,cout=None,cerr=None): |
|
93 | def __init__(self,cin=None,cout=None,cerr=None): | |
93 | self.cin = IOStream(cin,sys.stdin) |
|
94 | self.cin = IOStream(cin,sys.stdin) | |
94 | self.cout = IOStream(cout,sys.stdout) |
|
95 | self.cout = IOStream(cout,sys.stdout) | |
95 | self.cerr = IOStream(cerr,sys.stderr) |
|
96 | self.cerr = IOStream(cerr,sys.stderr) | |
96 |
|
97 | |||
97 | # Global variable to be used for all I/O |
|
98 | # Global variable to be used for all I/O | |
98 | Term = IOTerm() |
|
99 | Term = IOTerm() | |
99 |
|
100 | |||
100 | # Windows-specific code to load Gary Bishop's readline and configure it |
|
101 | # Windows-specific code to load Gary Bishop's readline and configure it | |
101 | # automatically for the users |
|
102 | # automatically for the users | |
102 | # Note: os.name on cygwin returns posix, so this should only pick up 'native' |
|
103 | # Note: os.name on cygwin returns posix, so this should only pick up 'native' | |
103 | # windows. Cygwin returns 'cygwin' for sys.platform. |
|
104 | # windows. Cygwin returns 'cygwin' for sys.platform. | |
104 | if os.name == 'nt': |
|
105 | if os.name == 'nt': | |
105 | try: |
|
106 | try: | |
106 | import readline |
|
107 | import readline | |
107 | except ImportError: |
|
108 | except ImportError: | |
108 | pass |
|
109 | pass | |
109 | else: |
|
110 | else: | |
110 | try: |
|
111 | try: | |
111 | _out = readline.GetOutputFile() |
|
112 | _out = readline.GetOutputFile() | |
112 | except AttributeError: |
|
113 | except AttributeError: | |
113 | pass |
|
114 | pass | |
114 | else: |
|
115 | else: | |
115 | # Remake Term to use the readline i/o facilities |
|
116 | # Remake Term to use the readline i/o facilities | |
116 | Term = IOTerm(cout=_out,cerr=_out) |
|
117 | Term = IOTerm(cout=_out,cerr=_out) | |
117 | del _out |
|
118 | del _out | |
118 |
|
119 | |||
119 | #**************************************************************************** |
|
120 | #**************************************************************************** | |
120 | # Generic warning/error printer, used by everything else |
|
121 | # Generic warning/error printer, used by everything else | |
121 | def warn(msg,level=2,exit_val=1): |
|
122 | def warn(msg,level=2,exit_val=1): | |
122 | """Standard warning printer. Gives formatting consistency. |
|
123 | """Standard warning printer. Gives formatting consistency. | |
123 |
|
124 | |||
124 | Output is sent to Term.cerr (sys.stderr by default). |
|
125 | Output is sent to Term.cerr (sys.stderr by default). | |
125 |
|
126 | |||
126 | Options: |
|
127 | Options: | |
127 |
|
128 | |||
128 | -level(2): allows finer control: |
|
129 | -level(2): allows finer control: | |
129 | 0 -> Do nothing, dummy function. |
|
130 | 0 -> Do nothing, dummy function. | |
130 | 1 -> Print message. |
|
131 | 1 -> Print message. | |
131 | 2 -> Print 'WARNING:' + message. (Default level). |
|
132 | 2 -> Print 'WARNING:' + message. (Default level). | |
132 | 3 -> Print 'ERROR:' + message. |
|
133 | 3 -> Print 'ERROR:' + message. | |
133 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). |
|
134 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). | |
134 |
|
135 | |||
135 | -exit_val (1): exit value returned by sys.exit() for a level 4 |
|
136 | -exit_val (1): exit value returned by sys.exit() for a level 4 | |
136 | warning. Ignored for all other levels.""" |
|
137 | warning. Ignored for all other levels.""" | |
137 |
|
138 | |||
138 | if level>0: |
|
139 | if level>0: | |
139 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
140 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] | |
140 | print >> Term.cerr, '%s%s' % (header[level],msg) |
|
141 | print >> Term.cerr, '%s%s' % (header[level],msg) | |
141 | if level == 4: |
|
142 | if level == 4: | |
142 | print >> Term.cerr,'Exiting.\n' |
|
143 | print >> Term.cerr,'Exiting.\n' | |
143 | sys.exit(exit_val) |
|
144 | sys.exit(exit_val) | |
144 |
|
145 | |||
145 | def info(msg): |
|
146 | def info(msg): | |
146 | """Equivalent to warn(msg,level=1).""" |
|
147 | """Equivalent to warn(msg,level=1).""" | |
147 |
|
148 | |||
148 | warn(msg,level=1) |
|
149 | warn(msg,level=1) | |
149 |
|
150 | |||
150 | def error(msg): |
|
151 | def error(msg): | |
151 | """Equivalent to warn(msg,level=3).""" |
|
152 | """Equivalent to warn(msg,level=3).""" | |
152 |
|
153 | |||
153 | warn(msg,level=3) |
|
154 | warn(msg,level=3) | |
154 |
|
155 | |||
155 | def fatal(msg,exit_val=1): |
|
156 | def fatal(msg,exit_val=1): | |
156 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" |
|
157 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" | |
157 |
|
158 | |||
158 | warn(msg,exit_val=exit_val,level=4) |
|
159 | warn(msg,exit_val=exit_val,level=4) | |
159 |
|
160 | |||
160 | #---------------------------------------------------------------------------- |
|
161 | #---------------------------------------------------------------------------- | |
161 | StringTypes = types.StringTypes |
|
162 | StringTypes = types.StringTypes | |
162 |
|
163 | |||
163 | # Basic timing functionality |
|
164 | # Basic timing functionality | |
164 |
|
165 | |||
165 | # If possible (Unix), use the resource module instead of time.clock() |
|
166 | # If possible (Unix), use the resource module instead of time.clock() | |
166 | try: |
|
167 | try: | |
167 | import resource |
|
168 | import resource | |
168 | def clock(): |
|
169 | def clock(): | |
169 | """clock() -> floating point number |
|
170 | """clock() -> floating point number | |
170 |
|
171 | |||
171 | Return the CPU time in seconds (user time only, system time is |
|
172 | Return the CPU time in seconds (user time only, system time is | |
172 | ignored) since the start of the process. This is done via a call to |
|
173 | ignored) since the start of the process. This is done via a call to | |
173 | resource.getrusage, so it avoids the wraparound problems in |
|
174 | resource.getrusage, so it avoids the wraparound problems in | |
174 | time.clock().""" |
|
175 | time.clock().""" | |
175 |
|
176 | |||
176 | return resource.getrusage(resource.RUSAGE_SELF)[0] |
|
177 | return resource.getrusage(resource.RUSAGE_SELF)[0] | |
177 |
|
178 | |||
178 | def clock2(): |
|
179 | def clock2(): | |
179 | """clock2() -> (t_user,t_system) |
|
180 | """clock2() -> (t_user,t_system) | |
180 |
|
181 | |||
181 | Similar to clock(), but return a tuple of user/system times.""" |
|
182 | Similar to clock(), but return a tuple of user/system times.""" | |
182 | return resource.getrusage(resource.RUSAGE_SELF)[:2] |
|
183 | return resource.getrusage(resource.RUSAGE_SELF)[:2] | |
183 |
|
184 | |||
184 | except ImportError: |
|
185 | except ImportError: | |
185 | clock = time.clock |
|
186 | clock = time.clock | |
186 | def clock2(): |
|
187 | def clock2(): | |
187 | """Under windows, system CPU time can't be measured. |
|
188 | """Under windows, system CPU time can't be measured. | |
188 |
|
189 | |||
189 | This just returns clock() and zero.""" |
|
190 | This just returns clock() and zero.""" | |
190 | return time.clock(),0.0 |
|
191 | return time.clock(),0.0 | |
191 |
|
192 | |||
192 | def timings_out(reps,func,*args,**kw): |
|
193 | def timings_out(reps,func,*args,**kw): | |
193 | """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) |
|
194 | """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) | |
194 |
|
195 | |||
195 | Execute a function reps times, return a tuple with the elapsed total |
|
196 | Execute a function reps times, return a tuple with the elapsed total | |
196 | CPU time in seconds, the time per call and the function's output. |
|
197 | CPU time in seconds, the time per call and the function's output. | |
197 |
|
198 | |||
198 | Under Unix, the return value is the sum of user+system time consumed by |
|
199 | Under Unix, the return value is the sum of user+system time consumed by | |
199 | the process, computed via the resource module. This prevents problems |
|
200 | the process, computed via the resource module. This prevents problems | |
200 | related to the wraparound effect which the time.clock() function has. |
|
201 | related to the wraparound effect which the time.clock() function has. | |
201 |
|
202 | |||
202 | Under Windows the return value is in wall clock seconds. See the |
|
203 | Under Windows the return value is in wall clock seconds. See the | |
203 | documentation for the time module for more details.""" |
|
204 | documentation for the time module for more details.""" | |
204 |
|
205 | |||
205 | reps = int(reps) |
|
206 | reps = int(reps) | |
206 | assert reps >=1, 'reps must be >= 1' |
|
207 | assert reps >=1, 'reps must be >= 1' | |
207 | if reps==1: |
|
208 | if reps==1: | |
208 | start = clock() |
|
209 | start = clock() | |
209 | out = func(*args,**kw) |
|
210 | out = func(*args,**kw) | |
210 | tot_time = clock()-start |
|
211 | tot_time = clock()-start | |
211 | else: |
|
212 | else: | |
212 | rng = xrange(reps-1) # the last time is executed separately to store output |
|
213 | rng = xrange(reps-1) # the last time is executed separately to store output | |
213 | start = clock() |
|
214 | start = clock() | |
214 | for dummy in rng: func(*args,**kw) |
|
215 | for dummy in rng: func(*args,**kw) | |
215 | out = func(*args,**kw) # one last time |
|
216 | out = func(*args,**kw) # one last time | |
216 | tot_time = clock()-start |
|
217 | tot_time = clock()-start | |
217 | av_time = tot_time / reps |
|
218 | av_time = tot_time / reps | |
218 | return tot_time,av_time,out |
|
219 | return tot_time,av_time,out | |
219 |
|
220 | |||
220 | def timings(reps,func,*args,**kw): |
|
221 | def timings(reps,func,*args,**kw): | |
221 | """timings(reps,func,*args,**kw) -> (t_total,t_per_call) |
|
222 | """timings(reps,func,*args,**kw) -> (t_total,t_per_call) | |
222 |
|
223 | |||
223 | Execute a function reps times, return a tuple with the elapsed total CPU |
|
224 | Execute a function reps times, return a tuple with the elapsed total CPU | |
224 | time in seconds and the time per call. These are just the first two values |
|
225 | time in seconds and the time per call. These are just the first two values | |
225 | in timings_out().""" |
|
226 | in timings_out().""" | |
226 |
|
227 | |||
227 | return timings_out(reps,func,*args,**kw)[0:2] |
|
228 | return timings_out(reps,func,*args,**kw)[0:2] | |
228 |
|
229 | |||
229 | def timing(func,*args,**kw): |
|
230 | def timing(func,*args,**kw): | |
230 | """timing(func,*args,**kw) -> t_total |
|
231 | """timing(func,*args,**kw) -> t_total | |
231 |
|
232 | |||
232 | Execute a function once, return the elapsed total CPU time in |
|
233 | Execute a function once, return the elapsed total CPU time in | |
233 | seconds. This is just the first value in timings_out().""" |
|
234 | seconds. This is just the first value in timings_out().""" | |
234 |
|
235 | |||
235 | return timings_out(1,func,*args,**kw)[0] |
|
236 | return timings_out(1,func,*args,**kw)[0] | |
236 |
|
237 | |||
237 | #**************************************************************************** |
|
238 | #**************************************************************************** | |
238 | # file and system |
|
239 | # file and system | |
239 |
|
240 | |||
240 | def system(cmd,verbose=0,debug=0,header=''): |
|
241 | def system(cmd,verbose=0,debug=0,header=''): | |
241 | """Execute a system command, return its exit status. |
|
242 | """Execute a system command, return its exit status. | |
242 |
|
243 | |||
243 | Options: |
|
244 | Options: | |
244 |
|
245 | |||
245 | - verbose (0): print the command to be executed. |
|
246 | - verbose (0): print the command to be executed. | |
246 |
|
247 | |||
247 | - debug (0): only print, do not actually execute. |
|
248 | - debug (0): only print, do not actually execute. | |
248 |
|
249 | |||
249 | - header (''): Header to print on screen prior to the executed command (it |
|
250 | - header (''): Header to print on screen prior to the executed command (it | |
250 | is only prepended to the command, no newlines are added). |
|
251 | is only prepended to the command, no newlines are added). | |
251 |
|
252 | |||
252 | Note: a stateful version of this function is available through the |
|
253 | Note: a stateful version of this function is available through the | |
253 | SystemExec class.""" |
|
254 | SystemExec class.""" | |
254 |
|
255 | |||
255 | stat = 0 |
|
256 | stat = 0 | |
256 | if verbose or debug: print header+cmd |
|
257 | if verbose or debug: print header+cmd | |
257 | sys.stdout.flush() |
|
258 | sys.stdout.flush() | |
258 | if not debug: stat = os.system(cmd) |
|
259 | if not debug: stat = os.system(cmd) | |
259 | return stat |
|
260 | return stat | |
260 |
|
261 | |||
261 | def shell(cmd,verbose=0,debug=0,header=''): |
|
262 | def shell(cmd,verbose=0,debug=0,header=''): | |
262 | """Execute a command in the system shell, always return None. |
|
263 | """Execute a command in the system shell, always return None. | |
263 |
|
264 | |||
264 | Options: |
|
265 | Options: | |
265 |
|
266 | |||
266 | - verbose (0): print the command to be executed. |
|
267 | - verbose (0): print the command to be executed. | |
267 |
|
268 | |||
268 | - debug (0): only print, do not actually execute. |
|
269 | - debug (0): only print, do not actually execute. | |
269 |
|
270 | |||
270 | - header (''): Header to print on screen prior to the executed command (it |
|
271 | - header (''): Header to print on screen prior to the executed command (it | |
271 | is only prepended to the command, no newlines are added). |
|
272 | is only prepended to the command, no newlines are added). | |
272 |
|
273 | |||
273 | Note: this is similar to genutils.system(), but it returns None so it can |
|
274 | Note: this is similar to genutils.system(), but it returns None so it can | |
274 | be conveniently used in interactive loops without getting the return value |
|
275 | be conveniently used in interactive loops without getting the return value | |
275 | (typically 0) printed many times.""" |
|
276 | (typically 0) printed many times.""" | |
276 |
|
277 | |||
277 | stat = 0 |
|
278 | stat = 0 | |
278 | if verbose or debug: print header+cmd |
|
279 | if verbose or debug: print header+cmd | |
279 | # flush stdout so we don't mangle python's buffering |
|
280 | # flush stdout so we don't mangle python's buffering | |
280 | sys.stdout.flush() |
|
281 | sys.stdout.flush() | |
281 | if not debug: |
|
282 | if not debug: | |
282 | os.system(cmd) |
|
283 | os.system(cmd) | |
283 |
|
284 | |||
284 | def getoutput(cmd,verbose=0,debug=0,header='',split=0): |
|
285 | def getoutput(cmd,verbose=0,debug=0,header='',split=0): | |
285 | """Dummy substitute for perl's backquotes. |
|
286 | """Dummy substitute for perl's backquotes. | |
286 |
|
287 | |||
287 | Executes a command and returns the output. |
|
288 | Executes a command and returns the output. | |
288 |
|
289 | |||
289 | Accepts the same arguments as system(), plus: |
|
290 | Accepts the same arguments as system(), plus: | |
290 |
|
291 | |||
291 | - split(0): if true, the output is returned as a list split on newlines. |
|
292 | - split(0): if true, the output is returned as a list split on newlines. | |
292 |
|
293 | |||
293 | Note: a stateful version of this function is available through the |
|
294 | Note: a stateful version of this function is available through the | |
294 | SystemExec class.""" |
|
295 | SystemExec class.""" | |
295 |
|
296 | |||
296 | if verbose or debug: print header+cmd |
|
297 | if verbose or debug: print header+cmd | |
297 | if not debug: |
|
298 | if not debug: | |
298 | output = commands.getoutput(cmd) |
|
299 | output = commands.getoutput(cmd) | |
299 | if split: |
|
300 | if split: | |
300 | return output.split('\n') |
|
301 | return output.split('\n') | |
301 | else: |
|
302 | else: | |
302 | return output |
|
303 | return output | |
303 |
|
304 | |||
304 | def getoutputerror(cmd,verbose=0,debug=0,header='',split=0): |
|
305 | def getoutputerror(cmd,verbose=0,debug=0,header='',split=0): | |
305 | """Return (standard output,standard error) of executing cmd in a shell. |
|
306 | """Return (standard output,standard error) of executing cmd in a shell. | |
306 |
|
307 | |||
307 | Accepts the same arguments as system(), plus: |
|
308 | Accepts the same arguments as system(), plus: | |
308 |
|
309 | |||
309 | - split(0): if true, each of stdout/err is returned as a list split on |
|
310 | - split(0): if true, each of stdout/err is returned as a list split on | |
310 | newlines. |
|
311 | newlines. | |
311 |
|
312 | |||
312 | Note: a stateful version of this function is available through the |
|
313 | Note: a stateful version of this function is available through the | |
313 | SystemExec class.""" |
|
314 | SystemExec class.""" | |
314 |
|
315 | |||
315 | if verbose or debug: print header+cmd |
|
316 | if verbose or debug: print header+cmd | |
316 | if not cmd: |
|
317 | if not cmd: | |
317 | if split: |
|
318 | if split: | |
318 | return [],[] |
|
319 | return [],[] | |
319 | else: |
|
320 | else: | |
320 | return '','' |
|
321 | return '','' | |
321 | if not debug: |
|
322 | if not debug: | |
322 | pin,pout,perr = os.popen3(cmd) |
|
323 | pin,pout,perr = os.popen3(cmd) | |
323 | tout = pout.read().rstrip() |
|
324 | tout = pout.read().rstrip() | |
324 | terr = perr.read().rstrip() |
|
325 | terr = perr.read().rstrip() | |
325 | pin.close() |
|
326 | pin.close() | |
326 | pout.close() |
|
327 | pout.close() | |
327 | perr.close() |
|
328 | perr.close() | |
328 | if split: |
|
329 | if split: | |
329 | return tout.split('\n'),terr.split('\n') |
|
330 | return tout.split('\n'),terr.split('\n') | |
330 | else: |
|
331 | else: | |
331 | return tout,terr |
|
332 | return tout,terr | |
332 |
|
333 | |||
333 | # for compatibility with older naming conventions |
|
334 | # for compatibility with older naming conventions | |
334 | xsys = system |
|
335 | xsys = system | |
335 | bq = getoutput |
|
336 | bq = getoutput | |
336 |
|
337 | |||
337 | class SystemExec: |
|
338 | class SystemExec: | |
338 | """Access the system and getoutput functions through a stateful interface. |
|
339 | """Access the system and getoutput functions through a stateful interface. | |
339 |
|
340 | |||
340 | Note: here we refer to the system and getoutput functions from this |
|
341 | Note: here we refer to the system and getoutput functions from this | |
341 | library, not the ones from the standard python library. |
|
342 | library, not the ones from the standard python library. | |
342 |
|
343 | |||
343 | This class offers the system and getoutput functions as methods, but the |
|
344 | This class offers the system and getoutput functions as methods, but the | |
344 | verbose, debug and header parameters can be set for the instance (at |
|
345 | verbose, debug and header parameters can be set for the instance (at | |
345 | creation time or later) so that they don't need to be specified on each |
|
346 | creation time or later) so that they don't need to be specified on each | |
346 | call. |
|
347 | call. | |
347 |
|
348 | |||
348 | For efficiency reasons, there's no way to override the parameters on a |
|
349 | For efficiency reasons, there's no way to override the parameters on a | |
349 | per-call basis other than by setting instance attributes. If you need |
|
350 | per-call basis other than by setting instance attributes. If you need | |
350 | local overrides, it's best to directly call system() or getoutput(). |
|
351 | local overrides, it's best to directly call system() or getoutput(). | |
351 |
|
352 | |||
352 | The following names are provided as alternate options: |
|
353 | The following names are provided as alternate options: | |
353 | - xsys: alias to system |
|
354 | - xsys: alias to system | |
354 | - bq: alias to getoutput |
|
355 | - bq: alias to getoutput | |
355 |
|
356 | |||
356 | An instance can then be created as: |
|
357 | An instance can then be created as: | |
357 | >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ') |
|
358 | >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ') | |
358 |
|
359 | |||
359 | And used as: |
|
360 | And used as: | |
360 | >>> sysexec.xsys('pwd') |
|
361 | >>> sysexec.xsys('pwd') | |
361 | >>> dirlist = sysexec.bq('ls -l') |
|
362 | >>> dirlist = sysexec.bq('ls -l') | |
362 | """ |
|
363 | """ | |
363 |
|
364 | |||
364 | def __init__(self,verbose=0,debug=0,header='',split=0): |
|
365 | def __init__(self,verbose=0,debug=0,header='',split=0): | |
365 | """Specify the instance's values for verbose, debug and header.""" |
|
366 | """Specify the instance's values for verbose, debug and header.""" | |
366 | setattr_list(self,'verbose debug header split') |
|
367 | setattr_list(self,'verbose debug header split') | |
367 |
|
368 | |||
368 | def system(self,cmd): |
|
369 | def system(self,cmd): | |
369 | """Stateful interface to system(), with the same keyword parameters.""" |
|
370 | """Stateful interface to system(), with the same keyword parameters.""" | |
370 |
|
371 | |||
371 | system(cmd,self.verbose,self.debug,self.header) |
|
372 | system(cmd,self.verbose,self.debug,self.header) | |
372 |
|
373 | |||
373 | def shell(self,cmd): |
|
374 | def shell(self,cmd): | |
374 | """Stateful interface to shell(), with the same keyword parameters.""" |
|
375 | """Stateful interface to shell(), with the same keyword parameters.""" | |
375 |
|
376 | |||
376 | shell(cmd,self.verbose,self.debug,self.header) |
|
377 | shell(cmd,self.verbose,self.debug,self.header) | |
377 |
|
378 | |||
378 | xsys = system # alias |
|
379 | xsys = system # alias | |
379 |
|
380 | |||
380 | def getoutput(self,cmd): |
|
381 | def getoutput(self,cmd): | |
381 | """Stateful interface to getoutput().""" |
|
382 | """Stateful interface to getoutput().""" | |
382 |
|
383 | |||
383 | return getoutput(cmd,self.verbose,self.debug,self.header,self.split) |
|
384 | return getoutput(cmd,self.verbose,self.debug,self.header,self.split) | |
384 |
|
385 | |||
385 | def getoutputerror(self,cmd): |
|
386 | def getoutputerror(self,cmd): | |
386 | """Stateful interface to getoutputerror().""" |
|
387 | """Stateful interface to getoutputerror().""" | |
387 |
|
388 | |||
388 | return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split) |
|
389 | return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split) | |
389 |
|
390 | |||
390 | bq = getoutput # alias |
|
391 | bq = getoutput # alias | |
391 |
|
392 | |||
392 | #----------------------------------------------------------------------------- |
|
393 | #----------------------------------------------------------------------------- | |
393 | def mutex_opts(dict,ex_op): |
|
394 | def mutex_opts(dict,ex_op): | |
394 | """Check for presence of mutually exclusive keys in a dict. |
|
395 | """Check for presence of mutually exclusive keys in a dict. | |
395 |
|
396 | |||
396 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" |
|
397 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" | |
397 | for op1,op2 in ex_op: |
|
398 | for op1,op2 in ex_op: | |
398 | if op1 in dict and op2 in dict: |
|
399 | if op1 in dict and op2 in dict: | |
399 | raise ValueError,'\n*** ERROR in Arguments *** '\ |
|
400 | raise ValueError,'\n*** ERROR in Arguments *** '\ | |
400 | 'Options '+op1+' and '+op2+' are mutually exclusive.' |
|
401 | 'Options '+op1+' and '+op2+' are mutually exclusive.' | |
401 |
|
402 | |||
402 | #----------------------------------------------------------------------------- |
|
403 | #----------------------------------------------------------------------------- | |
403 | def filefind(fname,alt_dirs = None): |
|
404 | def filefind(fname,alt_dirs = None): | |
404 | """Return the given filename either in the current directory, if it |
|
405 | """Return the given filename either in the current directory, if it | |
405 | exists, or in a specified list of directories. |
|
406 | exists, or in a specified list of directories. | |
406 |
|
407 | |||
407 | ~ expansion is done on all file and directory names. |
|
408 | ~ expansion is done on all file and directory names. | |
408 |
|
409 | |||
409 | Upon an unsuccessful search, raise an IOError exception.""" |
|
410 | Upon an unsuccessful search, raise an IOError exception.""" | |
410 |
|
411 | |||
411 | if alt_dirs is None: |
|
412 | if alt_dirs is None: | |
412 | try: |
|
413 | try: | |
413 | alt_dirs = get_home_dir() |
|
414 | alt_dirs = get_home_dir() | |
414 | except HomeDirError: |
|
415 | except HomeDirError: | |
415 | alt_dirs = os.getcwd() |
|
416 | alt_dirs = os.getcwd() | |
416 | search = [fname] + list_strings(alt_dirs) |
|
417 | search = [fname] + list_strings(alt_dirs) | |
417 | search = map(os.path.expanduser,search) |
|
418 | search = map(os.path.expanduser,search) | |
418 | #print 'search list for',fname,'list:',search # dbg |
|
419 | #print 'search list for',fname,'list:',search # dbg | |
419 | fname = search[0] |
|
420 | fname = search[0] | |
420 | if os.path.isfile(fname): |
|
421 | if os.path.isfile(fname): | |
421 | return fname |
|
422 | return fname | |
422 | for direc in search[1:]: |
|
423 | for direc in search[1:]: | |
423 | testname = os.path.join(direc,fname) |
|
424 | testname = os.path.join(direc,fname) | |
424 | #print 'testname',testname # dbg |
|
425 | #print 'testname',testname # dbg | |
425 | if os.path.isfile(testname): |
|
426 | if os.path.isfile(testname): | |
426 | return testname |
|
427 | return testname | |
427 | raise IOError,'File' + `fname` + \ |
|
428 | raise IOError,'File' + `fname` + \ | |
428 | ' not found in current or supplied directories:' + `alt_dirs` |
|
429 | ' not found in current or supplied directories:' + `alt_dirs` | |
429 |
|
430 | |||
430 | #---------------------------------------------------------------------------- |
|
431 | #---------------------------------------------------------------------------- | |
431 | def target_outdated(target,deps): |
|
432 | def target_outdated(target,deps): | |
432 | """Determine whether a target is out of date. |
|
433 | """Determine whether a target is out of date. | |
433 |
|
434 | |||
434 | target_outdated(target,deps) -> 1/0 |
|
435 | target_outdated(target,deps) -> 1/0 | |
435 |
|
436 | |||
436 | deps: list of filenames which MUST exist. |
|
437 | deps: list of filenames which MUST exist. | |
437 | target: single filename which may or may not exist. |
|
438 | target: single filename which may or may not exist. | |
438 |
|
439 | |||
439 | If target doesn't exist or is older than any file listed in deps, return |
|
440 | If target doesn't exist or is older than any file listed in deps, return | |
440 | true, otherwise return false. |
|
441 | true, otherwise return false. | |
441 | """ |
|
442 | """ | |
442 | try: |
|
443 | try: | |
443 | target_time = os.path.getmtime(target) |
|
444 | target_time = os.path.getmtime(target) | |
444 | except os.error: |
|
445 | except os.error: | |
445 | return 1 |
|
446 | return 1 | |
446 | for dep in deps: |
|
447 | for dep in deps: | |
447 | dep_time = os.path.getmtime(dep) |
|
448 | dep_time = os.path.getmtime(dep) | |
448 | if dep_time > target_time: |
|
449 | if dep_time > target_time: | |
449 | #print "For target",target,"Dep failed:",dep # dbg |
|
450 | #print "For target",target,"Dep failed:",dep # dbg | |
450 | #print "times (dep,tar):",dep_time,target_time # dbg |
|
451 | #print "times (dep,tar):",dep_time,target_time # dbg | |
451 | return 1 |
|
452 | return 1 | |
452 | return 0 |
|
453 | return 0 | |
453 |
|
454 | |||
454 | #----------------------------------------------------------------------------- |
|
455 | #----------------------------------------------------------------------------- | |
455 | def target_update(target,deps,cmd): |
|
456 | def target_update(target,deps,cmd): | |
456 | """Update a target with a given command given a list of dependencies. |
|
457 | """Update a target with a given command given a list of dependencies. | |
457 |
|
458 | |||
458 | target_update(target,deps,cmd) -> runs cmd if target is outdated. |
|
459 | target_update(target,deps,cmd) -> runs cmd if target is outdated. | |
459 |
|
460 | |||
460 | This is just a wrapper around target_outdated() which calls the given |
|
461 | This is just a wrapper around target_outdated() which calls the given | |
461 | command if target is outdated.""" |
|
462 | command if target is outdated.""" | |
462 |
|
463 | |||
463 | if target_outdated(target,deps): |
|
464 | if target_outdated(target,deps): | |
464 | xsys(cmd) |
|
465 | xsys(cmd) | |
465 |
|
466 | |||
466 | #---------------------------------------------------------------------------- |
|
467 | #---------------------------------------------------------------------------- | |
467 | def unquote_ends(istr): |
|
468 | def unquote_ends(istr): | |
468 | """Remove a single pair of quotes from the endpoints of a string.""" |
|
469 | """Remove a single pair of quotes from the endpoints of a string.""" | |
469 |
|
470 | |||
470 | if not istr: |
|
471 | if not istr: | |
471 | return istr |
|
472 | return istr | |
472 | if (istr[0]=="'" and istr[-1]=="'") or \ |
|
473 | if (istr[0]=="'" and istr[-1]=="'") or \ | |
473 | (istr[0]=='"' and istr[-1]=='"'): |
|
474 | (istr[0]=='"' and istr[-1]=='"'): | |
474 | return istr[1:-1] |
|
475 | return istr[1:-1] | |
475 | else: |
|
476 | else: | |
476 | return istr |
|
477 | return istr | |
477 |
|
478 | |||
478 | #---------------------------------------------------------------------------- |
|
479 | #---------------------------------------------------------------------------- | |
479 | def process_cmdline(argv,names=[],defaults={},usage=''): |
|
480 | def process_cmdline(argv,names=[],defaults={},usage=''): | |
480 | """ Process command-line options and arguments. |
|
481 | """ Process command-line options and arguments. | |
481 |
|
482 | |||
482 | Arguments: |
|
483 | Arguments: | |
483 |
|
484 | |||
484 | - argv: list of arguments, typically sys.argv. |
|
485 | - argv: list of arguments, typically sys.argv. | |
485 |
|
486 | |||
486 | - names: list of option names. See DPyGetOpt docs for details on options |
|
487 | - names: list of option names. See DPyGetOpt docs for details on options | |
487 | syntax. |
|
488 | syntax. | |
488 |
|
489 | |||
489 | - defaults: dict of default values. |
|
490 | - defaults: dict of default values. | |
490 |
|
491 | |||
491 | - usage: optional usage notice to print if a wrong argument is passed. |
|
492 | - usage: optional usage notice to print if a wrong argument is passed. | |
492 |
|
493 | |||
493 | Return a dict of options and a list of free arguments.""" |
|
494 | Return a dict of options and a list of free arguments.""" | |
494 |
|
495 | |||
495 | getopt = DPyGetOpt.DPyGetOpt() |
|
496 | getopt = DPyGetOpt.DPyGetOpt() | |
496 | getopt.setIgnoreCase(0) |
|
497 | getopt.setIgnoreCase(0) | |
497 | getopt.parseConfiguration(names) |
|
498 | getopt.parseConfiguration(names) | |
498 |
|
499 | |||
499 | try: |
|
500 | try: | |
500 | getopt.processArguments(argv) |
|
501 | getopt.processArguments(argv) | |
501 | except: |
|
502 | except: | |
502 | print usage |
|
503 | print usage | |
503 | warn(`sys.exc_value`,level=4) |
|
504 | warn(`sys.exc_value`,level=4) | |
504 |
|
505 | |||
505 | defaults.update(getopt.optionValues) |
|
506 | defaults.update(getopt.optionValues) | |
506 | args = getopt.freeValues |
|
507 | args = getopt.freeValues | |
507 |
|
508 | |||
508 | return defaults,args |
|
509 | return defaults,args | |
509 |
|
510 | |||
510 | #---------------------------------------------------------------------------- |
|
511 | #---------------------------------------------------------------------------- | |
511 | def optstr2types(ostr): |
|
512 | def optstr2types(ostr): | |
512 | """Convert a string of option names to a dict of type mappings. |
|
513 | """Convert a string of option names to a dict of type mappings. | |
513 |
|
514 | |||
514 | optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'} |
|
515 | optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'} | |
515 |
|
516 | |||
516 | This is used to get the types of all the options in a string formatted |
|
517 | This is used to get the types of all the options in a string formatted | |
517 | with the conventions of DPyGetOpt. The 'type' None is used for options |
|
518 | with the conventions of DPyGetOpt. The 'type' None is used for options | |
518 | which are strings (they need no further conversion). This function's main |
|
519 | which are strings (they need no further conversion). This function's main | |
519 | use is to get a typemap for use with read_dict(). |
|
520 | use is to get a typemap for use with read_dict(). | |
520 | """ |
|
521 | """ | |
521 |
|
522 | |||
522 | typeconv = {None:'',int:'',float:''} |
|
523 | typeconv = {None:'',int:'',float:''} | |
523 | typemap = {'s':None,'i':int,'f':float} |
|
524 | typemap = {'s':None,'i':int,'f':float} | |
524 | opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)') |
|
525 | opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)') | |
525 |
|
526 | |||
526 | for w in ostr.split(): |
|
527 | for w in ostr.split(): | |
527 | oname,alias,otype = opt_re.match(w).groups() |
|
528 | oname,alias,otype = opt_re.match(w).groups() | |
528 | if otype == '' or alias == '!': # simple switches are integers too |
|
529 | if otype == '' or alias == '!': # simple switches are integers too | |
529 | otype = 'i' |
|
530 | otype = 'i' | |
530 | typeconv[typemap[otype]] += oname + ' ' |
|
531 | typeconv[typemap[otype]] += oname + ' ' | |
531 | return typeconv |
|
532 | return typeconv | |
532 |
|
533 | |||
533 | #---------------------------------------------------------------------------- |
|
534 | #---------------------------------------------------------------------------- | |
534 | def read_dict(filename,type_conv=None,**opt): |
|
535 | def read_dict(filename,type_conv=None,**opt): | |
535 |
|
536 | |||
536 | """Read a dictionary of key=value pairs from an input file, optionally |
|
537 | """Read a dictionary of key=value pairs from an input file, optionally | |
537 | performing conversions on the resulting values. |
|
538 | performing conversions on the resulting values. | |
538 |
|
539 | |||
539 | read_dict(filename,type_conv,**opt) -> dict |
|
540 | read_dict(filename,type_conv,**opt) -> dict | |
540 |
|
541 | |||
541 | Only one value per line is accepted, the format should be |
|
542 | Only one value per line is accepted, the format should be | |
542 | # optional comments are ignored |
|
543 | # optional comments are ignored | |
543 | key value\n |
|
544 | key value\n | |
544 |
|
545 | |||
545 | Args: |
|
546 | Args: | |
546 |
|
547 | |||
547 | - type_conv: A dictionary specifying which keys need to be converted to |
|
548 | - type_conv: A dictionary specifying which keys need to be converted to | |
548 | which types. By default all keys are read as strings. This dictionary |
|
549 | which types. By default all keys are read as strings. This dictionary | |
549 | should have as its keys valid conversion functions for strings |
|
550 | should have as its keys valid conversion functions for strings | |
550 | (int,long,float,complex, or your own). The value for each key |
|
551 | (int,long,float,complex, or your own). The value for each key | |
551 | (converter) should be a whitespace separated string containing the names |
|
552 | (converter) should be a whitespace separated string containing the names | |
552 | of all the entries in the file to be converted using that function. For |
|
553 | of all the entries in the file to be converted using that function. For | |
553 | keys to be left alone, use None as the conversion function (only needed |
|
554 | keys to be left alone, use None as the conversion function (only needed | |
554 | with purge=1, see below). |
|
555 | with purge=1, see below). | |
555 |
|
556 | |||
556 | - opt: dictionary with extra options as below (default in parens) |
|
557 | - opt: dictionary with extra options as below (default in parens) | |
557 |
|
558 | |||
558 | purge(0): if set to 1, all keys *not* listed in type_conv are purged out |
|
559 | purge(0): if set to 1, all keys *not* listed in type_conv are purged out | |
559 | of the dictionary to be returned. If purge is going to be used, the |
|
560 | of the dictionary to be returned. If purge is going to be used, the | |
560 | set of keys to be left as strings also has to be explicitly specified |
|
561 | set of keys to be left as strings also has to be explicitly specified | |
561 | using the (non-existent) conversion function None. |
|
562 | using the (non-existent) conversion function None. | |
562 |
|
563 | |||
563 | fs(None): field separator. This is the key/value separator to be used |
|
564 | fs(None): field separator. This is the key/value separator to be used | |
564 | when parsing the file. The None default means any whitespace [behavior |
|
565 | when parsing the file. The None default means any whitespace [behavior | |
565 | of string.split()]. |
|
566 | of string.split()]. | |
566 |
|
567 | |||
567 | strip(0): if 1, strip string values of leading/trailinig whitespace. |
|
568 | strip(0): if 1, strip string values of leading/trailinig whitespace. | |
568 |
|
569 | |||
569 | warn(1): warning level if requested keys are not found in file. |
|
570 | warn(1): warning level if requested keys are not found in file. | |
570 | - 0: silently ignore. |
|
571 | - 0: silently ignore. | |
571 | - 1: inform but proceed. |
|
572 | - 1: inform but proceed. | |
572 | - 2: raise KeyError exception. |
|
573 | - 2: raise KeyError exception. | |
573 |
|
574 | |||
574 | no_empty(0): if 1, remove keys with whitespace strings as a value. |
|
575 | no_empty(0): if 1, remove keys with whitespace strings as a value. | |
575 |
|
576 | |||
576 | unique([]): list of keys (or space separated string) which can't be |
|
577 | unique([]): list of keys (or space separated string) which can't be | |
577 | repeated. If one such key is found in the file, each new instance |
|
578 | repeated. If one such key is found in the file, each new instance | |
578 | overwrites the previous one. For keys not listed here, the behavior is |
|
579 | overwrites the previous one. For keys not listed here, the behavior is | |
579 | to make a list of all appearances. |
|
580 | to make a list of all appearances. | |
580 |
|
581 | |||
581 | Example: |
|
582 | Example: | |
582 | If the input file test.ini has: |
|
583 | If the input file test.ini has: | |
583 | i 3 |
|
584 | i 3 | |
584 | x 4.5 |
|
585 | x 4.5 | |
585 | y 5.5 |
|
586 | y 5.5 | |
586 | s hi ho |
|
587 | s hi ho | |
587 | Then: |
|
588 | Then: | |
588 |
|
589 | |||
589 | >>> type_conv={int:'i',float:'x',None:'s'} |
|
590 | >>> type_conv={int:'i',float:'x',None:'s'} | |
590 | >>> read_dict('test.ini') |
|
591 | >>> read_dict('test.ini') | |
591 | {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'} |
|
592 | {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'} | |
592 | >>> read_dict('test.ini',type_conv) |
|
593 | >>> read_dict('test.ini',type_conv) | |
593 | {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'} |
|
594 | {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'} | |
594 | >>> read_dict('test.ini',type_conv,purge=1) |
|
595 | >>> read_dict('test.ini',type_conv,purge=1) | |
595 | {'i': 3, 's': 'hi ho', 'x': 4.5} |
|
596 | {'i': 3, 's': 'hi ho', 'x': 4.5} | |
596 | """ |
|
597 | """ | |
597 |
|
598 | |||
598 | # starting config |
|
599 | # starting config | |
599 | opt.setdefault('purge',0) |
|
600 | opt.setdefault('purge',0) | |
600 | opt.setdefault('fs',None) # field sep defaults to any whitespace |
|
601 | opt.setdefault('fs',None) # field sep defaults to any whitespace | |
601 | opt.setdefault('strip',0) |
|
602 | opt.setdefault('strip',0) | |
602 | opt.setdefault('warn',1) |
|
603 | opt.setdefault('warn',1) | |
603 | opt.setdefault('no_empty',0) |
|
604 | opt.setdefault('no_empty',0) | |
604 | opt.setdefault('unique','') |
|
605 | opt.setdefault('unique','') | |
605 | if type(opt['unique']) in StringTypes: |
|
606 | if type(opt['unique']) in StringTypes: | |
606 | unique_keys = qw(opt['unique']) |
|
607 | unique_keys = qw(opt['unique']) | |
607 | elif type(opt['unique']) in (types.TupleType,types.ListType): |
|
608 | elif type(opt['unique']) in (types.TupleType,types.ListType): | |
608 | unique_keys = opt['unique'] |
|
609 | unique_keys = opt['unique'] | |
609 | else: |
|
610 | else: | |
610 | raise ValueError, 'Unique keys must be given as a string, List or Tuple' |
|
611 | raise ValueError, 'Unique keys must be given as a string, List or Tuple' | |
611 |
|
612 | |||
612 | dict = {} |
|
613 | dict = {} | |
613 | # first read in table of values as strings |
|
614 | # first read in table of values as strings | |
614 | file = open(filename,'r') |
|
615 | file = open(filename,'r') | |
615 | for line in file.readlines(): |
|
616 | for line in file.readlines(): | |
616 | line = line.strip() |
|
617 | line = line.strip() | |
617 | if len(line) and line[0]=='#': continue |
|
618 | if len(line) and line[0]=='#': continue | |
618 | if len(line)>0: |
|
619 | if len(line)>0: | |
619 | lsplit = line.split(opt['fs'],1) |
|
620 | lsplit = line.split(opt['fs'],1) | |
620 | try: |
|
621 | try: | |
621 | key,val = lsplit |
|
622 | key,val = lsplit | |
622 | except ValueError: |
|
623 | except ValueError: | |
623 | key,val = lsplit[0],'' |
|
624 | key,val = lsplit[0],'' | |
624 | key = key.strip() |
|
625 | key = key.strip() | |
625 | if opt['strip']: val = val.strip() |
|
626 | if opt['strip']: val = val.strip() | |
626 | if val == "''" or val == '""': val = '' |
|
627 | if val == "''" or val == '""': val = '' | |
627 | if opt['no_empty'] and (val=='' or val.isspace()): |
|
628 | if opt['no_empty'] and (val=='' or val.isspace()): | |
628 | continue |
|
629 | continue | |
629 | # if a key is found more than once in the file, build a list |
|
630 | # if a key is found more than once in the file, build a list | |
630 | # unless it's in the 'unique' list. In that case, last found in file |
|
631 | # unless it's in the 'unique' list. In that case, last found in file | |
631 | # takes precedence. User beware. |
|
632 | # takes precedence. User beware. | |
632 | try: |
|
633 | try: | |
633 | if dict[key] and key in unique_keys: |
|
634 | if dict[key] and key in unique_keys: | |
634 | dict[key] = val |
|
635 | dict[key] = val | |
635 | elif type(dict[key]) is types.ListType: |
|
636 | elif type(dict[key]) is types.ListType: | |
636 | dict[key].append(val) |
|
637 | dict[key].append(val) | |
637 | else: |
|
638 | else: | |
638 | dict[key] = [dict[key],val] |
|
639 | dict[key] = [dict[key],val] | |
639 | except KeyError: |
|
640 | except KeyError: | |
640 | dict[key] = val |
|
641 | dict[key] = val | |
641 | # purge if requested |
|
642 | # purge if requested | |
642 | if opt['purge']: |
|
643 | if opt['purge']: | |
643 | accepted_keys = qwflat(type_conv.values()) |
|
644 | accepted_keys = qwflat(type_conv.values()) | |
644 | for key in dict.keys(): |
|
645 | for key in dict.keys(): | |
645 | if key in accepted_keys: continue |
|
646 | if key in accepted_keys: continue | |
646 | del(dict[key]) |
|
647 | del(dict[key]) | |
647 | # now convert if requested |
|
648 | # now convert if requested | |
648 | if type_conv==None: return dict |
|
649 | if type_conv==None: return dict | |
649 | conversions = type_conv.keys() |
|
650 | conversions = type_conv.keys() | |
650 | try: conversions.remove(None) |
|
651 | try: conversions.remove(None) | |
651 | except: pass |
|
652 | except: pass | |
652 | for convert in conversions: |
|
653 | for convert in conversions: | |
653 | for val in qw(type_conv[convert]): |
|
654 | for val in qw(type_conv[convert]): | |
654 | try: |
|
655 | try: | |
655 | dict[val] = convert(dict[val]) |
|
656 | dict[val] = convert(dict[val]) | |
656 | except KeyError,e: |
|
657 | except KeyError,e: | |
657 | if opt['warn'] == 0: |
|
658 | if opt['warn'] == 0: | |
658 | pass |
|
659 | pass | |
659 | elif opt['warn'] == 1: |
|
660 | elif opt['warn'] == 1: | |
660 | print >>sys.stderr, 'Warning: key',val,\ |
|
661 | print >>sys.stderr, 'Warning: key',val,\ | |
661 | 'not found in file',filename |
|
662 | 'not found in file',filename | |
662 | elif opt['warn'] == 2: |
|
663 | elif opt['warn'] == 2: | |
663 | raise KeyError,e |
|
664 | raise KeyError,e | |
664 | else: |
|
665 | else: | |
665 | raise ValueError,'Warning level must be 0,1 or 2' |
|
666 | raise ValueError,'Warning level must be 0,1 or 2' | |
666 |
|
667 | |||
667 | return dict |
|
668 | return dict | |
668 |
|
669 | |||
669 | #---------------------------------------------------------------------------- |
|
670 | #---------------------------------------------------------------------------- | |
670 | def flag_calls(func): |
|
671 | def flag_calls(func): | |
671 | """Wrap a function to detect and flag when it gets called. |
|
672 | """Wrap a function to detect and flag when it gets called. | |
672 |
|
673 | |||
673 | This is a decorator which takes a function and wraps it in a function with |
|
674 | This is a decorator which takes a function and wraps it in a function with | |
674 | a 'called' attribute. wrapper.called is initialized to False. |
|
675 | a 'called' attribute. wrapper.called is initialized to False. | |
675 |
|
676 | |||
676 | The wrapper.called attribute is set to False right before each call to the |
|
677 | The wrapper.called attribute is set to False right before each call to the | |
677 | wrapped function, so if the call fails it remains False. After the call |
|
678 | wrapped function, so if the call fails it remains False. After the call | |
678 | completes, wrapper.called is set to True and the output is returned. |
|
679 | completes, wrapper.called is set to True and the output is returned. | |
679 |
|
680 | |||
680 | Testing for truth in wrapper.called allows you to determine if a call to |
|
681 | Testing for truth in wrapper.called allows you to determine if a call to | |
681 | func() was attempted and succeeded.""" |
|
682 | func() was attempted and succeeded.""" | |
682 |
|
683 | |||
683 | def wrapper(*args,**kw): |
|
684 | def wrapper(*args,**kw): | |
684 | wrapper.called = False |
|
685 | wrapper.called = False | |
685 | out = func(*args,**kw) |
|
686 | out = func(*args,**kw) | |
686 | wrapper.called = True |
|
687 | wrapper.called = True | |
687 | return out |
|
688 | return out | |
688 |
|
689 | |||
689 | wrapper.called = False |
|
690 | wrapper.called = False | |
690 | wrapper.__doc__ = func.__doc__ |
|
691 | wrapper.__doc__ = func.__doc__ | |
691 | return wrapper |
|
692 | return wrapper | |
692 |
|
693 | |||
693 | #---------------------------------------------------------------------------- |
|
694 | #---------------------------------------------------------------------------- | |
694 | class HomeDirError(Error): |
|
695 | class HomeDirError(Error): | |
695 | pass |
|
696 | pass | |
696 |
|
697 | |||
697 | def get_home_dir(): |
|
698 | def get_home_dir(): | |
698 | """Return the closest possible equivalent to a 'home' directory. |
|
699 | """Return the closest possible equivalent to a 'home' directory. | |
699 |
|
700 | |||
700 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. |
|
701 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. | |
701 |
|
702 | |||
702 | Currently only Posix and NT are implemented, a HomeDirError exception is |
|
703 | Currently only Posix and NT are implemented, a HomeDirError exception is | |
703 | raised for all other OSes. """ |
|
704 | raised for all other OSes. """ | |
704 |
|
705 | |||
705 | isdir = os.path.isdir |
|
706 | isdir = os.path.isdir | |
706 | env = os.environ |
|
707 | env = os.environ | |
707 | try: |
|
708 | try: | |
708 | homedir = env['HOME'] |
|
709 | homedir = env['HOME'] | |
709 | if not isdir(homedir): |
|
710 | if not isdir(homedir): | |
710 | # in case a user stuck some string which does NOT resolve to a |
|
711 | # in case a user stuck some string which does NOT resolve to a | |
711 | # valid path, it's as good as if we hadn't foud it |
|
712 | # valid path, it's as good as if we hadn't foud it | |
712 | raise KeyError |
|
713 | raise KeyError | |
713 | return homedir |
|
714 | return homedir | |
714 | except KeyError: |
|
715 | except KeyError: | |
715 | if os.name == 'posix': |
|
716 | if os.name == 'posix': | |
716 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' |
|
717 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' | |
717 | elif os.name == 'nt': |
|
718 | elif os.name == 'nt': | |
718 | # For some strange reason, win9x returns 'nt' for os.name. |
|
719 | # For some strange reason, win9x returns 'nt' for os.name. | |
719 | try: |
|
720 | try: | |
720 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) |
|
721 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) | |
721 | if not isdir(homedir): |
|
722 | if not isdir(homedir): | |
722 | homedir = os.path.join(env['USERPROFILE']) |
|
723 | homedir = os.path.join(env['USERPROFILE']) | |
723 | if not isdir(homedir): |
|
724 | if not isdir(homedir): | |
724 | raise HomeDirError |
|
725 | raise HomeDirError | |
725 | return homedir |
|
726 | return homedir | |
726 | except: |
|
727 | except: | |
727 | try: |
|
728 | try: | |
728 | # Use the registry to get the 'My Documents' folder. |
|
729 | # Use the registry to get the 'My Documents' folder. | |
729 | import _winreg as wreg |
|
730 | import _winreg as wreg | |
730 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, |
|
731 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, | |
731 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") |
|
732 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") | |
732 | homedir = wreg.QueryValueEx(key,'Personal')[0] |
|
733 | homedir = wreg.QueryValueEx(key,'Personal')[0] | |
733 | key.Close() |
|
734 | key.Close() | |
734 | return homedir |
|
735 | return homedir | |
735 | except: |
|
736 | except: | |
736 | return 'C:\\' |
|
737 | return 'C:\\' | |
737 | elif os.name == 'dos': |
|
738 | elif os.name == 'dos': | |
738 | # Desperate, may do absurd things in classic MacOS. May work under DOS. |
|
739 | # Desperate, may do absurd things in classic MacOS. May work under DOS. | |
739 | return 'C:\\' |
|
740 | return 'C:\\' | |
740 | else: |
|
741 | else: | |
741 | raise HomeDirError,'support for your operating system not implemented.' |
|
742 | raise HomeDirError,'support for your operating system not implemented.' | |
742 |
|
743 | |||
743 | #**************************************************************************** |
|
744 | #**************************************************************************** | |
744 | # strings and text |
|
745 | # strings and text | |
745 |
|
746 | |||
746 | class LSString(str): |
|
747 | class LSString(str): | |
747 | """String derivative with a special access attributes. |
|
748 | """String derivative with a special access attributes. | |
748 |
|
749 | |||
749 | These are normal strings, but with the special attributes: |
|
750 | These are normal strings, but with the special attributes: | |
750 |
|
751 | |||
751 | .l (or .list) : value as list (split on newlines). |
|
752 | .l (or .list) : value as list (split on newlines). | |
752 | .n (or .nlstr): original value (the string itself). |
|
753 | .n (or .nlstr): original value (the string itself). | |
753 | .s (or .spstr): value as whitespace-separated string. |
|
754 | .s (or .spstr): value as whitespace-separated string. | |
754 |
|
755 | |||
755 | Any values which require transformations are computed only once and |
|
756 | Any values which require transformations are computed only once and | |
756 | cached. |
|
757 | cached. | |
757 |
|
758 | |||
758 | Such strings are very useful to efficiently interact with the shell, which |
|
759 | Such strings are very useful to efficiently interact with the shell, which | |
759 | typically only understands whitespace-separated options for commands.""" |
|
760 | typically only understands whitespace-separated options for commands.""" | |
760 |
|
761 | |||
761 | def get_list(self): |
|
762 | def get_list(self): | |
762 | try: |
|
763 | try: | |
763 | return self.__list |
|
764 | return self.__list | |
764 | except AttributeError: |
|
765 | except AttributeError: | |
765 | self.__list = self.split('\n') |
|
766 | self.__list = self.split('\n') | |
766 | return self.__list |
|
767 | return self.__list | |
767 |
|
768 | |||
768 | l = list = property(get_list) |
|
769 | l = list = property(get_list) | |
769 |
|
770 | |||
770 | def get_spstr(self): |
|
771 | def get_spstr(self): | |
771 | try: |
|
772 | try: | |
772 | return self.__spstr |
|
773 | return self.__spstr | |
773 | except AttributeError: |
|
774 | except AttributeError: | |
774 | self.__spstr = self.replace('\n',' ') |
|
775 | self.__spstr = self.replace('\n',' ') | |
775 | return self.__spstr |
|
776 | return self.__spstr | |
776 |
|
777 | |||
777 | s = spstr = property(get_spstr) |
|
778 | s = spstr = property(get_spstr) | |
778 |
|
779 | |||
779 | def get_nlstr(self): |
|
780 | def get_nlstr(self): | |
780 | return self |
|
781 | return self | |
781 |
|
782 | |||
782 | n = nlstr = property(get_nlstr) |
|
783 | n = nlstr = property(get_nlstr) | |
783 |
|
784 | |||
784 | class SList(list): |
|
785 | class SList(list): | |
785 | """List derivative with a special access attributes. |
|
786 | """List derivative with a special access attributes. | |
786 |
|
787 | |||
787 | These are normal lists, but with the special attributes: |
|
788 | These are normal lists, but with the special attributes: | |
788 |
|
789 | |||
789 | .l (or .list) : value as list (the list itself). |
|
790 | .l (or .list) : value as list (the list itself). | |
790 | .n (or .nlstr): value as a string, joined on newlines. |
|
791 | .n (or .nlstr): value as a string, joined on newlines. | |
791 | .s (or .spstr): value as a string, joined on spaces. |
|
792 | .s (or .spstr): value as a string, joined on spaces. | |
792 |
|
793 | |||
793 | Any values which require transformations are computed only once and |
|
794 | Any values which require transformations are computed only once and | |
794 | cached.""" |
|
795 | cached.""" | |
795 |
|
796 | |||
796 | def get_list(self): |
|
797 | def get_list(self): | |
797 | return self |
|
798 | return self | |
798 |
|
799 | |||
799 | l = list = property(get_list) |
|
800 | l = list = property(get_list) | |
800 |
|
801 | |||
801 | def get_spstr(self): |
|
802 | def get_spstr(self): | |
802 | try: |
|
803 | try: | |
803 | return self.__spstr |
|
804 | return self.__spstr | |
804 | except AttributeError: |
|
805 | except AttributeError: | |
805 | self.__spstr = ' '.join(self) |
|
806 | self.__spstr = ' '.join(self) | |
806 | return self.__spstr |
|
807 | return self.__spstr | |
807 |
|
808 | |||
808 | s = spstr = property(get_spstr) |
|
809 | s = spstr = property(get_spstr) | |
809 |
|
810 | |||
810 | def get_nlstr(self): |
|
811 | def get_nlstr(self): | |
811 | try: |
|
812 | try: | |
812 | return self.__nlstr |
|
813 | return self.__nlstr | |
813 | except AttributeError: |
|
814 | except AttributeError: | |
814 | self.__nlstr = '\n'.join(self) |
|
815 | self.__nlstr = '\n'.join(self) | |
815 | return self.__nlstr |
|
816 | return self.__nlstr | |
816 |
|
817 | |||
817 | n = nlstr = property(get_nlstr) |
|
818 | n = nlstr = property(get_nlstr) | |
818 |
|
819 | |||
819 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): |
|
820 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): | |
820 | """Take multiple lines of input. |
|
821 | """Take multiple lines of input. | |
821 |
|
822 | |||
822 | A list with each line of input as a separate element is returned when a |
|
823 | A list with each line of input as a separate element is returned when a | |
823 | termination string is entered (defaults to a single '.'). Input can also |
|
824 | termination string is entered (defaults to a single '.'). Input can also | |
824 | terminate via EOF (^D in Unix, ^Z-RET in Windows). |
|
825 | terminate via EOF (^D in Unix, ^Z-RET in Windows). | |
825 |
|
826 | |||
826 | Lines of input which end in \\ are joined into single entries (and a |
|
827 | Lines of input which end in \\ are joined into single entries (and a | |
827 | secondary continuation prompt is issued as long as the user terminates |
|
828 | secondary continuation prompt is issued as long as the user terminates | |
828 | lines with \\). This allows entering very long strings which are still |
|
829 | lines with \\). This allows entering very long strings which are still | |
829 | meant to be treated as single entities. |
|
830 | meant to be treated as single entities. | |
830 | """ |
|
831 | """ | |
831 |
|
832 | |||
832 | try: |
|
833 | try: | |
833 | if header: |
|
834 | if header: | |
834 | header += '\n' |
|
835 | header += '\n' | |
835 | lines = [raw_input(header + ps1)] |
|
836 | lines = [raw_input(header + ps1)] | |
836 | except EOFError: |
|
837 | except EOFError: | |
837 | return [] |
|
838 | return [] | |
838 | terminate = [terminate_str] |
|
839 | terminate = [terminate_str] | |
839 | try: |
|
840 | try: | |
840 | while lines[-1:] != terminate: |
|
841 | while lines[-1:] != terminate: | |
841 | new_line = raw_input(ps1) |
|
842 | new_line = raw_input(ps1) | |
842 | while new_line.endswith('\\'): |
|
843 | while new_line.endswith('\\'): | |
843 | new_line = new_line[:-1] + raw_input(ps2) |
|
844 | new_line = new_line[:-1] + raw_input(ps2) | |
844 | lines.append(new_line) |
|
845 | lines.append(new_line) | |
845 |
|
846 | |||
846 | return lines[:-1] # don't return the termination command |
|
847 | return lines[:-1] # don't return the termination command | |
847 | except EOFError: |
|
848 | except EOFError: | |
848 |
|
849 | |||
849 | return lines |
|
850 | return lines | |
850 |
|
851 | |||
851 | #---------------------------------------------------------------------------- |
|
852 | #---------------------------------------------------------------------------- | |
852 | def raw_input_ext(prompt='', ps2='... '): |
|
853 | def raw_input_ext(prompt='', ps2='... '): | |
853 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" |
|
854 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" | |
854 |
|
855 | |||
855 | line = raw_input(prompt) |
|
856 | line = raw_input(prompt) | |
856 | while line.endswith('\\'): |
|
857 | while line.endswith('\\'): | |
857 | line = line[:-1] + raw_input(ps2) |
|
858 | line = line[:-1] + raw_input(ps2) | |
858 | return line |
|
859 | return line | |
859 |
|
860 | |||
860 | #---------------------------------------------------------------------------- |
|
861 | #---------------------------------------------------------------------------- | |
861 | def ask_yes_no(prompt,default=None): |
|
862 | def ask_yes_no(prompt,default=None): | |
862 | """Asks a question and returns an integer 1/0 (y/n) answer. |
|
863 | """Asks a question and returns an integer 1/0 (y/n) answer. | |
863 |
|
864 | |||
864 | If default is given (one of 'y','n'), it is used if the user input is |
|
865 | If default is given (one of 'y','n'), it is used if the user input is | |
865 | empty. Otherwise the question is repeated until an answer is given. |
|
866 | empty. Otherwise the question is repeated until an answer is given. | |
866 | If EOF occurs 20 times consecutively, the default answer is assumed, |
|
867 | If EOF occurs 20 times consecutively, the default answer is assumed, | |
867 | or if there is no default, an exception is raised to prevent infinite |
|
868 | or if there is no default, an exception is raised to prevent infinite | |
868 | loops. |
|
869 | loops. | |
869 |
|
870 | |||
870 | Valid answers are: y/yes/n/no (match is not case sensitive).""" |
|
871 | Valid answers are: y/yes/n/no (match is not case sensitive).""" | |
871 |
|
872 | |||
872 | answers = {'y':1,'n':0,'yes':1,'no':0} |
|
873 | answers = {'y':1,'n':0,'yes':1,'no':0} | |
873 | ans = None |
|
874 | ans = None | |
874 | eofs, max_eofs = 0, 20 |
|
875 | eofs, max_eofs = 0, 20 | |
875 | while ans not in answers.keys(): |
|
876 | while ans not in answers.keys(): | |
876 | try: |
|
877 | try: | |
877 | ans = raw_input(prompt+' ').lower() |
|
878 | ans = raw_input(prompt+' ').lower() | |
878 | if not ans: # response was an empty string |
|
879 | if not ans: # response was an empty string | |
879 | ans = default |
|
880 | ans = default | |
880 | eofs = 0 |
|
881 | eofs = 0 | |
881 | except (EOFError,KeyboardInterrupt): |
|
882 | except (EOFError,KeyboardInterrupt): | |
882 | eofs = eofs + 1 |
|
883 | eofs = eofs + 1 | |
883 | if eofs >= max_eofs: |
|
884 | if eofs >= max_eofs: | |
884 | if default in answers.keys(): |
|
885 | if default in answers.keys(): | |
885 | ans = default |
|
886 | ans = default | |
886 | else: |
|
887 | else: | |
887 | raise |
|
888 | raise | |
888 |
|
889 | |||
889 | return answers[ans] |
|
890 | return answers[ans] | |
890 |
|
891 | |||
891 | #---------------------------------------------------------------------------- |
|
892 | #---------------------------------------------------------------------------- | |
892 | class EvalDict: |
|
893 | class EvalDict: | |
893 | """ |
|
894 | """ | |
894 | Emulate a dict which evaluates its contents in the caller's frame. |
|
895 | Emulate a dict which evaluates its contents in the caller's frame. | |
895 |
|
896 | |||
896 | Usage: |
|
897 | Usage: | |
897 | >>>number = 19 |
|
898 | >>>number = 19 | |
898 | >>>text = "python" |
|
899 | >>>text = "python" | |
899 | >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict() |
|
900 | >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict() | |
900 | """ |
|
901 | """ | |
901 |
|
902 | |||
902 | # This version is due to sismex01@hebmex.com on c.l.py, and is basically a |
|
903 | # This version is due to sismex01@hebmex.com on c.l.py, and is basically a | |
903 | # modified (shorter) version of: |
|
904 | # modified (shorter) version of: | |
904 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by |
|
905 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by | |
905 | # Skip Montanaro (skip@pobox.com). |
|
906 | # Skip Montanaro (skip@pobox.com). | |
906 |
|
907 | |||
907 | def __getitem__(self, name): |
|
908 | def __getitem__(self, name): | |
908 | frame = sys._getframe(1) |
|
909 | frame = sys._getframe(1) | |
909 | return eval(name, frame.f_globals, frame.f_locals) |
|
910 | return eval(name, frame.f_globals, frame.f_locals) | |
910 |
|
911 | |||
911 | EvalString = EvalDict # for backwards compatibility |
|
912 | EvalString = EvalDict # for backwards compatibility | |
912 | #---------------------------------------------------------------------------- |
|
913 | #---------------------------------------------------------------------------- | |
913 | def qw(words,flat=0,sep=None,maxsplit=-1): |
|
914 | def qw(words,flat=0,sep=None,maxsplit=-1): | |
914 | """Similar to Perl's qw() operator, but with some more options. |
|
915 | """Similar to Perl's qw() operator, but with some more options. | |
915 |
|
916 | |||
916 | qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) |
|
917 | qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) | |
917 |
|
918 | |||
918 | words can also be a list itself, and with flat=1, the output will be |
|
919 | words can also be a list itself, and with flat=1, the output will be | |
919 | recursively flattened. Examples: |
|
920 | recursively flattened. Examples: | |
920 |
|
921 | |||
921 | >>> qw('1 2') |
|
922 | >>> qw('1 2') | |
922 | ['1', '2'] |
|
923 | ['1', '2'] | |
923 | >>> qw(['a b','1 2',['m n','p q']]) |
|
924 | >>> qw(['a b','1 2',['m n','p q']]) | |
924 | [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] |
|
925 | [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] | |
925 | >>> qw(['a b','1 2',['m n','p q']],flat=1) |
|
926 | >>> qw(['a b','1 2',['m n','p q']],flat=1) | |
926 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ |
|
927 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ | |
927 |
|
928 | |||
928 | if type(words) in StringTypes: |
|
929 | if type(words) in StringTypes: | |
929 | return [word.strip() for word in words.split(sep,maxsplit) |
|
930 | return [word.strip() for word in words.split(sep,maxsplit) | |
930 | if word and not word.isspace() ] |
|
931 | if word and not word.isspace() ] | |
931 | if flat: |
|
932 | if flat: | |
932 | return flatten(map(qw,words,[1]*len(words))) |
|
933 | return flatten(map(qw,words,[1]*len(words))) | |
933 | return map(qw,words) |
|
934 | return map(qw,words) | |
934 |
|
935 | |||
935 | #---------------------------------------------------------------------------- |
|
936 | #---------------------------------------------------------------------------- | |
936 | def qwflat(words,sep=None,maxsplit=-1): |
|
937 | def qwflat(words,sep=None,maxsplit=-1): | |
937 | """Calls qw(words) in flat mode. It's just a convenient shorthand.""" |
|
938 | """Calls qw(words) in flat mode. It's just a convenient shorthand.""" | |
938 | return qw(words,1,sep,maxsplit) |
|
939 | return qw(words,1,sep,maxsplit) | |
939 |
|
940 | |||
940 | #----------------------------------------------------------------------------- |
|
941 | #----------------------------------------------------------------------------- | |
941 | def list_strings(arg): |
|
942 | def list_strings(arg): | |
942 | """Always return a list of strings, given a string or list of strings |
|
943 | """Always return a list of strings, given a string or list of strings | |
943 | as input.""" |
|
944 | as input.""" | |
944 |
|
945 | |||
945 | if type(arg) in StringTypes: return [arg] |
|
946 | if type(arg) in StringTypes: return [arg] | |
946 | else: return arg |
|
947 | else: return arg | |
947 |
|
948 | |||
948 | #---------------------------------------------------------------------------- |
|
949 | #---------------------------------------------------------------------------- | |
949 | def grep(pat,list,case=1): |
|
950 | def grep(pat,list,case=1): | |
950 | """Simple minded grep-like function. |
|
951 | """Simple minded grep-like function. | |
951 | grep(pat,list) returns occurrences of pat in list, None on failure. |
|
952 | grep(pat,list) returns occurrences of pat in list, None on failure. | |
952 |
|
953 | |||
953 | It only does simple string matching, with no support for regexps. Use the |
|
954 | It only does simple string matching, with no support for regexps. Use the | |
954 | option case=0 for case-insensitive matching.""" |
|
955 | option case=0 for case-insensitive matching.""" | |
955 |
|
956 | |||
956 | # This is pretty crude. At least it should implement copying only references |
|
957 | # This is pretty crude. At least it should implement copying only references | |
957 | # to the original data in case it's big. Now it copies the data for output. |
|
958 | # to the original data in case it's big. Now it copies the data for output. | |
958 | out=[] |
|
959 | out=[] | |
959 | if case: |
|
960 | if case: | |
960 | for term in list: |
|
961 | for term in list: | |
961 | if term.find(pat)>-1: out.append(term) |
|
962 | if term.find(pat)>-1: out.append(term) | |
962 | else: |
|
963 | else: | |
963 | lpat=pat.lower() |
|
964 | lpat=pat.lower() | |
964 | for term in list: |
|
965 | for term in list: | |
965 | if term.lower().find(lpat)>-1: out.append(term) |
|
966 | if term.lower().find(lpat)>-1: out.append(term) | |
966 |
|
967 | |||
967 | if len(out): return out |
|
968 | if len(out): return out | |
968 | else: return None |
|
969 | else: return None | |
969 |
|
970 | |||
970 | #---------------------------------------------------------------------------- |
|
971 | #---------------------------------------------------------------------------- | |
971 | def dgrep(pat,*opts): |
|
972 | def dgrep(pat,*opts): | |
972 | """Return grep() on dir()+dir(__builtins__). |
|
973 | """Return grep() on dir()+dir(__builtins__). | |
973 |
|
974 | |||
974 | A very common use of grep() when working interactively.""" |
|
975 | A very common use of grep() when working interactively.""" | |
975 |
|
976 | |||
976 | return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) |
|
977 | return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) | |
977 |
|
978 | |||
978 | #---------------------------------------------------------------------------- |
|
979 | #---------------------------------------------------------------------------- | |
979 | def idgrep(pat): |
|
980 | def idgrep(pat): | |
980 | """Case-insensitive dgrep()""" |
|
981 | """Case-insensitive dgrep()""" | |
981 |
|
982 | |||
982 | return dgrep(pat,0) |
|
983 | return dgrep(pat,0) | |
983 |
|
984 | |||
984 | #---------------------------------------------------------------------------- |
|
985 | #---------------------------------------------------------------------------- | |
985 | def igrep(pat,list): |
|
986 | def igrep(pat,list): | |
986 | """Synonym for case-insensitive grep.""" |
|
987 | """Synonym for case-insensitive grep.""" | |
987 |
|
988 | |||
988 | return grep(pat,list,case=0) |
|
989 | return grep(pat,list,case=0) | |
989 |
|
990 | |||
990 | #---------------------------------------------------------------------------- |
|
991 | #---------------------------------------------------------------------------- | |
991 | def indent(str,nspaces=4,ntabs=0): |
|
992 | def indent(str,nspaces=4,ntabs=0): | |
992 | """Indent a string a given number of spaces or tabstops. |
|
993 | """Indent a string a given number of spaces or tabstops. | |
993 |
|
994 | |||
994 | indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. |
|
995 | indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. | |
995 | """ |
|
996 | """ | |
996 | if str is None: |
|
997 | if str is None: | |
997 | return |
|
998 | return | |
998 | ind = '\t'*ntabs+' '*nspaces |
|
999 | ind = '\t'*ntabs+' '*nspaces | |
999 | outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind)) |
|
1000 | outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind)) | |
1000 | if outstr.endswith(os.linesep+ind): |
|
1001 | if outstr.endswith(os.linesep+ind): | |
1001 | return outstr[:-len(ind)] |
|
1002 | return outstr[:-len(ind)] | |
1002 | else: |
|
1003 | else: | |
1003 | return outstr |
|
1004 | return outstr | |
1004 |
|
1005 | |||
1005 | #----------------------------------------------------------------------------- |
|
1006 | #----------------------------------------------------------------------------- | |
1006 | def native_line_ends(filename,backup=1): |
|
1007 | def native_line_ends(filename,backup=1): | |
1007 | """Convert (in-place) a file to line-ends native to the current OS. |
|
1008 | """Convert (in-place) a file to line-ends native to the current OS. | |
1008 |
|
1009 | |||
1009 | If the optional backup argument is given as false, no backup of the |
|
1010 | If the optional backup argument is given as false, no backup of the | |
1010 | original file is left. """ |
|
1011 | original file is left. """ | |
1011 |
|
1012 | |||
1012 | backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} |
|
1013 | backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} | |
1013 |
|
1014 | |||
1014 | bak_filename = filename + backup_suffixes[os.name] |
|
1015 | bak_filename = filename + backup_suffixes[os.name] | |
1015 |
|
1016 | |||
1016 | original = open(filename).read() |
|
1017 | original = open(filename).read() | |
1017 | shutil.copy2(filename,bak_filename) |
|
1018 | shutil.copy2(filename,bak_filename) | |
1018 | try: |
|
1019 | try: | |
1019 | new = open(filename,'wb') |
|
1020 | new = open(filename,'wb') | |
1020 | new.write(os.linesep.join(original.splitlines())) |
|
1021 | new.write(os.linesep.join(original.splitlines())) | |
1021 | new.write(os.linesep) # ALWAYS put an eol at the end of the file |
|
1022 | new.write(os.linesep) # ALWAYS put an eol at the end of the file | |
1022 | new.close() |
|
1023 | new.close() | |
1023 | except: |
|
1024 | except: | |
1024 | os.rename(bak_filename,filename) |
|
1025 | os.rename(bak_filename,filename) | |
1025 | if not backup: |
|
1026 | if not backup: | |
1026 | try: |
|
1027 | try: | |
1027 | os.remove(bak_filename) |
|
1028 | os.remove(bak_filename) | |
1028 | except: |
|
1029 | except: | |
1029 | pass |
|
1030 | pass | |
1030 |
|
1031 | |||
1031 | #---------------------------------------------------------------------------- |
|
1032 | #---------------------------------------------------------------------------- | |
1032 | def get_pager_cmd(pager_cmd = None): |
|
1033 | def get_pager_cmd(pager_cmd = None): | |
1033 | """Return a pager command. |
|
1034 | """Return a pager command. | |
1034 |
|
1035 | |||
1035 | Makes some attempts at finding an OS-correct one.""" |
|
1036 | Makes some attempts at finding an OS-correct one.""" | |
1036 |
|
1037 | |||
1037 | if os.name == 'posix': |
|
1038 | if os.name == 'posix': | |
1038 | default_pager_cmd = 'less -r' # -r for color control sequences |
|
1039 | default_pager_cmd = 'less -r' # -r for color control sequences | |
1039 | elif os.name in ['nt','dos']: |
|
1040 | elif os.name in ['nt','dos']: | |
1040 | default_pager_cmd = 'type' |
|
1041 | default_pager_cmd = 'type' | |
1041 |
|
1042 | |||
1042 | if pager_cmd is None: |
|
1043 | if pager_cmd is None: | |
1043 | try: |
|
1044 | try: | |
1044 | pager_cmd = os.environ['PAGER'] |
|
1045 | pager_cmd = os.environ['PAGER'] | |
1045 | except: |
|
1046 | except: | |
1046 | pager_cmd = default_pager_cmd |
|
1047 | pager_cmd = default_pager_cmd | |
1047 | return pager_cmd |
|
1048 | return pager_cmd | |
1048 |
|
1049 | |||
1049 | #----------------------------------------------------------------------------- |
|
1050 | #----------------------------------------------------------------------------- | |
1050 | def get_pager_start(pager,start): |
|
1051 | def get_pager_start(pager,start): | |
1051 | """Return the string for paging files with an offset. |
|
1052 | """Return the string for paging files with an offset. | |
1052 |
|
1053 | |||
1053 | This is the '+N' argument which less and more (under Unix) accept. |
|
1054 | This is the '+N' argument which less and more (under Unix) accept. | |
1054 | """ |
|
1055 | """ | |
1055 |
|
1056 | |||
1056 | if pager in ['less','more']: |
|
1057 | if pager in ['less','more']: | |
1057 | if start: |
|
1058 | if start: | |
1058 | start_string = '+' + str(start) |
|
1059 | start_string = '+' + str(start) | |
1059 | else: |
|
1060 | else: | |
1060 | start_string = '' |
|
1061 | start_string = '' | |
1061 | else: |
|
1062 | else: | |
1062 | start_string = '' |
|
1063 | start_string = '' | |
1063 | return start_string |
|
1064 | return start_string | |
1064 |
|
1065 | |||
1065 | #---------------------------------------------------------------------------- |
|
1066 | #---------------------------------------------------------------------------- | |
1066 | def page_dumb(strng,start=0,screen_lines=25): |
|
1067 | def page_dumb(strng,start=0,screen_lines=25): | |
1067 | """Very dumb 'pager' in Python, for when nothing else works. |
|
1068 | """Very dumb 'pager' in Python, for when nothing else works. | |
1068 |
|
1069 | |||
1069 | Only moves forward, same interface as page(), except for pager_cmd and |
|
1070 | Only moves forward, same interface as page(), except for pager_cmd and | |
1070 | mode.""" |
|
1071 | mode.""" | |
1071 |
|
1072 | |||
1072 | out_ln = strng.splitlines()[start:] |
|
1073 | out_ln = strng.splitlines()[start:] | |
1073 | screens = chop(out_ln,screen_lines-1) |
|
1074 | screens = chop(out_ln,screen_lines-1) | |
1074 | if len(screens) == 1: |
|
1075 | if len(screens) == 1: | |
1075 | print >>Term.cout, os.linesep.join(screens[0]) |
|
1076 | print >>Term.cout, os.linesep.join(screens[0]) | |
1076 | else: |
|
1077 | else: | |
1077 | for scr in screens[0:-1]: |
|
1078 | for scr in screens[0:-1]: | |
1078 | print >>Term.cout, os.linesep.join(scr) |
|
1079 | print >>Term.cout, os.linesep.join(scr) | |
1079 | ans = raw_input('---Return to continue, q to quit--- ') |
|
1080 | ans = raw_input('---Return to continue, q to quit--- ') | |
1080 | if ans.lower().startswith('q'): |
|
1081 | if ans.lower().startswith('q'): | |
1081 | return |
|
1082 | return | |
1082 | print >>Term.cout, os.linesep.join(screens[-1]) |
|
1083 | print >>Term.cout, os.linesep.join(screens[-1]) | |
1083 |
|
1084 | |||
1084 | #---------------------------------------------------------------------------- |
|
1085 | #---------------------------------------------------------------------------- | |
1085 | def page(strng,start=0,screen_lines=0,pager_cmd = None): |
|
1086 | def page(strng,start=0,screen_lines=0,pager_cmd = None): | |
1086 | """Print a string, piping through a pager after a certain length. |
|
1087 | """Print a string, piping through a pager after a certain length. | |
1087 |
|
1088 | |||
1088 | The screen_lines parameter specifies the number of *usable* lines of your |
|
1089 | The screen_lines parameter specifies the number of *usable* lines of your | |
1089 | terminal screen (total lines minus lines you need to reserve to show other |
|
1090 | terminal screen (total lines minus lines you need to reserve to show other | |
1090 | information). |
|
1091 | information). | |
1091 |
|
1092 | |||
1092 | If you set screen_lines to a number <=0, page() will try to auto-determine |
|
1093 | If you set screen_lines to a number <=0, page() will try to auto-determine | |
1093 | your screen size and will only use up to (screen_size+screen_lines) for |
|
1094 | your screen size and will only use up to (screen_size+screen_lines) for | |
1094 | printing, paging after that. That is, if you want auto-detection but need |
|
1095 | printing, paging after that. That is, if you want auto-detection but need | |
1095 | to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for |
|
1096 | to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for | |
1096 | auto-detection without any lines reserved simply use screen_lines = 0. |
|
1097 | auto-detection without any lines reserved simply use screen_lines = 0. | |
1097 |
|
1098 | |||
1098 | If a string won't fit in the allowed lines, it is sent through the |
|
1099 | If a string won't fit in the allowed lines, it is sent through the | |
1099 | specified pager command. If none given, look for PAGER in the environment, |
|
1100 | specified pager command. If none given, look for PAGER in the environment, | |
1100 | and ultimately default to less. |
|
1101 | and ultimately default to less. | |
1101 |
|
1102 | |||
1102 | If no system pager works, the string is sent through a 'dumb pager' |
|
1103 | If no system pager works, the string is sent through a 'dumb pager' | |
1103 | written in python, very simplistic. |
|
1104 | written in python, very simplistic. | |
1104 | """ |
|
1105 | """ | |
1105 |
|
1106 | |||
1106 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs |
|
1107 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs | |
1107 | TERM = os.environ.get('TERM','dumb') |
|
1108 | TERM = os.environ.get('TERM','dumb') | |
1108 | if TERM in ['dumb','emacs'] and os.name != 'nt': |
|
1109 | if TERM in ['dumb','emacs'] and os.name != 'nt': | |
1109 | print strng |
|
1110 | print strng | |
1110 | return |
|
1111 | return | |
1111 | # chop off the topmost part of the string we don't want to see |
|
1112 | # chop off the topmost part of the string we don't want to see | |
1112 | str_lines = strng.split(os.linesep)[start:] |
|
1113 | str_lines = strng.split(os.linesep)[start:] | |
1113 | str_toprint = os.linesep.join(str_lines) |
|
1114 | str_toprint = os.linesep.join(str_lines) | |
1114 | num_newlines = len(str_lines) |
|
1115 | num_newlines = len(str_lines) | |
1115 | len_str = len(str_toprint) |
|
1116 | len_str = len(str_toprint) | |
1116 |
|
1117 | |||
1117 | # Dumb heuristics to guesstimate number of on-screen lines the string |
|
1118 | # Dumb heuristics to guesstimate number of on-screen lines the string | |
1118 | # takes. Very basic, but good enough for docstrings in reasonable |
|
1119 | # takes. Very basic, but good enough for docstrings in reasonable | |
1119 | # terminals. If someone later feels like refining it, it's not hard. |
|
1120 | # terminals. If someone later feels like refining it, it's not hard. | |
1120 | numlines = max(num_newlines,int(len_str/80)+1) |
|
1121 | numlines = max(num_newlines,int(len_str/80)+1) | |
1121 |
|
1122 | |||
1122 | screen_lines_def = 25 # default value if we can't auto-determine |
|
1123 | screen_lines_def = 25 # default value if we can't auto-determine | |
1123 |
|
1124 | |||
1124 | # auto-determine screen size |
|
1125 | # auto-determine screen size | |
1125 | if screen_lines <= 0: |
|
1126 | if screen_lines <= 0: | |
1126 | if TERM=='xterm': |
|
1127 | if TERM=='xterm': | |
1127 | try: |
|
1128 | try: | |
1128 | import curses |
|
1129 | import curses | |
1129 | if hasattr(curses,'initscr'): |
|
1130 | if hasattr(curses,'initscr'): | |
1130 | use_curses = 1 |
|
1131 | use_curses = 1 | |
1131 | else: |
|
1132 | else: | |
1132 | use_curses = 0 |
|
1133 | use_curses = 0 | |
1133 | except ImportError: |
|
1134 | except ImportError: | |
1134 | use_curses = 0 |
|
1135 | use_curses = 0 | |
1135 | else: |
|
1136 | else: | |
1136 | # curses causes problems on many terminals other than xterm. |
|
1137 | # curses causes problems on many terminals other than xterm. | |
1137 | use_curses = 0 |
|
1138 | use_curses = 0 | |
1138 | if use_curses: |
|
1139 | if use_curses: | |
1139 | scr = curses.initscr() |
|
1140 | scr = curses.initscr() | |
1140 | screen_lines_real,screen_cols = scr.getmaxyx() |
|
1141 | screen_lines_real,screen_cols = scr.getmaxyx() | |
1141 | curses.endwin() |
|
1142 | curses.endwin() | |
1142 | screen_lines += screen_lines_real |
|
1143 | screen_lines += screen_lines_real | |
1143 | #print '***Screen size:',screen_lines_real,'lines x',\ |
|
1144 | #print '***Screen size:',screen_lines_real,'lines x',\ | |
1144 | #screen_cols,'columns.' # dbg |
|
1145 | #screen_cols,'columns.' # dbg | |
1145 | else: |
|
1146 | else: | |
1146 | screen_lines += screen_lines_def |
|
1147 | screen_lines += screen_lines_def | |
1147 |
|
1148 | |||
1148 | #print 'numlines',numlines,'screenlines',screen_lines # dbg |
|
1149 | #print 'numlines',numlines,'screenlines',screen_lines # dbg | |
1149 | if numlines <= screen_lines : |
|
1150 | if numlines <= screen_lines : | |
1150 | #print '*** normal print' # dbg |
|
1151 | #print '*** normal print' # dbg | |
1151 | print >>Term.cout, str_toprint |
|
1152 | print >>Term.cout, str_toprint | |
1152 | else: |
|
1153 | else: | |
1153 | # Try to open pager and default to internal one if that fails. |
|
1154 | # Try to open pager and default to internal one if that fails. | |
1154 | # All failure modes are tagged as 'retval=1', to match the return |
|
1155 | # All failure modes are tagged as 'retval=1', to match the return | |
1155 | # value of a failed system command. If any intermediate attempt |
|
1156 | # value of a failed system command. If any intermediate attempt | |
1156 | # sets retval to 1, at the end we resort to our own page_dumb() pager. |
|
1157 | # sets retval to 1, at the end we resort to our own page_dumb() pager. | |
1157 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1158 | pager_cmd = get_pager_cmd(pager_cmd) | |
1158 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1159 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) | |
1159 | if os.name == 'nt': |
|
1160 | if os.name == 'nt': | |
1160 | if pager_cmd.startswith('type'): |
|
1161 | if pager_cmd.startswith('type'): | |
1161 | # The default WinXP 'type' command is failing on complex strings. |
|
1162 | # The default WinXP 'type' command is failing on complex strings. | |
1162 | retval = 1 |
|
1163 | retval = 1 | |
1163 | else: |
|
1164 | else: | |
1164 | tmpname = tempfile.mktemp('.txt') |
|
1165 | tmpname = tempfile.mktemp('.txt') | |
1165 | tmpfile = file(tmpname,'wt') |
|
1166 | tmpfile = file(tmpname,'wt') | |
1166 | tmpfile.write(strng) |
|
1167 | tmpfile.write(strng) | |
1167 | tmpfile.close() |
|
1168 | tmpfile.close() | |
1168 | cmd = "%s < %s" % (pager_cmd,tmpname) |
|
1169 | cmd = "%s < %s" % (pager_cmd,tmpname) | |
1169 | if os.system(cmd): |
|
1170 | if os.system(cmd): | |
1170 | retval = 1 |
|
1171 | retval = 1 | |
1171 | else: |
|
1172 | else: | |
1172 | retval = None |
|
1173 | retval = None | |
1173 | os.remove(tmpname) |
|
1174 | os.remove(tmpname) | |
1174 | else: |
|
1175 | else: | |
1175 | try: |
|
1176 | try: | |
1176 | retval = None |
|
1177 | retval = None | |
1177 | # if I use popen4, things hang. No idea why. |
|
1178 | # if I use popen4, things hang. No idea why. | |
1178 | #pager,shell_out = os.popen4(pager_cmd) |
|
1179 | #pager,shell_out = os.popen4(pager_cmd) | |
1179 | pager = os.popen(pager_cmd,'w') |
|
1180 | pager = os.popen(pager_cmd,'w') | |
1180 | pager.write(strng) |
|
1181 | pager.write(strng) | |
1181 | pager.close() |
|
1182 | pager.close() | |
1182 | retval = pager.close() # success returns None |
|
1183 | retval = pager.close() # success returns None | |
1183 | except IOError,msg: # broken pipe when user quits |
|
1184 | except IOError,msg: # broken pipe when user quits | |
1184 | if msg.args == (32,'Broken pipe'): |
|
1185 | if msg.args == (32,'Broken pipe'): | |
1185 | retval = None |
|
1186 | retval = None | |
1186 | else: |
|
1187 | else: | |
1187 | retval = 1 |
|
1188 | retval = 1 | |
1188 | except OSError: |
|
1189 | except OSError: | |
1189 | # Other strange problems, sometimes seen in Win2k/cygwin |
|
1190 | # Other strange problems, sometimes seen in Win2k/cygwin | |
1190 | retval = 1 |
|
1191 | retval = 1 | |
1191 | if retval is not None: |
|
1192 | if retval is not None: | |
1192 | page_dumb(strng,screen_lines=screen_lines) |
|
1193 | page_dumb(strng,screen_lines=screen_lines) | |
1193 |
|
1194 | |||
1194 | #---------------------------------------------------------------------------- |
|
1195 | #---------------------------------------------------------------------------- | |
1195 | def page_file(fname,start = 0, pager_cmd = None): |
|
1196 | def page_file(fname,start = 0, pager_cmd = None): | |
1196 | """Page a file, using an optional pager command and starting line. |
|
1197 | """Page a file, using an optional pager command and starting line. | |
1197 | """ |
|
1198 | """ | |
1198 |
|
1199 | |||
1199 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1200 | pager_cmd = get_pager_cmd(pager_cmd) | |
1200 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1201 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) | |
1201 |
|
1202 | |||
1202 | try: |
|
1203 | try: | |
1203 | if os.environ['TERM'] in ['emacs','dumb']: |
|
1204 | if os.environ['TERM'] in ['emacs','dumb']: | |
1204 | raise EnvironmentError |
|
1205 | raise EnvironmentError | |
1205 | xsys(pager_cmd + ' ' + fname) |
|
1206 | xsys(pager_cmd + ' ' + fname) | |
1206 | except: |
|
1207 | except: | |
1207 | try: |
|
1208 | try: | |
1208 | if start > 0: |
|
1209 | if start > 0: | |
1209 | start -= 1 |
|
1210 | start -= 1 | |
1210 | page(open(fname).read(),start) |
|
1211 | page(open(fname).read(),start) | |
1211 | except: |
|
1212 | except: | |
1212 | print 'Unable to show file',`fname` |
|
1213 | print 'Unable to show file',`fname` | |
1213 |
|
1214 | |||
1214 | #---------------------------------------------------------------------------- |
|
1215 | #---------------------------------------------------------------------------- | |
1215 | def snip_print(str,width = 75,print_full = 0,header = ''): |
|
1216 | def snip_print(str,width = 75,print_full = 0,header = ''): | |
1216 | """Print a string snipping the midsection to fit in width. |
|
1217 | """Print a string snipping the midsection to fit in width. | |
1217 |
|
1218 | |||
1218 | print_full: mode control: |
|
1219 | print_full: mode control: | |
1219 | - 0: only snip long strings |
|
1220 | - 0: only snip long strings | |
1220 | - 1: send to page() directly. |
|
1221 | - 1: send to page() directly. | |
1221 | - 2: snip long strings and ask for full length viewing with page() |
|
1222 | - 2: snip long strings and ask for full length viewing with page() | |
1222 | Return 1 if snipping was necessary, 0 otherwise.""" |
|
1223 | Return 1 if snipping was necessary, 0 otherwise.""" | |
1223 |
|
1224 | |||
1224 | if print_full == 1: |
|
1225 | if print_full == 1: | |
1225 | page(header+str) |
|
1226 | page(header+str) | |
1226 | return 0 |
|
1227 | return 0 | |
1227 |
|
1228 | |||
1228 | print header, |
|
1229 | print header, | |
1229 | if len(str) < width: |
|
1230 | if len(str) < width: | |
1230 | print str |
|
1231 | print str | |
1231 | snip = 0 |
|
1232 | snip = 0 | |
1232 | else: |
|
1233 | else: | |
1233 | whalf = int((width -5)/2) |
|
1234 | whalf = int((width -5)/2) | |
1234 | print str[:whalf] + ' <...> ' + str[-whalf:] |
|
1235 | print str[:whalf] + ' <...> ' + str[-whalf:] | |
1235 | snip = 1 |
|
1236 | snip = 1 | |
1236 | if snip and print_full == 2: |
|
1237 | if snip and print_full == 2: | |
1237 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': |
|
1238 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': | |
1238 | page(str) |
|
1239 | page(str) | |
1239 | return snip |
|
1240 | return snip | |
1240 |
|
1241 | |||
1241 | #**************************************************************************** |
|
1242 | #**************************************************************************** | |
1242 | # lists, dicts and structures |
|
1243 | # lists, dicts and structures | |
1243 |
|
1244 | |||
1244 | def belong(candidates,checklist): |
|
1245 | def belong(candidates,checklist): | |
1245 | """Check whether a list of items appear in a given list of options. |
|
1246 | """Check whether a list of items appear in a given list of options. | |
1246 |
|
1247 | |||
1247 | Returns a list of 1 and 0, one for each candidate given.""" |
|
1248 | Returns a list of 1 and 0, one for each candidate given.""" | |
1248 |
|
1249 | |||
1249 | return [x in checklist for x in candidates] |
|
1250 | return [x in checklist for x in candidates] | |
1250 |
|
1251 | |||
1251 | #---------------------------------------------------------------------------- |
|
1252 | #---------------------------------------------------------------------------- | |
1252 | def uniq_stable(elems): |
|
1253 | def uniq_stable(elems): | |
1253 | """uniq_stable(elems) -> list |
|
1254 | """uniq_stable(elems) -> list | |
1254 |
|
1255 | |||
1255 | Return from an iterable, a list of all the unique elements in the input, |
|
1256 | Return from an iterable, a list of all the unique elements in the input, | |
1256 | but maintaining the order in which they first appear. |
|
1257 | but maintaining the order in which they first appear. | |
1257 |
|
1258 | |||
1258 | A naive solution to this problem which just makes a dictionary with the |
|
1259 | A naive solution to this problem which just makes a dictionary with the | |
1259 | elements as keys fails to respect the stability condition, since |
|
1260 | elements as keys fails to respect the stability condition, since | |
1260 | dictionaries are unsorted by nature. |
|
1261 | dictionaries are unsorted by nature. | |
1261 |
|
1262 | |||
1262 | Note: All elements in the input must be valid dictionary keys for this |
|
1263 | Note: All elements in the input must be valid dictionary keys for this | |
1263 | routine to work, as it internally uses a dictionary for efficiency |
|
1264 | routine to work, as it internally uses a dictionary for efficiency | |
1264 | reasons.""" |
|
1265 | reasons.""" | |
1265 |
|
1266 | |||
1266 | unique = [] |
|
1267 | unique = [] | |
1267 | unique_dict = {} |
|
1268 | unique_dict = {} | |
1268 | for nn in elems: |
|
1269 | for nn in elems: | |
1269 | if nn not in unique_dict: |
|
1270 | if nn not in unique_dict: | |
1270 | unique.append(nn) |
|
1271 | unique.append(nn) | |
1271 | unique_dict[nn] = None |
|
1272 | unique_dict[nn] = None | |
1272 | return unique |
|
1273 | return unique | |
1273 |
|
1274 | |||
1274 | #---------------------------------------------------------------------------- |
|
1275 | #---------------------------------------------------------------------------- | |
1275 | class NLprinter: |
|
1276 | class NLprinter: | |
1276 | """Print an arbitrarily nested list, indicating index numbers. |
|
1277 | """Print an arbitrarily nested list, indicating index numbers. | |
1277 |
|
1278 | |||
1278 | An instance of this class called nlprint is available and callable as a |
|
1279 | An instance of this class called nlprint is available and callable as a | |
1279 | function. |
|
1280 | function. | |
1280 |
|
1281 | |||
1281 | nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' |
|
1282 | nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' | |
1282 | and using 'sep' to separate the index from the value. """ |
|
1283 | and using 'sep' to separate the index from the value. """ | |
1283 |
|
1284 | |||
1284 | def __init__(self): |
|
1285 | def __init__(self): | |
1285 | self.depth = 0 |
|
1286 | self.depth = 0 | |
1286 |
|
1287 | |||
1287 | def __call__(self,lst,pos='',**kw): |
|
1288 | def __call__(self,lst,pos='',**kw): | |
1288 | """Prints the nested list numbering levels.""" |
|
1289 | """Prints the nested list numbering levels.""" | |
1289 | kw.setdefault('indent',' ') |
|
1290 | kw.setdefault('indent',' ') | |
1290 | kw.setdefault('sep',': ') |
|
1291 | kw.setdefault('sep',': ') | |
1291 | kw.setdefault('start',0) |
|
1292 | kw.setdefault('start',0) | |
1292 | kw.setdefault('stop',len(lst)) |
|
1293 | kw.setdefault('stop',len(lst)) | |
1293 | # we need to remove start and stop from kw so they don't propagate |
|
1294 | # we need to remove start and stop from kw so they don't propagate | |
1294 | # into a recursive call for a nested list. |
|
1295 | # into a recursive call for a nested list. | |
1295 | start = kw['start']; del kw['start'] |
|
1296 | start = kw['start']; del kw['start'] | |
1296 | stop = kw['stop']; del kw['stop'] |
|
1297 | stop = kw['stop']; del kw['stop'] | |
1297 | if self.depth == 0 and 'header' in kw.keys(): |
|
1298 | if self.depth == 0 and 'header' in kw.keys(): | |
1298 | print kw['header'] |
|
1299 | print kw['header'] | |
1299 |
|
1300 | |||
1300 | for idx in range(start,stop): |
|
1301 | for idx in range(start,stop): | |
1301 | elem = lst[idx] |
|
1302 | elem = lst[idx] | |
1302 | if type(elem)==type([]): |
|
1303 | if type(elem)==type([]): | |
1303 | self.depth += 1 |
|
1304 | self.depth += 1 | |
1304 | self.__call__(elem,itpl('$pos$idx,'),**kw) |
|
1305 | self.__call__(elem,itpl('$pos$idx,'),**kw) | |
1305 | self.depth -= 1 |
|
1306 | self.depth -= 1 | |
1306 | else: |
|
1307 | else: | |
1307 | printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem') |
|
1308 | printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem') | |
1308 |
|
1309 | |||
1309 | nlprint = NLprinter() |
|
1310 | nlprint = NLprinter() | |
1310 | #---------------------------------------------------------------------------- |
|
1311 | #---------------------------------------------------------------------------- | |
1311 | def all_belong(candidates,checklist): |
|
1312 | def all_belong(candidates,checklist): | |
1312 | """Check whether a list of items ALL appear in a given list of options. |
|
1313 | """Check whether a list of items ALL appear in a given list of options. | |
1313 |
|
1314 | |||
1314 | Returns a single 1 or 0 value.""" |
|
1315 | Returns a single 1 or 0 value.""" | |
1315 |
|
1316 | |||
1316 | return 1-(0 in [x in checklist for x in candidates]) |
|
1317 | return 1-(0 in [x in checklist for x in candidates]) | |
1317 |
|
1318 | |||
1318 | #---------------------------------------------------------------------------- |
|
1319 | #---------------------------------------------------------------------------- | |
1319 | def sort_compare(lst1,lst2,inplace = 1): |
|
1320 | def sort_compare(lst1,lst2,inplace = 1): | |
1320 | """Sort and compare two lists. |
|
1321 | """Sort and compare two lists. | |
1321 |
|
1322 | |||
1322 | By default it does it in place, thus modifying the lists. Use inplace = 0 |
|
1323 | By default it does it in place, thus modifying the lists. Use inplace = 0 | |
1323 | to avoid that (at the cost of temporary copy creation).""" |
|
1324 | to avoid that (at the cost of temporary copy creation).""" | |
1324 | if not inplace: |
|
1325 | if not inplace: | |
1325 | lst1 = lst1[:] |
|
1326 | lst1 = lst1[:] | |
1326 | lst2 = lst2[:] |
|
1327 | lst2 = lst2[:] | |
1327 | lst1.sort(); lst2.sort() |
|
1328 | lst1.sort(); lst2.sort() | |
1328 | return lst1 == lst2 |
|
1329 | return lst1 == lst2 | |
1329 |
|
1330 | |||
1330 | #---------------------------------------------------------------------------- |
|
1331 | #---------------------------------------------------------------------------- | |
1331 | def mkdict(**kwargs): |
|
1332 | def mkdict(**kwargs): | |
1332 | """Return a dict from a keyword list. |
|
1333 | """Return a dict from a keyword list. | |
1333 |
|
1334 | |||
1334 | It's just syntactic sugar for making ditcionary creation more convenient: |
|
1335 | It's just syntactic sugar for making ditcionary creation more convenient: | |
1335 | # the standard way |
|
1336 | # the standard way | |
1336 | >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 } |
|
1337 | >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 } | |
1337 | # a cleaner way |
|
1338 | # a cleaner way | |
1338 | >>>data = dict(red=1, green=2, blue=3) |
|
1339 | >>>data = dict(red=1, green=2, blue=3) | |
1339 |
|
1340 | |||
1340 | If you need more than this, look at the Struct() class.""" |
|
1341 | If you need more than this, look at the Struct() class.""" | |
1341 |
|
1342 | |||
1342 | return kwargs |
|
1343 | return kwargs | |
1343 |
|
1344 | |||
1344 | #---------------------------------------------------------------------------- |
|
1345 | #---------------------------------------------------------------------------- | |
1345 | def list2dict(lst): |
|
1346 | def list2dict(lst): | |
1346 | """Takes a list of (key,value) pairs and turns it into a dict.""" |
|
1347 | """Takes a list of (key,value) pairs and turns it into a dict.""" | |
1347 |
|
1348 | |||
1348 | dic = {} |
|
1349 | dic = {} | |
1349 | for k,v in lst: dic[k] = v |
|
1350 | for k,v in lst: dic[k] = v | |
1350 | return dic |
|
1351 | return dic | |
1351 |
|
1352 | |||
1352 | #---------------------------------------------------------------------------- |
|
1353 | #---------------------------------------------------------------------------- | |
1353 | def list2dict2(lst,default=''): |
|
1354 | def list2dict2(lst,default=''): | |
1354 | """Takes a list and turns it into a dict. |
|
1355 | """Takes a list and turns it into a dict. | |
1355 | Much slower than list2dict, but more versatile. This version can take |
|
1356 | Much slower than list2dict, but more versatile. This version can take | |
1356 | lists with sublists of arbitrary length (including sclars).""" |
|
1357 | lists with sublists of arbitrary length (including sclars).""" | |
1357 |
|
1358 | |||
1358 | dic = {} |
|
1359 | dic = {} | |
1359 | for elem in lst: |
|
1360 | for elem in lst: | |
1360 | if type(elem) in (types.ListType,types.TupleType): |
|
1361 | if type(elem) in (types.ListType,types.TupleType): | |
1361 | size = len(elem) |
|
1362 | size = len(elem) | |
1362 | if size == 0: |
|
1363 | if size == 0: | |
1363 | pass |
|
1364 | pass | |
1364 | elif size == 1: |
|
1365 | elif size == 1: | |
1365 | dic[elem] = default |
|
1366 | dic[elem] = default | |
1366 | else: |
|
1367 | else: | |
1367 | k,v = elem[0], elem[1:] |
|
1368 | k,v = elem[0], elem[1:] | |
1368 | if len(v) == 1: v = v[0] |
|
1369 | if len(v) == 1: v = v[0] | |
1369 | dic[k] = v |
|
1370 | dic[k] = v | |
1370 | else: |
|
1371 | else: | |
1371 | dic[elem] = default |
|
1372 | dic[elem] = default | |
1372 | return dic |
|
1373 | return dic | |
1373 |
|
1374 | |||
1374 | #---------------------------------------------------------------------------- |
|
1375 | #---------------------------------------------------------------------------- | |
1375 | def flatten(seq): |
|
1376 | def flatten(seq): | |
1376 | """Flatten a list of lists (NOT recursive, only works for 2d lists).""" |
|
1377 | """Flatten a list of lists (NOT recursive, only works for 2d lists).""" | |
1377 |
|
1378 | |||
1378 | # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in). |
|
1379 | # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in). | |
1379 |
|
1380 | |||
1380 | # if the x=0 isn't made, a *global* variable x is left over after calling |
|
1381 | # if the x=0 isn't made, a *global* variable x is left over after calling | |
1381 | # this function, with the value of the last element in the return |
|
1382 | # this function, with the value of the last element in the return | |
1382 | # list. This does seem like a bug big time to me. |
|
1383 | # list. This does seem like a bug big time to me. | |
1383 |
|
1384 | |||
1384 | # the problem is fixed with the x=0, which seems to force the creation of |
|
1385 | # the problem is fixed with the x=0, which seems to force the creation of | |
1385 | # a local name |
|
1386 | # a local name | |
1386 |
|
1387 | |||
1387 | x = 0 |
|
1388 | x = 0 | |
1388 | return [x for subseq in seq for x in subseq] |
|
1389 | return [x for subseq in seq for x in subseq] | |
1389 |
|
1390 | |||
1390 | #---------------------------------------------------------------------------- |
|
1391 | #---------------------------------------------------------------------------- | |
1391 | def get_slice(seq,start=0,stop=None,step=1): |
|
1392 | def get_slice(seq,start=0,stop=None,step=1): | |
1392 | """Get a slice of a sequence with variable step. Specify start,stop,step.""" |
|
1393 | """Get a slice of a sequence with variable step. Specify start,stop,step.""" | |
1393 | if stop == None: |
|
1394 | if stop == None: | |
1394 | stop = len(seq) |
|
1395 | stop = len(seq) | |
1395 | item = lambda i: seq[i] |
|
1396 | item = lambda i: seq[i] | |
1396 | return map(item,xrange(start,stop,step)) |
|
1397 | return map(item,xrange(start,stop,step)) | |
1397 |
|
1398 | |||
1398 | #---------------------------------------------------------------------------- |
|
1399 | #---------------------------------------------------------------------------- | |
1399 | def chop(seq,size): |
|
1400 | def chop(seq,size): | |
1400 | """Chop a sequence into chunks of the given size.""" |
|
1401 | """Chop a sequence into chunks of the given size.""" | |
1401 | chunk = lambda i: seq[i:i+size] |
|
1402 | chunk = lambda i: seq[i:i+size] | |
1402 | return map(chunk,xrange(0,len(seq),size)) |
|
1403 | return map(chunk,xrange(0,len(seq),size)) | |
1403 |
|
1404 | |||
1404 | #---------------------------------------------------------------------------- |
|
1405 | #---------------------------------------------------------------------------- | |
1405 | def with(object, **args): |
|
1406 | def with(object, **args): | |
1406 | """Set multiple attributes for an object, similar to Pascal's with. |
|
1407 | """Set multiple attributes for an object, similar to Pascal's with. | |
1407 |
|
1408 | |||
1408 | Example: |
|
1409 | Example: | |
1409 | with(jim, |
|
1410 | with(jim, | |
1410 | born = 1960, |
|
1411 | born = 1960, | |
1411 | haircolour = 'Brown', |
|
1412 | haircolour = 'Brown', | |
1412 | eyecolour = 'Green') |
|
1413 | eyecolour = 'Green') | |
1413 |
|
1414 | |||
1414 | Credit: Greg Ewing, in |
|
1415 | Credit: Greg Ewing, in | |
1415 | http://mail.python.org/pipermail/python-list/2001-May/040703.html""" |
|
1416 | http://mail.python.org/pipermail/python-list/2001-May/040703.html""" | |
1416 |
|
1417 | |||
1417 | object.__dict__.update(args) |
|
1418 | object.__dict__.update(args) | |
1418 |
|
1419 | |||
1419 | #---------------------------------------------------------------------------- |
|
1420 | #---------------------------------------------------------------------------- | |
1420 | def setattr_list(obj,alist,nspace = None): |
|
1421 | def setattr_list(obj,alist,nspace = None): | |
1421 | """Set a list of attributes for an object taken from a namespace. |
|
1422 | """Set a list of attributes for an object taken from a namespace. | |
1422 |
|
1423 | |||
1423 | setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in |
|
1424 | setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in | |
1424 | alist with their values taken from nspace, which must be a dict (something |
|
1425 | alist with their values taken from nspace, which must be a dict (something | |
1425 | like locals() will often do) If nspace isn't given, locals() of the |
|
1426 | like locals() will often do) If nspace isn't given, locals() of the | |
1426 | *caller* is used, so in most cases you can omit it. |
|
1427 | *caller* is used, so in most cases you can omit it. | |
1427 |
|
1428 | |||
1428 | Note that alist can be given as a string, which will be automatically |
|
1429 | Note that alist can be given as a string, which will be automatically | |
1429 | split into a list on whitespace. If given as a list, it must be a list of |
|
1430 | split into a list on whitespace. If given as a list, it must be a list of | |
1430 | *strings* (the variable names themselves), not of variables.""" |
|
1431 | *strings* (the variable names themselves), not of variables.""" | |
1431 |
|
1432 | |||
1432 | # this grabs the local variables from the *previous* call frame -- that is |
|
1433 | # this grabs the local variables from the *previous* call frame -- that is | |
1433 | # the locals from the function that called setattr_list(). |
|
1434 | # the locals from the function that called setattr_list(). | |
1434 | # - snipped from weave.inline() |
|
1435 | # - snipped from weave.inline() | |
1435 | if nspace is None: |
|
1436 | if nspace is None: | |
1436 | call_frame = sys._getframe().f_back |
|
1437 | call_frame = sys._getframe().f_back | |
1437 | nspace = call_frame.f_locals |
|
1438 | nspace = call_frame.f_locals | |
1438 |
|
1439 | |||
1439 | if type(alist) in StringTypes: |
|
1440 | if type(alist) in StringTypes: | |
1440 | alist = alist.split() |
|
1441 | alist = alist.split() | |
1441 | for attr in alist: |
|
1442 | for attr in alist: | |
1442 | val = eval(attr,nspace) |
|
1443 | val = eval(attr,nspace) | |
1443 | setattr(obj,attr,val) |
|
1444 | setattr(obj,attr,val) | |
1444 |
|
1445 | |||
1445 | #---------------------------------------------------------------------------- |
|
1446 | #---------------------------------------------------------------------------- | |
1446 | def getattr_list(obj,alist,*args): |
|
1447 | def getattr_list(obj,alist,*args): | |
1447 | """getattr_list(obj,alist[, default]) -> attribute list. |
|
1448 | """getattr_list(obj,alist[, default]) -> attribute list. | |
1448 |
|
1449 | |||
1449 | Get a list of named attributes for an object. When a default argument is |
|
1450 | Get a list of named attributes for an object. When a default argument is | |
1450 | given, it is returned when the attribute doesn't exist; without it, an |
|
1451 | given, it is returned when the attribute doesn't exist; without it, an | |
1451 | exception is raised in that case. |
|
1452 | exception is raised in that case. | |
1452 |
|
1453 | |||
1453 | Note that alist can be given as a string, which will be automatically |
|
1454 | Note that alist can be given as a string, which will be automatically | |
1454 | split into a list on whitespace. If given as a list, it must be a list of |
|
1455 | split into a list on whitespace. If given as a list, it must be a list of | |
1455 | *strings* (the variable names themselves), not of variables.""" |
|
1456 | *strings* (the variable names themselves), not of variables.""" | |
1456 |
|
1457 | |||
1457 | if type(alist) in StringTypes: |
|
1458 | if type(alist) in StringTypes: | |
1458 | alist = alist.split() |
|
1459 | alist = alist.split() | |
1459 | if args: |
|
1460 | if args: | |
1460 | if len(args)==1: |
|
1461 | if len(args)==1: | |
1461 | default = args[0] |
|
1462 | default = args[0] | |
1462 | return map(lambda attr: getattr(obj,attr,default),alist) |
|
1463 | return map(lambda attr: getattr(obj,attr,default),alist) | |
1463 | else: |
|
1464 | else: | |
1464 | raise ValueError,'getattr_list() takes only one optional argument' |
|
1465 | raise ValueError,'getattr_list() takes only one optional argument' | |
1465 | else: |
|
1466 | else: | |
1466 | return map(lambda attr: getattr(obj,attr),alist) |
|
1467 | return map(lambda attr: getattr(obj,attr),alist) | |
1467 |
|
1468 | |||
1468 | #---------------------------------------------------------------------------- |
|
1469 | #---------------------------------------------------------------------------- | |
1469 | def map_method(method,object_list,*argseq,**kw): |
|
1470 | def map_method(method,object_list,*argseq,**kw): | |
1470 | """map_method(method,object_list,*args,**kw) -> list |
|
1471 | """map_method(method,object_list,*args,**kw) -> list | |
1471 |
|
1472 | |||
1472 | Return a list of the results of applying the methods to the items of the |
|
1473 | Return a list of the results of applying the methods to the items of the | |
1473 | argument sequence(s). If more than one sequence is given, the method is |
|
1474 | argument sequence(s). If more than one sequence is given, the method is | |
1474 | called with an argument list consisting of the corresponding item of each |
|
1475 | called with an argument list consisting of the corresponding item of each | |
1475 | sequence. All sequences must be of the same length. |
|
1476 | sequence. All sequences must be of the same length. | |
1476 |
|
1477 | |||
1477 | Keyword arguments are passed verbatim to all objects called. |
|
1478 | Keyword arguments are passed verbatim to all objects called. | |
1478 |
|
1479 | |||
1479 | This is Python code, so it's not nearly as fast as the builtin map().""" |
|
1480 | This is Python code, so it's not nearly as fast as the builtin map().""" | |
1480 |
|
1481 | |||
1481 | out_list = [] |
|
1482 | out_list = [] | |
1482 | idx = 0 |
|
1483 | idx = 0 | |
1483 | for object in object_list: |
|
1484 | for object in object_list: | |
1484 | try: |
|
1485 | try: | |
1485 | handler = getattr(object, method) |
|
1486 | handler = getattr(object, method) | |
1486 | except AttributeError: |
|
1487 | except AttributeError: | |
1487 | out_list.append(None) |
|
1488 | out_list.append(None) | |
1488 | else: |
|
1489 | else: | |
1489 | if argseq: |
|
1490 | if argseq: | |
1490 | args = map(lambda lst:lst[idx],argseq) |
|
1491 | args = map(lambda lst:lst[idx],argseq) | |
1491 | #print 'ob',object,'hand',handler,'ar',args # dbg |
|
1492 | #print 'ob',object,'hand',handler,'ar',args # dbg | |
1492 | out_list.append(handler(args,**kw)) |
|
1493 | out_list.append(handler(args,**kw)) | |
1493 | else: |
|
1494 | else: | |
1494 | out_list.append(handler(**kw)) |
|
1495 | out_list.append(handler(**kw)) | |
1495 | idx += 1 |
|
1496 | idx += 1 | |
1496 | return out_list |
|
1497 | return out_list | |
1497 |
|
1498 | |||
1498 | #---------------------------------------------------------------------------- |
|
1499 | #---------------------------------------------------------------------------- | |
1499 | # Proposed popitem() extension, written as a method |
|
1500 | # Proposed popitem() extension, written as a method | |
1500 |
|
1501 | |||
1501 | class NotGiven: pass |
|
1502 | class NotGiven: pass | |
1502 |
|
1503 | |||
1503 | def popkey(dct,key,default=NotGiven): |
|
1504 | def popkey(dct,key,default=NotGiven): | |
1504 | """Return dct[key] and delete dct[key]. |
|
1505 | """Return dct[key] and delete dct[key]. | |
1505 |
|
1506 | |||
1506 | If default is given, return it if dct[key] doesn't exist, otherwise raise |
|
1507 | If default is given, return it if dct[key] doesn't exist, otherwise raise | |
1507 | KeyError. """ |
|
1508 | KeyError. """ | |
1508 |
|
1509 | |||
1509 | try: |
|
1510 | try: | |
1510 | val = dct[key] |
|
1511 | val = dct[key] | |
1511 | except KeyError: |
|
1512 | except KeyError: | |
1512 | if default is NotGiven: |
|
1513 | if default is NotGiven: | |
1513 | raise |
|
1514 | raise | |
1514 | else: |
|
1515 | else: | |
1515 | return default |
|
1516 | return default | |
1516 | else: |
|
1517 | else: | |
1517 | del dct[key] |
|
1518 | del dct[key] | |
1518 | return val |
|
1519 | return val | |
1519 | #*************************** end of file <genutils.py> ********************** |
|
1520 | #*************************** end of file <genutils.py> ********************** | |
1520 |
|
1521 |
@@ -1,1999 +1,2004 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 |
|
9 | $Id: iplib.py 703 2005-08-16 17:34:44Z 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-2004 Fernando Perez. <fperez@colorado.edu> |
|
14 | # Copyright (C) 2001-2004 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, much of that class has been copied |
|
20 | # Python standard library. Over time, much 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. The Python License (sec. 2) allows for this, but it's always |
|
22 | # subclassing. The Python License (sec. 2) allows for this, but it's always | |
23 | # nice to acknowledge credit where credit is due. |
|
23 | # nice to acknowledge credit where credit is due. | |
24 | #***************************************************************************** |
|
24 | #***************************************************************************** | |
25 |
|
25 | |||
26 | #**************************************************************************** |
|
26 | #**************************************************************************** | |
27 | # Modules and globals |
|
27 | # Modules and globals | |
28 |
|
28 | |||
29 | from __future__ import generators # for 2.2 backwards-compatibility |
|
29 | from __future__ import generators # for 2.2 backwards-compatibility | |
30 |
|
30 | |||
31 | from IPython import Release |
|
31 | from IPython import Release | |
32 | __author__ = '%s <%s>\n%s <%s>' % \ |
|
32 | __author__ = '%s <%s>\n%s <%s>' % \ | |
33 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) |
|
33 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) | |
34 | __license__ = Release.license |
|
34 | __license__ = Release.license | |
35 | __version__ = Release.version |
|
35 | __version__ = Release.version | |
36 |
|
36 | |||
37 | # Python standard modules |
|
37 | # Python standard modules | |
38 | import __main__ |
|
38 | import __main__ | |
39 | import __builtin__ |
|
39 | import __builtin__ | |
40 | import exceptions |
|
40 | import exceptions | |
41 | import keyword |
|
41 | import keyword | |
42 | import new |
|
42 | import new | |
43 | import os, sys, shutil |
|
43 | import os, sys, shutil | |
44 | import code, glob, types, re |
|
44 | import code, glob, types, re | |
45 | import string, StringIO |
|
45 | import string, StringIO | |
46 | import inspect, pydoc |
|
46 | import inspect, pydoc | |
47 | import bdb, pdb |
|
47 | import bdb, pdb | |
48 | import UserList # don't subclass list so this works with Python2.1 |
|
48 | import UserList # don't subclass list so this works with Python2.1 | |
49 | from pprint import pprint, pformat |
|
49 | from pprint import pprint, pformat | |
50 | import cPickle as pickle |
|
50 | import cPickle as pickle | |
51 | import traceback |
|
51 | import traceback | |
52 |
|
52 | |||
53 | # IPython's own modules |
|
53 | # IPython's own modules | |
54 | import IPython |
|
54 | import IPython | |
55 | from IPython import OInspect,PyColorize,ultraTB |
|
55 | from IPython import OInspect,PyColorize,ultraTB | |
56 | from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names |
|
56 | from IPython.ultraTB import ColorScheme,ColorSchemeTable # too long names | |
57 | from IPython.Logger import Logger |
|
57 | from IPython.Logger import Logger | |
58 | from IPython.Magic import Magic,magic2python,shlex_split |
|
58 | from IPython.Magic import Magic,magic2python,shlex_split | |
59 | from IPython.usage import cmd_line_usage,interactive_usage |
|
59 | from IPython.usage import cmd_line_usage,interactive_usage | |
60 | from IPython.Struct import Struct |
|
60 | from IPython.Struct import Struct | |
61 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns |
|
61 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns | |
62 | from IPython.FakeModule import FakeModule |
|
62 | from IPython.FakeModule import FakeModule | |
63 | from IPython.background_jobs import BackgroundJobManager |
|
63 | from IPython.background_jobs import BackgroundJobManager | |
64 | from IPython.genutils import * |
|
64 | from IPython.genutils import * | |
65 |
|
65 | |||
66 | # Global pointer to the running |
|
66 | # Global pointer to the running | |
67 |
|
67 | |||
68 | # store the builtin raw_input globally, and use this always, in case user code |
|
68 | # store the builtin raw_input globally, and use this always, in case user code | |
69 | # overwrites it (like wx.py.PyShell does) |
|
69 | # overwrites it (like wx.py.PyShell does) | |
70 | raw_input_original = raw_input |
|
70 | raw_input_original = raw_input | |
71 |
|
71 | |||
72 | #**************************************************************************** |
|
72 | #**************************************************************************** | |
73 | # Some utility function definitions |
|
73 | # Some utility function definitions | |
74 |
|
74 | |||
75 | class Bunch: pass |
|
75 | class Bunch: pass | |
76 |
|
76 | |||
77 | def esc_quotes(strng): |
|
77 | def esc_quotes(strng): | |
78 | """Return the input string with single and double quotes escaped out""" |
|
78 | """Return the input string with single and double quotes escaped out""" | |
79 |
|
79 | |||
80 | return strng.replace('"','\\"').replace("'","\\'") |
|
80 | return strng.replace('"','\\"').replace("'","\\'") | |
81 |
|
81 | |||
82 | def import_fail_info(mod_name,fns=None): |
|
82 | def import_fail_info(mod_name,fns=None): | |
83 | """Inform load failure for a module.""" |
|
83 | """Inform load failure for a module.""" | |
84 |
|
84 | |||
85 | if fns == None: |
|
85 | if fns == None: | |
86 | warn("Loading of %s failed.\n" % (mod_name,)) |
|
86 | warn("Loading of %s failed.\n" % (mod_name,)) | |
87 | else: |
|
87 | else: | |
88 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) |
|
88 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) | |
89 |
|
89 | |||
90 | def qw_lol(indata): |
|
90 | def qw_lol(indata): | |
91 | """qw_lol('a b') -> [['a','b']], |
|
91 | """qw_lol('a b') -> [['a','b']], | |
92 | otherwise it's just a call to qw(). |
|
92 | otherwise it's just a call to qw(). | |
93 |
|
93 | |||
94 | We need this to make sure the modules_some keys *always* end up as a |
|
94 | We need this to make sure the modules_some keys *always* end up as a | |
95 | list of lists.""" |
|
95 | list of lists.""" | |
96 |
|
96 | |||
97 | if type(indata) in StringTypes: |
|
97 | if type(indata) in StringTypes: | |
98 | return [qw(indata)] |
|
98 | return [qw(indata)] | |
99 | else: |
|
99 | else: | |
100 | return qw(indata) |
|
100 | return qw(indata) | |
101 |
|
101 | |||
102 | def ipmagic(arg_s): |
|
102 | def ipmagic(arg_s): | |
103 | """Call a magic function by name. |
|
103 | """Call a magic function by name. | |
104 |
|
104 | |||
105 | Input: a string containing the name of the magic function to call and any |
|
105 | Input: a string containing the name of the magic function to call and any | |
106 | additional arguments to be passed to the magic. |
|
106 | additional arguments to be passed to the magic. | |
107 |
|
107 | |||
108 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython |
|
108 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython | |
109 | prompt: |
|
109 | prompt: | |
110 |
|
110 | |||
111 | In[1]: %name -opt foo bar |
|
111 | In[1]: %name -opt foo bar | |
112 |
|
112 | |||
113 | To call a magic without arguments, simply use ipmagic('name'). |
|
113 | To call a magic without arguments, simply use ipmagic('name'). | |
114 |
|
114 | |||
115 | This provides a proper Python function to call IPython's magics in any |
|
115 | This provides a proper Python function to call IPython's magics in any | |
116 | valid Python code you can type at the interpreter, including loops and |
|
116 | valid Python code you can type at the interpreter, including loops and | |
117 | compound statements. It is added by IPython to the Python builtin |
|
117 | compound statements. It is added by IPython to the Python builtin | |
118 | namespace upon initialization.""" |
|
118 | namespace upon initialization.""" | |
119 |
|
119 | |||
120 | args = arg_s.split(' ',1) |
|
120 | args = arg_s.split(' ',1) | |
121 | magic_name = args[0] |
|
121 | magic_name = args[0] | |
122 | if magic_name.startswith(__IPYTHON__.ESC_MAGIC): |
|
122 | if magic_name.startswith(__IPYTHON__.ESC_MAGIC): | |
123 | magic_name = magic_name[1:] |
|
123 | magic_name = magic_name[1:] | |
124 | try: |
|
124 | try: | |
125 | magic_args = args[1] |
|
125 | magic_args = args[1] | |
126 | except IndexError: |
|
126 | except IndexError: | |
127 | magic_args = '' |
|
127 | magic_args = '' | |
128 | fn = getattr(__IPYTHON__,'magic_'+magic_name,None) |
|
128 | fn = getattr(__IPYTHON__,'magic_'+magic_name,None) | |
129 | if fn is None: |
|
129 | if fn is None: | |
130 | error("Magic function `%s` not found." % magic_name) |
|
130 | error("Magic function `%s` not found." % magic_name) | |
131 | else: |
|
131 | else: | |
132 | magic_args = __IPYTHON__.var_expand(magic_args) |
|
132 | magic_args = __IPYTHON__.var_expand(magic_args) | |
133 | return fn(magic_args) |
|
133 | return fn(magic_args) | |
134 |
|
134 | |||
135 | def ipalias(arg_s): |
|
135 | def ipalias(arg_s): | |
136 | """Call an alias by name. |
|
136 | """Call an alias by name. | |
137 |
|
137 | |||
138 | Input: a string containing the name of the alias to call and any |
|
138 | Input: a string containing the name of the alias to call and any | |
139 | additional arguments to be passed to the magic. |
|
139 | additional arguments to be passed to the magic. | |
140 |
|
140 | |||
141 | ipalias('name -opt foo bar') is equivalent to typing at the ipython |
|
141 | ipalias('name -opt foo bar') is equivalent to typing at the ipython | |
142 | prompt: |
|
142 | prompt: | |
143 |
|
143 | |||
144 | In[1]: name -opt foo bar |
|
144 | In[1]: name -opt foo bar | |
145 |
|
145 | |||
146 | To call an alias without arguments, simply use ipalias('name'). |
|
146 | To call an alias without arguments, simply use ipalias('name'). | |
147 |
|
147 | |||
148 | This provides a proper Python function to call IPython's aliases in any |
|
148 | This provides a proper Python function to call IPython's aliases in any | |
149 | valid Python code you can type at the interpreter, including loops and |
|
149 | valid Python code you can type at the interpreter, including loops and | |
150 | compound statements. It is added by IPython to the Python builtin |
|
150 | compound statements. It is added by IPython to the Python builtin | |
151 | namespace upon initialization.""" |
|
151 | namespace upon initialization.""" | |
152 |
|
152 | |||
153 | args = arg_s.split(' ',1) |
|
153 | args = arg_s.split(' ',1) | |
154 | alias_name = args[0] |
|
154 | alias_name = args[0] | |
155 | try: |
|
155 | try: | |
156 | alias_args = args[1] |
|
156 | alias_args = args[1] | |
157 | except IndexError: |
|
157 | except IndexError: | |
158 | alias_args = '' |
|
158 | alias_args = '' | |
159 | if alias_name in __IPYTHON__.alias_table: |
|
159 | if alias_name in __IPYTHON__.alias_table: | |
160 | __IPYTHON__.call_alias(alias_name,alias_args) |
|
160 | __IPYTHON__.call_alias(alias_name,alias_args) | |
161 | else: |
|
161 | else: | |
162 | error("Alias `%s` not found." % alias_name) |
|
162 | error("Alias `%s` not found." % alias_name) | |
163 |
|
163 | |||
164 | #----------------------------------------------------------------------------- |
|
164 | #----------------------------------------------------------------------------- | |
165 | # Local use classes |
|
165 | # Local use classes | |
166 | try: |
|
166 | try: | |
167 | from IPython import FlexCompleter |
|
167 | from IPython import FlexCompleter | |
168 |
|
168 | |||
169 | class MagicCompleter(FlexCompleter.Completer): |
|
169 | class MagicCompleter(FlexCompleter.Completer): | |
170 | """Extension of the completer class to work on %-prefixed lines.""" |
|
170 | """Extension of the completer class to work on %-prefixed lines.""" | |
171 |
|
171 | |||
172 | def __init__(self,shell,namespace=None,omit__names=0,alias_table=None): |
|
172 | def __init__(self,shell,namespace=None,omit__names=0,alias_table=None): | |
173 | """MagicCompleter() -> completer |
|
173 | """MagicCompleter() -> completer | |
174 |
|
174 | |||
175 | Return a completer object suitable for use by the readline library |
|
175 | Return a completer object suitable for use by the readline library | |
176 | via readline.set_completer(). |
|
176 | via readline.set_completer(). | |
177 |
|
177 | |||
178 | Inputs: |
|
178 | Inputs: | |
179 |
|
179 | |||
180 | - shell: a pointer to the ipython shell itself. This is needed |
|
180 | - shell: a pointer to the ipython shell itself. This is needed | |
181 | because this completer knows about magic functions, and those can |
|
181 | because this completer knows about magic functions, and those can | |
182 | only be accessed via the ipython instance. |
|
182 | only be accessed via the ipython instance. | |
183 |
|
183 | |||
184 | - namespace: an optional dict where completions are performed. |
|
184 | - namespace: an optional dict where completions are performed. | |
185 |
|
185 | |||
186 | - The optional omit__names parameter sets the completer to omit the |
|
186 | - The optional omit__names parameter sets the completer to omit the | |
187 | 'magic' names (__magicname__) for python objects unless the text |
|
187 | 'magic' names (__magicname__) for python objects unless the text | |
188 | to be completed explicitly starts with one or more underscores. |
|
188 | to be completed explicitly starts with one or more underscores. | |
189 |
|
189 | |||
190 | - If alias_table is supplied, it should be a dictionary of aliases |
|
190 | - If alias_table is supplied, it should be a dictionary of aliases | |
191 | to complete. """ |
|
191 | to complete. """ | |
192 |
|
192 | |||
193 | FlexCompleter.Completer.__init__(self,namespace) |
|
193 | FlexCompleter.Completer.__init__(self,namespace) | |
194 | self.magic_prefix = shell.name+'.magic_' |
|
194 | self.magic_prefix = shell.name+'.magic_' | |
195 | self.magic_escape = shell.ESC_MAGIC |
|
195 | self.magic_escape = shell.ESC_MAGIC | |
196 | self.readline = FlexCompleter.readline |
|
196 | self.readline = FlexCompleter.readline | |
197 | delims = self.readline.get_completer_delims() |
|
197 | delims = self.readline.get_completer_delims() | |
198 | delims = delims.replace(self.magic_escape,'') |
|
198 | delims = delims.replace(self.magic_escape,'') | |
199 | self.readline.set_completer_delims(delims) |
|
199 | self.readline.set_completer_delims(delims) | |
200 | self.get_line_buffer = self.readline.get_line_buffer |
|
200 | self.get_line_buffer = self.readline.get_line_buffer | |
201 | self.omit__names = omit__names |
|
201 | self.omit__names = omit__names | |
202 | self.merge_completions = shell.rc.readline_merge_completions |
|
202 | self.merge_completions = shell.rc.readline_merge_completions | |
203 |
|
203 | |||
204 | if alias_table is None: |
|
204 | if alias_table is None: | |
205 | alias_table = {} |
|
205 | alias_table = {} | |
206 | self.alias_table = alias_table |
|
206 | self.alias_table = alias_table | |
207 | # Regexp to split filenames with spaces in them |
|
207 | # Regexp to split filenames with spaces in them | |
208 | self.space_name_re = re.compile(r'([^\\] )') |
|
208 | self.space_name_re = re.compile(r'([^\\] )') | |
209 | # Hold a local ref. to glob.glob for speed |
|
209 | # Hold a local ref. to glob.glob for speed | |
210 | self.glob = glob.glob |
|
210 | self.glob = glob.glob | |
211 | # Special handling of backslashes needed in win32 platforms |
|
211 | # Special handling of backslashes needed in win32 platforms | |
212 | if sys.platform == "win32": |
|
212 | if sys.platform == "win32": | |
213 | self.clean_glob = self._clean_glob_win32 |
|
213 | self.clean_glob = self._clean_glob_win32 | |
214 | else: |
|
214 | else: | |
215 | self.clean_glob = self._clean_glob |
|
215 | self.clean_glob = self._clean_glob | |
216 | self.matchers = [self.python_matches, |
|
216 | self.matchers = [self.python_matches, | |
217 | self.file_matches, |
|
217 | self.file_matches, | |
218 | self.alias_matches, |
|
218 | self.alias_matches, | |
219 | self.python_func_kw_matches] |
|
219 | self.python_func_kw_matches] | |
220 |
|
220 | |||
221 | # Code contributed by Alex Schmolck, for ipython/emacs integration |
|
221 | # Code contributed by Alex Schmolck, for ipython/emacs integration | |
222 | def all_completions(self, text): |
|
222 | def all_completions(self, text): | |
223 | """Return all possible completions for the benefit of emacs.""" |
|
223 | """Return all possible completions for the benefit of emacs.""" | |
224 |
|
224 | |||
225 | completions = [] |
|
225 | completions = [] | |
226 | try: |
|
226 | try: | |
227 | for i in xrange(sys.maxint): |
|
227 | for i in xrange(sys.maxint): | |
228 | res = self.complete(text, i) |
|
228 | res = self.complete(text, i) | |
229 |
|
229 | |||
230 | if not res: break |
|
230 | if not res: break | |
231 |
|
231 | |||
232 | completions.append(res) |
|
232 | completions.append(res) | |
233 | #XXX workaround for ``notDefined.<tab>`` |
|
233 | #XXX workaround for ``notDefined.<tab>`` | |
234 | except NameError: |
|
234 | except NameError: | |
235 | pass |
|
235 | pass | |
236 | return completions |
|
236 | return completions | |
237 | # /end Alex Schmolck code. |
|
237 | # /end Alex Schmolck code. | |
238 |
|
238 | |||
239 | def _clean_glob(self,text): |
|
239 | def _clean_glob(self,text): | |
240 | return self.glob("%s*" % text) |
|
240 | return self.glob("%s*" % text) | |
241 |
|
241 | |||
242 | def _clean_glob_win32(self,text): |
|
242 | def _clean_glob_win32(self,text): | |
243 | return [f.replace("\\","/") |
|
243 | return [f.replace("\\","/") | |
244 | for f in self.glob("%s*" % text)] |
|
244 | for f in self.glob("%s*" % text)] | |
245 |
|
245 | |||
246 | def file_matches(self, text): |
|
246 | def file_matches(self, text): | |
247 | """Match filneames, expanding ~USER type strings. |
|
247 | """Match filneames, expanding ~USER type strings. | |
248 |
|
248 | |||
249 | Most of the seemingly convoluted logic in this completer is an |
|
249 | Most of the seemingly convoluted logic in this completer is an | |
250 | attempt to handle filenames with spaces in them. And yet it's not |
|
250 | attempt to handle filenames with spaces in them. And yet it's not | |
251 | quite perfect, because Python's readline doesn't expose all of the |
|
251 | quite perfect, because Python's readline doesn't expose all of the | |
252 | GNU readline details needed for this to be done correctly. |
|
252 | GNU readline details needed for this to be done correctly. | |
253 |
|
253 | |||
254 | For a filename with a space in it, the printed completions will be |
|
254 | For a filename with a space in it, the printed completions will be | |
255 | only the parts after what's already been typed (instead of the |
|
255 | only the parts after what's already been typed (instead of the | |
256 | full completions, as is normally done). I don't think with the |
|
256 | full completions, as is normally done). I don't think with the | |
257 | current (as of Python 2.3) Python readline it's possible to do |
|
257 | current (as of Python 2.3) Python readline it's possible to do | |
258 | better.""" |
|
258 | better.""" | |
259 |
|
259 | |||
260 | #print 'Completer->file_matches: <%s>' % text # dbg |
|
260 | #print 'Completer->file_matches: <%s>' % text # dbg | |
261 |
|
261 | |||
262 | # chars that require escaping with backslash - i.e. chars |
|
262 | # chars that require escaping with backslash - i.e. chars | |
263 | # that readline treats incorrectly as delimiters, but we |
|
263 | # that readline treats incorrectly as delimiters, but we | |
264 | # don't want to treat as delimiters in filename matching |
|
264 | # don't want to treat as delimiters in filename matching | |
265 | # when escaped with backslash |
|
265 | # when escaped with backslash | |
266 |
|
266 | |||
267 | protectables = ' ()[]{}' |
|
267 | protectables = ' ()[]{}' | |
268 |
|
268 | |||
269 | def protect_filename(s): |
|
269 | def protect_filename(s): | |
270 | return "".join([(ch in protectables and '\\' + ch or ch) |
|
270 | return "".join([(ch in protectables and '\\' + ch or ch) | |
271 | for ch in s]) |
|
271 | for ch in s]) | |
272 |
|
272 | |||
273 | lbuf = self.get_line_buffer()[:self.readline.get_endidx()] |
|
273 | lbuf = self.get_line_buffer()[:self.readline.get_endidx()] | |
274 | open_quotes = 0 # track strings with open quotes |
|
274 | open_quotes = 0 # track strings with open quotes | |
275 | try: |
|
275 | try: | |
276 | lsplit = shlex_split(lbuf)[-1] |
|
276 | lsplit = shlex_split(lbuf)[-1] | |
277 | except ValueError: |
|
277 | except ValueError: | |
278 | # typically an unmatched ", or backslash without escaped char. |
|
278 | # typically an unmatched ", or backslash without escaped char. | |
279 | if lbuf.count('"')==1: |
|
279 | if lbuf.count('"')==1: | |
280 | open_quotes = 1 |
|
280 | open_quotes = 1 | |
281 | lsplit = lbuf.split('"')[-1] |
|
281 | lsplit = lbuf.split('"')[-1] | |
282 | elif lbuf.count("'")==1: |
|
282 | elif lbuf.count("'")==1: | |
283 | open_quotes = 1 |
|
283 | open_quotes = 1 | |
284 | lsplit = lbuf.split("'")[-1] |
|
284 | lsplit = lbuf.split("'")[-1] | |
285 | else: |
|
285 | else: | |
286 | return None |
|
286 | return None | |
287 | except IndexError: |
|
287 | except IndexError: | |
288 | # tab pressed on empty line |
|
288 | # tab pressed on empty line | |
289 | lsplit = "" |
|
289 | lsplit = "" | |
290 |
|
290 | |||
291 | if lsplit != protect_filename(lsplit): |
|
291 | if lsplit != protect_filename(lsplit): | |
292 | # if protectables are found, do matching on the whole escaped |
|
292 | # if protectables are found, do matching on the whole escaped | |
293 | # name |
|
293 | # name | |
294 | has_protectables = 1 |
|
294 | has_protectables = 1 | |
295 | text0,text = text,lsplit |
|
295 | text0,text = text,lsplit | |
296 | else: |
|
296 | else: | |
297 | has_protectables = 0 |
|
297 | has_protectables = 0 | |
298 | text = os.path.expanduser(text) |
|
298 | text = os.path.expanduser(text) | |
299 |
|
299 | |||
300 | if text == "": |
|
300 | if text == "": | |
301 | return [protect_filename(f) for f in self.glob("*")] |
|
301 | return [protect_filename(f) for f in self.glob("*")] | |
302 |
|
302 | |||
303 | m0 = self.clean_glob(text.replace('\\','')) |
|
303 | m0 = self.clean_glob(text.replace('\\','')) | |
304 | if has_protectables: |
|
304 | if has_protectables: | |
305 | # If we had protectables, we need to revert our changes to the |
|
305 | # If we had protectables, we need to revert our changes to the | |
306 | # beginning of filename so that we don't double-write the part |
|
306 | # beginning of filename so that we don't double-write the part | |
307 | # of the filename we have so far |
|
307 | # of the filename we have so far | |
308 | len_lsplit = len(lsplit) |
|
308 | len_lsplit = len(lsplit) | |
309 | matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0] |
|
309 | matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0] | |
310 | else: |
|
310 | else: | |
311 | if open_quotes: |
|
311 | if open_quotes: | |
312 | # if we have a string with an open quote, we don't need to |
|
312 | # if we have a string with an open quote, we don't need to | |
313 | # protect the names at all (and we _shouldn't_, as it |
|
313 | # protect the names at all (and we _shouldn't_, as it | |
314 | # would cause bugs when the filesystem call is made). |
|
314 | # would cause bugs when the filesystem call is made). | |
315 | matches = m0 |
|
315 | matches = m0 | |
316 | else: |
|
316 | else: | |
317 | matches = [protect_filename(f) for f in m0] |
|
317 | matches = [protect_filename(f) for f in m0] | |
318 | if len(matches) == 1 and os.path.isdir(matches[0]): |
|
318 | if len(matches) == 1 and os.path.isdir(matches[0]): | |
319 | # Takes care of links to directories also. Use '/' |
|
319 | # Takes care of links to directories also. Use '/' | |
320 | # explicitly, even under Windows, so that name completions |
|
320 | # explicitly, even under Windows, so that name completions | |
321 | # don't end up escaped. |
|
321 | # don't end up escaped. | |
322 | matches[0] += '/' |
|
322 | matches[0] += '/' | |
323 | return matches |
|
323 | return matches | |
324 |
|
324 | |||
325 | def alias_matches(self, text): |
|
325 | def alias_matches(self, text): | |
326 | """Match internal system aliases""" |
|
326 | """Match internal system aliases""" | |
327 | #print 'Completer->alias_matches:',text # dbg |
|
327 | #print 'Completer->alias_matches:',text # dbg | |
328 | text = os.path.expanduser(text) |
|
328 | text = os.path.expanduser(text) | |
329 | aliases = self.alias_table.keys() |
|
329 | aliases = self.alias_table.keys() | |
330 | if text == "": |
|
330 | if text == "": | |
331 | return aliases |
|
331 | return aliases | |
332 | else: |
|
332 | else: | |
333 | return [alias for alias in aliases if alias.startswith(text)] |
|
333 | return [alias for alias in aliases if alias.startswith(text)] | |
334 |
|
334 | |||
335 | def python_matches(self,text): |
|
335 | def python_matches(self,text): | |
336 | """Match attributes or global python names""" |
|
336 | """Match attributes or global python names""" | |
337 | #print 'Completer->python_matches' # dbg |
|
337 | #print 'Completer->python_matches' # dbg | |
338 | if "." in text: |
|
338 | if "." in text: | |
339 | try: |
|
339 | try: | |
340 | matches = self.attr_matches(text) |
|
340 | matches = self.attr_matches(text) | |
341 | if text.endswith('.') and self.omit__names: |
|
341 | if text.endswith('.') and self.omit__names: | |
342 | if self.omit__names == 1: |
|
342 | if self.omit__names == 1: | |
343 | # true if txt is _not_ a __ name, false otherwise: |
|
343 | # true if txt is _not_ a __ name, false otherwise: | |
344 | no__name = (lambda txt: |
|
344 | no__name = (lambda txt: | |
345 | re.match(r'.*\.__.*?__',txt) is None) |
|
345 | re.match(r'.*\.__.*?__',txt) is None) | |
346 | else: |
|
346 | else: | |
347 | # true if txt is _not_ a _ name, false otherwise: |
|
347 | # true if txt is _not_ a _ name, false otherwise: | |
348 | no__name = (lambda txt: |
|
348 | no__name = (lambda txt: | |
349 | re.match(r'.*\._.*?',txt) is None) |
|
349 | re.match(r'.*\._.*?',txt) is None) | |
350 | matches = filter(no__name, matches) |
|
350 | matches = filter(no__name, matches) | |
351 | except NameError: |
|
351 | except NameError: | |
352 | # catches <undefined attributes>.<tab> |
|
352 | # catches <undefined attributes>.<tab> | |
353 | matches = [] |
|
353 | matches = [] | |
354 | else: |
|
354 | else: | |
355 | matches = self.global_matches(text) |
|
355 | matches = self.global_matches(text) | |
356 | # this is so completion finds magics when automagic is on: |
|
356 | # this is so completion finds magics when automagic is on: | |
357 | if matches == [] and not text.startswith(os.sep): |
|
357 | if matches == [] and not text.startswith(os.sep): | |
358 | matches = self.attr_matches(self.magic_prefix+text) |
|
358 | matches = self.attr_matches(self.magic_prefix+text) | |
359 | return matches |
|
359 | return matches | |
360 |
|
360 | |||
361 | def _default_arguments(self, obj): |
|
361 | def _default_arguments(self, obj): | |
362 | """Return the list of default arguments of obj if it is callable, |
|
362 | """Return the list of default arguments of obj if it is callable, | |
363 | or empty list otherwise.""" |
|
363 | or empty list otherwise.""" | |
364 |
|
364 | |||
365 | if not (inspect.isfunction(obj) or inspect.ismethod(obj)): |
|
365 | if not (inspect.isfunction(obj) or inspect.ismethod(obj)): | |
366 | # for classes, check for __init__,__new__ |
|
366 | # for classes, check for __init__,__new__ | |
367 | if inspect.isclass(obj): |
|
367 | if inspect.isclass(obj): | |
368 | obj = (getattr(obj,'__init__',None) or |
|
368 | obj = (getattr(obj,'__init__',None) or | |
369 | getattr(obj,'__new__',None)) |
|
369 | getattr(obj,'__new__',None)) | |
370 | # for all others, check if they are __call__able |
|
370 | # for all others, check if they are __call__able | |
371 | elif hasattr(obj, '__call__'): |
|
371 | elif hasattr(obj, '__call__'): | |
372 | obj = obj.__call__ |
|
372 | obj = obj.__call__ | |
373 | # XXX: is there a way to handle the builtins ? |
|
373 | # XXX: is there a way to handle the builtins ? | |
374 | try: |
|
374 | try: | |
375 | args,_,_1,defaults = inspect.getargspec(obj) |
|
375 | args,_,_1,defaults = inspect.getargspec(obj) | |
376 | if defaults: |
|
376 | if defaults: | |
377 | return args[-len(defaults):] |
|
377 | return args[-len(defaults):] | |
378 | except TypeError: pass |
|
378 | except TypeError: pass | |
379 | return [] |
|
379 | return [] | |
380 |
|
380 | |||
381 | def python_func_kw_matches(self,text): |
|
381 | def python_func_kw_matches(self,text): | |
382 | """Match named parameters (kwargs) of the last open function""" |
|
382 | """Match named parameters (kwargs) of the last open function""" | |
383 |
|
383 | |||
384 | if "." in text: # a parameter cannot be dotted |
|
384 | if "." in text: # a parameter cannot be dotted | |
385 | return [] |
|
385 | return [] | |
386 | try: regexp = self.__funcParamsRegex |
|
386 | try: regexp = self.__funcParamsRegex | |
387 | except AttributeError: |
|
387 | except AttributeError: | |
388 | regexp = self.__funcParamsRegex = re.compile(r''' |
|
388 | regexp = self.__funcParamsRegex = re.compile(r''' | |
389 | '.*?' | # single quoted strings or |
|
389 | '.*?' | # single quoted strings or | |
390 | ".*?" | # double quoted strings or |
|
390 | ".*?" | # double quoted strings or | |
391 | \w+ | # identifier |
|
391 | \w+ | # identifier | |
392 | \S # other characters |
|
392 | \S # other characters | |
393 | ''', re.VERBOSE | re.DOTALL) |
|
393 | ''', re.VERBOSE | re.DOTALL) | |
394 | # 1. find the nearest identifier that comes before an unclosed |
|
394 | # 1. find the nearest identifier that comes before an unclosed | |
395 | # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo" |
|
395 | # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo" | |
396 | tokens = regexp.findall(self.get_line_buffer()) |
|
396 | tokens = regexp.findall(self.get_line_buffer()) | |
397 | tokens.reverse() |
|
397 | tokens.reverse() | |
398 | iterTokens = iter(tokens); openPar = 0 |
|
398 | iterTokens = iter(tokens); openPar = 0 | |
399 | for token in iterTokens: |
|
399 | for token in iterTokens: | |
400 | if token == ')': |
|
400 | if token == ')': | |
401 | openPar -= 1 |
|
401 | openPar -= 1 | |
402 | elif token == '(': |
|
402 | elif token == '(': | |
403 | openPar += 1 |
|
403 | openPar += 1 | |
404 | if openPar > 0: |
|
404 | if openPar > 0: | |
405 | # found the last unclosed parenthesis |
|
405 | # found the last unclosed parenthesis | |
406 | break |
|
406 | break | |
407 | else: |
|
407 | else: | |
408 | return [] |
|
408 | return [] | |
409 | # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" ) |
|
409 | # 2. Concatenate any dotted names (e.g. "foo.bar" for "foo.bar(x, pa" ) | |
410 | ids = [] |
|
410 | ids = [] | |
411 | isId = re.compile(r'\w+$').match |
|
411 | isId = re.compile(r'\w+$').match | |
412 | while True: |
|
412 | while True: | |
413 | try: |
|
413 | try: | |
414 | ids.append(iterTokens.next()) |
|
414 | ids.append(iterTokens.next()) | |
415 | if not isId(ids[-1]): |
|
415 | if not isId(ids[-1]): | |
416 | ids.pop(); break |
|
416 | ids.pop(); break | |
417 | if not iterTokens.next() == '.': |
|
417 | if not iterTokens.next() == '.': | |
418 | break |
|
418 | break | |
419 | except StopIteration: |
|
419 | except StopIteration: | |
420 | break |
|
420 | break | |
421 | # lookup the candidate callable matches either using global_matches |
|
421 | # lookup the candidate callable matches either using global_matches | |
422 | # or attr_matches for dotted names |
|
422 | # or attr_matches for dotted names | |
423 | if len(ids) == 1: |
|
423 | if len(ids) == 1: | |
424 | callableMatches = self.global_matches(ids[0]) |
|
424 | callableMatches = self.global_matches(ids[0]) | |
425 | else: |
|
425 | else: | |
426 | callableMatches = self.attr_matches('.'.join(ids[::-1])) |
|
426 | callableMatches = self.attr_matches('.'.join(ids[::-1])) | |
427 | argMatches = [] |
|
427 | argMatches = [] | |
428 | for callableMatch in callableMatches: |
|
428 | for callableMatch in callableMatches: | |
429 | try: namedArgs = self._default_arguments(eval(callableMatch, |
|
429 | try: namedArgs = self._default_arguments(eval(callableMatch, | |
430 | self.namespace)) |
|
430 | self.namespace)) | |
431 | except: continue |
|
431 | except: continue | |
432 | for namedArg in namedArgs: |
|
432 | for namedArg in namedArgs: | |
433 | if namedArg.startswith(text): |
|
433 | if namedArg.startswith(text): | |
434 | argMatches.append("%s=" %namedArg) |
|
434 | argMatches.append("%s=" %namedArg) | |
435 | return argMatches |
|
435 | return argMatches | |
436 |
|
436 | |||
437 | def complete(self, text, state): |
|
437 | def complete(self, text, state): | |
438 | """Return the next possible completion for 'text'. |
|
438 | """Return the next possible completion for 'text'. | |
439 |
|
439 | |||
440 | This is called successively with state == 0, 1, 2, ... until it |
|
440 | This is called successively with state == 0, 1, 2, ... until it | |
441 | returns None. The completion should begin with 'text'. """ |
|
441 | returns None. The completion should begin with 'text'. """ | |
442 |
|
442 | |||
443 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg |
|
443 | #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg | |
444 | magic_escape = self.magic_escape |
|
444 | magic_escape = self.magic_escape | |
445 | magic_prefix = self.magic_prefix |
|
445 | magic_prefix = self.magic_prefix | |
446 |
|
446 | |||
447 | try: |
|
447 | try: | |
448 | if text.startswith(magic_escape): |
|
448 | if text.startswith(magic_escape): | |
449 | text = text.replace(magic_escape,magic_prefix) |
|
449 | text = text.replace(magic_escape,magic_prefix) | |
450 | elif text.startswith('~'): |
|
450 | elif text.startswith('~'): | |
451 | text = os.path.expanduser(text) |
|
451 | text = os.path.expanduser(text) | |
452 | if state == 0: |
|
452 | if state == 0: | |
453 | # Extend the list of completions with the results of each |
|
453 | # Extend the list of completions with the results of each | |
454 | # matcher, so we return results to the user from all |
|
454 | # matcher, so we return results to the user from all | |
455 | # namespaces. |
|
455 | # namespaces. | |
456 | if self.merge_completions: |
|
456 | if self.merge_completions: | |
457 | self.matches = [] |
|
457 | self.matches = [] | |
458 | for matcher in self.matchers: |
|
458 | for matcher in self.matchers: | |
459 | self.matches.extend(matcher(text)) |
|
459 | self.matches.extend(matcher(text)) | |
460 | else: |
|
460 | else: | |
461 | for matcher in self.matchers: |
|
461 | for matcher in self.matchers: | |
462 | self.matches = matcher(text) |
|
462 | self.matches = matcher(text) | |
463 | if self.matches: |
|
463 | if self.matches: | |
464 | break |
|
464 | break | |
465 |
|
465 | |||
466 | try: |
|
466 | try: | |
467 | return self.matches[state].replace(magic_prefix,magic_escape) |
|
467 | return self.matches[state].replace(magic_prefix,magic_escape) | |
468 | except IndexError: |
|
468 | except IndexError: | |
469 | return None |
|
469 | return None | |
470 | except: |
|
470 | except: | |
471 | # If completion fails, don't annoy the user. |
|
471 | # If completion fails, don't annoy the user. | |
472 | pass |
|
472 | pass | |
473 |
|
473 | |||
474 | except ImportError: |
|
474 | except ImportError: | |
475 | pass # no readline support |
|
475 | pass # no readline support | |
476 |
|
476 | |||
477 | except KeyError: |
|
477 | except KeyError: | |
478 | pass # Windows doesn't set TERM, it doesn't matter |
|
478 | pass # Windows doesn't set TERM, it doesn't matter | |
479 |
|
479 | |||
480 |
|
480 | |||
481 | class InputList(UserList.UserList): |
|
481 | class InputList(UserList.UserList): | |
482 | """Class to store user input. |
|
482 | """Class to store user input. | |
483 |
|
483 | |||
484 | It's basically a list, but slices return a string instead of a list, thus |
|
484 | It's basically a list, but slices return a string instead of a list, thus | |
485 | allowing things like (assuming 'In' is an instance): |
|
485 | allowing things like (assuming 'In' is an instance): | |
486 |
|
486 | |||
487 | exec In[4:7] |
|
487 | exec In[4:7] | |
488 |
|
488 | |||
489 | or |
|
489 | or | |
490 |
|
490 | |||
491 | exec In[5:9] + In[14] + In[21:25]""" |
|
491 | exec In[5:9] + In[14] + In[21:25]""" | |
492 |
|
492 | |||
493 | def __getslice__(self,i,j): |
|
493 | def __getslice__(self,i,j): | |
494 | return ''.join(UserList.UserList.__getslice__(self,i,j)) |
|
494 | return ''.join(UserList.UserList.__getslice__(self,i,j)) | |
495 |
|
495 | |||
496 | #**************************************************************************** |
|
496 | #**************************************************************************** | |
497 | # Local use exceptions |
|
497 | # Local use exceptions | |
498 | class SpaceInInput(exceptions.Exception): |
|
498 | class SpaceInInput(exceptions.Exception): | |
499 | pass |
|
499 | pass | |
500 |
|
500 | |||
501 | #**************************************************************************** |
|
501 | #**************************************************************************** | |
502 | # Main IPython class |
|
502 | # Main IPython class | |
503 |
|
503 | |||
504 | class InteractiveShell(code.InteractiveConsole, Logger, Magic): |
|
504 | class InteractiveShell(code.InteractiveConsole, Logger, Magic): | |
505 | """An enhanced console for Python.""" |
|
505 | """An enhanced console for Python.""" | |
506 |
|
506 | |||
507 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
507 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), | |
508 | user_ns = None,banner2='', |
|
508 | user_ns = None,banner2='', | |
509 | custom_exceptions=((),None)): |
|
509 | custom_exceptions=((),None)): | |
510 |
|
510 | |||
511 | # Put a reference to self in builtins so that any form of embedded or |
|
511 | # Put a reference to self in builtins so that any form of embedded or | |
512 | # imported code can test for being inside IPython. |
|
512 | # imported code can test for being inside IPython. | |
513 | __builtin__.__IPYTHON__ = self |
|
513 | __builtin__.__IPYTHON__ = self | |
514 |
|
514 | |||
515 | # And load into builtins ipmagic/ipalias as well |
|
515 | # And load into builtins ipmagic/ipalias as well | |
516 | __builtin__.ipmagic = ipmagic |
|
516 | __builtin__.ipmagic = ipmagic | |
517 | __builtin__.ipalias = ipalias |
|
517 | __builtin__.ipalias = ipalias | |
518 |
|
518 | |||
519 | # Add to __builtin__ other parts of IPython's public API |
|
519 | # Add to __builtin__ other parts of IPython's public API | |
520 | __builtin__.ip_set_hook = self.set_hook |
|
520 | __builtin__.ip_set_hook = self.set_hook | |
521 |
|
521 | |||
522 | # Keep in the builtins a flag for when IPython is active. We set it |
|
522 | # Keep in the builtins a flag for when IPython is active. We set it | |
523 | # with setdefault so that multiple nested IPythons don't clobber one |
|
523 | # with setdefault so that multiple nested IPythons don't clobber one | |
524 | # another. Each will increase its value by one upon being activated, |
|
524 | # another. Each will increase its value by one upon being activated, | |
525 | # which also gives us a way to determine the nesting level. |
|
525 | # which also gives us a way to determine the nesting level. | |
526 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) |
|
526 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) | |
527 |
|
527 | |||
528 | # Inform the user of ipython's fast exit magics. |
|
528 | # Inform the user of ipython's fast exit magics. | |
529 | _exit = ' Use %Exit or %Quit to exit without confirmation.' |
|
529 | _exit = ' Use %Exit or %Quit to exit without confirmation.' | |
530 | __builtin__.exit += _exit |
|
530 | __builtin__.exit += _exit | |
531 | __builtin__.quit += _exit |
|
531 | __builtin__.quit += _exit | |
532 |
|
532 | |||
533 | # Create the namespace where the user will operate: |
|
533 | # Create the namespace where the user will operate: | |
534 |
|
534 | |||
535 | # FIXME. For some strange reason, __builtins__ is showing up at user |
|
535 | # FIXME. For some strange reason, __builtins__ is showing up at user | |
536 | # level as a dict instead of a module. This is a manual fix, but I |
|
536 | # level as a dict instead of a module. This is a manual fix, but I | |
537 | # should really track down where the problem is coming from. Alex |
|
537 | # should really track down where the problem is coming from. Alex | |
538 | # Schmolck reported this problem first. |
|
538 | # Schmolck reported this problem first. | |
539 |
|
539 | |||
540 | # A useful post by Alex Martelli on this topic: |
|
540 | # A useful post by Alex Martelli on this topic: | |
541 | # Re: inconsistent value from __builtins__ |
|
541 | # Re: inconsistent value from __builtins__ | |
542 | # Von: Alex Martelli <aleaxit@yahoo.com> |
|
542 | # Von: Alex Martelli <aleaxit@yahoo.com> | |
543 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends |
|
543 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends | |
544 | # Gruppen: comp.lang.python |
|
544 | # Gruppen: comp.lang.python | |
545 | # Referenzen: 1 |
|
545 | # Referenzen: 1 | |
546 |
|
546 | |||
547 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: |
|
547 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: | |
548 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) |
|
548 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) | |
549 | # > <type 'dict'> |
|
549 | # > <type 'dict'> | |
550 | # > >>> print type(__builtins__) |
|
550 | # > >>> print type(__builtins__) | |
551 | # > <type 'module'> |
|
551 | # > <type 'module'> | |
552 | # > Is this difference in return value intentional? |
|
552 | # > Is this difference in return value intentional? | |
553 |
|
553 | |||
554 | # Well, it's documented that '__builtins__' can be either a dictionary |
|
554 | # Well, it's documented that '__builtins__' can be either a dictionary | |
555 | # or a module, and it's been that way for a long time. Whether it's |
|
555 | # or a module, and it's been that way for a long time. Whether it's | |
556 | # intentional (or sensible), I don't know. In any case, the idea is that |
|
556 | # intentional (or sensible), I don't know. In any case, the idea is that | |
557 | # if you need to access the built-in namespace directly, you should start |
|
557 | # if you need to access the built-in namespace directly, you should start | |
558 | # with "import __builtin__" (note, no 's') which will definitely give you |
|
558 | # with "import __builtin__" (note, no 's') which will definitely give you | |
559 | # a module. Yeah, it's somewhatΒ confusing:-(. |
|
559 | # a module. Yeah, it's somewhatΒ confusing:-(. | |
560 |
|
560 | |||
561 | if user_ns is None: |
|
561 | if user_ns is None: | |
562 | # Set __name__ to __main__ to better match the behavior of the |
|
562 | # Set __name__ to __main__ to better match the behavior of the | |
563 | # normal interpreter. |
|
563 | # normal interpreter. | |
564 | self.user_ns = {'__name__' :'__main__', |
|
564 | self.user_ns = {'__name__' :'__main__', | |
565 | '__builtins__' : __builtin__, |
|
565 | '__builtins__' : __builtin__, | |
566 | } |
|
566 | } | |
567 | else: |
|
567 | else: | |
568 | self.user_ns = user_ns |
|
568 | self.user_ns = user_ns | |
569 |
|
569 | |||
570 | # The user namespace MUST have a pointer to the shell itself. |
|
570 | # The user namespace MUST have a pointer to the shell itself. | |
571 | self.user_ns[name] = self |
|
571 | self.user_ns[name] = self | |
572 |
|
572 | |||
573 | # We need to insert into sys.modules something that looks like a |
|
573 | # We need to insert into sys.modules something that looks like a | |
574 | # module but which accesses the IPython namespace, for shelve and |
|
574 | # module but which accesses the IPython namespace, for shelve and | |
575 | # pickle to work interactively. Normally they rely on getting |
|
575 | # pickle to work interactively. Normally they rely on getting | |
576 | # everything out of __main__, but for embedding purposes each IPython |
|
576 | # everything out of __main__, but for embedding purposes each IPython | |
577 | # instance has its own private namespace, so we can't go shoving |
|
577 | # instance has its own private namespace, so we can't go shoving | |
578 | # everything into __main__. |
|
578 | # everything into __main__. | |
579 |
|
579 | |||
580 | try: |
|
580 | try: | |
581 | main_name = self.user_ns['__name__'] |
|
581 | main_name = self.user_ns['__name__'] | |
582 | except KeyError: |
|
582 | except KeyError: | |
583 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
583 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' | |
584 | else: |
|
584 | else: | |
585 | #print "pickle hack in place" # dbg |
|
585 | #print "pickle hack in place" # dbg | |
586 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
586 | sys.modules[main_name] = FakeModule(self.user_ns) | |
587 |
|
587 | |||
588 | # List of input with multi-line handling. |
|
588 | # List of input with multi-line handling. | |
589 | # Fill its zero entry, user counter starts at 1 |
|
589 | # Fill its zero entry, user counter starts at 1 | |
590 | self.input_hist = InputList(['\n']) |
|
590 | self.input_hist = InputList(['\n']) | |
591 |
|
591 | |||
592 | # list of visited directories |
|
592 | # list of visited directories | |
593 | self.dir_hist = [os.getcwd()] |
|
593 | self.dir_hist = [os.getcwd()] | |
594 |
|
594 | |||
595 | # dict of output history |
|
595 | # dict of output history | |
596 | self.output_hist = {} |
|
596 | self.output_hist = {} | |
597 |
|
597 | |||
598 | # dict of names to be treated as system aliases. Each entry in the |
|
598 | # dict of names to be treated as system aliases. Each entry in the | |
599 | # alias table must be a 2-tuple of the form (N,name), where N is the |
|
599 | # alias table must be a 2-tuple of the form (N,name), where N is the | |
600 | # number of positional arguments of the alias. |
|
600 | # number of positional arguments of the alias. | |
601 | self.alias_table = {} |
|
601 | self.alias_table = {} | |
602 |
|
602 | |||
603 | # dict of things NOT to alias (keywords and builtins) |
|
603 | # dict of things NOT to alias (keywords and builtins) | |
604 | self.no_alias = {} |
|
604 | self.no_alias = {} | |
605 | for key in keyword.kwlist: |
|
605 | for key in keyword.kwlist: | |
606 | self.no_alias[key] = 1 |
|
606 | self.no_alias[key] = 1 | |
607 | self.no_alias.update(__builtin__.__dict__) |
|
607 | self.no_alias.update(__builtin__.__dict__) | |
608 |
|
608 | |||
609 | # make global variables for user access to these |
|
609 | # make global variables for user access to these | |
610 | self.user_ns['_ih'] = self.input_hist |
|
610 | self.user_ns['_ih'] = self.input_hist | |
611 | self.user_ns['_oh'] = self.output_hist |
|
611 | self.user_ns['_oh'] = self.output_hist | |
612 | self.user_ns['_dh'] = self.dir_hist |
|
612 | self.user_ns['_dh'] = self.dir_hist | |
613 |
|
613 | |||
614 | # user aliases to input and output histories |
|
614 | # user aliases to input and output histories | |
615 | self.user_ns['In'] = self.input_hist |
|
615 | self.user_ns['In'] = self.input_hist | |
616 | self.user_ns['Out'] = self.output_hist |
|
616 | self.user_ns['Out'] = self.output_hist | |
617 |
|
617 | |||
618 | # Store the actual shell's name |
|
618 | # Store the actual shell's name | |
619 | self.name = name |
|
619 | self.name = name | |
620 |
|
620 | |||
621 | # Object variable to store code object waiting execution. This is |
|
621 | # Object variable to store code object waiting execution. This is | |
622 | # used mainly by the multithreaded shells, but it can come in handy in |
|
622 | # used mainly by the multithreaded shells, but it can come in handy in | |
623 | # other situations. No need to use a Queue here, since it's a single |
|
623 | # other situations. No need to use a Queue here, since it's a single | |
624 | # item which gets cleared once run. |
|
624 | # item which gets cleared once run. | |
625 | self.code_to_run = None |
|
625 | self.code_to_run = None | |
626 | self.code_to_run_src = '' # corresponding source |
|
|||
627 |
|
626 | |||
628 | # Job manager (for jobs run as background threads) |
|
627 | # Job manager (for jobs run as background threads) | |
629 | self.jobs = BackgroundJobManager() |
|
628 | self.jobs = BackgroundJobManager() | |
630 | # Put the job manager into builtins so it's always there. |
|
629 | # Put the job manager into builtins so it's always there. | |
631 | __builtin__.jobs = self.jobs |
|
630 | __builtin__.jobs = self.jobs | |
632 |
|
631 | |||
633 | # escapes for automatic behavior on the command line |
|
632 | # escapes for automatic behavior on the command line | |
634 | self.ESC_SHELL = '!' |
|
633 | self.ESC_SHELL = '!' | |
635 | self.ESC_HELP = '?' |
|
634 | self.ESC_HELP = '?' | |
636 | self.ESC_MAGIC = '%' |
|
635 | self.ESC_MAGIC = '%' | |
637 | self.ESC_QUOTE = ',' |
|
636 | self.ESC_QUOTE = ',' | |
638 | self.ESC_QUOTE2 = ';' |
|
637 | self.ESC_QUOTE2 = ';' | |
639 | self.ESC_PAREN = '/' |
|
638 | self.ESC_PAREN = '/' | |
640 |
|
639 | |||
641 | # And their associated handlers |
|
640 | # And their associated handlers | |
642 | self.esc_handlers = {self.ESC_PAREN:self.handle_auto, |
|
641 | self.esc_handlers = {self.ESC_PAREN:self.handle_auto, | |
643 | self.ESC_QUOTE:self.handle_auto, |
|
642 | self.ESC_QUOTE:self.handle_auto, | |
644 | self.ESC_QUOTE2:self.handle_auto, |
|
643 | self.ESC_QUOTE2:self.handle_auto, | |
645 | self.ESC_MAGIC:self.handle_magic, |
|
644 | self.ESC_MAGIC:self.handle_magic, | |
646 | self.ESC_HELP:self.handle_help, |
|
645 | self.ESC_HELP:self.handle_help, | |
647 | self.ESC_SHELL:self.handle_shell_escape, |
|
646 | self.ESC_SHELL:self.handle_shell_escape, | |
648 | } |
|
647 | } | |
649 |
|
648 | |||
650 | # class initializations |
|
649 | # class initializations | |
651 | code.InteractiveConsole.__init__(self,locals = self.user_ns) |
|
650 | code.InteractiveConsole.__init__(self,locals = self.user_ns) | |
652 | Logger.__init__(self,log_ns = self.user_ns) |
|
651 | Logger.__init__(self,log_ns = self.user_ns) | |
653 | Magic.__init__(self,self) |
|
652 | Magic.__init__(self,self) | |
654 |
|
653 | |||
655 | # an ugly hack to get a pointer to the shell, so I can start writing |
|
654 | # an ugly hack to get a pointer to the shell, so I can start writing | |
656 | # magic code via this pointer instead of the current mixin salad. |
|
655 | # magic code via this pointer instead of the current mixin salad. | |
657 | Magic.set_shell(self,self) |
|
656 | Magic.set_shell(self,self) | |
658 |
|
657 | |||
659 | # hooks holds pointers used for user-side customizations |
|
658 | # hooks holds pointers used for user-side customizations | |
660 | self.hooks = Struct() |
|
659 | self.hooks = Struct() | |
661 |
|
660 | |||
662 | # Set all default hooks, defined in the IPython.hooks module. |
|
661 | # Set all default hooks, defined in the IPython.hooks module. | |
663 | hooks = IPython.hooks |
|
662 | hooks = IPython.hooks | |
664 | for hook_name in hooks.__all__: |
|
663 | for hook_name in hooks.__all__: | |
665 | self.set_hook(hook_name,getattr(hooks,hook_name)) |
|
664 | self.set_hook(hook_name,getattr(hooks,hook_name)) | |
666 |
|
665 | |||
667 | # Flag to mark unconditional exit |
|
666 | # Flag to mark unconditional exit | |
668 | self.exit_now = False |
|
667 | self.exit_now = False | |
669 |
|
668 | |||
670 | self.usage_min = """\ |
|
669 | self.usage_min = """\ | |
671 | An enhanced console for Python. |
|
670 | An enhanced console for Python. | |
672 | Some of its features are: |
|
671 | Some of its features are: | |
673 | - Readline support if the readline library is present. |
|
672 | - Readline support if the readline library is present. | |
674 | - Tab completion in the local namespace. |
|
673 | - Tab completion in the local namespace. | |
675 | - Logging of input, see command-line options. |
|
674 | - Logging of input, see command-line options. | |
676 | - System shell escape via ! , eg !ls. |
|
675 | - System shell escape via ! , eg !ls. | |
677 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) |
|
676 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) | |
678 | - Keeps track of locally defined variables via %who, %whos. |
|
677 | - Keeps track of locally defined variables via %who, %whos. | |
679 | - Show object information with a ? eg ?x or x? (use ?? for more info). |
|
678 | - Show object information with a ? eg ?x or x? (use ?? for more info). | |
680 | """ |
|
679 | """ | |
681 | if usage: self.usage = usage |
|
680 | if usage: self.usage = usage | |
682 | else: self.usage = self.usage_min |
|
681 | else: self.usage = self.usage_min | |
683 |
|
682 | |||
684 | # Storage |
|
683 | # Storage | |
685 | self.rc = rc # This will hold all configuration information |
|
684 | self.rc = rc # This will hold all configuration information | |
686 | self.inputcache = [] |
|
685 | self.inputcache = [] | |
687 | self._boundcache = [] |
|
686 | self._boundcache = [] | |
688 | self.pager = 'less' |
|
687 | self.pager = 'less' | |
689 | # temporary files used for various purposes. Deleted at exit. |
|
688 | # temporary files used for various purposes. Deleted at exit. | |
690 | self.tempfiles = [] |
|
689 | self.tempfiles = [] | |
691 |
|
690 | |||
692 | # for pushd/popd management |
|
691 | # for pushd/popd management | |
693 | try: |
|
692 | try: | |
694 | self.home_dir = get_home_dir() |
|
693 | self.home_dir = get_home_dir() | |
695 | except HomeDirError,msg: |
|
694 | except HomeDirError,msg: | |
696 | fatal(msg) |
|
695 | fatal(msg) | |
697 |
|
696 | |||
698 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] |
|
697 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] | |
699 |
|
698 | |||
700 | # Functions to call the underlying shell. |
|
699 | # Functions to call the underlying shell. | |
701 |
|
700 | |||
702 | # utility to expand user variables via Itpl |
|
701 | # utility to expand user variables via Itpl | |
703 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), |
|
702 | self.var_expand = lambda cmd: str(ItplNS(cmd.replace('#','\#'), | |
704 | self.user_ns)) |
|
703 | self.user_ns)) | |
705 | # The first is similar to os.system, but it doesn't return a value, |
|
704 | # The first is similar to os.system, but it doesn't return a value, | |
706 | # and it allows interpolation of variables in the user's namespace. |
|
705 | # and it allows interpolation of variables in the user's namespace. | |
707 | self.system = lambda cmd: shell(self.var_expand(cmd), |
|
706 | self.system = lambda cmd: shell(self.var_expand(cmd), | |
708 | header='IPython system call: ', |
|
707 | header='IPython system call: ', | |
709 | verbose=self.rc.system_verbose) |
|
708 | verbose=self.rc.system_verbose) | |
710 | # These are for getoutput and getoutputerror: |
|
709 | # These are for getoutput and getoutputerror: | |
711 | self.getoutput = lambda cmd: \ |
|
710 | self.getoutput = lambda cmd: \ | |
712 | getoutput(self.var_expand(cmd), |
|
711 | getoutput(self.var_expand(cmd), | |
713 | header='IPython system call: ', |
|
712 | header='IPython system call: ', | |
714 | verbose=self.rc.system_verbose) |
|
713 | verbose=self.rc.system_verbose) | |
715 | self.getoutputerror = lambda cmd: \ |
|
714 | self.getoutputerror = lambda cmd: \ | |
716 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), |
|
715 | getoutputerror(str(ItplNS(cmd.replace('#','\#'), | |
717 | self.user_ns)), |
|
716 | self.user_ns)), | |
718 | header='IPython system call: ', |
|
717 | header='IPython system call: ', | |
719 | verbose=self.rc.system_verbose) |
|
718 | verbose=self.rc.system_verbose) | |
720 |
|
719 | |||
721 | # RegExp for splitting line contents into pre-char//first |
|
720 | # RegExp for splitting line contents into pre-char//first | |
722 | # word-method//rest. For clarity, each group in on one line. |
|
721 | # word-method//rest. For clarity, each group in on one line. | |
723 |
|
722 | |||
724 | # WARNING: update the regexp if the above escapes are changed, as they |
|
723 | # WARNING: update the regexp if the above escapes are changed, as they | |
725 | # are hardwired in. |
|
724 | # are hardwired in. | |
726 |
|
725 | |||
727 | # Don't get carried away with trying to make the autocalling catch too |
|
726 | # Don't get carried away with trying to make the autocalling catch too | |
728 | # much: it's better to be conservative rather than to trigger hidden |
|
727 | # much: it's better to be conservative rather than to trigger hidden | |
729 | # evals() somewhere and end up causing side effects. |
|
728 | # evals() somewhere and end up causing side effects. | |
730 |
|
729 | |||
731 | self.line_split = re.compile(r'^([\s*,;/])' |
|
730 | self.line_split = re.compile(r'^([\s*,;/])' | |
732 | r'([\?\w\.]+\w*\s*)' |
|
731 | r'([\?\w\.]+\w*\s*)' | |
733 | r'(\(?.*$)') |
|
732 | r'(\(?.*$)') | |
734 |
|
733 | |||
735 | # Original re, keep around for a while in case changes break something |
|
734 | # Original re, keep around for a while in case changes break something | |
736 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' |
|
735 | #self.line_split = re.compile(r'(^[\s*!\?%,/]?)' | |
737 | # r'(\s*[\?\w\.]+\w*\s*)' |
|
736 | # r'(\s*[\?\w\.]+\w*\s*)' | |
738 | # r'(\(?.*$)') |
|
737 | # r'(\(?.*$)') | |
739 |
|
738 | |||
740 | # RegExp to identify potential function names |
|
739 | # RegExp to identify potential function names | |
741 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') |
|
740 | self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$') | |
742 | # RegExp to exclude strings with this start from autocalling |
|
741 | # RegExp to exclude strings with this start from autocalling | |
743 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') |
|
742 | self.re_exclude_auto = re.compile('^[!=()<>,\*/\+-]|^is ') | |
744 | # try to catch also methods for stuff in lists/tuples/dicts: off |
|
743 | # try to catch also methods for stuff in lists/tuples/dicts: off | |
745 | # (experimental). For this to work, the line_split regexp would need |
|
744 | # (experimental). For this to work, the line_split regexp would need | |
746 | # to be modified so it wouldn't break things at '['. That line is |
|
745 | # to be modified so it wouldn't break things at '['. That line is | |
747 | # nasty enough that I shouldn't change it until I can test it _well_. |
|
746 | # nasty enough that I shouldn't change it until I can test it _well_. | |
748 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') |
|
747 | #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$') | |
749 |
|
748 | |||
750 | # keep track of where we started running (mainly for crash post-mortem) |
|
749 | # keep track of where we started running (mainly for crash post-mortem) | |
751 | self.starting_dir = os.getcwd() |
|
750 | self.starting_dir = os.getcwd() | |
752 |
|
751 | |||
753 | # Attributes for Logger mixin class, make defaults here |
|
752 | # Attributes for Logger mixin class, make defaults here | |
754 | self._dolog = 0 |
|
753 | self._dolog = 0 | |
755 | self.LOG = '' |
|
754 | self.LOG = '' | |
756 | self.LOGDEF = '.InteractiveShell.log' |
|
755 | self.LOGDEF = '.InteractiveShell.log' | |
757 | self.LOGMODE = 'over' |
|
756 | self.LOGMODE = 'over' | |
758 | self.LOGHEAD = Itpl( |
|
757 | self.LOGHEAD = Itpl( | |
759 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** |
|
758 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** | |
760 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW |
|
759 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW | |
761 | #log# opts = $self.rc.opts |
|
760 | #log# opts = $self.rc.opts | |
762 | #log# args = $self.rc.args |
|
761 | #log# args = $self.rc.args | |
763 | #log# It is safe to make manual edits below here. |
|
762 | #log# It is safe to make manual edits below here. | |
764 | #log#----------------------------------------------------------------------- |
|
763 | #log#----------------------------------------------------------------------- | |
765 | """) |
|
764 | """) | |
766 | # Various switches which can be set |
|
765 | # Various switches which can be set | |
767 | self.CACHELENGTH = 5000 # this is cheap, it's just text |
|
766 | self.CACHELENGTH = 5000 # this is cheap, it's just text | |
768 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ |
|
767 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ | |
769 | self.banner2 = banner2 |
|
768 | self.banner2 = banner2 | |
770 |
|
769 | |||
771 | # TraceBack handlers: |
|
770 | # TraceBack handlers: | |
772 | # Need two, one for syntax errors and one for other exceptions. |
|
771 | # Need two, one for syntax errors and one for other exceptions. | |
773 | self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor') |
|
772 | self.SyntaxTB = ultraTB.ListTB(color_scheme='NoColor') | |
774 | # This one is initialized with an offset, meaning we always want to |
|
773 | # This one is initialized with an offset, meaning we always want to | |
775 | # remove the topmost item in the traceback, which is our own internal |
|
774 | # remove the topmost item in the traceback, which is our own internal | |
776 | # code. Valid modes: ['Plain','Context','Verbose'] |
|
775 | # code. Valid modes: ['Plain','Context','Verbose'] | |
777 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', |
|
776 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', | |
778 | color_scheme='NoColor', |
|
777 | color_scheme='NoColor', | |
779 | tb_offset = 1) |
|
778 | tb_offset = 1) | |
780 | # and add any custom exception handlers the user may have specified |
|
779 | # and add any custom exception handlers the user may have specified | |
781 | self.set_custom_exc(*custom_exceptions) |
|
780 | self.set_custom_exc(*custom_exceptions) | |
782 |
|
781 | |||
783 | # Object inspector |
|
782 | # Object inspector | |
784 | ins_colors = OInspect.InspectColors |
|
783 | ins_colors = OInspect.InspectColors | |
785 | code_colors = PyColorize.ANSICodeColors |
|
784 | code_colors = PyColorize.ANSICodeColors | |
786 | self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor') |
|
785 | self.inspector = OInspect.Inspector(ins_colors,code_colors,'NoColor') | |
787 | self.autoindent = 0 |
|
786 | self.autoindent = 0 | |
788 |
|
787 | |||
789 | # Make some aliases automatically |
|
788 | # Make some aliases automatically | |
790 | # Prepare list of shell aliases to auto-define |
|
789 | # Prepare list of shell aliases to auto-define | |
791 | if os.name == 'posix': |
|
790 | if os.name == 'posix': | |
792 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', |
|
791 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', | |
793 | 'mv mv -i','rm rm -i','cp cp -i', |
|
792 | 'mv mv -i','rm rm -i','cp cp -i', | |
794 | 'cat cat','less less','clear clear', |
|
793 | 'cat cat','less less','clear clear', | |
795 | # a better ls |
|
794 | # a better ls | |
796 | 'ls ls -F', |
|
795 | 'ls ls -F', | |
797 | # long ls |
|
796 | # long ls | |
798 | 'll ls -lF', |
|
797 | 'll ls -lF', | |
799 | # color ls |
|
798 | # color ls | |
800 | 'lc ls -F -o --color', |
|
799 | 'lc ls -F -o --color', | |
801 | # ls normal files only |
|
800 | # ls normal files only | |
802 | 'lf ls -F -o --color %l | grep ^-', |
|
801 | 'lf ls -F -o --color %l | grep ^-', | |
803 | # ls symbolic links |
|
802 | # ls symbolic links | |
804 | 'lk ls -F -o --color %l | grep ^l', |
|
803 | 'lk ls -F -o --color %l | grep ^l', | |
805 | # directories or links to directories, |
|
804 | # directories or links to directories, | |
806 | 'ldir ls -F -o --color %l | grep /$', |
|
805 | 'ldir ls -F -o --color %l | grep /$', | |
807 | # things which are executable |
|
806 | # things which are executable | |
808 | 'lx ls -F -o --color %l | grep ^-..x', |
|
807 | 'lx ls -F -o --color %l | grep ^-..x', | |
809 | ) |
|
808 | ) | |
810 | elif os.name in ['nt','dos']: |
|
809 | elif os.name in ['nt','dos']: | |
811 | auto_alias = ('dir dir /on', 'ls dir /on', |
|
810 | auto_alias = ('dir dir /on', 'ls dir /on', | |
812 | 'ddir dir /ad /on', 'ldir dir /ad /on', |
|
811 | 'ddir dir /ad /on', 'ldir dir /ad /on', | |
813 | 'mkdir mkdir','rmdir rmdir','echo echo', |
|
812 | 'mkdir mkdir','rmdir rmdir','echo echo', | |
814 | 'ren ren','cls cls','copy copy') |
|
813 | 'ren ren','cls cls','copy copy') | |
815 | else: |
|
814 | else: | |
816 | auto_alias = () |
|
815 | auto_alias = () | |
817 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) |
|
816 | self.auto_alias = map(lambda s:s.split(None,1),auto_alias) | |
818 | # Call the actual (public) initializer |
|
817 | # Call the actual (public) initializer | |
819 | self.init_auto_alias() |
|
818 | self.init_auto_alias() | |
820 | # end __init__ |
|
819 | # end __init__ | |
821 |
|
820 | |||
822 | def set_hook(self,name,hook): |
|
821 | def set_hook(self,name,hook): | |
823 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
822 | """set_hook(name,hook) -> sets an internal IPython hook. | |
824 |
|
823 | |||
825 | IPython exposes some of its internal API as user-modifiable hooks. By |
|
824 | IPython exposes some of its internal API as user-modifiable hooks. By | |
826 | resetting one of these hooks, you can modify IPython's behavior to |
|
825 | resetting one of these hooks, you can modify IPython's behavior to | |
827 | call at runtime your own routines.""" |
|
826 | call at runtime your own routines.""" | |
828 |
|
827 | |||
829 | # At some point in the future, this should validate the hook before it |
|
828 | # At some point in the future, this should validate the hook before it | |
830 | # accepts it. Probably at least check that the hook takes the number |
|
829 | # accepts it. Probably at least check that the hook takes the number | |
831 | # of args it's supposed to. |
|
830 | # of args it's supposed to. | |
832 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) |
|
831 | setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) | |
833 |
|
832 | |||
834 | def set_custom_exc(self,exc_tuple,handler): |
|
833 | def set_custom_exc(self,exc_tuple,handler): | |
835 | """set_custom_exc(exc_tuple,handler) |
|
834 | """set_custom_exc(exc_tuple,handler) | |
836 |
|
835 | |||
837 | Set a custom exception handler, which will be called if any of the |
|
836 | Set a custom exception handler, which will be called if any of the | |
838 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
837 | exceptions in exc_tuple occur in the mainloop (specifically, in the | |
839 | runcode() method. |
|
838 | runcode() method. | |
840 |
|
839 | |||
841 | Inputs: |
|
840 | Inputs: | |
842 |
|
841 | |||
843 | - exc_tuple: a *tuple* of valid exceptions to call the defined |
|
842 | - exc_tuple: a *tuple* of valid exceptions to call the defined | |
844 | handler for. It is very important that you use a tuple, and NOT A |
|
843 | handler for. It is very important that you use a tuple, and NOT A | |
845 | LIST here, because of the way Python's except statement works. If |
|
844 | LIST here, because of the way Python's except statement works. If | |
846 | you only want to trap a single exception, use a singleton tuple: |
|
845 | you only want to trap a single exception, use a singleton tuple: | |
847 |
|
846 | |||
848 | exc_tuple == (MyCustomException,) |
|
847 | exc_tuple == (MyCustomException,) | |
849 |
|
848 | |||
850 | - handler: this must be defined as a function with the following |
|
849 | - handler: this must be defined as a function with the following | |
851 | basic interface: def my_handler(self,etype,value,tb). |
|
850 | basic interface: def my_handler(self,etype,value,tb). | |
852 |
|
851 | |||
853 | This will be made into an instance method (via new.instancemethod) |
|
852 | This will be made into an instance method (via new.instancemethod) | |
854 | of IPython itself, and it will be called if any of the exceptions |
|
853 | of IPython itself, and it will be called if any of the exceptions | |
855 | listed in the exc_tuple are caught. If the handler is None, an |
|
854 | listed in the exc_tuple are caught. If the handler is None, an | |
856 | internal basic one is used, which just prints basic info. |
|
855 | internal basic one is used, which just prints basic info. | |
857 |
|
856 | |||
858 | WARNING: by putting in your own exception handler into IPython's main |
|
857 | WARNING: by putting in your own exception handler into IPython's main | |
859 | execution loop, you run a very good chance of nasty crashes. This |
|
858 | execution loop, you run a very good chance of nasty crashes. This | |
860 | facility should only be used if you really know what you are doing.""" |
|
859 | facility should only be used if you really know what you are doing.""" | |
861 |
|
860 | |||
862 | assert type(exc_tuple)==type(()) , \ |
|
861 | assert type(exc_tuple)==type(()) , \ | |
863 | "The custom exceptions must be given AS A TUPLE." |
|
862 | "The custom exceptions must be given AS A TUPLE." | |
864 |
|
863 | |||
865 | def dummy_handler(self,etype,value,tb): |
|
864 | def dummy_handler(self,etype,value,tb): | |
866 | print '*** Simple custom exception handler ***' |
|
865 | print '*** Simple custom exception handler ***' | |
867 | print 'Exception type :',etype |
|
866 | print 'Exception type :',etype | |
868 | print 'Exception value:',value |
|
867 | print 'Exception value:',value | |
869 | print 'Traceback :',tb |
|
868 | print 'Traceback :',tb | |
870 |
print 'Source code :',self. |
|
869 | print 'Source code :','\n'.join(self.buffer) | |
871 |
|
870 | |||
872 | if handler is None: handler = dummy_handler |
|
871 | if handler is None: handler = dummy_handler | |
873 |
|
872 | |||
874 | self.CustomTB = new.instancemethod(handler,self,self.__class__) |
|
873 | self.CustomTB = new.instancemethod(handler,self,self.__class__) | |
875 | self.custom_exceptions = exc_tuple |
|
874 | self.custom_exceptions = exc_tuple | |
876 |
|
875 | |||
877 | def set_custom_completer(self,completer,pos=0): |
|
876 | def set_custom_completer(self,completer,pos=0): | |
878 | """set_custom_completer(completer,pos=0) |
|
877 | """set_custom_completer(completer,pos=0) | |
879 |
|
878 | |||
880 | Adds a new custom completer function. |
|
879 | Adds a new custom completer function. | |
881 |
|
880 | |||
882 | The position argument (defaults to 0) is the index in the completers |
|
881 | The position argument (defaults to 0) is the index in the completers | |
883 | list where you want the completer to be inserted.""" |
|
882 | list where you want the completer to be inserted.""" | |
884 |
|
883 | |||
885 | newcomp = new.instancemethod(completer,self.Completer, |
|
884 | newcomp = new.instancemethod(completer,self.Completer, | |
886 | self.Completer.__class__) |
|
885 | self.Completer.__class__) | |
887 | self.Completer.matchers.insert(pos,newcomp) |
|
886 | self.Completer.matchers.insert(pos,newcomp) | |
888 |
|
887 | |||
889 | def post_config_initialization(self): |
|
888 | def post_config_initialization(self): | |
890 | """Post configuration init method |
|
889 | """Post configuration init method | |
891 |
|
890 | |||
892 | This is called after the configuration files have been processed to |
|
891 | This is called after the configuration files have been processed to | |
893 | 'finalize' the initialization.""" |
|
892 | 'finalize' the initialization.""" | |
894 |
|
893 | |||
895 | # dynamic data that survives through sessions |
|
894 | # dynamic data that survives through sessions | |
896 | # XXX make the filename a config option? |
|
895 | # XXX make the filename a config option? | |
897 | persist_base = 'persist' |
|
896 | persist_base = 'persist' | |
898 | if self.rc.profile: |
|
897 | if self.rc.profile: | |
899 | persist_base += '_%s' % self.rc.profile |
|
898 | persist_base += '_%s' % self.rc.profile | |
900 | self.persist_fname = os.path.join(self.rc.ipythondir,persist_base) |
|
899 | self.persist_fname = os.path.join(self.rc.ipythondir,persist_base) | |
901 |
|
900 | |||
902 | try: |
|
901 | try: | |
903 | self.persist = pickle.load(file(self.persist_fname)) |
|
902 | self.persist = pickle.load(file(self.persist_fname)) | |
904 | except: |
|
903 | except: | |
905 | self.persist = {} |
|
904 | self.persist = {} | |
906 |
|
905 | |||
907 | def init_auto_alias(self): |
|
906 | def init_auto_alias(self): | |
908 | """Define some aliases automatically. |
|
907 | """Define some aliases automatically. | |
909 |
|
908 | |||
910 | These are ALL parameter-less aliases""" |
|
909 | These are ALL parameter-less aliases""" | |
911 | for alias,cmd in self.auto_alias: |
|
910 | for alias,cmd in self.auto_alias: | |
912 | self.alias_table[alias] = (0,cmd) |
|
911 | self.alias_table[alias] = (0,cmd) | |
913 |
|
912 | |||
914 | def alias_table_validate(self,verbose=0): |
|
913 | def alias_table_validate(self,verbose=0): | |
915 | """Update information about the alias table. |
|
914 | """Update information about the alias table. | |
916 |
|
915 | |||
917 | In particular, make sure no Python keywords/builtins are in it.""" |
|
916 | In particular, make sure no Python keywords/builtins are in it.""" | |
918 |
|
917 | |||
919 | no_alias = self.no_alias |
|
918 | no_alias = self.no_alias | |
920 | for k in self.alias_table.keys(): |
|
919 | for k in self.alias_table.keys(): | |
921 | if k in no_alias: |
|
920 | if k in no_alias: | |
922 | del self.alias_table[k] |
|
921 | del self.alias_table[k] | |
923 | if verbose: |
|
922 | if verbose: | |
924 | print ("Deleting alias <%s>, it's a Python " |
|
923 | print ("Deleting alias <%s>, it's a Python " | |
925 | "keyword or builtin." % k) |
|
924 | "keyword or builtin." % k) | |
926 |
|
925 | |||
927 | def set_autoindent(self,value=None): |
|
926 | def set_autoindent(self,value=None): | |
928 | """Set the autoindent flag, checking for readline support. |
|
927 | """Set the autoindent flag, checking for readline support. | |
929 |
|
928 | |||
930 | If called with no arguments, it acts as a toggle.""" |
|
929 | If called with no arguments, it acts as a toggle.""" | |
931 |
|
930 | |||
932 | if not self.has_readline: |
|
931 | if not self.has_readline: | |
933 | if os.name == 'posix': |
|
932 | if os.name == 'posix': | |
934 | warn("The auto-indent feature requires the readline library") |
|
933 | warn("The auto-indent feature requires the readline library") | |
935 | self.autoindent = 0 |
|
934 | self.autoindent = 0 | |
936 | return |
|
935 | return | |
937 | if value is None: |
|
936 | if value is None: | |
938 | self.autoindent = not self.autoindent |
|
937 | self.autoindent = not self.autoindent | |
939 | else: |
|
938 | else: | |
940 | self.autoindent = value |
|
939 | self.autoindent = value | |
941 |
|
940 | |||
942 | def rc_set_toggle(self,rc_field,value=None): |
|
941 | def rc_set_toggle(self,rc_field,value=None): | |
943 | """Set or toggle a field in IPython's rc config. structure. |
|
942 | """Set or toggle a field in IPython's rc config. structure. | |
944 |
|
943 | |||
945 | If called with no arguments, it acts as a toggle. |
|
944 | If called with no arguments, it acts as a toggle. | |
946 |
|
945 | |||
947 | If called with a non-existent field, the resulting AttributeError |
|
946 | If called with a non-existent field, the resulting AttributeError | |
948 | exception will propagate out.""" |
|
947 | exception will propagate out.""" | |
949 |
|
948 | |||
950 | rc_val = getattr(self.rc,rc_field) |
|
949 | rc_val = getattr(self.rc,rc_field) | |
951 | if value is None: |
|
950 | if value is None: | |
952 | value = not rc_val |
|
951 | value = not rc_val | |
953 | setattr(self.rc,rc_field,value) |
|
952 | setattr(self.rc,rc_field,value) | |
954 |
|
953 | |||
955 | def user_setup(self,ipythondir,rc_suffix,mode='install'): |
|
954 | def user_setup(self,ipythondir,rc_suffix,mode='install'): | |
956 | """Install the user configuration directory. |
|
955 | """Install the user configuration directory. | |
957 |
|
956 | |||
958 | Can be called when running for the first time or to upgrade the user's |
|
957 | Can be called when running for the first time or to upgrade the user's | |
959 | .ipython/ directory with the mode parameter. Valid modes are 'install' |
|
958 | .ipython/ directory with the mode parameter. Valid modes are 'install' | |
960 | and 'upgrade'.""" |
|
959 | and 'upgrade'.""" | |
961 |
|
960 | |||
962 | def wait(): |
|
961 | def wait(): | |
963 | try: |
|
962 | try: | |
964 | raw_input("Please press <RETURN> to start IPython.") |
|
963 | raw_input("Please press <RETURN> to start IPython.") | |
965 | except EOFError: |
|
964 | except EOFError: | |
966 | print >> Term.cout |
|
965 | print >> Term.cout | |
967 | print '*'*70 |
|
966 | print '*'*70 | |
968 |
|
967 | |||
969 | cwd = os.getcwd() # remember where we started |
|
968 | cwd = os.getcwd() # remember where we started | |
970 | glb = glob.glob |
|
969 | glb = glob.glob | |
971 | print '*'*70 |
|
970 | print '*'*70 | |
972 | if mode == 'install': |
|
971 | if mode == 'install': | |
973 | print \ |
|
972 | print \ | |
974 | """Welcome to IPython. I will try to create a personal configuration directory |
|
973 | """Welcome to IPython. I will try to create a personal configuration directory | |
975 | where you can customize many aspects of IPython's functionality in:\n""" |
|
974 | where you can customize many aspects of IPython's functionality in:\n""" | |
976 | else: |
|
975 | else: | |
977 | print 'I am going to upgrade your configuration in:' |
|
976 | print 'I am going to upgrade your configuration in:' | |
978 |
|
977 | |||
979 | print ipythondir |
|
978 | print ipythondir | |
980 |
|
979 | |||
981 | rcdirend = os.path.join('IPython','UserConfig') |
|
980 | rcdirend = os.path.join('IPython','UserConfig') | |
982 | cfg = lambda d: os.path.join(d,rcdirend) |
|
981 | cfg = lambda d: os.path.join(d,rcdirend) | |
983 | try: |
|
982 | try: | |
984 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] |
|
983 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] | |
985 | except IOError: |
|
984 | except IOError: | |
986 | warning = """ |
|
985 | warning = """ | |
987 | Installation error. IPython's directory was not found. |
|
986 | Installation error. IPython's directory was not found. | |
988 |
|
987 | |||
989 | Check the following: |
|
988 | Check the following: | |
990 |
|
989 | |||
991 | The ipython/IPython directory should be in a directory belonging to your |
|
990 | The ipython/IPython directory should be in a directory belonging to your | |
992 | PYTHONPATH environment variable (that is, it should be in a directory |
|
991 | PYTHONPATH environment variable (that is, it should be in a directory | |
993 | belonging to sys.path). You can copy it explicitly there or just link to it. |
|
992 | belonging to sys.path). You can copy it explicitly there or just link to it. | |
994 |
|
993 | |||
995 | IPython will proceed with builtin defaults. |
|
994 | IPython will proceed with builtin defaults. | |
996 | """ |
|
995 | """ | |
997 | warn(warning) |
|
996 | warn(warning) | |
998 | wait() |
|
997 | wait() | |
999 | return |
|
998 | return | |
1000 |
|
999 | |||
1001 | if mode == 'install': |
|
1000 | if mode == 'install': | |
1002 | try: |
|
1001 | try: | |
1003 | shutil.copytree(rcdir,ipythondir) |
|
1002 | shutil.copytree(rcdir,ipythondir) | |
1004 | os.chdir(ipythondir) |
|
1003 | os.chdir(ipythondir) | |
1005 | rc_files = glb("ipythonrc*") |
|
1004 | rc_files = glb("ipythonrc*") | |
1006 | for rc_file in rc_files: |
|
1005 | for rc_file in rc_files: | |
1007 | os.rename(rc_file,rc_file+rc_suffix) |
|
1006 | os.rename(rc_file,rc_file+rc_suffix) | |
1008 | except: |
|
1007 | except: | |
1009 | warning = """ |
|
1008 | warning = """ | |
1010 |
|
1009 | |||
1011 | There was a problem with the installation: |
|
1010 | There was a problem with the installation: | |
1012 | %s |
|
1011 | %s | |
1013 | Try to correct it or contact the developers if you think it's a bug. |
|
1012 | Try to correct it or contact the developers if you think it's a bug. | |
1014 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] |
|
1013 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] | |
1015 | warn(warning) |
|
1014 | warn(warning) | |
1016 | wait() |
|
1015 | wait() | |
1017 | return |
|
1016 | return | |
1018 |
|
1017 | |||
1019 | elif mode == 'upgrade': |
|
1018 | elif mode == 'upgrade': | |
1020 | try: |
|
1019 | try: | |
1021 | os.chdir(ipythondir) |
|
1020 | os.chdir(ipythondir) | |
1022 | except: |
|
1021 | except: | |
1023 | print """ |
|
1022 | print """ | |
1024 | Can not upgrade: changing to directory %s failed. Details: |
|
1023 | Can not upgrade: changing to directory %s failed. Details: | |
1025 | %s |
|
1024 | %s | |
1026 | """ % (ipythondir,sys.exc_info()[1]) |
|
1025 | """ % (ipythondir,sys.exc_info()[1]) | |
1027 | wait() |
|
1026 | wait() | |
1028 | return |
|
1027 | return | |
1029 | else: |
|
1028 | else: | |
1030 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) |
|
1029 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) | |
1031 | for new_full_path in sources: |
|
1030 | for new_full_path in sources: | |
1032 | new_filename = os.path.basename(new_full_path) |
|
1031 | new_filename = os.path.basename(new_full_path) | |
1033 | if new_filename.startswith('ipythonrc'): |
|
1032 | if new_filename.startswith('ipythonrc'): | |
1034 | new_filename = new_filename + rc_suffix |
|
1033 | new_filename = new_filename + rc_suffix | |
1035 | # The config directory should only contain files, skip any |
|
1034 | # The config directory should only contain files, skip any | |
1036 | # directories which may be there (like CVS) |
|
1035 | # directories which may be there (like CVS) | |
1037 | if os.path.isdir(new_full_path): |
|
1036 | if os.path.isdir(new_full_path): | |
1038 | continue |
|
1037 | continue | |
1039 | if os.path.exists(new_filename): |
|
1038 | if os.path.exists(new_filename): | |
1040 | old_file = new_filename+'.old' |
|
1039 | old_file = new_filename+'.old' | |
1041 | if os.path.exists(old_file): |
|
1040 | if os.path.exists(old_file): | |
1042 | os.remove(old_file) |
|
1041 | os.remove(old_file) | |
1043 | os.rename(new_filename,old_file) |
|
1042 | os.rename(new_filename,old_file) | |
1044 | shutil.copy(new_full_path,new_filename) |
|
1043 | shutil.copy(new_full_path,new_filename) | |
1045 | else: |
|
1044 | else: | |
1046 | raise ValueError,'unrecognized mode for install:',`mode` |
|
1045 | raise ValueError,'unrecognized mode for install:',`mode` | |
1047 |
|
1046 | |||
1048 | # Fix line-endings to those native to each platform in the config |
|
1047 | # Fix line-endings to those native to each platform in the config | |
1049 | # directory. |
|
1048 | # directory. | |
1050 | try: |
|
1049 | try: | |
1051 | os.chdir(ipythondir) |
|
1050 | os.chdir(ipythondir) | |
1052 | except: |
|
1051 | except: | |
1053 | print """ |
|
1052 | print """ | |
1054 | Problem: changing to directory %s failed. |
|
1053 | Problem: changing to directory %s failed. | |
1055 | Details: |
|
1054 | Details: | |
1056 | %s |
|
1055 | %s | |
1057 |
|
1056 | |||
1058 | Some configuration files may have incorrect line endings. This should not |
|
1057 | Some configuration files may have incorrect line endings. This should not | |
1059 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) |
|
1058 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) | |
1060 | wait() |
|
1059 | wait() | |
1061 | else: |
|
1060 | else: | |
1062 | for fname in glb('ipythonrc*'): |
|
1061 | for fname in glb('ipythonrc*'): | |
1063 | try: |
|
1062 | try: | |
1064 | native_line_ends(fname,backup=0) |
|
1063 | native_line_ends(fname,backup=0) | |
1065 | except IOError: |
|
1064 | except IOError: | |
1066 | pass |
|
1065 | pass | |
1067 |
|
1066 | |||
1068 | if mode == 'install': |
|
1067 | if mode == 'install': | |
1069 | print """ |
|
1068 | print """ | |
1070 | Successful installation! |
|
1069 | Successful installation! | |
1071 |
|
1070 | |||
1072 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the |
|
1071 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the | |
1073 | IPython manual (there are both HTML and PDF versions supplied with the |
|
1072 | IPython manual (there are both HTML and PDF versions supplied with the | |
1074 | distribution) to make sure that your system environment is properly configured |
|
1073 | distribution) to make sure that your system environment is properly configured | |
1075 | to take advantage of IPython's features.""" |
|
1074 | to take advantage of IPython's features.""" | |
1076 | else: |
|
1075 | else: | |
1077 | print """ |
|
1076 | print """ | |
1078 | Successful upgrade! |
|
1077 | Successful upgrade! | |
1079 |
|
1078 | |||
1080 | All files in your directory: |
|
1079 | All files in your directory: | |
1081 | %(ipythondir)s |
|
1080 | %(ipythondir)s | |
1082 | which would have been overwritten by the upgrade were backed up with a .old |
|
1081 | which would have been overwritten by the upgrade were backed up with a .old | |
1083 | extension. If you had made particular customizations in those files you may |
|
1082 | extension. If you had made particular customizations in those files you may | |
1084 | want to merge them back into the new files.""" % locals() |
|
1083 | want to merge them back into the new files.""" % locals() | |
1085 | wait() |
|
1084 | wait() | |
1086 | os.chdir(cwd) |
|
1085 | os.chdir(cwd) | |
1087 | # end user_setup() |
|
1086 | # end user_setup() | |
1088 |
|
1087 | |||
1089 | def atexit_operations(self): |
|
1088 | def atexit_operations(self): | |
1090 | """This will be executed at the time of exit. |
|
1089 | """This will be executed at the time of exit. | |
1091 |
|
1090 | |||
1092 | Saving of persistent data should be performed here. """ |
|
1091 | Saving of persistent data should be performed here. """ | |
1093 |
|
1092 | |||
1094 | # input history |
|
1093 | # input history | |
1095 | self.savehist() |
|
1094 | self.savehist() | |
1096 |
|
1095 | |||
1097 | # Cleanup all tempfiles left around |
|
1096 | # Cleanup all tempfiles left around | |
1098 | for tfile in self.tempfiles: |
|
1097 | for tfile in self.tempfiles: | |
1099 | try: |
|
1098 | try: | |
1100 | os.unlink(tfile) |
|
1099 | os.unlink(tfile) | |
1101 | except OSError: |
|
1100 | except OSError: | |
1102 | pass |
|
1101 | pass | |
1103 |
|
1102 | |||
1104 | # save the "persistent data" catch-all dictionary |
|
1103 | # save the "persistent data" catch-all dictionary | |
1105 | try: |
|
1104 | try: | |
1106 | pickle.dump(self.persist, open(self.persist_fname,"w")) |
|
1105 | pickle.dump(self.persist, open(self.persist_fname,"w")) | |
1107 | except: |
|
1106 | except: | |
1108 | print "*** ERROR *** persistent data saving failed." |
|
1107 | print "*** ERROR *** persistent data saving failed." | |
1109 |
|
1108 | |||
1110 | def savehist(self): |
|
1109 | def savehist(self): | |
1111 | """Save input history to a file (via readline library).""" |
|
1110 | """Save input history to a file (via readline library).""" | |
1112 | try: |
|
1111 | try: | |
1113 | self.readline.write_history_file(self.histfile) |
|
1112 | self.readline.write_history_file(self.histfile) | |
1114 | except: |
|
1113 | except: | |
1115 | print 'Unable to save IPython command history to file: ' + \ |
|
1114 | print 'Unable to save IPython command history to file: ' + \ | |
1116 | `self.histfile` |
|
1115 | `self.histfile` | |
1117 |
|
1116 | |||
1118 | def pre_readline(self): |
|
1117 | def pre_readline(self): | |
1119 | """readline hook to be used at the start of each line. |
|
1118 | """readline hook to be used at the start of each line. | |
1120 |
|
1119 | |||
1121 | Currently it handles auto-indent only.""" |
|
1120 | Currently it handles auto-indent only.""" | |
1122 |
|
1121 | |||
1123 | self.readline.insert_text(' '* self.readline_indent) |
|
1122 | self.readline.insert_text(' '* self.readline_indent) | |
1124 |
|
1123 | |||
1125 | def init_readline(self): |
|
1124 | def init_readline(self): | |
1126 | """Command history completion/saving/reloading.""" |
|
1125 | """Command history completion/saving/reloading.""" | |
1127 | try: |
|
1126 | try: | |
1128 | import readline |
|
1127 | import readline | |
1129 | self.Completer = MagicCompleter(self, |
|
1128 | self.Completer = MagicCompleter(self, | |
1130 | self.user_ns, |
|
1129 | self.user_ns, | |
1131 | self.rc.readline_omit__names, |
|
1130 | self.rc.readline_omit__names, | |
1132 | self.alias_table) |
|
1131 | self.alias_table) | |
1133 | except ImportError,NameError: |
|
1132 | except ImportError,NameError: | |
1134 | # If FlexCompleter failed to import, MagicCompleter won't be |
|
1133 | # If FlexCompleter failed to import, MagicCompleter won't be | |
1135 | # defined. This can happen because of a problem with readline |
|
1134 | # defined. This can happen because of a problem with readline | |
1136 | self.has_readline = 0 |
|
1135 | self.has_readline = 0 | |
1137 | # no point in bugging windows users with this every time: |
|
1136 | # no point in bugging windows users with this every time: | |
1138 | if os.name == 'posix': |
|
1137 | if os.name == 'posix': | |
1139 | warn('Readline services not available on this platform.') |
|
1138 | warn('Readline services not available on this platform.') | |
1140 | else: |
|
1139 | else: | |
1141 | import atexit |
|
1140 | import atexit | |
1142 |
|
1141 | |||
1143 | # Platform-specific configuration |
|
1142 | # Platform-specific configuration | |
1144 | if os.name == 'nt': |
|
1143 | if os.name == 'nt': | |
1145 | # readline under Windows modifies the default exit behavior |
|
1144 | # readline under Windows modifies the default exit behavior | |
1146 | # from being Ctrl-Z/Return to the Unix Ctrl-D one. |
|
1145 | # from being Ctrl-Z/Return to the Unix Ctrl-D one. | |
1147 | __builtin__.exit = __builtin__.quit = \ |
|
1146 | __builtin__.exit = __builtin__.quit = \ | |
1148 | ('Use Ctrl-D (i.e. EOF) to exit. ' |
|
1147 | ('Use Ctrl-D (i.e. EOF) to exit. ' | |
1149 | 'Use %Exit or %Quit to exit without confirmation.') |
|
1148 | 'Use %Exit or %Quit to exit without confirmation.') | |
1150 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1149 | self.readline_startup_hook = readline.set_pre_input_hook | |
1151 | else: |
|
1150 | else: | |
1152 | self.readline_startup_hook = readline.set_startup_hook |
|
1151 | self.readline_startup_hook = readline.set_startup_hook | |
1153 |
|
1152 | |||
1154 | # Load user's initrc file (readline config) |
|
1153 | # Load user's initrc file (readline config) | |
1155 | inputrc_name = os.environ.get('INPUTRC') |
|
1154 | inputrc_name = os.environ.get('INPUTRC') | |
1156 | if inputrc_name is None: |
|
1155 | if inputrc_name is None: | |
1157 | home_dir = get_home_dir() |
|
1156 | home_dir = get_home_dir() | |
1158 | if home_dir is not None: |
|
1157 | if home_dir is not None: | |
1159 | inputrc_name = os.path.join(home_dir,'.inputrc') |
|
1158 | inputrc_name = os.path.join(home_dir,'.inputrc') | |
1160 | if os.path.isfile(inputrc_name): |
|
1159 | if os.path.isfile(inputrc_name): | |
1161 | try: |
|
1160 | try: | |
1162 | readline.read_init_file(inputrc_name) |
|
1161 | readline.read_init_file(inputrc_name) | |
1163 | except: |
|
1162 | except: | |
1164 | warn('Problems reading readline initialization file <%s>' |
|
1163 | warn('Problems reading readline initialization file <%s>' | |
1165 | % inputrc_name) |
|
1164 | % inputrc_name) | |
1166 |
|
1165 | |||
1167 | self.has_readline = 1 |
|
1166 | self.has_readline = 1 | |
1168 | self.readline = readline |
|
1167 | self.readline = readline | |
1169 | self.readline_indent = 0 # for auto-indenting via readline |
|
1168 | self.readline_indent = 0 # for auto-indenting via readline | |
1170 | # save this in sys so embedded copies can restore it properly |
|
1169 | # save this in sys so embedded copies can restore it properly | |
1171 | sys.ipcompleter = self.Completer.complete |
|
1170 | sys.ipcompleter = self.Completer.complete | |
1172 | readline.set_completer(self.Completer.complete) |
|
1171 | readline.set_completer(self.Completer.complete) | |
1173 |
|
1172 | |||
1174 | # Configure readline according to user's prefs |
|
1173 | # Configure readline according to user's prefs | |
1175 | for rlcommand in self.rc.readline_parse_and_bind: |
|
1174 | for rlcommand in self.rc.readline_parse_and_bind: | |
1176 | readline.parse_and_bind(rlcommand) |
|
1175 | readline.parse_and_bind(rlcommand) | |
1177 |
|
1176 | |||
1178 | # remove some chars from the delimiters list |
|
1177 | # remove some chars from the delimiters list | |
1179 | delims = readline.get_completer_delims() |
|
1178 | delims = readline.get_completer_delims() | |
1180 | delims = delims.translate(string._idmap, |
|
1179 | delims = delims.translate(string._idmap, | |
1181 | self.rc.readline_remove_delims) |
|
1180 | self.rc.readline_remove_delims) | |
1182 | readline.set_completer_delims(delims) |
|
1181 | readline.set_completer_delims(delims) | |
1183 | # otherwise we end up with a monster history after a while: |
|
1182 | # otherwise we end up with a monster history after a while: | |
1184 | readline.set_history_length(1000) |
|
1183 | readline.set_history_length(1000) | |
1185 | try: |
|
1184 | try: | |
1186 | #print '*** Reading readline history' # dbg |
|
1185 | #print '*** Reading readline history' # dbg | |
1187 | readline.read_history_file(self.histfile) |
|
1186 | readline.read_history_file(self.histfile) | |
1188 | except IOError: |
|
1187 | except IOError: | |
1189 | pass # It doesn't exist yet. |
|
1188 | pass # It doesn't exist yet. | |
1190 |
|
1189 | |||
1191 | atexit.register(self.atexit_operations) |
|
1190 | atexit.register(self.atexit_operations) | |
1192 | del atexit |
|
1191 | del atexit | |
1193 |
|
1192 | |||
1194 | # Configure auto-indent for all platforms |
|
1193 | # Configure auto-indent for all platforms | |
1195 | self.set_autoindent(self.rc.autoindent) |
|
1194 | self.set_autoindent(self.rc.autoindent) | |
1196 |
|
1195 | |||
1197 | def showsyntaxerror(self, filename=None): |
|
1196 | def showsyntaxerror(self, filename=None): | |
1198 | """Display the syntax error that just occurred. |
|
1197 | """Display the syntax error that just occurred. | |
1199 |
|
1198 | |||
1200 | This doesn't display a stack trace because there isn't one. |
|
1199 | This doesn't display a stack trace because there isn't one. | |
1201 |
|
1200 | |||
1202 | If a filename is given, it is stuffed in the exception instead |
|
1201 | If a filename is given, it is stuffed in the exception instead | |
1203 | of what was there before (because Python's parser always uses |
|
1202 | of what was there before (because Python's parser always uses | |
1204 | "<string>" when reading from a string). |
|
1203 | "<string>" when reading from a string). | |
1205 | """ |
|
1204 | """ | |
1206 | type, value, sys.last_traceback = sys.exc_info() |
|
1205 | type, value, sys.last_traceback = sys.exc_info() | |
1207 | sys.last_type = type |
|
1206 | sys.last_type = type | |
1208 | sys.last_value = value |
|
1207 | sys.last_value = value | |
1209 | if filename and type is SyntaxError: |
|
1208 | if filename and type is SyntaxError: | |
1210 | # Work hard to stuff the correct filename in the exception |
|
1209 | # Work hard to stuff the correct filename in the exception | |
1211 | try: |
|
1210 | try: | |
1212 | msg, (dummy_filename, lineno, offset, line) = value |
|
1211 | msg, (dummy_filename, lineno, offset, line) = value | |
1213 | except: |
|
1212 | except: | |
1214 | # Not the format we expect; leave it alone |
|
1213 | # Not the format we expect; leave it alone | |
1215 | pass |
|
1214 | pass | |
1216 | else: |
|
1215 | else: | |
1217 | # Stuff in the right filename |
|
1216 | # Stuff in the right filename | |
1218 | try: |
|
1217 | try: | |
1219 | # Assume SyntaxError is a class exception |
|
1218 | # Assume SyntaxError is a class exception | |
1220 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
1219 | value = SyntaxError(msg, (filename, lineno, offset, line)) | |
1221 | except: |
|
1220 | except: | |
1222 | # If that failed, assume SyntaxError is a string |
|
1221 | # If that failed, assume SyntaxError is a string | |
1223 | value = msg, (filename, lineno, offset, line) |
|
1222 | value = msg, (filename, lineno, offset, line) | |
1224 | self.SyntaxTB(type,value,[]) |
|
1223 | self.SyntaxTB(type,value,[]) | |
1225 |
|
1224 | |||
1226 | def debugger(self): |
|
1225 | def debugger(self): | |
1227 | """Call the pdb debugger.""" |
|
1226 | """Call the pdb debugger.""" | |
1228 |
|
1227 | |||
1229 | if not self.rc.pdb: |
|
1228 | if not self.rc.pdb: | |
1230 | return |
|
1229 | return | |
1231 | pdb.pm() |
|
1230 | pdb.pm() | |
1232 |
|
1231 | |||
1233 | def showtraceback(self,exc_tuple = None): |
|
1232 | def showtraceback(self,exc_tuple = None): | |
1234 | """Display the exception that just occurred.""" |
|
1233 | """Display the exception that just occurred.""" | |
1235 |
|
1234 | |||
1236 | # Though this won't be called by syntax errors in the input line, |
|
1235 | # Though this won't be called by syntax errors in the input line, | |
1237 | # there may be SyntaxError cases whith imported code. |
|
1236 | # there may be SyntaxError cases whith imported code. | |
1238 | if exc_tuple is None: |
|
1237 | if exc_tuple is None: | |
1239 | type, value, tb = sys.exc_info() |
|
1238 | type, value, tb = sys.exc_info() | |
1240 | else: |
|
1239 | else: | |
1241 | type, value, tb = exc_tuple |
|
1240 | type, value, tb = exc_tuple | |
1242 | if type is SyntaxError: |
|
1241 | if type is SyntaxError: | |
1243 | self.showsyntaxerror() |
|
1242 | self.showsyntaxerror() | |
1244 | else: |
|
1243 | else: | |
1245 | sys.last_type = type |
|
1244 | sys.last_type = type | |
1246 | sys.last_value = value |
|
1245 | sys.last_value = value | |
1247 | sys.last_traceback = tb |
|
1246 | sys.last_traceback = tb | |
1248 | self.InteractiveTB() |
|
1247 | self.InteractiveTB() | |
1249 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1248 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1250 | # pdb mucks up readline, fix it back |
|
1249 | # pdb mucks up readline, fix it back | |
1251 | self.readline.set_completer(self.Completer.complete) |
|
1250 | self.readline.set_completer(self.Completer.complete) | |
1252 |
|
1251 | |||
1253 | def update_cache(self, line): |
|
1252 | def update_cache(self, line): | |
1254 | """puts line into cache""" |
|
1253 | """puts line into cache""" | |
1255 | self.inputcache.insert(0, line) # This copies the cache every time ... :-( |
|
1254 | self.inputcache.insert(0, line) # This copies the cache every time ... :-( | |
1256 | if len(self.inputcache) >= self.CACHELENGTH: |
|
1255 | if len(self.inputcache) >= self.CACHELENGTH: | |
1257 | self.inputcache.pop() # This not :-) |
|
1256 | self.inputcache.pop() # This not :-) | |
1258 |
|
1257 | |||
1259 | def name_space_init(self): |
|
1258 | def name_space_init(self): | |
1260 | """Create local namespace.""" |
|
1259 | """Create local namespace.""" | |
1261 | # We want this to be a method to facilitate embedded initialization. |
|
1260 | # We want this to be a method to facilitate embedded initialization. | |
1262 | code.InteractiveConsole.__init__(self,self.user_ns) |
|
1261 | code.InteractiveConsole.__init__(self,self.user_ns) | |
1263 |
|
1262 | |||
1264 | def mainloop(self,banner=None): |
|
1263 | def mainloop(self,banner=None): | |
1265 | """Creates the local namespace and starts the mainloop. |
|
1264 | """Creates the local namespace and starts the mainloop. | |
1266 |
|
1265 | |||
1267 | If an optional banner argument is given, it will override the |
|
1266 | If an optional banner argument is given, it will override the | |
1268 | internally created default banner.""" |
|
1267 | internally created default banner.""" | |
1269 |
|
1268 | |||
1270 | self.name_space_init() |
|
1269 | self.name_space_init() | |
1271 | if self.rc.c: # Emulate Python's -c option |
|
1270 | if self.rc.c: # Emulate Python's -c option | |
1272 | self.exec_init_cmd() |
|
1271 | self.exec_init_cmd() | |
1273 | if banner is None: |
|
1272 | if banner is None: | |
1274 | if self.rc.banner: |
|
1273 | if self.rc.banner: | |
1275 | banner = self.BANNER+self.banner2 |
|
1274 | banner = self.BANNER+self.banner2 | |
1276 | else: |
|
1275 | else: | |
1277 | banner = '' |
|
1276 | banner = '' | |
1278 | self.interact(banner) |
|
1277 | self.interact(banner) | |
1279 |
|
1278 | |||
1280 | def exec_init_cmd(self): |
|
1279 | def exec_init_cmd(self): | |
1281 | """Execute a command given at the command line. |
|
1280 | """Execute a command given at the command line. | |
1282 |
|
1281 | |||
1283 | This emulates Python's -c option.""" |
|
1282 | This emulates Python's -c option.""" | |
1284 |
|
1283 | |||
1285 | sys.argv = ['-c'] |
|
1284 | sys.argv = ['-c'] | |
1286 | self.push(self.rc.c) |
|
1285 | self.push(self.rc.c) | |
1287 |
|
1286 | |||
1288 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): |
|
1287 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): | |
1289 | """Embeds IPython into a running python program. |
|
1288 | """Embeds IPython into a running python program. | |
1290 |
|
1289 | |||
1291 | Input: |
|
1290 | Input: | |
1292 |
|
1291 | |||
1293 | - header: An optional header message can be specified. |
|
1292 | - header: An optional header message can be specified. | |
1294 |
|
1293 | |||
1295 | - local_ns, global_ns: working namespaces. If given as None, the |
|
1294 | - local_ns, global_ns: working namespaces. If given as None, the | |
1296 | IPython-initialized one is updated with __main__.__dict__, so that |
|
1295 | IPython-initialized one is updated with __main__.__dict__, so that | |
1297 | program variables become visible but user-specific configuration |
|
1296 | program variables become visible but user-specific configuration | |
1298 | remains possible. |
|
1297 | remains possible. | |
1299 |
|
1298 | |||
1300 | - stack_depth: specifies how many levels in the stack to go to |
|
1299 | - stack_depth: specifies how many levels in the stack to go to | |
1301 | looking for namespaces (when local_ns and global_ns are None). This |
|
1300 | looking for namespaces (when local_ns and global_ns are None). This | |
1302 | allows an intermediate caller to make sure that this function gets |
|
1301 | allows an intermediate caller to make sure that this function gets | |
1303 | the namespace from the intended level in the stack. By default (0) |
|
1302 | the namespace from the intended level in the stack. By default (0) | |
1304 | it will get its locals and globals from the immediate caller. |
|
1303 | it will get its locals and globals from the immediate caller. | |
1305 |
|
1304 | |||
1306 | Warning: it's possible to use this in a program which is being run by |
|
1305 | Warning: it's possible to use this in a program which is being run by | |
1307 | IPython itself (via %run), but some funny things will happen (a few |
|
1306 | IPython itself (via %run), but some funny things will happen (a few | |
1308 | globals get overwritten). In the future this will be cleaned up, as |
|
1307 | globals get overwritten). In the future this will be cleaned up, as | |
1309 | there is no fundamental reason why it can't work perfectly.""" |
|
1308 | there is no fundamental reason why it can't work perfectly.""" | |
1310 |
|
1309 | |||
1311 | # Patch for global embedding to make sure that things don't overwrite |
|
1310 | # Patch for global embedding to make sure that things don't overwrite | |
1312 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> |
|
1311 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> | |
1313 | # FIXME. Test this a bit more carefully (the if.. is new) |
|
1312 | # FIXME. Test this a bit more carefully (the if.. is new) | |
1314 | if local_ns is None and global_ns is None: |
|
1313 | if local_ns is None and global_ns is None: | |
1315 | self.user_ns.update(__main__.__dict__) |
|
1314 | self.user_ns.update(__main__.__dict__) | |
1316 |
|
1315 | |||
1317 | # Get locals and globals from caller |
|
1316 | # Get locals and globals from caller | |
1318 | if local_ns is None or global_ns is None: |
|
1317 | if local_ns is None or global_ns is None: | |
1319 | call_frame = sys._getframe(stack_depth).f_back |
|
1318 | call_frame = sys._getframe(stack_depth).f_back | |
1320 |
|
1319 | |||
1321 | if local_ns is None: |
|
1320 | if local_ns is None: | |
1322 | local_ns = call_frame.f_locals |
|
1321 | local_ns = call_frame.f_locals | |
1323 | if global_ns is None: |
|
1322 | if global_ns is None: | |
1324 | global_ns = call_frame.f_globals |
|
1323 | global_ns = call_frame.f_globals | |
1325 |
|
1324 | |||
1326 | # Update namespaces and fire up interpreter |
|
1325 | # Update namespaces and fire up interpreter | |
1327 | self.user_ns.update(local_ns) |
|
1326 | self.user_ns.update(local_ns) | |
1328 | self.interact(header) |
|
1327 | self.interact(header) | |
1329 |
|
1328 | |||
1330 | # Remove locals from namespace |
|
1329 | # Remove locals from namespace | |
1331 | for k in local_ns: |
|
1330 | for k in local_ns: | |
1332 | del self.user_ns[k] |
|
1331 | del self.user_ns[k] | |
1333 |
|
1332 | |||
1334 | def interact(self, banner=None): |
|
1333 | def interact(self, banner=None): | |
1335 | """Closely emulate the interactive Python console. |
|
1334 | """Closely emulate the interactive Python console. | |
1336 |
|
1335 | |||
1337 | The optional banner argument specify the banner to print |
|
1336 | The optional banner argument specify the banner to print | |
1338 | before the first interaction; by default it prints a banner |
|
1337 | before the first interaction; by default it prints a banner | |
1339 | similar to the one printed by the real Python interpreter, |
|
1338 | similar to the one printed by the real Python interpreter, | |
1340 | followed by the current class name in parentheses (so as not |
|
1339 | followed by the current class name in parentheses (so as not | |
1341 | to confuse this with the real interpreter -- since it's so |
|
1340 | to confuse this with the real interpreter -- since it's so | |
1342 | close!). |
|
1341 | close!). | |
1343 |
|
1342 | |||
1344 | """ |
|
1343 | """ | |
1345 | cprt = 'Type "copyright", "credits" or "license" for more information.' |
|
1344 | cprt = 'Type "copyright", "credits" or "license" for more information.' | |
1346 | if banner is None: |
|
1345 | if banner is None: | |
1347 | self.write("Python %s on %s\n%s\n(%s)\n" % |
|
1346 | self.write("Python %s on %s\n%s\n(%s)\n" % | |
1348 | (sys.version, sys.platform, cprt, |
|
1347 | (sys.version, sys.platform, cprt, | |
1349 | self.__class__.__name__)) |
|
1348 | self.__class__.__name__)) | |
1350 | else: |
|
1349 | else: | |
1351 | self.write(banner) |
|
1350 | self.write(banner) | |
1352 |
|
1351 | |||
1353 | more = 0 |
|
1352 | more = 0 | |
1354 |
|
1353 | |||
1355 | # Mark activity in the builtins |
|
1354 | # Mark activity in the builtins | |
1356 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1355 | __builtin__.__dict__['__IPYTHON__active'] += 1 | |
1357 |
|
1356 | |||
1358 | # exit_now is set by a call to %Exit or %Quit |
|
1357 | # exit_now is set by a call to %Exit or %Quit | |
1359 | while not self.exit_now: |
|
1358 | while not self.exit_now: | |
1360 | try: |
|
1359 | try: | |
1361 | if more: |
|
1360 | if more: | |
1362 | prompt = self.outputcache.prompt2 |
|
1361 | prompt = self.outputcache.prompt2 | |
1363 | if self.autoindent: |
|
1362 | if self.autoindent: | |
1364 | self.readline_startup_hook(self.pre_readline) |
|
1363 | self.readline_startup_hook(self.pre_readline) | |
1365 | else: |
|
1364 | else: | |
1366 | prompt = self.outputcache.prompt1 |
|
1365 | prompt = self.outputcache.prompt1 | |
1367 | try: |
|
1366 | try: | |
1368 | line = self.raw_input(prompt) |
|
1367 | line = self.raw_input(prompt) | |
1369 | if self.autoindent: |
|
1368 | if self.autoindent: | |
1370 | self.readline_startup_hook(None) |
|
1369 | self.readline_startup_hook(None) | |
1371 | except EOFError: |
|
1370 | except EOFError: | |
1372 | if self.autoindent: |
|
1371 | if self.autoindent: | |
1373 | self.readline_startup_hook(None) |
|
1372 | self.readline_startup_hook(None) | |
1374 | self.write("\n") |
|
1373 | self.write("\n") | |
1375 | if self.rc.confirm_exit: |
|
1374 | if self.rc.confirm_exit: | |
1376 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): |
|
1375 | if ask_yes_no('Do you really want to exit ([y]/n)?','y'): | |
1377 | break |
|
1376 | break | |
1378 | else: |
|
1377 | else: | |
1379 | break |
|
1378 | break | |
1380 | else: |
|
1379 | else: | |
1381 | more = self.push(line) |
|
1380 | more = self.push(line) | |
1382 | # Auto-indent management |
|
1381 | # Auto-indent management | |
1383 | if self.autoindent: |
|
1382 | if self.autoindent: | |
1384 | if line: |
|
1383 | if line: | |
1385 | ini_spaces = re.match('^(\s+)',line) |
|
1384 | ini_spaces = re.match('^(\s+)',line) | |
1386 | if ini_spaces: |
|
1385 | if ini_spaces: | |
1387 | nspaces = ini_spaces.end() |
|
1386 | nspaces = ini_spaces.end() | |
1388 | else: |
|
1387 | else: | |
1389 | nspaces = 0 |
|
1388 | nspaces = 0 | |
1390 | self.readline_indent = nspaces |
|
1389 | self.readline_indent = nspaces | |
1391 |
|
1390 | |||
1392 | if line[-1] == ':': |
|
1391 | if line[-1] == ':': | |
1393 | self.readline_indent += 4 |
|
1392 | self.readline_indent += 4 | |
1394 | elif re.match(r'^\s+raise|^\s+return',line): |
|
1393 | elif re.match(r'^\s+raise|^\s+return',line): | |
1395 | self.readline_indent -= 4 |
|
1394 | self.readline_indent -= 4 | |
1396 | else: |
|
1395 | else: | |
1397 | self.readline_indent = 0 |
|
1396 | self.readline_indent = 0 | |
1398 |
|
1397 | |||
1399 | except KeyboardInterrupt: |
|
1398 | except KeyboardInterrupt: | |
1400 | self.write("\nKeyboardInterrupt\n") |
|
1399 | self.write("\nKeyboardInterrupt\n") | |
1401 | self.resetbuffer() |
|
1400 | self.resetbuffer() | |
1402 | more = 0 |
|
1401 | more = 0 | |
1403 | # keep cache in sync with the prompt counter: |
|
1402 | # keep cache in sync with the prompt counter: | |
1404 | self.outputcache.prompt_count -= 1 |
|
1403 | self.outputcache.prompt_count -= 1 | |
1405 |
|
1404 | |||
1406 | if self.autoindent: |
|
1405 | if self.autoindent: | |
1407 | self.readline_indent = 0 |
|
1406 | self.readline_indent = 0 | |
1408 |
|
1407 | |||
1409 | except bdb.BdbQuit: |
|
1408 | except bdb.BdbQuit: | |
1410 | warn("The Python debugger has exited with a BdbQuit exception.\n" |
|
1409 | warn("The Python debugger has exited with a BdbQuit exception.\n" | |
1411 | "Because of how pdb handles the stack, it is impossible\n" |
|
1410 | "Because of how pdb handles the stack, it is impossible\n" | |
1412 | "for IPython to properly format this particular exception.\n" |
|
1411 | "for IPython to properly format this particular exception.\n" | |
1413 | "IPython will resume normal operation.") |
|
1412 | "IPython will resume normal operation.") | |
1414 |
|
1413 | |||
1415 | # We are off again... |
|
1414 | # We are off again... | |
1416 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
1415 | __builtin__.__dict__['__IPYTHON__active'] -= 1 | |
1417 |
|
1416 | |||
1418 | def excepthook(self, type, value, tb): |
|
1417 | def excepthook(self, type, value, tb): | |
1419 | """One more defense for GUI apps that call sys.excepthook. |
|
1418 | """One more defense for GUI apps that call sys.excepthook. | |
1420 |
|
1419 | |||
1421 | GUI frameworks like wxPython trap exceptions and call |
|
1420 | GUI frameworks like wxPython trap exceptions and call | |
1422 | sys.excepthook themselves. I guess this is a feature that |
|
1421 | sys.excepthook themselves. I guess this is a feature that | |
1423 | enables them to keep running after exceptions that would |
|
1422 | enables them to keep running after exceptions that would | |
1424 | otherwise kill their mainloop. This is a bother for IPython |
|
1423 | otherwise kill their mainloop. This is a bother for IPython | |
1425 | which excepts to catch all of the program exceptions with a try: |
|
1424 | which excepts to catch all of the program exceptions with a try: | |
1426 | except: statement. |
|
1425 | except: statement. | |
1427 |
|
1426 | |||
1428 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if |
|
1427 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if | |
1429 | any app directly invokes sys.excepthook, it will look to the user like |
|
1428 | any app directly invokes sys.excepthook, it will look to the user like | |
1430 | IPython crashed. In order to work around this, we can disable the |
|
1429 | IPython crashed. In order to work around this, we can disable the | |
1431 | CrashHandler and replace it with this excepthook instead, which prints a |
|
1430 | CrashHandler and replace it with this excepthook instead, which prints a | |
1432 | regular traceback using our InteractiveTB. In this fashion, apps which |
|
1431 | regular traceback using our InteractiveTB. In this fashion, apps which | |
1433 | call sys.excepthook will generate a regular-looking exception from |
|
1432 | call sys.excepthook will generate a regular-looking exception from | |
1434 | IPython, and the CrashHandler will only be triggered by real IPython |
|
1433 | IPython, and the CrashHandler will only be triggered by real IPython | |
1435 | crashes. |
|
1434 | crashes. | |
1436 |
|
1435 | |||
1437 | This hook should be used sparingly, only in places which are not likely |
|
1436 | This hook should be used sparingly, only in places which are not likely | |
1438 | to be true IPython errors. |
|
1437 | to be true IPython errors. | |
1439 | """ |
|
1438 | """ | |
1440 |
|
1439 | |||
1441 | self.InteractiveTB(type, value, tb, tb_offset=0) |
|
1440 | self.InteractiveTB(type, value, tb, tb_offset=0) | |
1442 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1441 | if self.InteractiveTB.call_pdb and self.has_readline: | |
1443 | self.readline.set_completer(self.Completer.complete) |
|
1442 | self.readline.set_completer(self.Completer.complete) | |
1444 |
|
1443 | |||
1445 | def call_alias(self,alias,rest=''): |
|
1444 | def call_alias(self,alias,rest=''): | |
1446 | """Call an alias given its name and the rest of the line. |
|
1445 | """Call an alias given its name and the rest of the line. | |
1447 |
|
1446 | |||
1448 | This function MUST be given a proper alias, because it doesn't make |
|
1447 | This function MUST be given a proper alias, because it doesn't make | |
1449 | any checks when looking up into the alias table. The caller is |
|
1448 | any checks when looking up into the alias table. The caller is | |
1450 | responsible for invoking it only with a valid alias.""" |
|
1449 | responsible for invoking it only with a valid alias.""" | |
1451 |
|
1450 | |||
1452 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg |
|
1451 | #print 'ALIAS: <%s>+<%s>' % (alias,rest) # dbg | |
1453 | nargs,cmd = self.alias_table[alias] |
|
1452 | nargs,cmd = self.alias_table[alias] | |
1454 | # Expand the %l special to be the user's input line |
|
1453 | # Expand the %l special to be the user's input line | |
1455 | if cmd.find('%l') >= 0: |
|
1454 | if cmd.find('%l') >= 0: | |
1456 | cmd = cmd.replace('%l',rest) |
|
1455 | cmd = cmd.replace('%l',rest) | |
1457 | rest = '' |
|
1456 | rest = '' | |
1458 | if nargs==0: |
|
1457 | if nargs==0: | |
1459 | # Simple, argument-less aliases |
|
1458 | # Simple, argument-less aliases | |
1460 | cmd = '%s %s' % (cmd,rest) |
|
1459 | cmd = '%s %s' % (cmd,rest) | |
1461 | else: |
|
1460 | else: | |
1462 | # Handle aliases with positional arguments |
|
1461 | # Handle aliases with positional arguments | |
1463 | args = rest.split(None,nargs) |
|
1462 | args = rest.split(None,nargs) | |
1464 | if len(args)< nargs: |
|
1463 | if len(args)< nargs: | |
1465 | error('Alias <%s> requires %s arguments, %s given.' % |
|
1464 | error('Alias <%s> requires %s arguments, %s given.' % | |
1466 | (alias,nargs,len(args))) |
|
1465 | (alias,nargs,len(args))) | |
1467 | return |
|
1466 | return | |
1468 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
|
1467 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) | |
1469 | # Now call the macro, evaluating in the user's namespace |
|
1468 | # Now call the macro, evaluating in the user's namespace | |
1470 | try: |
|
1469 | try: | |
1471 | self.system(cmd) |
|
1470 | self.system(cmd) | |
1472 | except: |
|
1471 | except: | |
1473 | self.showtraceback() |
|
1472 | self.showtraceback() | |
1474 |
|
1473 | |||
1475 | def runlines(self,lines): |
|
1474 | def runlines(self,lines): | |
1476 | """Run a string of one or more lines of source. |
|
1475 | """Run a string of one or more lines of source. | |
1477 |
|
1476 | |||
1478 | This method is capable of running a string containing multiple source |
|
1477 | This method is capable of running a string containing multiple source | |
1479 | lines, as if they had been entered at the IPython prompt. Since it |
|
1478 | lines, as if they had been entered at the IPython prompt. Since it | |
1480 | exposes IPython's processing machinery, the given strings can contain |
|
1479 | exposes IPython's processing machinery, the given strings can contain | |
1481 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
1480 | magic calls (%magic), special shell access (!cmd), etc.""" | |
1482 |
|
1481 | |||
1483 | # We must start with a clean buffer, in case this is run from an |
|
1482 | # We must start with a clean buffer, in case this is run from an | |
1484 | # interactive IPython session (via a magic, for example). |
|
1483 | # interactive IPython session (via a magic, for example). | |
1485 | self.resetbuffer() |
|
1484 | self.resetbuffer() | |
1486 | lines = lines.split('\n') |
|
1485 | lines = lines.split('\n') | |
1487 | more = 0 |
|
1486 | more = 0 | |
1488 | for line in lines: |
|
1487 | for line in lines: | |
1489 | # skip blank lines so we don't mess up the prompt counter, but do |
|
1488 | # skip blank lines so we don't mess up the prompt counter, but do | |
1490 | # NOT skip even a blank line if we are in a code block (more is |
|
1489 | # NOT skip even a blank line if we are in a code block (more is | |
1491 | # true) |
|
1490 | # true) | |
1492 | if line or more: |
|
1491 | if line or more: | |
1493 | more = self.push((self.prefilter(line,more))) |
|
1492 | more = self.push((self.prefilter(line,more))) | |
1494 | # IPython's runsource returns None if there was an error |
|
1493 | # IPython's runsource returns None if there was an error | |
1495 | # compiling the code. This allows us to stop processing right |
|
1494 | # compiling the code. This allows us to stop processing right | |
1496 | # away, so the user gets the error message at the right place. |
|
1495 | # away, so the user gets the error message at the right place. | |
1497 | if more is None: |
|
1496 | if more is None: | |
1498 | break |
|
1497 | break | |
1499 | # final newline in case the input didn't have it, so that the code |
|
1498 | # final newline in case the input didn't have it, so that the code | |
1500 | # actually does get executed |
|
1499 | # actually does get executed | |
1501 | if more: |
|
1500 | if more: | |
1502 | self.push('\n') |
|
1501 | self.push('\n') | |
1503 |
|
1502 | |||
1504 | def runsource(self, source, filename="<input>", symbol="single"): |
|
1503 | def runsource(self, source, filename="<input>", symbol="single"): | |
1505 | """Compile and run some source in the interpreter. |
|
1504 | """Compile and run some source in the interpreter. | |
1506 |
|
1505 | |||
1507 | Arguments are as for compile_command(). |
|
1506 | Arguments are as for compile_command(). | |
1508 |
|
1507 | |||
1509 | One several things can happen: |
|
1508 | One several things can happen: | |
1510 |
|
1509 | |||
1511 | 1) The input is incorrect; compile_command() raised an |
|
1510 | 1) The input is incorrect; compile_command() raised an | |
1512 | exception (SyntaxError or OverflowError). A syntax traceback |
|
1511 | exception (SyntaxError or OverflowError). A syntax traceback | |
1513 | will be printed by calling the showsyntaxerror() method. |
|
1512 | will be printed by calling the showsyntaxerror() method. | |
1514 |
|
1513 | |||
1515 | 2) The input is incomplete, and more input is required; |
|
1514 | 2) The input is incomplete, and more input is required; | |
1516 | compile_command() returned None. Nothing happens. |
|
1515 | compile_command() returned None. Nothing happens. | |
1517 |
|
1516 | |||
1518 | 3) The input is complete; compile_command() returned a code |
|
1517 | 3) The input is complete; compile_command() returned a code | |
1519 | object. The code is executed by calling self.runcode() (which |
|
1518 | object. The code is executed by calling self.runcode() (which | |
1520 | also handles run-time exceptions, except for SystemExit). |
|
1519 | also handles run-time exceptions, except for SystemExit). | |
1521 |
|
1520 | |||
1522 | The return value is: |
|
1521 | The return value is: | |
1523 |
|
1522 | |||
1524 | - True in case 2 |
|
1523 | - True in case 2 | |
1525 |
|
1524 | |||
1526 | - False in the other cases, unless an exception is raised, where |
|
1525 | - False in the other cases, unless an exception is raised, where | |
1527 | None is returned instead. This can be used by external callers to |
|
1526 | None is returned instead. This can be used by external callers to | |
1528 | know whether to continue feeding input or not. |
|
1527 | know whether to continue feeding input or not. | |
1529 |
|
1528 | |||
1530 | The return value can be used to decide whether to use sys.ps1 or |
|
1529 | The return value can be used to decide whether to use sys.ps1 or | |
1531 | sys.ps2 to prompt the next line.""" |
|
1530 | sys.ps2 to prompt the next line.""" | |
|
1531 | ||||
1532 | try: |
|
1532 | try: | |
1533 | code = self.compile(source, filename, symbol) |
|
1533 | code = self.compile(source, filename, symbol) | |
1534 | except (OverflowError, SyntaxError, ValueError): |
|
1534 | except (OverflowError, SyntaxError, ValueError): | |
1535 | # Case 1 |
|
1535 | # Case 1 | |
1536 | self.showsyntaxerror(filename) |
|
1536 | self.showsyntaxerror(filename) | |
1537 | return None |
|
1537 | return None | |
1538 |
|
1538 | |||
1539 | if code is None: |
|
1539 | if code is None: | |
1540 | # Case 2 |
|
1540 | # Case 2 | |
1541 | return True |
|
1541 | return True | |
1542 |
|
1542 | |||
1543 | # Case 3 |
|
1543 | # Case 3 | |
1544 |
# We store the code |
|
1544 | # We store the code object so that threaded shells and | |
1545 | # custom exception handlers can access all this info if needed. |
|
1545 | # custom exception handlers can access all this info if needed. | |
1546 | self.code_to_run_src = source |
|
1546 | # The source corresponding to this can be obtained from the | |
|
1547 | # buffer attribute as '\n'.join(self.buffer). | |||
1547 | self.code_to_run = code |
|
1548 | self.code_to_run = code | |
1548 | # now actually execute the code object |
|
1549 | # now actually execute the code object | |
1549 | if self.runcode(code) == 0: |
|
1550 | if self.runcode(code) == 0: | |
1550 | return False |
|
1551 | return False | |
1551 | else: |
|
1552 | else: | |
1552 | return None |
|
1553 | return None | |
1553 |
|
1554 | |||
1554 | def runcode(self,code_obj): |
|
1555 | def runcode(self,code_obj): | |
1555 | """Execute a code object. |
|
1556 | """Execute a code object. | |
1556 |
|
1557 | |||
1557 | When an exception occurs, self.showtraceback() is called to display a |
|
1558 | When an exception occurs, self.showtraceback() is called to display a | |
1558 | traceback. |
|
1559 | traceback. | |
1559 |
|
1560 | |||
1560 | Return value: a flag indicating whether the code to be run completed |
|
1561 | Return value: a flag indicating whether the code to be run completed | |
1561 | successfully: |
|
1562 | successfully: | |
1562 |
|
1563 | |||
1563 | - 0: successful execution. |
|
1564 | - 0: successful execution. | |
1564 | - 1: an error occurred. |
|
1565 | - 1: an error occurred. | |
1565 | """ |
|
1566 | """ | |
1566 |
|
1567 | |||
1567 | # Set our own excepthook in case the user code tries to call it |
|
1568 | # Set our own excepthook in case the user code tries to call it | |
1568 | # directly, so that the IPython crash handler doesn't get triggered |
|
1569 | # directly, so that the IPython crash handler doesn't get triggered | |
1569 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook |
|
1570 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook | |
1570 | outflag = 1 # happens in more places, so it's easier as default |
|
1571 | outflag = 1 # happens in more places, so it's easier as default | |
1571 | try: |
|
1572 | try: | |
1572 | try: |
|
1573 | try: | |
1573 | exec code_obj in self.locals |
|
1574 | exec code_obj in self.locals | |
1574 | finally: |
|
1575 | finally: | |
1575 | # Reset our crash handler in place |
|
1576 | # Reset our crash handler in place | |
1576 | sys.excepthook = old_excepthook |
|
1577 | sys.excepthook = old_excepthook | |
1577 | except SystemExit: |
|
1578 | except SystemExit: | |
1578 | self.resetbuffer() |
|
1579 | self.resetbuffer() | |
1579 | self.showtraceback() |
|
1580 | self.showtraceback() | |
1580 | warn( __builtin__.exit,level=1) |
|
1581 | warn( __builtin__.exit,level=1) | |
1581 | except self.custom_exceptions: |
|
1582 | except self.custom_exceptions: | |
1582 | etype,value,tb = sys.exc_info() |
|
1583 | etype,value,tb = sys.exc_info() | |
1583 | self.CustomTB(etype,value,tb) |
|
1584 | self.CustomTB(etype,value,tb) | |
1584 | except: |
|
1585 | except: | |
1585 | self.showtraceback() |
|
1586 | self.showtraceback() | |
1586 | else: |
|
1587 | else: | |
1587 | outflag = 0 |
|
1588 | outflag = 0 | |
1588 | if code.softspace(sys.stdout, 0): |
|
1589 | if code.softspace(sys.stdout, 0): | |
1589 |
|
1590 | |||
1590 | # Flush out code object which has been run (and source) |
|
1591 | # Flush out code object which has been run (and source) | |
1591 | self.code_to_run = None |
|
1592 | self.code_to_run = None | |
1592 | self.code_to_run_src = '' |
|
|||
1593 | return outflag |
|
1593 | return outflag | |
1594 |
|
1594 | |||
1595 | def raw_input(self, prompt=""): |
|
1595 | def raw_input(self, prompt=""): | |
1596 | """Write a prompt and read a line. |
|
1596 | """Write a prompt and read a line. | |
1597 |
|
1597 | |||
1598 | The returned line does not include the trailing newline. |
|
1598 | The returned line does not include the trailing newline. | |
1599 | When the user enters the EOF key sequence, EOFError is raised. |
|
1599 | When the user enters the EOF key sequence, EOFError is raised. | |
1600 |
|
1600 | |||
1601 | The base implementation uses the built-in function |
|
1601 | The base implementation uses the built-in function | |
1602 | raw_input(); a subclass may replace this with a different |
|
1602 | raw_input(); a subclass may replace this with a different | |
1603 | implementation. |
|
1603 | implementation. | |
1604 | """ |
|
1604 | """ | |
1605 | return self.prefilter(raw_input_original(prompt), |
|
1605 | return self.prefilter(raw_input_original(prompt), | |
1606 | prompt==self.outputcache.prompt2) |
|
1606 | prompt==self.outputcache.prompt2) | |
1607 |
|
1607 | |||
1608 | def split_user_input(self,line): |
|
1608 | def split_user_input(self,line): | |
1609 | """Split user input into pre-char, function part and rest.""" |
|
1609 | """Split user input into pre-char, function part and rest.""" | |
1610 |
|
1610 | |||
1611 | lsplit = self.line_split.match(line) |
|
1611 | lsplit = self.line_split.match(line) | |
1612 | if lsplit is None: # no regexp match returns None |
|
1612 | if lsplit is None: # no regexp match returns None | |
1613 | try: |
|
1613 | try: | |
1614 | iFun,theRest = line.split(None,1) |
|
1614 | iFun,theRest = line.split(None,1) | |
1615 | except ValueError: |
|
1615 | except ValueError: | |
1616 | iFun,theRest = line,'' |
|
1616 | iFun,theRest = line,'' | |
1617 | pre = re.match('^(\s*)(.*)',line).groups()[0] |
|
1617 | pre = re.match('^(\s*)(.*)',line).groups()[0] | |
1618 | else: |
|
1618 | else: | |
1619 | pre,iFun,theRest = lsplit.groups() |
|
1619 | pre,iFun,theRest = lsplit.groups() | |
1620 |
|
1620 | |||
1621 | #print 'line:<%s>' % line # dbg |
|
1621 | #print 'line:<%s>' % line # dbg | |
1622 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg |
|
1622 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg | |
1623 | return pre,iFun.strip(),theRest |
|
1623 | return pre,iFun.strip(),theRest | |
1624 |
|
1624 | |||
1625 | def _prefilter(self, line, continue_prompt): |
|
1625 | def _prefilter(self, line, continue_prompt): | |
1626 | """Calls different preprocessors, depending on the form of line.""" |
|
1626 | """Calls different preprocessors, depending on the form of line.""" | |
1627 |
|
1627 | |||
1628 | # All handlers *must* return a value, even if it's blank (''). |
|
1628 | # All handlers *must* return a value, even if it's blank (''). | |
1629 |
|
1629 | |||
1630 | # Lines are NOT logged here. Handlers should process the line as |
|
1630 | # Lines are NOT logged here. Handlers should process the line as | |
1631 | # needed, update the cache AND log it (so that the input cache array |
|
1631 | # needed, update the cache AND log it (so that the input cache array | |
1632 | # stays synced). |
|
1632 | # stays synced). | |
1633 |
|
1633 | |||
1634 | # This function is _very_ delicate, and since it's also the one which |
|
1634 | # This function is _very_ delicate, and since it's also the one which | |
1635 | # determines IPython's response to user input, it must be as efficient |
|
1635 | # determines IPython's response to user input, it must be as efficient | |
1636 | # as possible. For this reason it has _many_ returns in it, trying |
|
1636 | # as possible. For this reason it has _many_ returns in it, trying | |
1637 | # always to exit as quickly as it can figure out what it needs to do. |
|
1637 | # always to exit as quickly as it can figure out what it needs to do. | |
1638 |
|
1638 | |||
1639 | # This function is the main responsible for maintaining IPython's |
|
1639 | # This function is the main responsible for maintaining IPython's | |
1640 | # behavior respectful of Python's semantics. So be _very_ careful if |
|
1640 | # behavior respectful of Python's semantics. So be _very_ careful if | |
1641 | # making changes to anything here. |
|
1641 | # making changes to anything here. | |
1642 |
|
1642 | |||
1643 | #..................................................................... |
|
1643 | #..................................................................... | |
1644 | # Code begins |
|
1644 | # Code begins | |
1645 |
|
1645 | |||
1646 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg |
|
1646 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg | |
1647 |
|
1647 | |||
1648 | # save the line away in case we crash, so the post-mortem handler can |
|
1648 | # save the line away in case we crash, so the post-mortem handler can | |
1649 | # record it |
|
1649 | # record it | |
1650 | self._last_input_line = line |
|
1650 | self._last_input_line = line | |
1651 |
|
1651 | |||
1652 | #print '***line: <%s>' % line # dbg |
|
1652 | #print '***line: <%s>' % line # dbg | |
1653 |
|
1653 | |||
1654 | # the input history needs to track even empty lines |
|
1654 | # the input history needs to track even empty lines | |
1655 | if not line.strip(): |
|
1655 | if not line.strip(): | |
1656 | if not continue_prompt: |
|
1656 | if not continue_prompt: | |
1657 | self.outputcache.prompt_count -= 1 |
|
1657 | self.outputcache.prompt_count -= 1 | |
1658 | return self.handle_normal('',continue_prompt) |
|
1658 | return self.handle_normal('',continue_prompt) | |
1659 |
|
1659 | |||
1660 | # print '***cont',continue_prompt # dbg |
|
1660 | # print '***cont',continue_prompt # dbg | |
1661 | # special handlers are only allowed for single line statements |
|
1661 | # special handlers are only allowed for single line statements | |
1662 | if continue_prompt and not self.rc.multi_line_specials: |
|
1662 | if continue_prompt and not self.rc.multi_line_specials: | |
1663 | return self.handle_normal(line,continue_prompt) |
|
1663 | return self.handle_normal(line,continue_prompt) | |
1664 |
|
1664 | |||
1665 | # For the rest, we need the structure of the input |
|
1665 | # For the rest, we need the structure of the input | |
1666 | pre,iFun,theRest = self.split_user_input(line) |
|
1666 | pre,iFun,theRest = self.split_user_input(line) | |
1667 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1667 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1668 |
|
1668 | |||
1669 | # First check for explicit escapes in the last/first character |
|
1669 | # First check for explicit escapes in the last/first character | |
1670 | handler = None |
|
1670 | handler = None | |
1671 | if line[-1] == self.ESC_HELP: |
|
1671 | if line[-1] == self.ESC_HELP: | |
1672 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end |
|
1672 | handler = self.esc_handlers.get(line[-1]) # the ? can be at the end | |
1673 | if handler is None: |
|
1673 | if handler is None: | |
1674 | # look at the first character of iFun, NOT of line, so we skip |
|
1674 | # look at the first character of iFun, NOT of line, so we skip | |
1675 | # leading whitespace in multiline input |
|
1675 | # leading whitespace in multiline input | |
1676 | handler = self.esc_handlers.get(iFun[0:1]) |
|
1676 | handler = self.esc_handlers.get(iFun[0:1]) | |
1677 | if handler is not None: |
|
1677 | if handler is not None: | |
1678 | return handler(line,continue_prompt,pre,iFun,theRest) |
|
1678 | return handler(line,continue_prompt,pre,iFun,theRest) | |
1679 | # Emacs ipython-mode tags certain input lines |
|
1679 | # Emacs ipython-mode tags certain input lines | |
1680 | if line.endswith('# PYTHON-MODE'): |
|
1680 | if line.endswith('# PYTHON-MODE'): | |
1681 | return self.handle_emacs(line,continue_prompt) |
|
1681 | return self.handle_emacs(line,continue_prompt) | |
1682 |
|
1682 | |||
1683 | # Next, check if we can automatically execute this thing |
|
1683 | # Next, check if we can automatically execute this thing | |
1684 |
|
1684 | |||
1685 | # Allow ! in multi-line statements if multi_line_specials is on: |
|
1685 | # Allow ! in multi-line statements if multi_line_specials is on: | |
1686 | if continue_prompt and self.rc.multi_line_specials and \ |
|
1686 | if continue_prompt and self.rc.multi_line_specials and \ | |
1687 | iFun.startswith(self.ESC_SHELL): |
|
1687 | iFun.startswith(self.ESC_SHELL): | |
1688 | return self.handle_shell_escape(line,continue_prompt, |
|
1688 | return self.handle_shell_escape(line,continue_prompt, | |
1689 | pre=pre,iFun=iFun, |
|
1689 | pre=pre,iFun=iFun, | |
1690 | theRest=theRest) |
|
1690 | theRest=theRest) | |
1691 |
|
1691 | |||
1692 | # Let's try to find if the input line is a magic fn |
|
1692 | # Let's try to find if the input line is a magic fn | |
1693 | oinfo = None |
|
1693 | oinfo = None | |
1694 | if hasattr(self,'magic_'+iFun): |
|
1694 | if hasattr(self,'magic_'+iFun): | |
1695 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1695 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1696 | if oinfo['ismagic']: |
|
1696 | if oinfo['ismagic']: | |
1697 | # Be careful not to call magics when a variable assignment is |
|
1697 | # Be careful not to call magics when a variable assignment is | |
1698 | # being made (ls='hi', for example) |
|
1698 | # being made (ls='hi', for example) | |
1699 | if self.rc.automagic and \ |
|
1699 | if self.rc.automagic and \ | |
1700 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ |
|
1700 | (len(theRest)==0 or theRest[0] not in '!=()<>,') and \ | |
1701 | (self.rc.multi_line_specials or not continue_prompt): |
|
1701 | (self.rc.multi_line_specials or not continue_prompt): | |
1702 | return self.handle_magic(line,continue_prompt, |
|
1702 | return self.handle_magic(line,continue_prompt, | |
1703 | pre,iFun,theRest) |
|
1703 | pre,iFun,theRest) | |
1704 | else: |
|
1704 | else: | |
1705 | return self.handle_normal(line,continue_prompt) |
|
1705 | return self.handle_normal(line,continue_prompt) | |
1706 |
|
1706 | |||
1707 | # If the rest of the line begins with an (in)equality, assginment or |
|
1707 | # If the rest of the line begins with an (in)equality, assginment or | |
1708 | # function call, we should not call _ofind but simply execute it. |
|
1708 | # function call, we should not call _ofind but simply execute it. | |
1709 | # This avoids spurious geattr() accesses on objects upon assignment. |
|
1709 | # This avoids spurious geattr() accesses on objects upon assignment. | |
1710 | # |
|
1710 | # | |
1711 | # It also allows users to assign to either alias or magic names true |
|
1711 | # It also allows users to assign to either alias or magic names true | |
1712 | # python variables (the magic/alias systems always take second seat to |
|
1712 | # python variables (the magic/alias systems always take second seat to | |
1713 | # true python code). |
|
1713 | # true python code). | |
1714 | if theRest and theRest[0] in '!=()': |
|
1714 | if theRest and theRest[0] in '!=()': | |
1715 | return self.handle_normal(line,continue_prompt) |
|
1715 | return self.handle_normal(line,continue_prompt) | |
1716 |
|
1716 | |||
1717 | if oinfo is None: |
|
1717 | if oinfo is None: | |
1718 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic |
|
1718 | oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic | |
1719 |
|
1719 | |||
1720 | if not oinfo['found']: |
|
1720 | if not oinfo['found']: | |
1721 | return self.handle_normal(line,continue_prompt) |
|
1721 | return self.handle_normal(line,continue_prompt) | |
1722 | else: |
|
1722 | else: | |
1723 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg |
|
1723 | #print 'iFun <%s> rest <%s>' % (iFun,theRest) # dbg | |
1724 | if oinfo['isalias']: |
|
1724 | if oinfo['isalias']: | |
1725 | return self.handle_alias(line,continue_prompt, |
|
1725 | return self.handle_alias(line,continue_prompt, | |
1726 | pre,iFun,theRest) |
|
1726 | pre,iFun,theRest) | |
1727 |
|
1727 | |||
1728 | if self.rc.autocall and \ |
|
1728 | if self.rc.autocall and \ | |
1729 | not self.re_exclude_auto.match(theRest) and \ |
|
1729 | not self.re_exclude_auto.match(theRest) and \ | |
1730 | self.re_fun_name.match(iFun) and \ |
|
1730 | self.re_fun_name.match(iFun) and \ | |
1731 | callable(oinfo['obj']) : |
|
1731 | callable(oinfo['obj']) : | |
1732 | #print 'going auto' # dbg |
|
1732 | #print 'going auto' # dbg | |
1733 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) |
|
1733 | return self.handle_auto(line,continue_prompt,pre,iFun,theRest) | |
1734 | else: |
|
1734 | else: | |
1735 | #print 'was callable?', callable(oinfo['obj']) # dbg |
|
1735 | #print 'was callable?', callable(oinfo['obj']) # dbg | |
1736 | return self.handle_normal(line,continue_prompt) |
|
1736 | return self.handle_normal(line,continue_prompt) | |
1737 |
|
1737 | |||
1738 | # If we get here, we have a normal Python line. Log and return. |
|
1738 | # If we get here, we have a normal Python line. Log and return. | |
1739 | return self.handle_normal(line,continue_prompt) |
|
1739 | return self.handle_normal(line,continue_prompt) | |
1740 |
|
1740 | |||
1741 | def _prefilter_dumb(self, line, continue_prompt): |
|
1741 | def _prefilter_dumb(self, line, continue_prompt): | |
1742 | """simple prefilter function, for debugging""" |
|
1742 | """simple prefilter function, for debugging""" | |
1743 | return self.handle_normal(line,continue_prompt) |
|
1743 | return self.handle_normal(line,continue_prompt) | |
1744 |
|
1744 | |||
1745 | # Set the default prefilter() function (this can be user-overridden) |
|
1745 | # Set the default prefilter() function (this can be user-overridden) | |
1746 | prefilter = _prefilter |
|
1746 | prefilter = _prefilter | |
1747 |
|
1747 | |||
1748 | def handle_normal(self,line,continue_prompt=None, |
|
1748 | def handle_normal(self,line,continue_prompt=None, | |
1749 | pre=None,iFun=None,theRest=None): |
|
1749 | pre=None,iFun=None,theRest=None): | |
1750 | """Handle normal input lines. Use as a template for handlers.""" |
|
1750 | """Handle normal input lines. Use as a template for handlers.""" | |
1751 |
|
1751 | |||
1752 | self.log(line,continue_prompt) |
|
1752 | self.log(line,continue_prompt) | |
1753 | self.update_cache(line) |
|
1753 | self.update_cache(line) | |
1754 | return line |
|
1754 | return line | |
1755 |
|
1755 | |||
1756 | def handle_alias(self,line,continue_prompt=None, |
|
1756 | def handle_alias(self,line,continue_prompt=None, | |
1757 | pre=None,iFun=None,theRest=None): |
|
1757 | pre=None,iFun=None,theRest=None): | |
1758 | """Handle alias input lines. """ |
|
1758 | """Handle alias input lines. """ | |
1759 |
|
1759 | |||
1760 | theRest = esc_quotes(theRest) |
|
1760 | theRest = esc_quotes(theRest) | |
1761 | line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest) |
|
1761 | line_out = "%s%s.call_alias('%s','%s')" % (pre,self.name,iFun,theRest) | |
1762 | self.log(line_out,continue_prompt) |
|
1762 | self.log(line_out,continue_prompt) | |
1763 | self.update_cache(line_out) |
|
1763 | self.update_cache(line_out) | |
1764 | return line_out |
|
1764 | return line_out | |
1765 |
|
1765 | |||
1766 | def handle_shell_escape(self, line, continue_prompt=None, |
|
1766 | def handle_shell_escape(self, line, continue_prompt=None, | |
1767 | pre=None,iFun=None,theRest=None): |
|
1767 | pre=None,iFun=None,theRest=None): | |
1768 | """Execute the line in a shell, empty return value""" |
|
1768 | """Execute the line in a shell, empty return value""" | |
1769 |
|
1769 | |||
|
1770 | #print 'line in :', `line` # dbg | |||
1770 | # Example of a special handler. Others follow a similar pattern. |
|
1771 | # Example of a special handler. Others follow a similar pattern. | |
1771 | if continue_prompt: # multi-line statements |
|
1772 | if continue_prompt: # multi-line statements | |
1772 | if iFun.startswith('!!'): |
|
1773 | if iFun.startswith('!!'): | |
1773 | print 'SyntaxError: !! is not allowed in multiline statements' |
|
1774 | print 'SyntaxError: !! is not allowed in multiline statements' | |
1774 | return pre |
|
1775 | return pre | |
1775 | else: |
|
1776 | else: | |
1776 | cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"') |
|
1777 | cmd = ("%s %s" % (iFun[1:],theRest)).replace('"','\\"') | |
1777 | line_out = '%s%s.system("%s")' % (pre,self.name,cmd) |
|
1778 | line_out = '%s%s.system("%s")' % (pre,self.name,cmd) | |
|
1779 | #line_out = ('%s%s.system(' % (pre,self.name)) + repr(cmd) + ')' | |||
1778 | else: # single-line input |
|
1780 | else: # single-line input | |
1779 | if line.startswith('!!'): |
|
1781 | if line.startswith('!!'): | |
1780 | # rewrite iFun/theRest to properly hold the call to %sx and |
|
1782 | # rewrite iFun/theRest to properly hold the call to %sx and | |
1781 | # the actual command to be executed, so handle_magic can work |
|
1783 | # the actual command to be executed, so handle_magic can work | |
1782 | # correctly |
|
1784 | # correctly | |
1783 | theRest = '%s %s' % (iFun[2:],theRest) |
|
1785 | theRest = '%s %s' % (iFun[2:],theRest) | |
1784 | iFun = 'sx' |
|
1786 | iFun = 'sx' | |
1785 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), |
|
1787 | return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,line[2:]), | |
1786 | continue_prompt,pre,iFun,theRest) |
|
1788 | continue_prompt,pre,iFun,theRest) | |
1787 | else: |
|
1789 | else: | |
1788 | cmd = esc_quotes(line[1:]) |
|
1790 | cmd = esc_quotes(line[1:]) | |
1789 | line_out = '%s.system("%s")' % (self.name,cmd) |
|
1791 | line_out = '%s.system("%s")' % (self.name,cmd) | |
|
1792 | #line_out = ('%s.system(' % self.name) + repr(cmd)+ ')' | |||
1790 | # update cache/log and return |
|
1793 | # update cache/log and return | |
1791 | self.log(line_out,continue_prompt) |
|
1794 | self.log(line_out,continue_prompt) | |
1792 | self.update_cache(line_out) # readline cache gets normal line |
|
1795 | self.update_cache(line_out) # readline cache gets normal line | |
|
1796 | #print 'line out r:', `line_out` # dbg | |||
|
1797 | #print 'line out s:', line_out # dbg | |||
1793 | return line_out |
|
1798 | return line_out | |
1794 |
|
1799 | |||
1795 | def handle_magic(self, line, continue_prompt=None, |
|
1800 | def handle_magic(self, line, continue_prompt=None, | |
1796 | pre=None,iFun=None,theRest=None): |
|
1801 | pre=None,iFun=None,theRest=None): | |
1797 | """Execute magic functions. |
|
1802 | """Execute magic functions. | |
1798 |
|
1803 | |||
1799 | Also log them with a prepended # so the log is clean Python.""" |
|
1804 | Also log them with a prepended # so the log is clean Python.""" | |
1800 |
|
1805 | |||
1801 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) |
|
1806 | cmd = '%sipmagic("%s")' % (pre,esc_quotes('%s %s' % (iFun,theRest))) | |
1802 | self.log(cmd,continue_prompt) |
|
1807 | self.log(cmd,continue_prompt) | |
1803 | self.update_cache(line) |
|
1808 | self.update_cache(line) | |
1804 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg |
|
1809 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg | |
1805 | return cmd |
|
1810 | return cmd | |
1806 |
|
1811 | |||
1807 | def handle_auto(self, line, continue_prompt=None, |
|
1812 | def handle_auto(self, line, continue_prompt=None, | |
1808 | pre=None,iFun=None,theRest=None): |
|
1813 | pre=None,iFun=None,theRest=None): | |
1809 | """Hande lines which can be auto-executed, quoting if requested.""" |
|
1814 | """Hande lines which can be auto-executed, quoting if requested.""" | |
1810 |
|
1815 | |||
1811 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1816 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg | |
1812 |
|
1817 | |||
1813 | # This should only be active for single-line input! |
|
1818 | # This should only be active for single-line input! | |
1814 | if continue_prompt: |
|
1819 | if continue_prompt: | |
1815 | return line |
|
1820 | return line | |
1816 |
|
1821 | |||
1817 | if pre == self.ESC_QUOTE: |
|
1822 | if pre == self.ESC_QUOTE: | |
1818 | # Auto-quote splitting on whitespace |
|
1823 | # Auto-quote splitting on whitespace | |
1819 | newcmd = '%s("%s")\n' % (iFun,'", "'.join(theRest.split()) ) |
|
1824 | newcmd = '%s("%s")\n' % (iFun,'", "'.join(theRest.split()) ) | |
1820 | elif pre == self.ESC_QUOTE2: |
|
1825 | elif pre == self.ESC_QUOTE2: | |
1821 | # Auto-quote whole string |
|
1826 | # Auto-quote whole string | |
1822 | newcmd = '%s("%s")\n' % (iFun,theRest) |
|
1827 | newcmd = '%s("%s")\n' % (iFun,theRest) | |
1823 | else: |
|
1828 | else: | |
1824 | # Auto-paren |
|
1829 | # Auto-paren | |
1825 | if theRest[0:1] in ('=','['): |
|
1830 | if theRest[0:1] in ('=','['): | |
1826 | # Don't autocall in these cases. They can be either |
|
1831 | # Don't autocall in these cases. They can be either | |
1827 | # rebindings of an existing callable's name, or item access |
|
1832 | # rebindings of an existing callable's name, or item access | |
1828 | # for an object which is BOTH callable and implements |
|
1833 | # for an object which is BOTH callable and implements | |
1829 | # __getitem__. |
|
1834 | # __getitem__. | |
1830 | return '%s %s\n' % (iFun,theRest) |
|
1835 | return '%s %s\n' % (iFun,theRest) | |
1831 | if theRest.endswith(';'): |
|
1836 | if theRest.endswith(';'): | |
1832 | newcmd = '%s(%s);\n' % (iFun.rstrip(),theRest[:-1]) |
|
1837 | newcmd = '%s(%s);\n' % (iFun.rstrip(),theRest[:-1]) | |
1833 | else: |
|
1838 | else: | |
1834 | newcmd = '%s(%s)\n' % (iFun.rstrip(),theRest) |
|
1839 | newcmd = '%s(%s)\n' % (iFun.rstrip(),theRest) | |
1835 |
|
1840 | |||
1836 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd, |
|
1841 | print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd, | |
1837 | # log what is now valid Python, not the actual user input (without the |
|
1842 | # log what is now valid Python, not the actual user input (without the | |
1838 | # final newline) |
|
1843 | # final newline) | |
1839 | self.log(newcmd.strip(),continue_prompt) |
|
1844 | self.log(newcmd.strip(),continue_prompt) | |
1840 | return newcmd |
|
1845 | return newcmd | |
1841 |
|
1846 | |||
1842 | def handle_help(self, line, continue_prompt=None, |
|
1847 | def handle_help(self, line, continue_prompt=None, | |
1843 | pre=None,iFun=None,theRest=None): |
|
1848 | pre=None,iFun=None,theRest=None): | |
1844 | """Try to get some help for the object. |
|
1849 | """Try to get some help for the object. | |
1845 |
|
1850 | |||
1846 | obj? or ?obj -> basic information. |
|
1851 | obj? or ?obj -> basic information. | |
1847 | obj?? or ??obj -> more details. |
|
1852 | obj?? or ??obj -> more details. | |
1848 | """ |
|
1853 | """ | |
1849 |
|
1854 | |||
1850 | # We need to make sure that we don't process lines which would be |
|
1855 | # We need to make sure that we don't process lines which would be | |
1851 | # otherwise valid python, such as "x=1 # what?" |
|
1856 | # otherwise valid python, such as "x=1 # what?" | |
1852 | try: |
|
1857 | try: | |
1853 | code.compile_command(line) |
|
1858 | code.compile_command(line) | |
1854 | except SyntaxError: |
|
1859 | except SyntaxError: | |
1855 | # We should only handle as help stuff which is NOT valid syntax |
|
1860 | # We should only handle as help stuff which is NOT valid syntax | |
1856 | if line[0]==self.ESC_HELP: |
|
1861 | if line[0]==self.ESC_HELP: | |
1857 | line = line[1:] |
|
1862 | line = line[1:] | |
1858 | elif line[-1]==self.ESC_HELP: |
|
1863 | elif line[-1]==self.ESC_HELP: | |
1859 | line = line[:-1] |
|
1864 | line = line[:-1] | |
1860 | self.log('#?'+line) |
|
1865 | self.log('#?'+line) | |
1861 | self.update_cache(line) |
|
1866 | self.update_cache(line) | |
1862 | if line: |
|
1867 | if line: | |
1863 | self.magic_pinfo(line) |
|
1868 | self.magic_pinfo(line) | |
1864 | else: |
|
1869 | else: | |
1865 | page(self.usage,screen_lines=self.rc.screen_length) |
|
1870 | page(self.usage,screen_lines=self.rc.screen_length) | |
1866 | return '' # Empty string is needed here! |
|
1871 | return '' # Empty string is needed here! | |
1867 | except: |
|
1872 | except: | |
1868 | # Pass any other exceptions through to the normal handler |
|
1873 | # Pass any other exceptions through to the normal handler | |
1869 | return self.handle_normal(line,continue_prompt) |
|
1874 | return self.handle_normal(line,continue_prompt) | |
1870 | else: |
|
1875 | else: | |
1871 | # If the code compiles ok, we should handle it normally |
|
1876 | # If the code compiles ok, we should handle it normally | |
1872 | return self.handle_normal(line,continue_prompt) |
|
1877 | return self.handle_normal(line,continue_prompt) | |
1873 |
|
1878 | |||
1874 | def handle_emacs(self,line,continue_prompt=None, |
|
1879 | def handle_emacs(self,line,continue_prompt=None, | |
1875 | pre=None,iFun=None,theRest=None): |
|
1880 | pre=None,iFun=None,theRest=None): | |
1876 | """Handle input lines marked by python-mode.""" |
|
1881 | """Handle input lines marked by python-mode.""" | |
1877 |
|
1882 | |||
1878 | # Currently, nothing is done. Later more functionality can be added |
|
1883 | # Currently, nothing is done. Later more functionality can be added | |
1879 | # here if needed. |
|
1884 | # here if needed. | |
1880 |
|
1885 | |||
1881 | # The input cache shouldn't be updated |
|
1886 | # The input cache shouldn't be updated | |
1882 |
|
1887 | |||
1883 | return line |
|
1888 | return line | |
1884 |
|
1889 | |||
1885 | def write(self,data): |
|
1890 | def write(self,data): | |
1886 | """Write a string to the default output""" |
|
1891 | """Write a string to the default output""" | |
1887 | Term.cout.write(data) |
|
1892 | Term.cout.write(data) | |
1888 |
|
1893 | |||
1889 | def write_err(self,data): |
|
1894 | def write_err(self,data): | |
1890 | """Write a string to the default error output""" |
|
1895 | """Write a string to the default error output""" | |
1891 | Term.cerr.write(data) |
|
1896 | Term.cerr.write(data) | |
1892 |
|
1897 | |||
1893 | def safe_execfile(self,fname,*where,**kw): |
|
1898 | def safe_execfile(self,fname,*where,**kw): | |
1894 | fname = os.path.expanduser(fname) |
|
1899 | fname = os.path.expanduser(fname) | |
1895 |
|
1900 | |||
1896 | # find things also in current directory |
|
1901 | # find things also in current directory | |
1897 | dname = os.path.dirname(fname) |
|
1902 | dname = os.path.dirname(fname) | |
1898 | if not sys.path.count(dname): |
|
1903 | if not sys.path.count(dname): | |
1899 | sys.path.append(dname) |
|
1904 | sys.path.append(dname) | |
1900 |
|
1905 | |||
1901 | try: |
|
1906 | try: | |
1902 | xfile = open(fname) |
|
1907 | xfile = open(fname) | |
1903 | except: |
|
1908 | except: | |
1904 | print >> Term.cerr, \ |
|
1909 | print >> Term.cerr, \ | |
1905 | 'Could not open file <%s> for safe execution.' % fname |
|
1910 | 'Could not open file <%s> for safe execution.' % fname | |
1906 | return None |
|
1911 | return None | |
1907 |
|
1912 | |||
1908 | kw.setdefault('islog',0) |
|
1913 | kw.setdefault('islog',0) | |
1909 | kw.setdefault('quiet',1) |
|
1914 | kw.setdefault('quiet',1) | |
1910 | kw.setdefault('exit_ignore',0) |
|
1915 | kw.setdefault('exit_ignore',0) | |
1911 | first = xfile.readline() |
|
1916 | first = xfile.readline() | |
1912 | _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip() |
|
1917 | _LOGHEAD = str(self.LOGHEAD).split('\n',1)[0].strip() | |
1913 | xfile.close() |
|
1918 | xfile.close() | |
1914 | # line by line execution |
|
1919 | # line by line execution | |
1915 | if first.startswith(_LOGHEAD) or kw['islog']: |
|
1920 | if first.startswith(_LOGHEAD) or kw['islog']: | |
1916 | print 'Loading log file <%s> one line at a time...' % fname |
|
1921 | print 'Loading log file <%s> one line at a time...' % fname | |
1917 | if kw['quiet']: |
|
1922 | if kw['quiet']: | |
1918 | stdout_save = sys.stdout |
|
1923 | stdout_save = sys.stdout | |
1919 | sys.stdout = StringIO.StringIO() |
|
1924 | sys.stdout = StringIO.StringIO() | |
1920 | try: |
|
1925 | try: | |
1921 | globs,locs = where[0:2] |
|
1926 | globs,locs = where[0:2] | |
1922 | except: |
|
1927 | except: | |
1923 | try: |
|
1928 | try: | |
1924 | globs = locs = where[0] |
|
1929 | globs = locs = where[0] | |
1925 | except: |
|
1930 | except: | |
1926 | globs = locs = globals() |
|
1931 | globs = locs = globals() | |
1927 | badblocks = [] |
|
1932 | badblocks = [] | |
1928 |
|
1933 | |||
1929 | # we also need to identify indented blocks of code when replaying |
|
1934 | # we also need to identify indented blocks of code when replaying | |
1930 | # logs and put them together before passing them to an exec |
|
1935 | # logs and put them together before passing them to an exec | |
1931 | # statement. This takes a bit of regexp and look-ahead work in the |
|
1936 | # statement. This takes a bit of regexp and look-ahead work in the | |
1932 | # file. It's easiest if we swallow the whole thing in memory |
|
1937 | # file. It's easiest if we swallow the whole thing in memory | |
1933 | # first, and manually walk through the lines list moving the |
|
1938 | # first, and manually walk through the lines list moving the | |
1934 | # counter ourselves. |
|
1939 | # counter ourselves. | |
1935 | indent_re = re.compile('\s+\S') |
|
1940 | indent_re = re.compile('\s+\S') | |
1936 | xfile = open(fname) |
|
1941 | xfile = open(fname) | |
1937 | filelines = xfile.readlines() |
|
1942 | filelines = xfile.readlines() | |
1938 | xfile.close() |
|
1943 | xfile.close() | |
1939 | nlines = len(filelines) |
|
1944 | nlines = len(filelines) | |
1940 | lnum = 0 |
|
1945 | lnum = 0 | |
1941 | while lnum < nlines: |
|
1946 | while lnum < nlines: | |
1942 | line = filelines[lnum] |
|
1947 | line = filelines[lnum] | |
1943 | lnum += 1 |
|
1948 | lnum += 1 | |
1944 | # don't re-insert logger status info into cache |
|
1949 | # don't re-insert logger status info into cache | |
1945 | if line.startswith('#log#'): |
|
1950 | if line.startswith('#log#'): | |
1946 | continue |
|
1951 | continue | |
1947 | elif line.startswith('#%s'% self.ESC_MAGIC): |
|
1952 | elif line.startswith('#%s'% self.ESC_MAGIC): | |
1948 | self.update_cache(line[1:]) |
|
1953 | self.update_cache(line[1:]) | |
1949 | line = magic2python(line) |
|
1954 | line = magic2python(line) | |
1950 | elif line.startswith('#!'): |
|
1955 | elif line.startswith('#!'): | |
1951 | self.update_cache(line[1:]) |
|
1956 | self.update_cache(line[1:]) | |
1952 | else: |
|
1957 | else: | |
1953 | # build a block of code (maybe a single line) for execution |
|
1958 | # build a block of code (maybe a single line) for execution | |
1954 | block = line |
|
1959 | block = line | |
1955 | try: |
|
1960 | try: | |
1956 | next = filelines[lnum] # lnum has already incremented |
|
1961 | next = filelines[lnum] # lnum has already incremented | |
1957 | except: |
|
1962 | except: | |
1958 | next = None |
|
1963 | next = None | |
1959 | while next and indent_re.match(next): |
|
1964 | while next and indent_re.match(next): | |
1960 | block += next |
|
1965 | block += next | |
1961 | lnum += 1 |
|
1966 | lnum += 1 | |
1962 | try: |
|
1967 | try: | |
1963 | next = filelines[lnum] |
|
1968 | next = filelines[lnum] | |
1964 | except: |
|
1969 | except: | |
1965 | next = None |
|
1970 | next = None | |
1966 | # now execute the block of one or more lines |
|
1971 | # now execute the block of one or more lines | |
1967 | try: |
|
1972 | try: | |
1968 | exec block in globs,locs |
|
1973 | exec block in globs,locs | |
1969 | self.update_cache(block.rstrip()) |
|
1974 | self.update_cache(block.rstrip()) | |
1970 | except SystemExit: |
|
1975 | except SystemExit: | |
1971 | pass |
|
1976 | pass | |
1972 | except: |
|
1977 | except: | |
1973 | badblocks.append(block.rstrip()) |
|
1978 | badblocks.append(block.rstrip()) | |
1974 | if kw['quiet']: # restore stdout |
|
1979 | if kw['quiet']: # restore stdout | |
1975 | sys.stdout.close() |
|
1980 | sys.stdout.close() | |
1976 | sys.stdout = stdout_save |
|
1981 | sys.stdout = stdout_save | |
1977 | print 'Finished replaying log file <%s>' % fname |
|
1982 | print 'Finished replaying log file <%s>' % fname | |
1978 | if badblocks: |
|
1983 | if badblocks: | |
1979 | print >> sys.stderr, \ |
|
1984 | print >> sys.stderr, \ | |
1980 | '\nThe following lines/blocks in file <%s> reported errors:' \ |
|
1985 | '\nThe following lines/blocks in file <%s> reported errors:' \ | |
1981 | % fname |
|
1986 | % fname | |
1982 | for badline in badblocks: |
|
1987 | for badline in badblocks: | |
1983 | print >> sys.stderr, badline |
|
1988 | print >> sys.stderr, badline | |
1984 | else: # regular file execution |
|
1989 | else: # regular file execution | |
1985 | try: |
|
1990 | try: | |
1986 | execfile(fname,*where) |
|
1991 | execfile(fname,*where) | |
1987 | except SyntaxError: |
|
1992 | except SyntaxError: | |
1988 | etype, evalue = sys.exc_info()[0:2] |
|
1993 | etype, evalue = sys.exc_info()[0:2] | |
1989 | self.SyntaxTB(etype,evalue,[]) |
|
1994 | self.SyntaxTB(etype,evalue,[]) | |
1990 | warn('Failure executing file: <%s>' % fname) |
|
1995 | warn('Failure executing file: <%s>' % fname) | |
1991 | except SystemExit,status: |
|
1996 | except SystemExit,status: | |
1992 | if not kw['exit_ignore']: |
|
1997 | if not kw['exit_ignore']: | |
1993 | self.InteractiveTB() |
|
1998 | self.InteractiveTB() | |
1994 | warn('Failure executing file: <%s>' % fname) |
|
1999 | warn('Failure executing file: <%s>' % fname) | |
1995 | except: |
|
2000 | except: | |
1996 | self.InteractiveTB() |
|
2001 | self.InteractiveTB() | |
1997 | warn('Failure executing file: <%s>' % fname) |
|
2002 | warn('Failure executing file: <%s>' % fname) | |
1998 |
|
2003 | |||
1999 | #************************* end of file <iplib.py> ***************************** |
|
2004 | #************************* end of file <iplib.py> ***************************** |
@@ -1,859 +1,860 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | ultraTB.py -- Spice up your tracebacks! |
|
3 | ultraTB.py -- Spice up your tracebacks! | |
4 |
|
4 | |||
5 | * ColorTB |
|
5 | * ColorTB | |
6 | I've always found it a bit hard to visually parse tracebacks in Python. The |
|
6 | I've always found it a bit hard to visually parse tracebacks in Python. The | |
7 | ColorTB class is a solution to that problem. It colors the different parts of a |
|
7 | ColorTB class is a solution to that problem. It colors the different parts of a | |
8 | traceback in a manner similar to what you would expect from a syntax-highlighting |
|
8 | traceback in a manner similar to what you would expect from a syntax-highlighting | |
9 | text editor. |
|
9 | text editor. | |
10 |
|
10 | |||
11 | Installation instructions for ColorTB: |
|
11 | Installation instructions for ColorTB: | |
12 | import sys,ultraTB |
|
12 | import sys,ultraTB | |
13 | sys.excepthook = ultraTB.ColorTB() |
|
13 | sys.excepthook = ultraTB.ColorTB() | |
14 |
|
14 | |||
15 | * VerboseTB |
|
15 | * VerboseTB | |
16 | I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds |
|
16 | I've also included a port of Ka-Ping Yee's "cgitb.py" that produces all kinds | |
17 | of useful info when a traceback occurs. Ping originally had it spit out HTML |
|
17 | of useful info when a traceback occurs. Ping originally had it spit out HTML | |
18 | and intended it for CGI programmers, but why should they have all the fun? I |
|
18 | and intended it for CGI programmers, but why should they have all the fun? I | |
19 | altered it to spit out colored text to the terminal. It's a bit overwhelming, |
|
19 | altered it to spit out colored text to the terminal. It's a bit overwhelming, | |
20 | but kind of neat, and maybe useful for long-running programs that you believe |
|
20 | but kind of neat, and maybe useful for long-running programs that you believe | |
21 | are bug-free. If a crash *does* occur in that type of program you want details. |
|
21 | are bug-free. If a crash *does* occur in that type of program you want details. | |
22 | Give it a shot--you'll love it or you'll hate it. |
|
22 | Give it a shot--you'll love it or you'll hate it. | |
23 |
|
23 | |||
24 | Note: |
|
24 | Note: | |
25 |
|
25 | |||
26 | The Verbose mode prints the variables currently visible where the exception |
|
26 | The Verbose mode prints the variables currently visible where the exception | |
27 | happened (shortening their strings if too long). This can potentially be |
|
27 | happened (shortening their strings if too long). This can potentially be | |
28 | very slow, if you happen to have a huge data structure whose string |
|
28 | very slow, if you happen to have a huge data structure whose string | |
29 | representation is complex to compute. Your computer may appear to freeze for |
|
29 | representation is complex to compute. Your computer may appear to freeze for | |
30 | a while with cpu usage at 100%. If this occurs, you can cancel the traceback |
|
30 | a while with cpu usage at 100%. If this occurs, you can cancel the traceback | |
31 | with Ctrl-C (maybe hitting it more than once). |
|
31 | with Ctrl-C (maybe hitting it more than once). | |
32 |
|
32 | |||
33 | If you encounter this kind of situation often, you may want to use the |
|
33 | If you encounter this kind of situation often, you may want to use the | |
34 | Verbose_novars mode instead of the regular Verbose, which avoids formatting |
|
34 | Verbose_novars mode instead of the regular Verbose, which avoids formatting | |
35 | variables (but otherwise includes the information and context given by |
|
35 | variables (but otherwise includes the information and context given by | |
36 | Verbose). |
|
36 | Verbose). | |
37 |
|
37 | |||
38 |
|
38 | |||
39 | Installation instructions for ColorTB: |
|
39 | Installation instructions for ColorTB: | |
40 | import sys,ultraTB |
|
40 | import sys,ultraTB | |
41 | sys.excepthook = ultraTB.VerboseTB() |
|
41 | sys.excepthook = ultraTB.VerboseTB() | |
42 |
|
42 | |||
43 | Note: Much of the code in this module was lifted verbatim from the standard |
|
43 | Note: Much of the code in this module was lifted verbatim from the standard | |
44 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. |
|
44 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. | |
45 |
|
45 | |||
46 | * Color schemes |
|
46 | * Color schemes | |
47 | The colors are defined in the class TBTools through the use of the |
|
47 | The colors are defined in the class TBTools through the use of the | |
48 | ColorSchemeTable class. Currently the following exist: |
|
48 | ColorSchemeTable class. Currently the following exist: | |
49 |
|
49 | |||
50 | - NoColor: allows all of this module to be used in any terminal (the color |
|
50 | - NoColor: allows all of this module to be used in any terminal (the color | |
51 | escapes are just dummy blank strings). |
|
51 | escapes are just dummy blank strings). | |
52 |
|
52 | |||
53 | - Linux: is meant to look good in a terminal like the Linux console (black |
|
53 | - Linux: is meant to look good in a terminal like the Linux console (black | |
54 | or very dark background). |
|
54 | or very dark background). | |
55 |
|
55 | |||
56 | - LightBG: similar to Linux but swaps dark/light colors to be more readable |
|
56 | - LightBG: similar to Linux but swaps dark/light colors to be more readable | |
57 | in light background terminals. |
|
57 | in light background terminals. | |
58 |
|
58 | |||
59 | You can implement other color schemes easily, the syntax is fairly |
|
59 | You can implement other color schemes easily, the syntax is fairly | |
60 | self-explanatory. Please send back new schemes you develop to the author for |
|
60 | self-explanatory. Please send back new schemes you develop to the author for | |
61 | possible inclusion in future releases. |
|
61 | possible inclusion in future releases. | |
62 |
|
62 | |||
63 |
$Id: ultraTB.py |
|
63 | $Id: ultraTB.py 703 2005-08-16 17:34:44Z fperez $""" | |
64 |
|
64 | |||
65 | #***************************************************************************** |
|
65 | #***************************************************************************** | |
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> |
|
66 | # Copyright (C) 2001 Nathaniel Gray <n8gray@caltech.edu> | |
67 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> |
|
67 | # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu> | |
68 | # |
|
68 | # | |
69 | # Distributed under the terms of the BSD License. The full license is in |
|
69 | # Distributed under the terms of the BSD License. The full license is in | |
70 | # the file COPYING, distributed as part of this software. |
|
70 | # the file COPYING, distributed as part of this software. | |
71 | #***************************************************************************** |
|
71 | #***************************************************************************** | |
72 |
|
72 | |||
73 | from IPython import Release |
|
73 | from IPython import Release | |
74 | __author__ = '%s <%s>\n%s <%s>' % (Release.authors['Nathan']+ |
|
74 | __author__ = '%s <%s>\n%s <%s>' % (Release.authors['Nathan']+ | |
75 | Release.authors['Fernando']) |
|
75 | Release.authors['Fernando']) | |
76 | __license__ = Release.license |
|
76 | __license__ = Release.license | |
77 |
|
77 | |||
78 | # Required modules |
|
78 | # Required modules | |
79 | import sys, os, traceback, types, string, time |
|
79 | import sys, os, traceback, types, string, time | |
80 | import keyword, tokenize, linecache, inspect, pydoc |
|
80 | import keyword, tokenize, linecache, inspect, pydoc | |
81 | from UserDict import UserDict |
|
81 | from UserDict import UserDict | |
82 |
|
82 | |||
83 | # IPython's own modules |
|
83 | # IPython's own modules | |
84 | # Modified pdb which doesn't damage IPython's readline handling |
|
84 | # Modified pdb which doesn't damage IPython's readline handling | |
85 | from IPython import Debugger |
|
85 | from IPython import Debugger | |
86 |
|
86 | |||
87 | from IPython.Struct import Struct |
|
87 | from IPython.Struct import Struct | |
88 | from IPython.ColorANSI import * |
|
88 | from IPython.ColorANSI import * | |
89 | from IPython.genutils import Term,uniq_stable,error,info |
|
89 | from IPython.genutils import Term,uniq_stable,error,info | |
90 |
|
90 | |||
91 | #--------------------------------------------------------------------------- |
|
91 | #--------------------------------------------------------------------------- | |
92 | # Code begins |
|
92 | # Code begins | |
93 |
|
93 | |||
94 | def inspect_error(): |
|
94 | def inspect_error(): | |
95 | """Print a message about internal inspect errors. |
|
95 | """Print a message about internal inspect errors. | |
96 |
|
96 | |||
97 | These are unfortunately quite common.""" |
|
97 | These are unfortunately quite common.""" | |
98 |
|
98 | |||
99 | error('Internal Python error in the inspect module.\n' |
|
99 | error('Internal Python error in the inspect module.\n' | |
100 | 'Below is the traceback from this internal error.\n') |
|
100 | 'Below is the traceback from this internal error.\n') | |
101 |
|
101 | |||
102 | # Make a global variable out of the color scheme table used for coloring |
|
102 | # Make a global variable out of the color scheme table used for coloring | |
103 | # exception tracebacks. This allows user code to add new schemes at runtime. |
|
103 | # exception tracebacks. This allows user code to add new schemes at runtime. | |
104 | ExceptionColors = ColorSchemeTable() |
|
104 | ExceptionColors = ColorSchemeTable() | |
105 |
|
105 | |||
106 | # Populate it with color schemes |
|
106 | # Populate it with color schemes | |
107 | C = TermColors # shorthand and local lookup |
|
107 | C = TermColors # shorthand and local lookup | |
108 | ExceptionColors.add_scheme(ColorScheme( |
|
108 | ExceptionColors.add_scheme(ColorScheme( | |
109 | 'NoColor', |
|
109 | 'NoColor', | |
110 | # The color to be used for the top line |
|
110 | # The color to be used for the top line | |
111 | topline = C.NoColor, |
|
111 | topline = C.NoColor, | |
112 |
|
112 | |||
113 | # The colors to be used in the traceback |
|
113 | # The colors to be used in the traceback | |
114 | filename = C.NoColor, |
|
114 | filename = C.NoColor, | |
115 | lineno = C.NoColor, |
|
115 | lineno = C.NoColor, | |
116 | name = C.NoColor, |
|
116 | name = C.NoColor, | |
117 | vName = C.NoColor, |
|
117 | vName = C.NoColor, | |
118 | val = C.NoColor, |
|
118 | val = C.NoColor, | |
119 | em = C.NoColor, |
|
119 | em = C.NoColor, | |
120 |
|
120 | |||
121 | # Emphasized colors for the last frame of the traceback |
|
121 | # Emphasized colors for the last frame of the traceback | |
122 | normalEm = C.NoColor, |
|
122 | normalEm = C.NoColor, | |
123 | filenameEm = C.NoColor, |
|
123 | filenameEm = C.NoColor, | |
124 | linenoEm = C.NoColor, |
|
124 | linenoEm = C.NoColor, | |
125 | nameEm = C.NoColor, |
|
125 | nameEm = C.NoColor, | |
126 | valEm = C.NoColor, |
|
126 | valEm = C.NoColor, | |
127 |
|
127 | |||
128 | # Colors for printing the exception |
|
128 | # Colors for printing the exception | |
129 | excName = C.NoColor, |
|
129 | excName = C.NoColor, | |
130 | line = C.NoColor, |
|
130 | line = C.NoColor, | |
131 | caret = C.NoColor, |
|
131 | caret = C.NoColor, | |
132 | Normal = C.NoColor |
|
132 | Normal = C.NoColor | |
133 | )) |
|
133 | )) | |
134 |
|
134 | |||
135 | # make some schemes as instances so we can copy them for modification easily |
|
135 | # make some schemes as instances so we can copy them for modification easily | |
136 | ExceptionColors.add_scheme(ColorScheme( |
|
136 | ExceptionColors.add_scheme(ColorScheme( | |
137 | 'Linux', |
|
137 | 'Linux', | |
138 | # The color to be used for the top line |
|
138 | # The color to be used for the top line | |
139 | topline = C.LightRed, |
|
139 | topline = C.LightRed, | |
140 |
|
140 | |||
141 | # The colors to be used in the traceback |
|
141 | # The colors to be used in the traceback | |
142 | filename = C.Green, |
|
142 | filename = C.Green, | |
143 | lineno = C.Green, |
|
143 | lineno = C.Green, | |
144 | name = C.Purple, |
|
144 | name = C.Purple, | |
145 | vName = C.Cyan, |
|
145 | vName = C.Cyan, | |
146 | val = C.Green, |
|
146 | val = C.Green, | |
147 | em = C.LightCyan, |
|
147 | em = C.LightCyan, | |
148 |
|
148 | |||
149 | # Emphasized colors for the last frame of the traceback |
|
149 | # Emphasized colors for the last frame of the traceback | |
150 | normalEm = C.LightCyan, |
|
150 | normalEm = C.LightCyan, | |
151 | filenameEm = C.LightGreen, |
|
151 | filenameEm = C.LightGreen, | |
152 | linenoEm = C.LightGreen, |
|
152 | linenoEm = C.LightGreen, | |
153 | nameEm = C.LightPurple, |
|
153 | nameEm = C.LightPurple, | |
154 | valEm = C.LightBlue, |
|
154 | valEm = C.LightBlue, | |
155 |
|
155 | |||
156 | # Colors for printing the exception |
|
156 | # Colors for printing the exception | |
157 | excName = C.LightRed, |
|
157 | excName = C.LightRed, | |
158 | line = C.Yellow, |
|
158 | line = C.Yellow, | |
159 | caret = C.White, |
|
159 | caret = C.White, | |
160 | Normal = C.Normal |
|
160 | Normal = C.Normal | |
161 | )) |
|
161 | )) | |
162 |
|
162 | |||
163 | # For light backgrounds, swap dark/light colors |
|
163 | # For light backgrounds, swap dark/light colors | |
164 | ExceptionColors.add_scheme(ColorScheme( |
|
164 | ExceptionColors.add_scheme(ColorScheme( | |
165 | 'LightBG', |
|
165 | 'LightBG', | |
166 | # The color to be used for the top line |
|
166 | # The color to be used for the top line | |
167 | topline = C.Red, |
|
167 | topline = C.Red, | |
168 |
|
168 | |||
169 | # The colors to be used in the traceback |
|
169 | # The colors to be used in the traceback | |
170 | filename = C.LightGreen, |
|
170 | filename = C.LightGreen, | |
171 | lineno = C.LightGreen, |
|
171 | lineno = C.LightGreen, | |
172 | name = C.LightPurple, |
|
172 | name = C.LightPurple, | |
173 | vName = C.Cyan, |
|
173 | vName = C.Cyan, | |
174 | val = C.LightGreen, |
|
174 | val = C.LightGreen, | |
175 | em = C.Cyan, |
|
175 | em = C.Cyan, | |
176 |
|
176 | |||
177 | # Emphasized colors for the last frame of the traceback |
|
177 | # Emphasized colors for the last frame of the traceback | |
178 | normalEm = C.Cyan, |
|
178 | normalEm = C.Cyan, | |
179 | filenameEm = C.Green, |
|
179 | filenameEm = C.Green, | |
180 | linenoEm = C.Green, |
|
180 | linenoEm = C.Green, | |
181 | nameEm = C.Purple, |
|
181 | nameEm = C.Purple, | |
182 | valEm = C.Blue, |
|
182 | valEm = C.Blue, | |
183 |
|
183 | |||
184 | # Colors for printing the exception |
|
184 | # Colors for printing the exception | |
185 | excName = C.Red, |
|
185 | excName = C.Red, | |
186 | #line = C.Brown, # brown often is displayed as yellow |
|
186 | #line = C.Brown, # brown often is displayed as yellow | |
187 | line = C.Red, |
|
187 | line = C.Red, | |
188 | caret = C.Normal, |
|
188 | caret = C.Normal, | |
189 | Normal = C.Normal |
|
189 | Normal = C.Normal | |
190 | )) |
|
190 | )) | |
191 |
|
191 | |||
192 | class TBTools: |
|
192 | class TBTools: | |
193 | """Basic tools used by all traceback printer classes.""" |
|
193 | """Basic tools used by all traceback printer classes.""" | |
194 |
|
194 | |||
195 | def __init__(self,color_scheme = 'NoColor',call_pdb=0): |
|
195 | def __init__(self,color_scheme = 'NoColor',call_pdb=0): | |
196 | # Whether to call the interactive pdb debugger after printing |
|
196 | # Whether to call the interactive pdb debugger after printing | |
197 | # tracebacks or not |
|
197 | # tracebacks or not | |
198 | self.call_pdb = call_pdb |
|
198 | self.call_pdb = call_pdb | |
199 | if call_pdb: |
|
199 | if call_pdb: | |
200 | self.pdb = Debugger.Pdb() |
|
200 | self.pdb = Debugger.Pdb() | |
201 | else: |
|
201 | else: | |
202 | self.pdb = None |
|
202 | self.pdb = None | |
203 |
|
203 | |||
204 | # Create color table |
|
204 | # Create color table | |
205 | self.ColorSchemeTable = ExceptionColors |
|
205 | self.ColorSchemeTable = ExceptionColors | |
206 |
|
206 | |||
207 | self.set_colors(color_scheme) |
|
207 | self.set_colors(color_scheme) | |
208 | self.old_scheme = color_scheme # save initial value for toggles |
|
208 | self.old_scheme = color_scheme # save initial value for toggles | |
209 |
|
209 | |||
210 | def set_colors(self,*args,**kw): |
|
210 | def set_colors(self,*args,**kw): | |
211 | """Shorthand access to the color table scheme selector method.""" |
|
211 | """Shorthand access to the color table scheme selector method.""" | |
212 |
|
212 | |||
213 | self.ColorSchemeTable.set_active_scheme(*args,**kw) |
|
213 | self.ColorSchemeTable.set_active_scheme(*args,**kw) | |
214 | # for convenience, set Colors to the active scheme |
|
214 | # for convenience, set Colors to the active scheme | |
215 | self.Colors = self.ColorSchemeTable.active_colors |
|
215 | self.Colors = self.ColorSchemeTable.active_colors | |
216 |
|
216 | |||
217 | def color_toggle(self): |
|
217 | def color_toggle(self): | |
218 | """Toggle between the currently active color scheme and NoColor.""" |
|
218 | """Toggle between the currently active color scheme and NoColor.""" | |
219 |
|
219 | |||
220 | if self.ColorSchemeTable.active_scheme_name == 'NoColor': |
|
220 | if self.ColorSchemeTable.active_scheme_name == 'NoColor': | |
221 | self.ColorSchemeTable.set_active_scheme(self.old_scheme) |
|
221 | self.ColorSchemeTable.set_active_scheme(self.old_scheme) | |
222 | self.Colors = self.ColorSchemeTable.active_colors |
|
222 | self.Colors = self.ColorSchemeTable.active_colors | |
223 | else: |
|
223 | else: | |
224 | self.old_scheme = self.ColorSchemeTable.active_scheme_name |
|
224 | self.old_scheme = self.ColorSchemeTable.active_scheme_name | |
225 | self.ColorSchemeTable.set_active_scheme('NoColor') |
|
225 | self.ColorSchemeTable.set_active_scheme('NoColor') | |
226 | self.Colors = self.ColorSchemeTable.active_colors |
|
226 | self.Colors = self.ColorSchemeTable.active_colors | |
227 |
|
227 | |||
228 | #--------------------------------------------------------------------------- |
|
228 | #--------------------------------------------------------------------------- | |
229 | class ListTB(TBTools): |
|
229 | class ListTB(TBTools): | |
230 | """Print traceback information from a traceback list, with optional color. |
|
230 | """Print traceback information from a traceback list, with optional color. | |
231 |
|
231 | |||
232 | Calling: requires 3 arguments: |
|
232 | Calling: requires 3 arguments: | |
233 | (etype, evalue, elist) |
|
233 | (etype, evalue, elist) | |
234 | as would be obtained by: |
|
234 | as would be obtained by: | |
235 | etype, evalue, tb = sys.exc_info() |
|
235 | etype, evalue, tb = sys.exc_info() | |
236 | if tb: |
|
236 | if tb: | |
237 | elist = traceback.extract_tb(tb) |
|
237 | elist = traceback.extract_tb(tb) | |
238 | else: |
|
238 | else: | |
239 | elist = None |
|
239 | elist = None | |
240 |
|
240 | |||
241 | It can thus be used by programs which need to process the traceback before |
|
241 | It can thus be used by programs which need to process the traceback before | |
242 | printing (such as console replacements based on the code module from the |
|
242 | printing (such as console replacements based on the code module from the | |
243 | standard library). |
|
243 | standard library). | |
244 |
|
244 | |||
245 | Because they are meant to be called without a full traceback (only a |
|
245 | Because they are meant to be called without a full traceback (only a | |
246 | list), instances of this class can't call the interactive pdb debugger.""" |
|
246 | list), instances of this class can't call the interactive pdb debugger.""" | |
247 |
|
247 | |||
248 | def __init__(self,color_scheme = 'NoColor'): |
|
248 | def __init__(self,color_scheme = 'NoColor'): | |
249 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) |
|
249 | TBTools.__init__(self,color_scheme = color_scheme,call_pdb=0) | |
250 |
|
250 | |||
251 | def __call__(self, etype, value, elist): |
|
251 | def __call__(self, etype, value, elist): | |
252 | print >> Term.cerr, self.text(etype,value,elist) |
|
252 | print >> Term.cerr, self.text(etype,value,elist) | |
253 |
|
253 | |||
254 | def text(self,etype, value, elist,context=5): |
|
254 | def text(self,etype, value, elist,context=5): | |
255 | """Return a color formatted string with the traceback info.""" |
|
255 | """Return a color formatted string with the traceback info.""" | |
256 |
|
256 | |||
257 | Colors = self.Colors |
|
257 | Colors = self.Colors | |
258 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] |
|
258 | out_string = ['%s%s%s\n' % (Colors.topline,'-'*60,Colors.Normal)] | |
259 | if elist: |
|
259 | if elist: | |
260 | out_string.append('Traceback %s(most recent call last)%s:' % \ |
|
260 | out_string.append('Traceback %s(most recent call last)%s:' % \ | |
261 | (Colors.normalEm, Colors.Normal) + '\n') |
|
261 | (Colors.normalEm, Colors.Normal) + '\n') | |
262 | out_string.extend(self._format_list(elist)) |
|
262 | out_string.extend(self._format_list(elist)) | |
263 | lines = self._format_exception_only(etype, value) |
|
263 | lines = self._format_exception_only(etype, value) | |
264 | for line in lines[:-1]: |
|
264 | for line in lines[:-1]: | |
265 | out_string.append(" "+line) |
|
265 | out_string.append(" "+line) | |
266 | out_string.append(lines[-1]) |
|
266 | out_string.append(lines[-1]) | |
267 | return ''.join(out_string) |
|
267 | return ''.join(out_string) | |
268 |
|
268 | |||
269 | def _format_list(self, extracted_list): |
|
269 | def _format_list(self, extracted_list): | |
270 | """Format a list of traceback entry tuples for printing. |
|
270 | """Format a list of traceback entry tuples for printing. | |
271 |
|
271 | |||
272 | Given a list of tuples as returned by extract_tb() or |
|
272 | Given a list of tuples as returned by extract_tb() or | |
273 | extract_stack(), return a list of strings ready for printing. |
|
273 | extract_stack(), return a list of strings ready for printing. | |
274 | Each string in the resulting list corresponds to the item with the |
|
274 | Each string in the resulting list corresponds to the item with the | |
275 | same index in the argument list. Each string ends in a newline; |
|
275 | same index in the argument list. Each string ends in a newline; | |
276 | the strings may contain internal newlines as well, for those items |
|
276 | the strings may contain internal newlines as well, for those items | |
277 | whose source text line is not None. |
|
277 | whose source text line is not None. | |
278 |
|
278 | |||
279 | Lifted almost verbatim from traceback.py |
|
279 | Lifted almost verbatim from traceback.py | |
280 | """ |
|
280 | """ | |
281 |
|
281 | |||
282 | Colors = self.Colors |
|
282 | Colors = self.Colors | |
283 | list = [] |
|
283 | list = [] | |
284 | for filename, lineno, name, line in extracted_list[:-1]: |
|
284 | for filename, lineno, name, line in extracted_list[:-1]: | |
285 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ |
|
285 | item = ' File %s"%s"%s, line %s%d%s, in %s%s%s\n' % \ | |
286 | (Colors.filename, filename, Colors.Normal, |
|
286 | (Colors.filename, filename, Colors.Normal, | |
287 | Colors.lineno, lineno, Colors.Normal, |
|
287 | Colors.lineno, lineno, Colors.Normal, | |
288 | Colors.name, name, Colors.Normal) |
|
288 | Colors.name, name, Colors.Normal) | |
289 | if line: |
|
289 | if line: | |
290 | item = item + ' %s\n' % line.strip() |
|
290 | item = item + ' %s\n' % line.strip() | |
291 | list.append(item) |
|
291 | list.append(item) | |
292 | # Emphasize the last entry |
|
292 | # Emphasize the last entry | |
293 | filename, lineno, name, line = extracted_list[-1] |
|
293 | filename, lineno, name, line = extracted_list[-1] | |
294 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ |
|
294 | item = '%s File %s"%s"%s, line %s%d%s, in %s%s%s%s\n' % \ | |
295 | (Colors.normalEm, |
|
295 | (Colors.normalEm, | |
296 | Colors.filenameEm, filename, Colors.normalEm, |
|
296 | Colors.filenameEm, filename, Colors.normalEm, | |
297 | Colors.linenoEm, lineno, Colors.normalEm, |
|
297 | Colors.linenoEm, lineno, Colors.normalEm, | |
298 | Colors.nameEm, name, Colors.normalEm, |
|
298 | Colors.nameEm, name, Colors.normalEm, | |
299 | Colors.Normal) |
|
299 | Colors.Normal) | |
300 | if line: |
|
300 | if line: | |
301 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), |
|
301 | item = item + '%s %s%s\n' % (Colors.line, line.strip(), | |
302 | Colors.Normal) |
|
302 | Colors.Normal) | |
303 | list.append(item) |
|
303 | list.append(item) | |
304 | return list |
|
304 | return list | |
305 |
|
305 | |||
306 | def _format_exception_only(self, etype, value): |
|
306 | def _format_exception_only(self, etype, value): | |
307 | """Format the exception part of a traceback. |
|
307 | """Format the exception part of a traceback. | |
308 |
|
308 | |||
309 | The arguments are the exception type and value such as given by |
|
309 | The arguments are the exception type and value such as given by | |
310 | sys.last_type and sys.last_value. The return value is a list of |
|
310 | sys.last_type and sys.last_value. The return value is a list of | |
311 | strings, each ending in a newline. Normally, the list contains a |
|
311 | strings, each ending in a newline. Normally, the list contains a | |
312 | single string; however, for SyntaxError exceptions, it contains |
|
312 | single string; however, for SyntaxError exceptions, it contains | |
313 | several lines that (when printed) display detailed information |
|
313 | several lines that (when printed) display detailed information | |
314 | about where the syntax error occurred. The message indicating |
|
314 | about where the syntax error occurred. The message indicating | |
315 | which exception occurred is the always last string in the list. |
|
315 | which exception occurred is the always last string in the list. | |
316 |
|
316 | |||
317 | Also lifted nearly verbatim from traceback.py |
|
317 | Also lifted nearly verbatim from traceback.py | |
318 | """ |
|
318 | """ | |
319 |
|
319 | |||
320 | Colors = self.Colors |
|
320 | Colors = self.Colors | |
321 | list = [] |
|
321 | list = [] | |
322 | if type(etype) == types.ClassType: |
|
322 | if type(etype) == types.ClassType: | |
323 | stype = Colors.excName + etype.__name__ + Colors.Normal |
|
323 | stype = Colors.excName + etype.__name__ + Colors.Normal | |
324 | else: |
|
324 | else: | |
325 | stype = etype # String exceptions don't get special coloring |
|
325 | stype = etype # String exceptions don't get special coloring | |
326 | if value is None: |
|
326 | if value is None: | |
327 | list.append( str(stype) + '\n') |
|
327 | list.append( str(stype) + '\n') | |
328 | else: |
|
328 | else: | |
329 | if etype is SyntaxError: |
|
329 | if etype is SyntaxError: | |
330 | try: |
|
330 | try: | |
331 | msg, (filename, lineno, offset, line) = value |
|
331 | msg, (filename, lineno, offset, line) = value | |
332 | except: |
|
332 | except: | |
333 | pass |
|
333 | pass | |
334 | else: |
|
334 | else: | |
335 | #print 'filename is',filename # dbg |
|
335 | #print 'filename is',filename # dbg | |
336 | if not filename: filename = "<string>" |
|
336 | if not filename: filename = "<string>" | |
337 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ |
|
337 | list.append('%s File %s"%s"%s, line %s%d%s\n' % \ | |
338 | (Colors.normalEm, |
|
338 | (Colors.normalEm, | |
339 | Colors.filenameEm, filename, Colors.normalEm, |
|
339 | Colors.filenameEm, filename, Colors.normalEm, | |
340 | Colors.linenoEm, lineno, Colors.Normal )) |
|
340 | Colors.linenoEm, lineno, Colors.Normal )) | |
341 | if line is not None: |
|
341 | if line is not None: | |
342 | i = 0 |
|
342 | i = 0 | |
343 | while i < len(line) and line[i].isspace(): |
|
343 | while i < len(line) and line[i].isspace(): | |
344 | i = i+1 |
|
344 | i = i+1 | |
345 | list.append('%s %s%s\n' % (Colors.line, |
|
345 | list.append('%s %s%s\n' % (Colors.line, | |
346 | line.strip(), |
|
346 | line.strip(), | |
347 | Colors.Normal)) |
|
347 | Colors.Normal)) | |
348 | if offset is not None: |
|
348 | if offset is not None: | |
349 | s = ' ' |
|
349 | s = ' ' | |
350 | for c in line[i:offset-1]: |
|
350 | for c in line[i:offset-1]: | |
351 | if c.isspace(): |
|
351 | if c.isspace(): | |
352 | s = s + c |
|
352 | s = s + c | |
353 | else: |
|
353 | else: | |
354 | s = s + ' ' |
|
354 | s = s + ' ' | |
355 | list.append('%s%s^%s\n' % (Colors.caret, s, |
|
355 | list.append('%s%s^%s\n' % (Colors.caret, s, | |
356 | Colors.Normal) ) |
|
356 | Colors.Normal) ) | |
357 | value = msg |
|
357 | value = msg | |
358 | s = self._some_str(value) |
|
358 | s = self._some_str(value) | |
359 | if s: |
|
359 | if s: | |
360 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, |
|
360 | list.append('%s%s:%s %s\n' % (str(stype), Colors.excName, | |
361 | Colors.Normal, s)) |
|
361 | Colors.Normal, s)) | |
362 | else: |
|
362 | else: | |
363 | list.append('%s\n' % str(stype)) |
|
363 | list.append('%s\n' % str(stype)) | |
364 | return list |
|
364 | return list | |
365 |
|
365 | |||
366 | def _some_str(self, value): |
|
366 | def _some_str(self, value): | |
367 | # Lifted from traceback.py |
|
367 | # Lifted from traceback.py | |
368 | try: |
|
368 | try: | |
369 | return str(value) |
|
369 | return str(value) | |
370 | except: |
|
370 | except: | |
371 | return '<unprintable %s object>' % type(value).__name__ |
|
371 | return '<unprintable %s object>' % type(value).__name__ | |
372 |
|
372 | |||
373 | #---------------------------------------------------------------------------- |
|
373 | #---------------------------------------------------------------------------- | |
374 | class VerboseTB(TBTools): |
|
374 | class VerboseTB(TBTools): | |
375 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead |
|
375 | """A port of Ka-Ping Yee's cgitb.py module that outputs color text instead | |
376 | of HTML. Requires inspect and pydoc. Crazy, man. |
|
376 | of HTML. Requires inspect and pydoc. Crazy, man. | |
377 |
|
377 | |||
378 | Modified version which optionally strips the topmost entries from the |
|
378 | Modified version which optionally strips the topmost entries from the | |
379 | traceback, to be used with alternate interpreters (because their own code |
|
379 | traceback, to be used with alternate interpreters (because their own code | |
380 | would appear in the traceback).""" |
|
380 | would appear in the traceback).""" | |
381 |
|
381 | |||
382 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, |
|
382 | def __init__(self,color_scheme = 'Linux',tb_offset=0,long_header=0, | |
383 | call_pdb = 0, include_vars=1): |
|
383 | call_pdb = 0, include_vars=1): | |
384 | """Specify traceback offset, headers and color scheme. |
|
384 | """Specify traceback offset, headers and color scheme. | |
385 |
|
385 | |||
386 | Define how many frames to drop from the tracebacks. Calling it with |
|
386 | Define how many frames to drop from the tracebacks. Calling it with | |
387 | tb_offset=1 allows use of this handler in interpreters which will have |
|
387 | tb_offset=1 allows use of this handler in interpreters which will have | |
388 | their own code at the top of the traceback (VerboseTB will first |
|
388 | their own code at the top of the traceback (VerboseTB will first | |
389 | remove that frame before printing the traceback info).""" |
|
389 | remove that frame before printing the traceback info).""" | |
390 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) |
|
390 | TBTools.__init__(self,color_scheme=color_scheme,call_pdb=call_pdb) | |
391 | self.tb_offset = tb_offset |
|
391 | self.tb_offset = tb_offset | |
392 | self.long_header = long_header |
|
392 | self.long_header = long_header | |
393 | self.include_vars = include_vars |
|
393 | self.include_vars = include_vars | |
394 |
|
394 | |||
395 | def text(self, etype, evalue, etb, context=5): |
|
395 | def text(self, etype, evalue, etb, context=5): | |
396 | """Return a nice text document describing the traceback.""" |
|
396 | """Return a nice text document describing the traceback.""" | |
397 |
|
397 | |||
398 | # some locals |
|
398 | # some locals | |
399 | Colors = self.Colors # just a shorthand + quicker name lookup |
|
399 | Colors = self.Colors # just a shorthand + quicker name lookup | |
400 | ColorsNormal = Colors.Normal # used a lot |
|
400 | ColorsNormal = Colors.Normal # used a lot | |
401 | indent_size = 8 # we need some space to put line numbers before |
|
401 | indent_size = 8 # we need some space to put line numbers before | |
402 | indent = ' '*indent_size |
|
402 | indent = ' '*indent_size | |
403 | numbers_width = indent_size - 1 # leave space between numbers & code |
|
403 | numbers_width = indent_size - 1 # leave space between numbers & code | |
404 | text_repr = pydoc.text.repr |
|
404 | text_repr = pydoc.text.repr | |
405 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) |
|
405 | exc = '%s%s%s' % (Colors.excName, str(etype), ColorsNormal) | |
406 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) |
|
406 | em_normal = '%s\n%s%s' % (Colors.valEm, indent,ColorsNormal) | |
407 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) |
|
407 | undefined = '%sundefined%s' % (Colors.em, ColorsNormal) | |
408 |
|
408 | |||
409 | # some internal-use functions |
|
409 | # some internal-use functions | |
410 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) |
|
410 | def eqrepr(value, repr=text_repr): return '=%s' % repr(value) | |
411 | def nullrepr(value, repr=text_repr): return '' |
|
411 | def nullrepr(value, repr=text_repr): return '' | |
412 |
|
412 | |||
413 | # meat of the code begins |
|
413 | # meat of the code begins | |
414 | if type(etype) is types.ClassType: |
|
414 | if type(etype) is types.ClassType: | |
415 | etype = etype.__name__ |
|
415 | etype = etype.__name__ | |
416 |
|
416 | |||
417 | if self.long_header: |
|
417 | if self.long_header: | |
418 | # Header with the exception type, python version, and date |
|
418 | # Header with the exception type, python version, and date | |
419 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable |
|
419 | pyver = 'Python ' + string.split(sys.version)[0] + ': ' + sys.executable | |
420 | date = time.ctime(time.time()) |
|
420 | date = time.ctime(time.time()) | |
421 |
|
421 | |||
422 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, |
|
422 | head = '%s%s%s\n%s%s%s\n%s' % (Colors.topline, '-'*75, ColorsNormal, | |
423 | exc, ' '*(75-len(str(etype))-len(pyver)), |
|
423 | exc, ' '*(75-len(str(etype))-len(pyver)), | |
424 | pyver, string.rjust(date, 75) ) |
|
424 | pyver, string.rjust(date, 75) ) | |
425 | head += "\nA problem occured executing Python code. Here is the sequence of function"\ |
|
425 | head += "\nA problem occured executing Python code. Here is the sequence of function"\ | |
426 | "\ncalls leading up to the error, with the most recent (innermost) call last." |
|
426 | "\ncalls leading up to the error, with the most recent (innermost) call last." | |
427 | else: |
|
427 | else: | |
428 | # Simplified header |
|
428 | # Simplified header | |
429 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, |
|
429 | head = '%s%s%s\n%s%s' % (Colors.topline, '-'*75, ColorsNormal,exc, | |
430 | string.rjust('Traceback (most recent call last)', |
|
430 | string.rjust('Traceback (most recent call last)', | |
431 | 75 - len(str(etype)) ) ) |
|
431 | 75 - len(str(etype)) ) ) | |
432 | frames = [] |
|
432 | frames = [] | |
433 | # Flush cache before calling inspect. This helps alleviate some of the |
|
433 | # Flush cache before calling inspect. This helps alleviate some of the | |
434 | # problems with python 2.3's inspect.py. |
|
434 | # problems with python 2.3's inspect.py. | |
435 | linecache.checkcache() |
|
435 | linecache.checkcache() | |
436 | # Drop topmost frames if requested |
|
436 | # Drop topmost frames if requested | |
437 | try: |
|
437 | try: | |
438 | records = inspect.getinnerframes(etb, context)[self.tb_offset:] |
|
438 | records = inspect.getinnerframes(etb, context)[self.tb_offset:] | |
439 | except: |
|
439 | except: | |
440 |
|
440 | |||
441 | # FIXME: I've been getting many crash reports from python 2.3 |
|
441 | # FIXME: I've been getting many crash reports from python 2.3 | |
442 | # users, traceable to inspect.py. If I can find a small test-case |
|
442 | # users, traceable to inspect.py. If I can find a small test-case | |
443 | # to reproduce this, I should either write a better workaround or |
|
443 | # to reproduce this, I should either write a better workaround or | |
444 | # file a bug report against inspect (if that's the real problem). |
|
444 | # file a bug report against inspect (if that's the real problem). | |
445 | # So far, I haven't been able to find an isolated example to |
|
445 | # So far, I haven't been able to find an isolated example to | |
446 | # reproduce the problem. |
|
446 | # reproduce the problem. | |
447 | inspect_error() |
|
447 | inspect_error() | |
448 | traceback.print_exc(file=Term.cerr) |
|
448 | traceback.print_exc(file=Term.cerr) | |
449 | info('\nUnfortunately, your original traceback can not be constructed.\n') |
|
449 | info('\nUnfortunately, your original traceback can not be constructed.\n') | |
450 | return '' |
|
450 | return '' | |
451 |
|
451 | |||
452 | # build some color string templates outside these nested loops |
|
452 | # build some color string templates outside these nested loops | |
453 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) |
|
453 | tpl_link = '%s%%s%s' % (Colors.filenameEm,ColorsNormal) | |
454 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, |
|
454 | tpl_call = 'in %s%%s%s%%s%s' % (Colors.vName, Colors.valEm, | |
455 | ColorsNormal) |
|
455 | ColorsNormal) | |
456 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ |
|
456 | tpl_call_fail = 'in %s%%s%s(***failed resolving arguments***)%s' % \ | |
457 | (Colors.vName, Colors.valEm, ColorsNormal) |
|
457 | (Colors.vName, Colors.valEm, ColorsNormal) | |
458 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) |
|
458 | tpl_local_var = '%s%%s%s' % (Colors.vName, ColorsNormal) | |
459 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, |
|
459 | tpl_global_var = '%sglobal%s %s%%s%s' % (Colors.em, ColorsNormal, | |
460 | Colors.vName, ColorsNormal) |
|
460 | Colors.vName, ColorsNormal) | |
461 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) |
|
461 | tpl_name_val = '%%s %s= %%s%s' % (Colors.valEm, ColorsNormal) | |
462 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) |
|
462 | tpl_line = '%s%%s%s %%s' % (Colors.lineno, ColorsNormal) | |
463 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, |
|
463 | tpl_line_em = '%s%%s%s %%s%s' % (Colors.linenoEm,Colors.line, | |
464 | ColorsNormal) |
|
464 | ColorsNormal) | |
465 |
|
465 | |||
466 | # now, loop over all records printing context and info |
|
466 | # now, loop over all records printing context and info | |
467 | abspath = os.path.abspath |
|
467 | abspath = os.path.abspath | |
468 | for frame, file, lnum, func, lines, index in records: |
|
468 | for frame, file, lnum, func, lines, index in records: | |
469 | #print '*** record:',file,lnum,func,lines,index # dbg |
|
469 | #print '*** record:',file,lnum,func,lines,index # dbg | |
470 | try: |
|
470 | try: | |
471 | file = file and abspath(file) or '?' |
|
471 | file = file and abspath(file) or '?' | |
472 | except OSError: |
|
472 | except OSError: | |
473 | # if file is '<console>' or something not in the filesystem, |
|
473 | # if file is '<console>' or something not in the filesystem, | |
474 | # the abspath call will throw an OSError. Just ignore it and |
|
474 | # the abspath call will throw an OSError. Just ignore it and | |
475 | # keep the original file string. |
|
475 | # keep the original file string. | |
476 | pass |
|
476 | pass | |
477 | link = tpl_link % file |
|
477 | link = tpl_link % file | |
478 | try: |
|
478 | try: | |
479 | args, varargs, varkw, locals = inspect.getargvalues(frame) |
|
479 | args, varargs, varkw, locals = inspect.getargvalues(frame) | |
480 | except: |
|
480 | except: | |
481 | # This can happen due to a bug in python2.3. We should be |
|
481 | # This can happen due to a bug in python2.3. We should be | |
482 | # able to remove this try/except when 2.4 becomes a |
|
482 | # able to remove this try/except when 2.4 becomes a | |
483 | # requirement. Bug details at http://python.org/sf/1005466 |
|
483 | # requirement. Bug details at http://python.org/sf/1005466 | |
484 | inspect_error() |
|
484 | inspect_error() | |
485 | traceback.print_exc(file=Term.cerr) |
|
485 | traceback.print_exc(file=Term.cerr) | |
486 | info("\nIPython's exception reporting continues...\n") |
|
486 | info("\nIPython's exception reporting continues...\n") | |
487 |
|
487 | |||
488 | if func == '?': |
|
488 | if func == '?': | |
489 | call = '' |
|
489 | call = '' | |
490 | else: |
|
490 | else: | |
491 | # Decide whether to include variable details or not |
|
491 | # Decide whether to include variable details or not | |
492 | var_repr = self.include_vars and eqrepr or nullrepr |
|
492 | var_repr = self.include_vars and eqrepr or nullrepr | |
493 | try: |
|
493 | try: | |
494 | call = tpl_call % (func,inspect.formatargvalues(args, |
|
494 | call = tpl_call % (func,inspect.formatargvalues(args, | |
495 | varargs, varkw, |
|
495 | varargs, varkw, | |
496 | locals,formatvalue=var_repr)) |
|
496 | locals,formatvalue=var_repr)) | |
497 | except KeyError: |
|
497 | except KeyError: | |
498 | # Very odd crash from inspect.formatargvalues(). The |
|
498 | # Very odd crash from inspect.formatargvalues(). The | |
499 | # scenario under which it appeared was a call to |
|
499 | # scenario under which it appeared was a call to | |
500 | # view(array,scale) in NumTut.view.view(), where scale had |
|
500 | # view(array,scale) in NumTut.view.view(), where scale had | |
501 | # been defined as a scalar (it should be a tuple). Somehow |
|
501 | # been defined as a scalar (it should be a tuple). Somehow | |
502 | # inspect messes up resolving the argument list of view() |
|
502 | # inspect messes up resolving the argument list of view() | |
503 | # and barfs out. At some point I should dig into this one |
|
503 | # and barfs out. At some point I should dig into this one | |
504 | # and file a bug report about it. |
|
504 | # and file a bug report about it. | |
505 | inspect_error() |
|
505 | inspect_error() | |
506 | traceback.print_exc(file=Term.cerr) |
|
506 | traceback.print_exc(file=Term.cerr) | |
507 | info("\nIPython's exception reporting continues...\n") |
|
507 | info("\nIPython's exception reporting continues...\n") | |
508 | call = tpl_call_fail % func |
|
508 | call = tpl_call_fail % func | |
509 |
|
509 | |||
510 | # Initialize a list of names on the current line, which the |
|
510 | # Initialize a list of names on the current line, which the | |
511 | # tokenizer below will populate. |
|
511 | # tokenizer below will populate. | |
512 | names = [] |
|
512 | names = [] | |
513 |
|
513 | |||
514 | def tokeneater(token_type, token, start, end, line): |
|
514 | def tokeneater(token_type, token, start, end, line): | |
515 | """Stateful tokeneater which builds dotted names. |
|
515 | """Stateful tokeneater which builds dotted names. | |
516 |
|
516 | |||
517 | The list of names it appends to (from the enclosing scope) can |
|
517 | The list of names it appends to (from the enclosing scope) can | |
518 | contain repeated composite names. This is unavoidable, since |
|
518 | contain repeated composite names. This is unavoidable, since | |
519 | there is no way to disambguate partial dotted structures until |
|
519 | there is no way to disambguate partial dotted structures until | |
520 | the full list is known. The caller is responsible for pruning |
|
520 | the full list is known. The caller is responsible for pruning | |
521 | the final list of duplicates before using it.""" |
|
521 | the final list of duplicates before using it.""" | |
522 |
|
522 | |||
523 | # build composite names |
|
523 | # build composite names | |
524 | if token == '.': |
|
524 | if token == '.': | |
525 | try: |
|
525 | try: | |
526 | names[-1] += '.' |
|
526 | names[-1] += '.' | |
527 | # store state so the next token is added for x.y.z names |
|
527 | # store state so the next token is added for x.y.z names | |
528 | tokeneater.name_cont = True |
|
528 | tokeneater.name_cont = True | |
529 | return |
|
529 | return | |
530 | except IndexError: |
|
530 | except IndexError: | |
531 | pass |
|
531 | pass | |
532 | if token_type == tokenize.NAME and token not in keyword.kwlist: |
|
532 | if token_type == tokenize.NAME and token not in keyword.kwlist: | |
533 | if tokeneater.name_cont: |
|
533 | if tokeneater.name_cont: | |
534 | # Dotted names |
|
534 | # Dotted names | |
535 | names[-1] += token |
|
535 | names[-1] += token | |
536 | tokeneater.name_cont = False |
|
536 | tokeneater.name_cont = False | |
537 | else: |
|
537 | else: | |
538 | # Regular new names. We append everything, the caller |
|
538 | # Regular new names. We append everything, the caller | |
539 | # will be responsible for pruning the list later. It's |
|
539 | # will be responsible for pruning the list later. It's | |
540 | # very tricky to try to prune as we go, b/c composite |
|
540 | # very tricky to try to prune as we go, b/c composite | |
541 | # names can fool us. The pruning at the end is easy |
|
541 | # names can fool us. The pruning at the end is easy | |
542 | # to do (or the caller can print a list with repeated |
|
542 | # to do (or the caller can print a list with repeated | |
543 | # names if so desired. |
|
543 | # names if so desired. | |
544 | names.append(token) |
|
544 | names.append(token) | |
545 | elif token_type == tokenize.NEWLINE: |
|
545 | elif token_type == tokenize.NEWLINE: | |
546 | raise IndexError |
|
546 | raise IndexError | |
547 | # we need to store a bit of state in the tokenizer to build |
|
547 | # we need to store a bit of state in the tokenizer to build | |
548 | # dotted names |
|
548 | # dotted names | |
549 | tokeneater.name_cont = False |
|
549 | tokeneater.name_cont = False | |
550 |
|
550 | |||
551 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): |
|
551 | def linereader(file=file, lnum=[lnum], getline=linecache.getline): | |
552 | line = getline(file, lnum[0]) |
|
552 | line = getline(file, lnum[0]) | |
553 | lnum[0] += 1 |
|
553 | lnum[0] += 1 | |
554 | return line |
|
554 | return line | |
555 |
|
555 | |||
556 | # Build the list of names on this line of code where the exception |
|
556 | # Build the list of names on this line of code where the exception | |
557 | # occurred. |
|
557 | # occurred. | |
558 | try: |
|
558 | try: | |
559 | # This builds the names list in-place by capturing it from the |
|
559 | # This builds the names list in-place by capturing it from the | |
560 | # enclosing scope. |
|
560 | # enclosing scope. | |
561 | tokenize.tokenize(linereader, tokeneater) |
|
561 | tokenize.tokenize(linereader, tokeneater) | |
562 | except IndexError: |
|
562 | except IndexError: | |
563 | # signals exit of tokenizer |
|
563 | # signals exit of tokenizer | |
564 | pass |
|
564 | pass | |
565 | except tokenize.TokenError,msg: |
|
565 | except tokenize.TokenError,msg: | |
566 | _m = ("An unexpected error occurred while tokenizing input\n" |
|
566 | _m = ("An unexpected error occurred while tokenizing input\n" | |
567 | "The following traceback may be corrupted or invalid\n" |
|
567 | "The following traceback may be corrupted or invalid\n" | |
568 | "The error message is: %s\n" % msg) |
|
568 | "The error message is: %s\n" % msg) | |
569 | error(_m) |
|
569 | error(_m) | |
570 |
|
570 | |||
571 | # prune names list of duplicates, but keep the right order |
|
571 | # prune names list of duplicates, but keep the right order | |
572 | unique_names = uniq_stable(names) |
|
572 | unique_names = uniq_stable(names) | |
573 |
|
573 | |||
574 | # Start loop over vars |
|
574 | # Start loop over vars | |
575 | lvals = [] |
|
575 | lvals = [] | |
576 | if self.include_vars: |
|
576 | if self.include_vars: | |
577 | for name_full in unique_names: |
|
577 | for name_full in unique_names: | |
578 | name_base = name_full.split('.',1)[0] |
|
578 | name_base = name_full.split('.',1)[0] | |
579 | if name_base in frame.f_code.co_varnames: |
|
579 | if name_base in frame.f_code.co_varnames: | |
580 | if locals.has_key(name_base): |
|
580 | if locals.has_key(name_base): | |
581 | try: |
|
581 | try: | |
582 | value = repr(eval(name_full,locals)) |
|
582 | value = repr(eval(name_full,locals)) | |
583 | except: |
|
583 | except: | |
584 | value = undefined |
|
584 | value = undefined | |
585 | else: |
|
585 | else: | |
586 | value = undefined |
|
586 | value = undefined | |
587 | name = tpl_local_var % name_full |
|
587 | name = tpl_local_var % name_full | |
588 | else: |
|
588 | else: | |
589 | if frame.f_globals.has_key(name_base): |
|
589 | if frame.f_globals.has_key(name_base): | |
590 | try: |
|
590 | try: | |
591 | value = repr(eval(name_full,frame.f_globals)) |
|
591 | value = repr(eval(name_full,frame.f_globals)) | |
592 | except: |
|
592 | except: | |
593 | value = undefined |
|
593 | value = undefined | |
594 | else: |
|
594 | else: | |
595 | value = undefined |
|
595 | value = undefined | |
596 | name = tpl_global_var % name_full |
|
596 | name = tpl_global_var % name_full | |
597 | lvals.append(tpl_name_val % (name,value)) |
|
597 | lvals.append(tpl_name_val % (name,value)) | |
598 | if lvals: |
|
598 | if lvals: | |
599 | lvals = '%s%s' % (indent,em_normal.join(lvals)) |
|
599 | lvals = '%s%s' % (indent,em_normal.join(lvals)) | |
600 | else: |
|
600 | else: | |
601 | lvals = '' |
|
601 | lvals = '' | |
602 |
|
602 | |||
603 | level = '%s %s\n' % (link,call) |
|
603 | level = '%s %s\n' % (link,call) | |
604 | excerpt = [] |
|
604 | excerpt = [] | |
605 | if index is not None: |
|
605 | if index is not None: | |
606 | i = lnum - index |
|
606 | i = lnum - index | |
607 | for line in lines: |
|
607 | for line in lines: | |
608 | if i == lnum: |
|
608 | if i == lnum: | |
609 | # This is the line with the error |
|
609 | # This is the line with the error | |
610 | pad = numbers_width - len(str(i)) |
|
610 | pad = numbers_width - len(str(i)) | |
611 | if pad >= 3: |
|
611 | if pad >= 3: | |
612 | marker = '-'*(pad-3) + '-> ' |
|
612 | marker = '-'*(pad-3) + '-> ' | |
613 | elif pad == 2: |
|
613 | elif pad == 2: | |
614 | marker = '> ' |
|
614 | marker = '> ' | |
615 | elif pad == 1: |
|
615 | elif pad == 1: | |
616 | marker = '>' |
|
616 | marker = '>' | |
617 | else: |
|
617 | else: | |
618 | marker = '' |
|
618 | marker = '' | |
619 | num = '%s%s' % (marker,i) |
|
619 | num = '%s%s' % (marker,i) | |
620 | line = tpl_line_em % (num,line) |
|
620 | line = tpl_line_em % (num,line) | |
621 | else: |
|
621 | else: | |
622 | num = '%*s' % (numbers_width,i) |
|
622 | num = '%*s' % (numbers_width,i) | |
623 | line = tpl_line % (num,line) |
|
623 | line = tpl_line % (num,line) | |
624 |
|
624 | |||
625 | excerpt.append(line) |
|
625 | excerpt.append(line) | |
626 | if self.include_vars and i == lnum: |
|
626 | if self.include_vars and i == lnum: | |
627 | excerpt.append('%s\n' % lvals) |
|
627 | excerpt.append('%s\n' % lvals) | |
628 | i += 1 |
|
628 | i += 1 | |
629 | frames.append('%s%s' % (level,''.join(excerpt)) ) |
|
629 | frames.append('%s%s' % (level,''.join(excerpt)) ) | |
630 |
|
630 | |||
631 | # Get (safely) a string form of the exception info |
|
631 | # Get (safely) a string form of the exception info | |
632 | try: |
|
632 | try: | |
633 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
633 | etype_str,evalue_str = map(str,(etype,evalue)) | |
634 | except: |
|
634 | except: | |
635 | # User exception is improperly defined. |
|
635 | # User exception is improperly defined. | |
636 | etype,evalue = str,sys.exc_info()[:2] |
|
636 | etype,evalue = str,sys.exc_info()[:2] | |
637 | etype_str,evalue_str = map(str,(etype,evalue)) |
|
637 | etype_str,evalue_str = map(str,(etype,evalue)) | |
638 | # ... and format it |
|
638 | # ... and format it | |
639 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, |
|
639 | exception = ['%s%s%s: %s' % (Colors.excName, etype_str, | |
640 | ColorsNormal, evalue_str)] |
|
640 | ColorsNormal, evalue_str)] | |
641 | if type(evalue) is types.InstanceType: |
|
641 | if type(evalue) is types.InstanceType: | |
642 | for name in dir(evalue): |
|
642 | names = [w for w in dir(evalue) if isinstance(w, basestring)] | |
|
643 | for name in names: | |||
643 | value = text_repr(getattr(evalue, name)) |
|
644 | value = text_repr(getattr(evalue, name)) | |
644 | exception.append('\n%s%s = %s' % (indent, name, value)) |
|
645 | exception.append('\n%s%s = %s' % (indent, name, value)) | |
645 | # return all our info assembled as a single string |
|
646 | # return all our info assembled as a single string | |
646 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) |
|
647 | return '%s\n\n%s\n%s' % (head,'\n'.join(frames),''.join(exception[0]) ) | |
647 |
|
648 | |||
648 | def debugger(self): |
|
649 | def debugger(self): | |
649 | """Call up the pdb debugger if desired, always clean up the tb reference. |
|
650 | """Call up the pdb debugger if desired, always clean up the tb reference. | |
650 |
|
651 | |||
651 | If the call_pdb flag is set, the pdb interactive debugger is |
|
652 | If the call_pdb flag is set, the pdb interactive debugger is | |
652 | invoked. In all cases, the self.tb reference to the current traceback |
|
653 | invoked. In all cases, the self.tb reference to the current traceback | |
653 | is deleted to prevent lingering references which hamper memory |
|
654 | is deleted to prevent lingering references which hamper memory | |
654 | management. |
|
655 | management. | |
655 |
|
656 | |||
656 | Note that each call to pdb() does an 'import readline', so if your app |
|
657 | Note that each call to pdb() does an 'import readline', so if your app | |
657 | requires a special setup for the readline completers, you'll have to |
|
658 | requires a special setup for the readline completers, you'll have to | |
658 | fix that by hand after invoking the exception handler.""" |
|
659 | fix that by hand after invoking the exception handler.""" | |
659 |
|
660 | |||
660 | if self.call_pdb: |
|
661 | if self.call_pdb: | |
661 | if self.pdb is None: |
|
662 | if self.pdb is None: | |
662 | self.pdb = Debugger.Pdb() |
|
663 | self.pdb = Debugger.Pdb() | |
663 | # the system displayhook may have changed, restore the original for pdb |
|
664 | # the system displayhook may have changed, restore the original for pdb | |
664 | dhook = sys.displayhook |
|
665 | dhook = sys.displayhook | |
665 | sys.displayhook = sys.__displayhook__ |
|
666 | sys.displayhook = sys.__displayhook__ | |
666 | self.pdb.reset() |
|
667 | self.pdb.reset() | |
667 | while self.tb.tb_next is not None: |
|
668 | while self.tb.tb_next is not None: | |
668 | self.tb = self.tb.tb_next |
|
669 | self.tb = self.tb.tb_next | |
669 | try: |
|
670 | try: | |
670 | self.pdb.interaction(self.tb.tb_frame, self.tb) |
|
671 | self.pdb.interaction(self.tb.tb_frame, self.tb) | |
671 | except: |
|
672 | except: | |
672 | print '*** ERROR ***' |
|
673 | print '*** ERROR ***' | |
673 | print 'This version of pdb has a bug and crashed.' |
|
674 | print 'This version of pdb has a bug and crashed.' | |
674 | print 'Returning to IPython...' |
|
675 | print 'Returning to IPython...' | |
675 | sys.displayhook = dhook |
|
676 | sys.displayhook = dhook | |
676 | del self.tb |
|
677 | del self.tb | |
677 |
|
678 | |||
678 | def handler(self, info=None): |
|
679 | def handler(self, info=None): | |
679 | (etype, evalue, etb) = info or sys.exc_info() |
|
680 | (etype, evalue, etb) = info or sys.exc_info() | |
680 | self.tb = etb |
|
681 | self.tb = etb | |
681 | print >> Term.cerr, self.text(etype, evalue, etb) |
|
682 | print >> Term.cerr, self.text(etype, evalue, etb) | |
682 |
|
683 | |||
683 | # Changed so an instance can just be called as VerboseTB_inst() and print |
|
684 | # Changed so an instance can just be called as VerboseTB_inst() and print | |
684 | # out the right info on its own. |
|
685 | # out the right info on its own. | |
685 | def __call__(self, etype=None, evalue=None, etb=None): |
|
686 | def __call__(self, etype=None, evalue=None, etb=None): | |
686 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" |
|
687 | """This hook can replace sys.excepthook (for Python 2.1 or higher).""" | |
687 | if etb is not None: |
|
688 | if etb is not None: | |
688 | self.handler((etype, evalue, etb)) |
|
689 | self.handler((etype, evalue, etb)) | |
689 | else: |
|
690 | else: | |
690 | self.handler() |
|
691 | self.handler() | |
691 | self.debugger() |
|
692 | self.debugger() | |
692 |
|
693 | |||
693 | #---------------------------------------------------------------------------- |
|
694 | #---------------------------------------------------------------------------- | |
694 | class FormattedTB(VerboseTB,ListTB): |
|
695 | class FormattedTB(VerboseTB,ListTB): | |
695 | """Subclass ListTB but allow calling with a traceback. |
|
696 | """Subclass ListTB but allow calling with a traceback. | |
696 |
|
697 | |||
697 | It can thus be used as a sys.excepthook for Python > 2.1. |
|
698 | It can thus be used as a sys.excepthook for Python > 2.1. | |
698 |
|
699 | |||
699 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. |
|
700 | Also adds 'Context' and 'Verbose' modes, not available in ListTB. | |
700 |
|
701 | |||
701 | Allows a tb_offset to be specified. This is useful for situations where |
|
702 | Allows a tb_offset to be specified. This is useful for situations where | |
702 | one needs to remove a number of topmost frames from the traceback (such as |
|
703 | one needs to remove a number of topmost frames from the traceback (such as | |
703 | occurs with python programs that themselves execute other python code, |
|
704 | occurs with python programs that themselves execute other python code, | |
704 | like Python shells). """ |
|
705 | like Python shells). """ | |
705 |
|
706 | |||
706 | def __init__(self, mode = 'Plain', color_scheme='Linux', |
|
707 | def __init__(self, mode = 'Plain', color_scheme='Linux', | |
707 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): |
|
708 | tb_offset = 0,long_header=0,call_pdb=0,include_vars=0): | |
708 |
|
709 | |||
709 | # NEVER change the order of this list. Put new modes at the end: |
|
710 | # NEVER change the order of this list. Put new modes at the end: | |
710 | self.valid_modes = ['Plain','Context','Verbose'] |
|
711 | self.valid_modes = ['Plain','Context','Verbose'] | |
711 | self.verbose_modes = self.valid_modes[1:3] |
|
712 | self.verbose_modes = self.valid_modes[1:3] | |
712 |
|
713 | |||
713 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, |
|
714 | VerboseTB.__init__(self,color_scheme,tb_offset,long_header, | |
714 | call_pdb=call_pdb,include_vars=include_vars) |
|
715 | call_pdb=call_pdb,include_vars=include_vars) | |
715 | self.set_mode(mode) |
|
716 | self.set_mode(mode) | |
716 |
|
717 | |||
717 | def _extract_tb(self,tb): |
|
718 | def _extract_tb(self,tb): | |
718 | if tb: |
|
719 | if tb: | |
719 | return traceback.extract_tb(tb) |
|
720 | return traceback.extract_tb(tb) | |
720 | else: |
|
721 | else: | |
721 | return None |
|
722 | return None | |
722 |
|
723 | |||
723 | def text(self, etype, value, tb,context=5,mode=None): |
|
724 | def text(self, etype, value, tb,context=5,mode=None): | |
724 | """Return formatted traceback. |
|
725 | """Return formatted traceback. | |
725 |
|
726 | |||
726 | If the optional mode parameter is given, it overrides the current |
|
727 | If the optional mode parameter is given, it overrides the current | |
727 | mode.""" |
|
728 | mode.""" | |
728 |
|
729 | |||
729 | if mode is None: |
|
730 | if mode is None: | |
730 | mode = self.mode |
|
731 | mode = self.mode | |
731 | if mode in self.verbose_modes: |
|
732 | if mode in self.verbose_modes: | |
732 | # verbose modes need a full traceback |
|
733 | # verbose modes need a full traceback | |
733 | return VerboseTB.text(self,etype, value, tb,context=5) |
|
734 | return VerboseTB.text(self,etype, value, tb,context=5) | |
734 | else: |
|
735 | else: | |
735 | # We must check the source cache because otherwise we can print |
|
736 | # We must check the source cache because otherwise we can print | |
736 | # out-of-date source code. |
|
737 | # out-of-date source code. | |
737 | linecache.checkcache() |
|
738 | linecache.checkcache() | |
738 | # Now we can extract and format the exception |
|
739 | # Now we can extract and format the exception | |
739 | elist = self._extract_tb(tb) |
|
740 | elist = self._extract_tb(tb) | |
740 | if len(elist) > self.tb_offset: |
|
741 | if len(elist) > self.tb_offset: | |
741 | del elist[:self.tb_offset] |
|
742 | del elist[:self.tb_offset] | |
742 | return ListTB.text(self,etype,value,elist) |
|
743 | return ListTB.text(self,etype,value,elist) | |
743 |
|
744 | |||
744 | def set_mode(self,mode=None): |
|
745 | def set_mode(self,mode=None): | |
745 | """Switch to the desired mode. |
|
746 | """Switch to the desired mode. | |
746 |
|
747 | |||
747 | If mode is not specified, cycles through the available modes.""" |
|
748 | If mode is not specified, cycles through the available modes.""" | |
748 |
|
749 | |||
749 | if not mode: |
|
750 | if not mode: | |
750 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ |
|
751 | new_idx = ( self.valid_modes.index(self.mode) + 1 ) % \ | |
751 | len(self.valid_modes) |
|
752 | len(self.valid_modes) | |
752 | self.mode = self.valid_modes[new_idx] |
|
753 | self.mode = self.valid_modes[new_idx] | |
753 | elif mode not in self.valid_modes: |
|
754 | elif mode not in self.valid_modes: | |
754 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ |
|
755 | raise ValueError, 'Unrecognized mode in FormattedTB: <'+mode+'>\n'\ | |
755 | 'Valid modes: '+str(self.valid_modes) |
|
756 | 'Valid modes: '+str(self.valid_modes) | |
756 | else: |
|
757 | else: | |
757 | self.mode = mode |
|
758 | self.mode = mode | |
758 | # include variable details only in 'Verbose' mode |
|
759 | # include variable details only in 'Verbose' mode | |
759 | self.include_vars = (self.mode == self.valid_modes[2]) |
|
760 | self.include_vars = (self.mode == self.valid_modes[2]) | |
760 |
|
761 | |||
761 | # some convenient shorcuts |
|
762 | # some convenient shorcuts | |
762 | def plain(self): |
|
763 | def plain(self): | |
763 | self.set_mode(self.valid_modes[0]) |
|
764 | self.set_mode(self.valid_modes[0]) | |
764 |
|
765 | |||
765 | def context(self): |
|
766 | def context(self): | |
766 | self.set_mode(self.valid_modes[1]) |
|
767 | self.set_mode(self.valid_modes[1]) | |
767 |
|
768 | |||
768 | def verbose(self): |
|
769 | def verbose(self): | |
769 | self.set_mode(self.valid_modes[2]) |
|
770 | self.set_mode(self.valid_modes[2]) | |
770 |
|
771 | |||
771 | #---------------------------------------------------------------------------- |
|
772 | #---------------------------------------------------------------------------- | |
772 | class AutoFormattedTB(FormattedTB): |
|
773 | class AutoFormattedTB(FormattedTB): | |
773 | """A traceback printer which can be called on the fly. |
|
774 | """A traceback printer which can be called on the fly. | |
774 |
|
775 | |||
775 | It will find out about exceptions by itself. |
|
776 | It will find out about exceptions by itself. | |
776 |
|
777 | |||
777 | A brief example: |
|
778 | A brief example: | |
778 |
|
779 | |||
779 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') |
|
780 | AutoTB = AutoFormattedTB(mode = 'Verbose',color_scheme='Linux') | |
780 | try: |
|
781 | try: | |
781 | ... |
|
782 | ... | |
782 | except: |
|
783 | except: | |
783 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object |
|
784 | AutoTB() # or AutoTB(out=logfile) where logfile is an open file object | |
784 | """ |
|
785 | """ | |
785 | def __call__(self,etype=None,evalue=None,etb=None, |
|
786 | def __call__(self,etype=None,evalue=None,etb=None, | |
786 | out=None,tb_offset=None): |
|
787 | out=None,tb_offset=None): | |
787 | """Print out a formatted exception traceback. |
|
788 | """Print out a formatted exception traceback. | |
788 |
|
789 | |||
789 | Optional arguments: |
|
790 | Optional arguments: | |
790 | - out: an open file-like object to direct output to. |
|
791 | - out: an open file-like object to direct output to. | |
791 |
|
792 | |||
792 | - tb_offset: the number of frames to skip over in the stack, on a |
|
793 | - tb_offset: the number of frames to skip over in the stack, on a | |
793 | per-call basis (this overrides temporarily the instance's tb_offset |
|
794 | per-call basis (this overrides temporarily the instance's tb_offset | |
794 | given at initialization time. """ |
|
795 | given at initialization time. """ | |
795 |
|
796 | |||
796 | if out is None: |
|
797 | if out is None: | |
797 | out = Term.cerr |
|
798 | out = Term.cerr | |
798 | if tb_offset is not None: |
|
799 | if tb_offset is not None: | |
799 | tb_offset, self.tb_offset = self.tb_offset, tb_offset |
|
800 | tb_offset, self.tb_offset = self.tb_offset, tb_offset | |
800 | print >> out, self.text(etype, evalue, etb) |
|
801 | print >> out, self.text(etype, evalue, etb) | |
801 | self.tb_offset = tb_offset |
|
802 | self.tb_offset = tb_offset | |
802 | else: |
|
803 | else: | |
803 | print >> out, self.text() |
|
804 | print >> out, self.text() | |
804 | self.debugger() |
|
805 | self.debugger() | |
805 |
|
806 | |||
806 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): |
|
807 | def text(self,etype=None,value=None,tb=None,context=5,mode=None): | |
807 | if etype is None: |
|
808 | if etype is None: | |
808 | etype,value,tb = sys.exc_info() |
|
809 | etype,value,tb = sys.exc_info() | |
809 | self.tb = tb |
|
810 | self.tb = tb | |
810 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) |
|
811 | return FormattedTB.text(self,etype,value,tb,context=5,mode=mode) | |
811 |
|
812 | |||
812 | #--------------------------------------------------------------------------- |
|
813 | #--------------------------------------------------------------------------- | |
813 | # A simple class to preserve Nathan's original functionality. |
|
814 | # A simple class to preserve Nathan's original functionality. | |
814 | class ColorTB(FormattedTB): |
|
815 | class ColorTB(FormattedTB): | |
815 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" |
|
816 | """Shorthand to initialize a FormattedTB in Linux colors mode.""" | |
816 | def __init__(self,color_scheme='Linux',call_pdb=0): |
|
817 | def __init__(self,color_scheme='Linux',call_pdb=0): | |
817 | FormattedTB.__init__(self,color_scheme=color_scheme, |
|
818 | FormattedTB.__init__(self,color_scheme=color_scheme, | |
818 | call_pdb=call_pdb) |
|
819 | call_pdb=call_pdb) | |
819 |
|
820 | |||
820 | #---------------------------------------------------------------------------- |
|
821 | #---------------------------------------------------------------------------- | |
821 | # module testing (minimal) |
|
822 | # module testing (minimal) | |
822 | if __name__ == "__main__": |
|
823 | if __name__ == "__main__": | |
823 | def spam(c, (d, e)): |
|
824 | def spam(c, (d, e)): | |
824 | x = c + d |
|
825 | x = c + d | |
825 | y = c * d |
|
826 | y = c * d | |
826 | foo(x, y) |
|
827 | foo(x, y) | |
827 |
|
828 | |||
828 | def foo(a, b, bar=1): |
|
829 | def foo(a, b, bar=1): | |
829 | eggs(a, b + bar) |
|
830 | eggs(a, b + bar) | |
830 |
|
831 | |||
831 | def eggs(f, g, z=globals()): |
|
832 | def eggs(f, g, z=globals()): | |
832 | h = f + g |
|
833 | h = f + g | |
833 | i = f - g |
|
834 | i = f - g | |
834 | return h / i |
|
835 | return h / i | |
835 |
|
836 | |||
836 | print '' |
|
837 | print '' | |
837 | print '*** Before ***' |
|
838 | print '*** Before ***' | |
838 | try: |
|
839 | try: | |
839 | print spam(1, (2, 3)) |
|
840 | print spam(1, (2, 3)) | |
840 | except: |
|
841 | except: | |
841 | traceback.print_exc() |
|
842 | traceback.print_exc() | |
842 | print '' |
|
843 | print '' | |
843 |
|
844 | |||
844 | handler = ColorTB() |
|
845 | handler = ColorTB() | |
845 | print '*** ColorTB ***' |
|
846 | print '*** ColorTB ***' | |
846 | try: |
|
847 | try: | |
847 | print spam(1, (2, 3)) |
|
848 | print spam(1, (2, 3)) | |
848 | except: |
|
849 | except: | |
849 | apply(handler, sys.exc_info() ) |
|
850 | apply(handler, sys.exc_info() ) | |
850 | print '' |
|
851 | print '' | |
851 |
|
852 | |||
852 | handler = VerboseTB() |
|
853 | handler = VerboseTB() | |
853 | print '*** VerboseTB ***' |
|
854 | print '*** VerboseTB ***' | |
854 | try: |
|
855 | try: | |
855 | print spam(1, (2, 3)) |
|
856 | print spam(1, (2, 3)) | |
856 | except: |
|
857 | except: | |
857 | apply(handler, sys.exc_info() ) |
|
858 | apply(handler, sys.exc_info() ) | |
858 | print '' |
|
859 | print '' | |
859 |
|
860 |
@@ -1,4299 +1,4322 b'' | |||||
|
1 | 2005-08-16 Fernando Perez <fperez@colorado.edu> | |||
|
2 | ||||
|
3 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object | |||
|
4 | contains non-string attribute. Closes | |||
|
5 | http://www.scipy.net/roundup/ipython/issue38. | |||
|
6 | ||||
|
7 | 2005-08-14 Fernando Perez <fperez@colorado.edu> | |||
|
8 | ||||
|
9 | * tools/ipsvnc: Minor improvements, to add changeset info. | |||
|
10 | ||||
|
11 | 2005-08-12 Fernando Perez <fperez@colorado.edu> | |||
|
12 | ||||
|
13 | * IPython/iplib.py (runsource): remove self.code_to_run_src | |||
|
14 | attribute. I realized this is nothing more than | |||
|
15 | '\n'.join(self.buffer), and having the same data in two different | |||
|
16 | places is just asking for synchronization bugs. This may impact | |||
|
17 | people who have custom exception handlers, so I need to warn | |||
|
18 | ipython-dev about it (F. Mantegazza may use them). | |||
|
19 | ||||
|
20 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> | |||
|
21 | ||||
|
22 | * IPython/genutils.py: fix 2.2 compatibility (generators) | |||
|
23 | ||||
1 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
24 | 2005-07-18 Fernando Perez <fperez@colorado.edu> | |
2 |
|
25 | |||
3 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
26 | * IPython/genutils.py (get_home_dir): fix to help users with | |
4 | invalid $HOME under win32. |
|
27 | invalid $HOME under win32. | |
5 |
|
28 | |||
6 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
29 | 2005-07-17 Fernando Perez <fperez@colorado.edu> | |
7 |
|
30 | |||
8 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
31 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove | |
9 | some old hacks and clean up a bit other routines; code should be |
|
32 | some old hacks and clean up a bit other routines; code should be | |
10 | simpler and a bit faster. |
|
33 | simpler and a bit faster. | |
11 |
|
34 | |||
12 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
35 | * IPython/iplib.py (interact): removed some last-resort attempts | |
13 | to survive broken stdout/stderr. That code was only making it |
|
36 | to survive broken stdout/stderr. That code was only making it | |
14 | harder to abstract out the i/o (necessary for gui integration), |
|
37 | harder to abstract out the i/o (necessary for gui integration), | |
15 | and the crashes it could prevent were extremely rare in practice |
|
38 | and the crashes it could prevent were extremely rare in practice | |
16 | (besides being fully user-induced in a pretty violent manner). |
|
39 | (besides being fully user-induced in a pretty violent manner). | |
17 |
|
40 | |||
18 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
41 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. | |
19 | Nothing major yet, but the code is simpler to read; this should |
|
42 | Nothing major yet, but the code is simpler to read; this should | |
20 | make it easier to do more serious modifications in the future. |
|
43 | make it easier to do more serious modifications in the future. | |
21 |
|
44 | |||
22 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
45 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, | |
23 | which broke in .15 (thanks to a report by Ville). |
|
46 | which broke in .15 (thanks to a report by Ville). | |
24 |
|
47 | |||
25 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
48 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not | |
26 | be quite correct, I know next to nothing about unicode). This |
|
49 | be quite correct, I know next to nothing about unicode). This | |
27 | will allow unicode strings to be used in prompts, amongst other |
|
50 | will allow unicode strings to be used in prompts, amongst other | |
28 | cases. It also will prevent ipython from crashing when unicode |
|
51 | cases. It also will prevent ipython from crashing when unicode | |
29 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
52 | shows up unexpectedly in many places. If ascii encoding fails, we | |
30 | assume utf_8. Currently the encoding is not a user-visible |
|
53 | assume utf_8. Currently the encoding is not a user-visible | |
31 | setting, though it could be made so if there is demand for it. |
|
54 | setting, though it could be made so if there is demand for it. | |
32 |
|
55 | |||
33 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
56 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. | |
34 |
|
57 | |||
35 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
58 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. | |
36 |
|
59 | |||
37 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
60 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. | |
38 |
|
61 | |||
39 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
62 | * IPython/genutils.py: Add 2.2 compatibility here, so all other | |
40 | code can work transparently for 2.2/2.3. |
|
63 | code can work transparently for 2.2/2.3. | |
41 |
|
64 | |||
42 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
65 | 2005-07-16 Fernando Perez <fperez@colorado.edu> | |
43 |
|
66 | |||
44 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
67 | * IPython/ultraTB.py (ExceptionColors): Make a global variable | |
45 | out of the color scheme table used for coloring exception |
|
68 | out of the color scheme table used for coloring exception | |
46 | tracebacks. This allows user code to add new schemes at runtime. |
|
69 | tracebacks. This allows user code to add new schemes at runtime. | |
47 | This is a minimally modified version of the patch at |
|
70 | This is a minimally modified version of the patch at | |
48 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
71 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw | |
49 | for the contribution. |
|
72 | for the contribution. | |
50 |
|
73 | |||
51 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
74 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a | |
52 | slightly modified version of the patch in |
|
75 | slightly modified version of the patch in | |
53 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
76 | http://www.scipy.net/roundup/ipython/issue34, which also allows me | |
54 | to remove the previous try/except solution (which was costlier). |
|
77 | to remove the previous try/except solution (which was costlier). | |
55 | Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix. |
|
78 | Thanks to Gaetan Lehmann <gaetan.lehmann AT jouy.inra.fr> for the fix. | |
56 |
|
79 | |||
57 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
80 | 2005-06-08 Fernando Perez <fperez@colorado.edu> | |
58 |
|
81 | |||
59 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
82 | * IPython/iplib.py (write/write_err): Add methods to abstract all | |
60 | I/O a bit more. |
|
83 | I/O a bit more. | |
61 |
|
84 | |||
62 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
85 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation | |
63 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
86 | warning, reported by Aric Hagberg, fix by JD Hunter. | |
64 |
|
87 | |||
65 | 2005-06-02 *** Released version 0.6.15 |
|
88 | 2005-06-02 *** Released version 0.6.15 | |
66 |
|
89 | |||
67 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
90 | 2005-06-01 Fernando Perez <fperez@colorado.edu> | |
68 |
|
91 | |||
69 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
92 | * IPython/iplib.py (MagicCompleter.file_matches): Fix | |
70 | tab-completion of filenames within open-quoted strings. Note that |
|
93 | tab-completion of filenames within open-quoted strings. Note that | |
71 | this requires that in ~/.ipython/ipythonrc, users change the |
|
94 | this requires that in ~/.ipython/ipythonrc, users change the | |
72 | readline delimiters configuration to read: |
|
95 | readline delimiters configuration to read: | |
73 |
|
96 | |||
74 | readline_remove_delims -/~ |
|
97 | readline_remove_delims -/~ | |
75 |
|
98 | |||
76 |
|
99 | |||
77 | 2005-05-31 *** Released version 0.6.14 |
|
100 | 2005-05-31 *** Released version 0.6.14 | |
78 |
|
101 | |||
79 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
102 | 2005-05-29 Fernando Perez <fperez@colorado.edu> | |
80 |
|
103 | |||
81 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
104 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks | |
82 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
105 | with files not on the filesystem. Reported by Eliyahu Sandler | |
83 | <eli@gondolin.net> |
|
106 | <eli@gondolin.net> | |
84 |
|
107 | |||
85 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
108 | 2005-05-22 Fernando Perez <fperez@colorado.edu> | |
86 |
|
109 | |||
87 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
110 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. | |
88 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
111 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. | |
89 |
|
112 | |||
90 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
113 | 2005-05-19 Fernando Perez <fperez@colorado.edu> | |
91 |
|
114 | |||
92 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
115 | * IPython/iplib.py (safe_execfile): close a file which could be | |
93 | left open (causing problems in win32, which locks open files). |
|
116 | left open (causing problems in win32, which locks open files). | |
94 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
117 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. | |
95 |
|
118 | |||
96 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
119 | 2005-05-18 Fernando Perez <fperez@colorado.edu> | |
97 |
|
120 | |||
98 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
121 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all | |
99 | keyword arguments correctly to safe_execfile(). |
|
122 | keyword arguments correctly to safe_execfile(). | |
100 |
|
123 | |||
101 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
124 | 2005-05-13 Fernando Perez <fperez@colorado.edu> | |
102 |
|
125 | |||
103 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
126 | * ipython.1: Added info about Qt to manpage, and threads warning | |
104 | to usage page (invoked with --help). |
|
127 | to usage page (invoked with --help). | |
105 |
|
128 | |||
106 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
129 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added | |
107 | new matcher (it goes at the end of the priority list) to do |
|
130 | new matcher (it goes at the end of the priority list) to do | |
108 | tab-completion on named function arguments. Submitted by George |
|
131 | tab-completion on named function arguments. Submitted by George | |
109 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
132 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at | |
110 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
133 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html | |
111 | for more details. |
|
134 | for more details. | |
112 |
|
135 | |||
113 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
136 | * IPython/Magic.py (magic_run): Added new -e flag to ignore | |
114 | SystemExit exceptions in the script being run. Thanks to a report |
|
137 | SystemExit exceptions in the script being run. Thanks to a report | |
115 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
138 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this | |
116 | producing very annoying behavior when running unit tests. |
|
139 | producing very annoying behavior when running unit tests. | |
117 |
|
140 | |||
118 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
141 | 2005-05-12 Fernando Perez <fperez@colorado.edu> | |
119 |
|
142 | |||
120 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
143 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, | |
121 | which I'd broken (again) due to a changed regexp. In the process, |
|
144 | which I'd broken (again) due to a changed regexp. In the process, | |
122 | added ';' as an escape to auto-quote the whole line without |
|
145 | added ';' as an escape to auto-quote the whole line without | |
123 | splitting its arguments. Thanks to a report by Jerry McRae |
|
146 | splitting its arguments. Thanks to a report by Jerry McRae | |
124 | <qrs0xyc02-AT-sneakemail.com>. |
|
147 | <qrs0xyc02-AT-sneakemail.com>. | |
125 |
|
148 | |||
126 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
149 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but | |
127 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
150 | possible crashes caused by a TokenError. Reported by Ed Schofield | |
128 | <schofield-AT-ftw.at>. |
|
151 | <schofield-AT-ftw.at>. | |
129 |
|
152 | |||
130 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
153 | 2005-05-06 Fernando Perez <fperez@colorado.edu> | |
131 |
|
154 | |||
132 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
155 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. | |
133 |
|
156 | |||
134 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
157 | 2005-04-29 Fernando Perez <fperez@colorado.edu> | |
135 |
|
158 | |||
136 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
159 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière | |
137 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
160 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin | |
138 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
161 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option | |
139 | which provides support for Qt interactive usage (similar to the |
|
162 | which provides support for Qt interactive usage (similar to the | |
140 | existing one for WX and GTK). This had been often requested. |
|
163 | existing one for WX and GTK). This had been often requested. | |
141 |
|
164 | |||
142 | 2005-04-14 *** Released version 0.6.13 |
|
165 | 2005-04-14 *** Released version 0.6.13 | |
143 |
|
166 | |||
144 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
167 | 2005-04-08 Fernando Perez <fperez@colorado.edu> | |
145 |
|
168 | |||
146 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
169 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation | |
147 | from _ofind, which gets called on almost every input line. Now, |
|
170 | from _ofind, which gets called on almost every input line. Now, | |
148 | we only try to get docstrings if they are actually going to be |
|
171 | we only try to get docstrings if they are actually going to be | |
149 | used (the overhead of fetching unnecessary docstrings can be |
|
172 | used (the overhead of fetching unnecessary docstrings can be | |
150 | noticeable for certain objects, such as Pyro proxies). |
|
173 | noticeable for certain objects, such as Pyro proxies). | |
151 |
|
174 | |||
152 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
175 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API | |
153 | for completers. For some reason I had been passing them the state |
|
176 | for completers. For some reason I had been passing them the state | |
154 | variable, which completers never actually need, and was in |
|
177 | variable, which completers never actually need, and was in | |
155 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
178 | conflict with the rlcompleter API. Custom completers ONLY need to | |
156 | take the text parameter. |
|
179 | take the text parameter. | |
157 |
|
180 | |||
158 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
181 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics | |
159 | work correctly in pysh. I've also moved all the logic which used |
|
182 | work correctly in pysh. I've also moved all the logic which used | |
160 | to be in pysh.py here, which will prevent problems with future |
|
183 | to be in pysh.py here, which will prevent problems with future | |
161 | upgrades. However, this time I must warn users to update their |
|
184 | upgrades. However, this time I must warn users to update their | |
162 | pysh profile to include the line |
|
185 | pysh profile to include the line | |
163 |
|
186 | |||
164 | import_all IPython.Extensions.InterpreterExec |
|
187 | import_all IPython.Extensions.InterpreterExec | |
165 |
|
188 | |||
166 | because otherwise things won't work for them. They MUST also |
|
189 | because otherwise things won't work for them. They MUST also | |
167 | delete pysh.py and the line |
|
190 | delete pysh.py and the line | |
168 |
|
191 | |||
169 | execfile pysh.py |
|
192 | execfile pysh.py | |
170 |
|
193 | |||
171 | from their ipythonrc-pysh. |
|
194 | from their ipythonrc-pysh. | |
172 |
|
195 | |||
173 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
196 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more | |
174 | robust in the face of objects whose dir() returns non-strings |
|
197 | robust in the face of objects whose dir() returns non-strings | |
175 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
198 | (which it shouldn't, but some broken libs like ITK do). Thanks to | |
176 | a patch by John Hunter (implemented differently, though). Also |
|
199 | a patch by John Hunter (implemented differently, though). Also | |
177 | minor improvements by using .extend instead of + on lists. |
|
200 | minor improvements by using .extend instead of + on lists. | |
178 |
|
201 | |||
179 | * pysh.py: |
|
202 | * pysh.py: | |
180 |
|
203 | |||
181 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
204 | 2005-04-06 Fernando Perez <fperez@colorado.edu> | |
182 |
|
205 | |||
183 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
206 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on | |
184 | by default, so that all users benefit from it. Those who don't |
|
207 | by default, so that all users benefit from it. Those who don't | |
185 | want it can still turn it off. |
|
208 | want it can still turn it off. | |
186 |
|
209 | |||
187 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
210 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the | |
188 | config file, I'd forgotten about this, so users were getting it |
|
211 | config file, I'd forgotten about this, so users were getting it | |
189 | off by default. |
|
212 | off by default. | |
190 |
|
213 | |||
191 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
214 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for | |
192 | consistency. Now magics can be called in multiline statements, |
|
215 | consistency. Now magics can be called in multiline statements, | |
193 | and python variables can be expanded in magic calls via $var. |
|
216 | and python variables can be expanded in magic calls via $var. | |
194 | This makes the magic system behave just like aliases or !system |
|
217 | This makes the magic system behave just like aliases or !system | |
195 | calls. |
|
218 | calls. | |
196 |
|
219 | |||
197 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
220 | 2005-03-28 Fernando Perez <fperez@colorado.edu> | |
198 |
|
221 | |||
199 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
222 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of | |
200 | expensive string additions for building command. Add support for |
|
223 | expensive string additions for building command. Add support for | |
201 | trailing ';' when autocall is used. |
|
224 | trailing ';' when autocall is used. | |
202 |
|
225 | |||
203 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
226 | 2005-03-26 Fernando Perez <fperez@colorado.edu> | |
204 |
|
227 | |||
205 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
228 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. | |
206 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
229 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make | |
207 | ipython.el robust against prompts with any number of spaces |
|
230 | ipython.el robust against prompts with any number of spaces | |
208 | (including 0) after the ':' character. |
|
231 | (including 0) after the ':' character. | |
209 |
|
232 | |||
210 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
233 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in | |
211 | continuation prompt, which misled users to think the line was |
|
234 | continuation prompt, which misled users to think the line was | |
212 | already indented. Closes debian Bug#300847, reported to me by |
|
235 | already indented. Closes debian Bug#300847, reported to me by | |
213 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
236 | Norbert Tretkowski <tretkowski-AT-inittab.de>. | |
214 |
|
237 | |||
215 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
238 | 2005-03-23 Fernando Perez <fperez@colorado.edu> | |
216 |
|
239 | |||
217 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
240 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are | |
218 | properly aligned if they have embedded newlines. |
|
241 | properly aligned if they have embedded newlines. | |
219 |
|
242 | |||
220 | * IPython/iplib.py (runlines): Add a public method to expose |
|
243 | * IPython/iplib.py (runlines): Add a public method to expose | |
221 | IPython's code execution machinery, so that users can run strings |
|
244 | IPython's code execution machinery, so that users can run strings | |
222 | as if they had been typed at the prompt interactively. |
|
245 | as if they had been typed at the prompt interactively. | |
223 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
246 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ | |
224 | methods which can call the system shell, but with python variable |
|
247 | methods which can call the system shell, but with python variable | |
225 | expansion. The three such methods are: __IPYTHON__.system, |
|
248 | expansion. The three such methods are: __IPYTHON__.system, | |
226 | .getoutput and .getoutputerror. These need to be documented in a |
|
249 | .getoutput and .getoutputerror. These need to be documented in a | |
227 | 'public API' section (to be written) of the manual. |
|
250 | 'public API' section (to be written) of the manual. | |
228 |
|
251 | |||
229 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
252 | 2005-03-20 Fernando Perez <fperez@colorado.edu> | |
230 |
|
253 | |||
231 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
254 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system | |
232 | for custom exception handling. This is quite powerful, and it |
|
255 | for custom exception handling. This is quite powerful, and it | |
233 | allows for user-installable exception handlers which can trap |
|
256 | allows for user-installable exception handlers which can trap | |
234 | custom exceptions at runtime and treat them separately from |
|
257 | custom exceptions at runtime and treat them separately from | |
235 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric |
|
258 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric | |
236 | Mantegazza <mantegazza-AT-ill.fr>. |
|
259 | Mantegazza <mantegazza-AT-ill.fr>. | |
237 | (InteractiveShell.set_custom_completer): public API function to |
|
260 | (InteractiveShell.set_custom_completer): public API function to | |
238 | add new completers at runtime. |
|
261 | add new completers at runtime. | |
239 |
|
262 | |||
240 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
263 | 2005-03-19 Fernando Perez <fperez@colorado.edu> | |
241 |
|
264 | |||
242 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
265 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to | |
243 | allow objects which provide their docstrings via non-standard |
|
266 | allow objects which provide their docstrings via non-standard | |
244 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
267 | mechanisms (like Pyro proxies) to still be inspected by ipython's | |
245 | ? system. |
|
268 | ? system. | |
246 |
|
269 | |||
247 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
270 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e | |
248 | automatic capture system. I tried quite hard to make it work |
|
271 | automatic capture system. I tried quite hard to make it work | |
249 | reliably, and simply failed. I tried many combinations with the |
|
272 | reliably, and simply failed. I tried many combinations with the | |
250 | subprocess module, but eventually nothing worked in all needed |
|
273 | subprocess module, but eventually nothing worked in all needed | |
251 | cases (not blocking stdin for the child, duplicating stdout |
|
274 | cases (not blocking stdin for the child, duplicating stdout | |
252 | without blocking, etc). The new %sc/%sx still do capture to these |
|
275 | without blocking, etc). The new %sc/%sx still do capture to these | |
253 | magical list/string objects which make shell use much more |
|
276 | magical list/string objects which make shell use much more | |
254 | conveninent, so not all is lost. |
|
277 | conveninent, so not all is lost. | |
255 |
|
278 | |||
256 | XXX - FIX MANUAL for the change above! |
|
279 | XXX - FIX MANUAL for the change above! | |
257 |
|
280 | |||
258 | (runsource): I copied code.py's runsource() into ipython to modify |
|
281 | (runsource): I copied code.py's runsource() into ipython to modify | |
259 | it a bit. Now the code object and source to be executed are |
|
282 | it a bit. Now the code object and source to be executed are | |
260 | stored in ipython. This makes this info accessible to third-party |
|
283 | stored in ipython. This makes this info accessible to third-party | |
261 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric |
|
284 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric | |
262 | Mantegazza <mantegazza-AT-ill.fr>. |
|
285 | Mantegazza <mantegazza-AT-ill.fr>. | |
263 |
|
286 | |||
264 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
287 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to | |
265 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
288 | history-search via readline (like C-p/C-n). I'd wanted this for a | |
266 | long time, but only recently found out how to do it. For users |
|
289 | long time, but only recently found out how to do it. For users | |
267 | who already have their ipythonrc files made and want this, just |
|
290 | who already have their ipythonrc files made and want this, just | |
268 | add: |
|
291 | add: | |
269 |
|
292 | |||
270 | readline_parse_and_bind "\e[A": history-search-backward |
|
293 | readline_parse_and_bind "\e[A": history-search-backward | |
271 | readline_parse_and_bind "\e[B": history-search-forward |
|
294 | readline_parse_and_bind "\e[B": history-search-forward | |
272 |
|
295 | |||
273 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
296 | 2005-03-18 Fernando Perez <fperez@colorado.edu> | |
274 |
|
297 | |||
275 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
298 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy | |
276 | LSString and SList classes which allow transparent conversions |
|
299 | LSString and SList classes which allow transparent conversions | |
277 | between list mode and whitespace-separated string. |
|
300 | between list mode and whitespace-separated string. | |
278 | (magic_r): Fix recursion problem in %r. |
|
301 | (magic_r): Fix recursion problem in %r. | |
279 |
|
302 | |||
280 | * IPython/genutils.py (LSString): New class to be used for |
|
303 | * IPython/genutils.py (LSString): New class to be used for | |
281 | automatic storage of the results of all alias/system calls in _o |
|
304 | automatic storage of the results of all alias/system calls in _o | |
282 | and _e (stdout/err). These provide a .l/.list attribute which |
|
305 | and _e (stdout/err). These provide a .l/.list attribute which | |
283 | does automatic splitting on newlines. This means that for most |
|
306 | does automatic splitting on newlines. This means that for most | |
284 | uses, you'll never need to do capturing of output with %sc/%sx |
|
307 | uses, you'll never need to do capturing of output with %sc/%sx | |
285 | anymore, since ipython keeps this always done for you. Note that |
|
308 | anymore, since ipython keeps this always done for you. Note that | |
286 | only the LAST results are stored, the _o/e variables are |
|
309 | only the LAST results are stored, the _o/e variables are | |
287 | overwritten on each call. If you need to save their contents |
|
310 | overwritten on each call. If you need to save their contents | |
288 | further, simply bind them to any other name. |
|
311 | further, simply bind them to any other name. | |
289 |
|
312 | |||
290 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
313 | 2005-03-17 Fernando Perez <fperez@colorado.edu> | |
291 |
|
314 | |||
292 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
315 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for | |
293 | prompt namespace handling. |
|
316 | prompt namespace handling. | |
294 |
|
317 | |||
295 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
318 | 2005-03-16 Fernando Perez <fperez@colorado.edu> | |
296 |
|
319 | |||
297 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
320 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and | |
298 | classic prompts to be '>>> ' (final space was missing, and it |
|
321 | classic prompts to be '>>> ' (final space was missing, and it | |
299 | trips the emacs python mode). |
|
322 | trips the emacs python mode). | |
300 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
323 | (BasePrompt.__str__): Added safe support for dynamic prompt | |
301 | strings. Now you can set your prompt string to be '$x', and the |
|
324 | strings. Now you can set your prompt string to be '$x', and the | |
302 | value of x will be printed from your interactive namespace. The |
|
325 | value of x will be printed from your interactive namespace. The | |
303 | interpolation syntax includes the full Itpl support, so |
|
326 | interpolation syntax includes the full Itpl support, so | |
304 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
327 | ${foo()+x+bar()} is a valid prompt string now, and the function | |
305 | calls will be made at runtime. |
|
328 | calls will be made at runtime. | |
306 |
|
329 | |||
307 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
330 | 2005-03-15 Fernando Perez <fperez@colorado.edu> | |
308 |
|
331 | |||
309 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
332 | * IPython/Magic.py (magic_history): renamed %hist to %history, to | |
310 | avoid name clashes in pylab. %hist still works, it just forwards |
|
333 | avoid name clashes in pylab. %hist still works, it just forwards | |
311 | the call to %history. |
|
334 | the call to %history. | |
312 |
|
335 | |||
313 | 2005-03-02 *** Released version 0.6.12 |
|
336 | 2005-03-02 *** Released version 0.6.12 | |
314 |
|
337 | |||
315 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
338 | 2005-03-02 Fernando Perez <fperez@colorado.edu> | |
316 |
|
339 | |||
317 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
340 | * IPython/iplib.py (handle_magic): log magic calls properly as | |
318 | ipmagic() function calls. |
|
341 | ipmagic() function calls. | |
319 |
|
342 | |||
320 | * IPython/Magic.py (magic_time): Improved %time to support |
|
343 | * IPython/Magic.py (magic_time): Improved %time to support | |
321 | statements and provide wall-clock as well as CPU time. |
|
344 | statements and provide wall-clock as well as CPU time. | |
322 |
|
345 | |||
323 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
346 | 2005-02-27 Fernando Perez <fperez@colorado.edu> | |
324 |
|
347 | |||
325 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
348 | * IPython/hooks.py: New hooks module, to expose user-modifiable | |
326 | IPython functionality in a clean manner. For now only the editor |
|
349 | IPython functionality in a clean manner. For now only the editor | |
327 | hook is actually written, and other thigns which I intend to turn |
|
350 | hook is actually written, and other thigns which I intend to turn | |
328 | into proper hooks aren't yet there. The display and prefilter |
|
351 | into proper hooks aren't yet there. The display and prefilter | |
329 | stuff, for example, should be hooks. But at least now the |
|
352 | stuff, for example, should be hooks. But at least now the | |
330 | framework is in place, and the rest can be moved here with more |
|
353 | framework is in place, and the rest can be moved here with more | |
331 | time later. IPython had had a .hooks variable for a long time for |
|
354 | time later. IPython had had a .hooks variable for a long time for | |
332 | this purpose, but I'd never actually used it for anything. |
|
355 | this purpose, but I'd never actually used it for anything. | |
333 |
|
356 | |||
334 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
357 | 2005-02-26 Fernando Perez <fperez@colorado.edu> | |
335 |
|
358 | |||
336 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
359 | * IPython/ipmaker.py (make_IPython): make the default ipython | |
337 | directory be called _ipython under win32, to follow more the |
|
360 | directory be called _ipython under win32, to follow more the | |
338 | naming peculiarities of that platform (where buggy software like |
|
361 | naming peculiarities of that platform (where buggy software like | |
339 | Visual Sourcesafe breaks with .named directories). Reported by |
|
362 | Visual Sourcesafe breaks with .named directories). Reported by | |
340 | Ville Vainio. |
|
363 | Ville Vainio. | |
341 |
|
364 | |||
342 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
365 | 2005-02-23 Fernando Perez <fperez@colorado.edu> | |
343 |
|
366 | |||
344 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
367 | * IPython/iplib.py (InteractiveShell.__init__): removed a few | |
345 | auto_aliases for win32 which were causing problems. Users can |
|
368 | auto_aliases for win32 which were causing problems. Users can | |
346 | define the ones they personally like. |
|
369 | define the ones they personally like. | |
347 |
|
370 | |||
348 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
371 | 2005-02-21 Fernando Perez <fperez@colorado.edu> | |
349 |
|
372 | |||
350 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
373 | * IPython/Magic.py (magic_time): new magic to time execution of | |
351 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
374 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. | |
352 |
|
375 | |||
353 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
376 | 2005-02-19 Fernando Perez <fperez@colorado.edu> | |
354 |
|
377 | |||
355 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
378 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings | |
356 | into keys (for prompts, for example). |
|
379 | into keys (for prompts, for example). | |
357 |
|
380 | |||
358 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
381 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty | |
359 | prompts in case users want them. This introduces a small behavior |
|
382 | prompts in case users want them. This introduces a small behavior | |
360 | change: ipython does not automatically add a space to all prompts |
|
383 | change: ipython does not automatically add a space to all prompts | |
361 | anymore. To get the old prompts with a space, users should add it |
|
384 | anymore. To get the old prompts with a space, users should add it | |
362 | manually to their ipythonrc file, so for example prompt_in1 should |
|
385 | manually to their ipythonrc file, so for example prompt_in1 should | |
363 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
386 | now read 'In [\#]: ' instead of 'In [\#]:'. | |
364 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
387 | (BasePrompt.__init__): New option prompts_pad_left (only in rc | |
365 | file) to control left-padding of secondary prompts. |
|
388 | file) to control left-padding of secondary prompts. | |
366 |
|
389 | |||
367 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
390 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if | |
368 | the profiler can't be imported. Fix for Debian, which removed |
|
391 | the profiler can't be imported. Fix for Debian, which removed | |
369 | profile.py because of License issues. I applied a slightly |
|
392 | profile.py because of License issues. I applied a slightly | |
370 | modified version of the original Debian patch at |
|
393 | modified version of the original Debian patch at | |
371 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
394 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. | |
372 |
|
395 | |||
373 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
396 | 2005-02-17 Fernando Perez <fperez@colorado.edu> | |
374 |
|
397 | |||
375 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
398 | * IPython/genutils.py (native_line_ends): Fix bug which would | |
376 | cause improper line-ends under win32 b/c I was not opening files |
|
399 | cause improper line-ends under win32 b/c I was not opening files | |
377 | in binary mode. Bug report and fix thanks to Ville. |
|
400 | in binary mode. Bug report and fix thanks to Ville. | |
378 |
|
401 | |||
379 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
402 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when | |
380 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
403 | trying to catch spurious foo[1] autocalls. My fix actually broke | |
381 | ',/' autoquote/call with explicit escape (bad regexp). |
|
404 | ',/' autoquote/call with explicit escape (bad regexp). | |
382 |
|
405 | |||
383 | 2005-02-15 *** Released version 0.6.11 |
|
406 | 2005-02-15 *** Released version 0.6.11 | |
384 |
|
407 | |||
385 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
408 | 2005-02-14 Fernando Perez <fperez@colorado.edu> | |
386 |
|
409 | |||
387 | * IPython/background_jobs.py: New background job management |
|
410 | * IPython/background_jobs.py: New background job management | |
388 | subsystem. This is implemented via a new set of classes, and |
|
411 | subsystem. This is implemented via a new set of classes, and | |
389 | IPython now provides a builtin 'jobs' object for background job |
|
412 | IPython now provides a builtin 'jobs' object for background job | |
390 | execution. A convenience %bg magic serves as a lightweight |
|
413 | execution. A convenience %bg magic serves as a lightweight | |
391 | frontend for starting the more common type of calls. This was |
|
414 | frontend for starting the more common type of calls. This was | |
392 | inspired by discussions with B. Granger and the BackgroundCommand |
|
415 | inspired by discussions with B. Granger and the BackgroundCommand | |
393 | class described in the book Python Scripting for Computational |
|
416 | class described in the book Python Scripting for Computational | |
394 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
417 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting | |
395 | (although ultimately no code from this text was used, as IPython's |
|
418 | (although ultimately no code from this text was used, as IPython's | |
396 | system is a separate implementation). |
|
419 | system is a separate implementation). | |
397 |
|
420 | |||
398 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
421 | * IPython/iplib.py (MagicCompleter.python_matches): add new option | |
399 | to control the completion of single/double underscore names |
|
422 | to control the completion of single/double underscore names | |
400 | separately. As documented in the example ipytonrc file, the |
|
423 | separately. As documented in the example ipytonrc file, the | |
401 | readline_omit__names variable can now be set to 2, to omit even |
|
424 | readline_omit__names variable can now be set to 2, to omit even | |
402 | single underscore names. Thanks to a patch by Brian Wong |
|
425 | single underscore names. Thanks to a patch by Brian Wong | |
403 | <BrianWong-AT-AirgoNetworks.Com>. |
|
426 | <BrianWong-AT-AirgoNetworks.Com>. | |
404 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
427 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to | |
405 | be autocalled as foo([1]) if foo were callable. A problem for |
|
428 | be autocalled as foo([1]) if foo were callable. A problem for | |
406 | things which are both callable and implement __getitem__. |
|
429 | things which are both callable and implement __getitem__. | |
407 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
430 | (init_readline): Fix autoindentation for win32. Thanks to a patch | |
408 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
431 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. | |
409 |
|
432 | |||
410 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
433 | 2005-02-12 Fernando Perez <fperez@colorado.edu> | |
411 |
|
434 | |||
412 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
435 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps | |
413 | which I had written long ago to sort out user error messages which |
|
436 | which I had written long ago to sort out user error messages which | |
414 | may occur during startup. This seemed like a good idea initially, |
|
437 | may occur during startup. This seemed like a good idea initially, | |
415 | but it has proven a disaster in retrospect. I don't want to |
|
438 | but it has proven a disaster in retrospect. I don't want to | |
416 | change much code for now, so my fix is to set the internal 'debug' |
|
439 | change much code for now, so my fix is to set the internal 'debug' | |
417 | flag to true everywhere, whose only job was precisely to control |
|
440 | flag to true everywhere, whose only job was precisely to control | |
418 | this subsystem. This closes issue 28 (as well as avoiding all |
|
441 | this subsystem. This closes issue 28 (as well as avoiding all | |
419 | sorts of strange hangups which occur from time to time). |
|
442 | sorts of strange hangups which occur from time to time). | |
420 |
|
443 | |||
421 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
444 | 2005-02-07 Fernando Perez <fperez@colorado.edu> | |
422 |
|
445 | |||
423 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
446 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the | |
424 | previous call produced a syntax error. |
|
447 | previous call produced a syntax error. | |
425 |
|
448 | |||
426 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
449 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
427 | classes without constructor. |
|
450 | classes without constructor. | |
428 |
|
451 | |||
429 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
452 | 2005-02-06 Fernando Perez <fperez@colorado.edu> | |
430 |
|
453 | |||
431 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
454 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of | |
432 | completions with the results of each matcher, so we return results |
|
455 | completions with the results of each matcher, so we return results | |
433 | to the user from all namespaces. This breaks with ipython |
|
456 | to the user from all namespaces. This breaks with ipython | |
434 | tradition, but I think it's a nicer behavior. Now you get all |
|
457 | tradition, but I think it's a nicer behavior. Now you get all | |
435 | possible completions listed, from all possible namespaces (python, |
|
458 | possible completions listed, from all possible namespaces (python, | |
436 | filesystem, magics...) After a request by John Hunter |
|
459 | filesystem, magics...) After a request by John Hunter | |
437 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
460 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
438 |
|
461 | |||
439 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
462 | 2005-02-05 Fernando Perez <fperez@colorado.edu> | |
440 |
|
463 | |||
441 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
464 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if | |
442 | the call had quote characters in it (the quotes were stripped). |
|
465 | the call had quote characters in it (the quotes were stripped). | |
443 |
|
466 | |||
444 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
467 | 2005-01-31 Fernando Perez <fperez@colorado.edu> | |
445 |
|
468 | |||
446 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
469 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on | |
447 | Itpl.itpl() to make the code more robust against psyco |
|
470 | Itpl.itpl() to make the code more robust against psyco | |
448 | optimizations. |
|
471 | optimizations. | |
449 |
|
472 | |||
450 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
473 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead | |
451 | of causing an exception. Quicker, cleaner. |
|
474 | of causing an exception. Quicker, cleaner. | |
452 |
|
475 | |||
453 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
476 | 2005-01-28 Fernando Perez <fperez@colorado.edu> | |
454 |
|
477 | |||
455 | * scripts/ipython_win_post_install.py (install): hardcode |
|
478 | * scripts/ipython_win_post_install.py (install): hardcode | |
456 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
479 | sys.prefix+'python.exe' as the executable path. It turns out that | |
457 | during the post-installation run, sys.executable resolves to the |
|
480 | during the post-installation run, sys.executable resolves to the | |
458 | name of the binary installer! I should report this as a distutils |
|
481 | name of the binary installer! I should report this as a distutils | |
459 | bug, I think. I updated the .10 release with this tiny fix, to |
|
482 | bug, I think. I updated the .10 release with this tiny fix, to | |
460 | avoid annoying the lists further. |
|
483 | avoid annoying the lists further. | |
461 |
|
484 | |||
462 | 2005-01-27 *** Released version 0.6.10 |
|
485 | 2005-01-27 *** Released version 0.6.10 | |
463 |
|
486 | |||
464 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
487 | 2005-01-27 Fernando Perez <fperez@colorado.edu> | |
465 |
|
488 | |||
466 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
489 | * IPython/numutils.py (norm): Added 'inf' as optional name for | |
467 | L-infinity norm, included references to mathworld.com for vector |
|
490 | L-infinity norm, included references to mathworld.com for vector | |
468 | norm definitions. |
|
491 | norm definitions. | |
469 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
492 | (amin/amax): added amin/amax for array min/max. Similar to what | |
470 | pylab ships with after the recent reorganization of names. |
|
493 | pylab ships with after the recent reorganization of names. | |
471 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
494 | (spike/spike_odd): removed deprecated spike/spike_odd functions. | |
472 |
|
495 | |||
473 | * ipython.el: committed Alex's recent fixes and improvements. |
|
496 | * ipython.el: committed Alex's recent fixes and improvements. | |
474 | Tested with python-mode from CVS, and it looks excellent. Since |
|
497 | Tested with python-mode from CVS, and it looks excellent. Since | |
475 | python-mode hasn't released anything in a while, I'm temporarily |
|
498 | python-mode hasn't released anything in a while, I'm temporarily | |
476 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
499 | putting a copy of today's CVS (v 4.70) of python-mode in: | |
477 | http://ipython.scipy.org/tmp/python-mode.el |
|
500 | http://ipython.scipy.org/tmp/python-mode.el | |
478 |
|
501 | |||
479 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
502 | * scripts/ipython_win_post_install.py (install): Win32 fix to use | |
480 | sys.executable for the executable name, instead of assuming it's |
|
503 | sys.executable for the executable name, instead of assuming it's | |
481 | called 'python.exe' (the post-installer would have produced broken |
|
504 | called 'python.exe' (the post-installer would have produced broken | |
482 | setups on systems with a differently named python binary). |
|
505 | setups on systems with a differently named python binary). | |
483 |
|
506 | |||
484 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
507 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' | |
485 | references to os.linesep, to make the code more |
|
508 | references to os.linesep, to make the code more | |
486 | platform-independent. This is also part of the win32 coloring |
|
509 | platform-independent. This is also part of the win32 coloring | |
487 | fixes. |
|
510 | fixes. | |
488 |
|
511 | |||
489 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
512 | * IPython/genutils.py (page_dumb): Remove attempts to chop long | |
490 | lines, which actually cause coloring bugs because the length of |
|
513 | lines, which actually cause coloring bugs because the length of | |
491 | the line is very difficult to correctly compute with embedded |
|
514 | the line is very difficult to correctly compute with embedded | |
492 | escapes. This was the source of all the coloring problems under |
|
515 | escapes. This was the source of all the coloring problems under | |
493 | Win32. I think that _finally_, Win32 users have a properly |
|
516 | Win32. I think that _finally_, Win32 users have a properly | |
494 | working ipython in all respects. This would never have happened |
|
517 | working ipython in all respects. This would never have happened | |
495 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
518 | if not for Gary Bishop and Viktor Ransmayr's great help and work. | |
496 |
|
519 | |||
497 | 2005-01-26 *** Released version 0.6.9 |
|
520 | 2005-01-26 *** Released version 0.6.9 | |
498 |
|
521 | |||
499 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
522 | 2005-01-25 Fernando Perez <fperez@colorado.edu> | |
500 |
|
523 | |||
501 | * setup.py: finally, we have a true Windows installer, thanks to |
|
524 | * setup.py: finally, we have a true Windows installer, thanks to | |
502 | the excellent work of Viktor Ransmayr |
|
525 | the excellent work of Viktor Ransmayr | |
503 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
526 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for | |
504 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
527 | Windows users. The setup routine is quite a bit cleaner thanks to | |
505 | this, and the post-install script uses the proper functions to |
|
528 | this, and the post-install script uses the proper functions to | |
506 | allow a clean de-installation using the standard Windows Control |
|
529 | allow a clean de-installation using the standard Windows Control | |
507 | Panel. |
|
530 | Panel. | |
508 |
|
531 | |||
509 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
532 | * IPython/genutils.py (get_home_dir): changed to use the $HOME | |
510 | environment variable under all OSes (including win32) if |
|
533 | environment variable under all OSes (including win32) if | |
511 | available. This will give consistency to win32 users who have set |
|
534 | available. This will give consistency to win32 users who have set | |
512 | this variable for any reason. If os.environ['HOME'] fails, the |
|
535 | this variable for any reason. If os.environ['HOME'] fails, the | |
513 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
536 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. | |
514 |
|
537 | |||
515 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
538 | 2005-01-24 Fernando Perez <fperez@colorado.edu> | |
516 |
|
539 | |||
517 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
540 | * IPython/numutils.py (empty_like): add empty_like(), similar to | |
518 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
541 | zeros_like() but taking advantage of the new empty() Numeric routine. | |
519 |
|
542 | |||
520 | 2005-01-23 *** Released version 0.6.8 |
|
543 | 2005-01-23 *** Released version 0.6.8 | |
521 |
|
544 | |||
522 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
545 | 2005-01-22 Fernando Perez <fperez@colorado.edu> | |
523 |
|
546 | |||
524 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
547 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the | |
525 | automatic show() calls. After discussing things with JDH, it |
|
548 | automatic show() calls. After discussing things with JDH, it | |
526 | turns out there are too many corner cases where this can go wrong. |
|
549 | turns out there are too many corner cases where this can go wrong. | |
527 | It's best not to try to be 'too smart', and simply have ipython |
|
550 | It's best not to try to be 'too smart', and simply have ipython | |
528 | reproduce as much as possible the default behavior of a normal |
|
551 | reproduce as much as possible the default behavior of a normal | |
529 | python shell. |
|
552 | python shell. | |
530 |
|
553 | |||
531 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
554 | * IPython/iplib.py (InteractiveShell.__init__): Modified the | |
532 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
555 | line-splitting regexp and _prefilter() to avoid calling getattr() | |
533 | on assignments. This closes |
|
556 | on assignments. This closes | |
534 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
557 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's | |
535 | readline uses getattr(), so a simple <TAB> keypress is still |
|
558 | readline uses getattr(), so a simple <TAB> keypress is still | |
536 | enough to trigger getattr() calls on an object. |
|
559 | enough to trigger getattr() calls on an object. | |
537 |
|
560 | |||
538 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
561 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
539 |
|
562 | |||
540 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
563 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run | |
541 | docstring under pylab so it doesn't mask the original. |
|
564 | docstring under pylab so it doesn't mask the original. | |
542 |
|
565 | |||
543 | 2005-01-21 *** Released version 0.6.7 |
|
566 | 2005-01-21 *** Released version 0.6.7 | |
544 |
|
567 | |||
545 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
568 | 2005-01-21 Fernando Perez <fperez@colorado.edu> | |
546 |
|
569 | |||
547 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
570 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with | |
548 | signal handling for win32 users in multithreaded mode. |
|
571 | signal handling for win32 users in multithreaded mode. | |
549 |
|
572 | |||
550 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
573 | 2005-01-17 Fernando Perez <fperez@colorado.edu> | |
551 |
|
574 | |||
552 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
575 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting | |
553 | instances with no __init__. After a crash report by Norbert Nemec |
|
576 | instances with no __init__. After a crash report by Norbert Nemec | |
554 | <Norbert-AT-nemec-online.de>. |
|
577 | <Norbert-AT-nemec-online.de>. | |
555 |
|
578 | |||
556 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
579 | 2005-01-14 Fernando Perez <fperez@colorado.edu> | |
557 |
|
580 | |||
558 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
581 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of | |
559 | names for verbose exceptions, when multiple dotted names and the |
|
582 | names for verbose exceptions, when multiple dotted names and the | |
560 | 'parent' object were present on the same line. |
|
583 | 'parent' object were present on the same line. | |
561 |
|
584 | |||
562 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
585 | 2005-01-11 Fernando Perez <fperez@colorado.edu> | |
563 |
|
586 | |||
564 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
587 | * IPython/genutils.py (flag_calls): new utility to trap and flag | |
565 | calls in functions. I need it to clean up matplotlib support. |
|
588 | calls in functions. I need it to clean up matplotlib support. | |
566 | Also removed some deprecated code in genutils. |
|
589 | Also removed some deprecated code in genutils. | |
567 |
|
590 | |||
568 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
591 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so | |
569 | that matplotlib scripts called with %run, which don't call show() |
|
592 | that matplotlib scripts called with %run, which don't call show() | |
570 | themselves, still have their plotting windows open. |
|
593 | themselves, still have their plotting windows open. | |
571 |
|
594 | |||
572 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
595 | 2005-01-05 Fernando Perez <fperez@colorado.edu> | |
573 |
|
596 | |||
574 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
597 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw | |
575 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
598 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. | |
576 |
|
599 | |||
577 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
600 | 2004-12-19 Fernando Perez <fperez@colorado.edu> | |
578 |
|
601 | |||
579 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
602 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of | |
580 | parent_runcode, which was an eyesore. The same result can be |
|
603 | parent_runcode, which was an eyesore. The same result can be | |
581 | obtained with Python's regular superclass mechanisms. |
|
604 | obtained with Python's regular superclass mechanisms. | |
582 |
|
605 | |||
583 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
606 | 2004-12-17 Fernando Perez <fperez@colorado.edu> | |
584 |
|
607 | |||
585 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
608 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem | |
586 | reported by Prabhu. |
|
609 | reported by Prabhu. | |
587 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
610 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to | |
588 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
611 | sys.stderr) instead of explicitly calling sys.stderr. This helps | |
589 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
612 | maintain our I/O abstractions clean, for future GUI embeddings. | |
590 |
|
613 | |||
591 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
614 | * IPython/genutils.py (info): added new utility for sys.stderr | |
592 | unified info message handling (thin wrapper around warn()). |
|
615 | unified info message handling (thin wrapper around warn()). | |
593 |
|
616 | |||
594 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
617 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global | |
595 | composite (dotted) names on verbose exceptions. |
|
618 | composite (dotted) names on verbose exceptions. | |
596 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
619 | (VerboseTB.nullrepr): harden against another kind of errors which | |
597 | Python's inspect module can trigger, and which were crashing |
|
620 | Python's inspect module can trigger, and which were crashing | |
598 | IPython. Thanks to a report by Marco Lombardi |
|
621 | IPython. Thanks to a report by Marco Lombardi | |
599 | <mlombard-AT-ma010192.hq.eso.org>. |
|
622 | <mlombard-AT-ma010192.hq.eso.org>. | |
600 |
|
623 | |||
601 | 2004-12-13 *** Released version 0.6.6 |
|
624 | 2004-12-13 *** Released version 0.6.6 | |
602 |
|
625 | |||
603 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
626 | 2004-12-12 Fernando Perez <fperez@colorado.edu> | |
604 |
|
627 | |||
605 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
628 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors | |
606 | generated by pygtk upon initialization if it was built without |
|
629 | generated by pygtk upon initialization if it was built without | |
607 | threads (for matplotlib users). After a crash reported by |
|
630 | threads (for matplotlib users). After a crash reported by | |
608 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
631 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. | |
609 |
|
632 | |||
610 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
633 | * IPython/ipmaker.py (make_IPython): fix small bug in the | |
611 | import_some parameter for multiple imports. |
|
634 | import_some parameter for multiple imports. | |
612 |
|
635 | |||
613 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
636 | * IPython/iplib.py (ipmagic): simplified the interface of | |
614 | ipmagic() to take a single string argument, just as it would be |
|
637 | ipmagic() to take a single string argument, just as it would be | |
615 | typed at the IPython cmd line. |
|
638 | typed at the IPython cmd line. | |
616 | (ipalias): Added new ipalias() with an interface identical to |
|
639 | (ipalias): Added new ipalias() with an interface identical to | |
617 | ipmagic(). This completes exposing a pure python interface to the |
|
640 | ipmagic(). This completes exposing a pure python interface to the | |
618 | alias and magic system, which can be used in loops or more complex |
|
641 | alias and magic system, which can be used in loops or more complex | |
619 | code where IPython's automatic line mangling is not active. |
|
642 | code where IPython's automatic line mangling is not active. | |
620 |
|
643 | |||
621 | * IPython/genutils.py (timing): changed interface of timing to |
|
644 | * IPython/genutils.py (timing): changed interface of timing to | |
622 | simply run code once, which is the most common case. timings() |
|
645 | simply run code once, which is the most common case. timings() | |
623 | remains unchanged, for the cases where you want multiple runs. |
|
646 | remains unchanged, for the cases where you want multiple runs. | |
624 |
|
647 | |||
625 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
648 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a | |
626 | bug where Python2.2 crashes with exec'ing code which does not end |
|
649 | bug where Python2.2 crashes with exec'ing code which does not end | |
627 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
650 | in a single newline. Python 2.3 is OK, so I hadn't noticed this | |
628 | before. |
|
651 | before. | |
629 |
|
652 | |||
630 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
653 | 2004-12-10 Fernando Perez <fperez@colorado.edu> | |
631 |
|
654 | |||
632 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
655 | * IPython/Magic.py (Magic.magic_prun): changed name of option from | |
633 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
656 | -t to -T, to accomodate the new -t flag in %run (the %run and | |
634 | %prun options are kind of intermixed, and it's not easy to change |
|
657 | %prun options are kind of intermixed, and it's not easy to change | |
635 | this with the limitations of python's getopt). |
|
658 | this with the limitations of python's getopt). | |
636 |
|
659 | |||
637 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
660 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time | |
638 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
661 | the execution of scripts. It's not as fine-tuned as timeit.py, | |
639 | but it works from inside ipython (and under 2.2, which lacks |
|
662 | but it works from inside ipython (and under 2.2, which lacks | |
640 | timeit.py). Optionally a number of runs > 1 can be given for |
|
663 | timeit.py). Optionally a number of runs > 1 can be given for | |
641 | timing very short-running code. |
|
664 | timing very short-running code. | |
642 |
|
665 | |||
643 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
666 | * IPython/genutils.py (uniq_stable): new routine which returns a | |
644 | list of unique elements in any iterable, but in stable order of |
|
667 | list of unique elements in any iterable, but in stable order of | |
645 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
668 | appearance. I needed this for the ultraTB fixes, and it's a handy | |
646 | utility. |
|
669 | utility. | |
647 |
|
670 | |||
648 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
671 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of | |
649 | dotted names in Verbose exceptions. This had been broken since |
|
672 | dotted names in Verbose exceptions. This had been broken since | |
650 | the very start, now x.y will properly be printed in a Verbose |
|
673 | the very start, now x.y will properly be printed in a Verbose | |
651 | traceback, instead of x being shown and y appearing always as an |
|
674 | traceback, instead of x being shown and y appearing always as an | |
652 | 'undefined global'. Getting this to work was a bit tricky, |
|
675 | 'undefined global'. Getting this to work was a bit tricky, | |
653 | because by default python tokenizers are stateless. Saved by |
|
676 | because by default python tokenizers are stateless. Saved by | |
654 | python's ability to easily add a bit of state to an arbitrary |
|
677 | python's ability to easily add a bit of state to an arbitrary | |
655 | function (without needing to build a full-blown callable object). |
|
678 | function (without needing to build a full-blown callable object). | |
656 |
|
679 | |||
657 | Also big cleanup of this code, which had horrendous runtime |
|
680 | Also big cleanup of this code, which had horrendous runtime | |
658 | lookups of zillions of attributes for colorization. Moved all |
|
681 | lookups of zillions of attributes for colorization. Moved all | |
659 | this code into a few templates, which make it cleaner and quicker. |
|
682 | this code into a few templates, which make it cleaner and quicker. | |
660 |
|
683 | |||
661 | Printout quality was also improved for Verbose exceptions: one |
|
684 | Printout quality was also improved for Verbose exceptions: one | |
662 | variable per line, and memory addresses are printed (this can be |
|
685 | variable per line, and memory addresses are printed (this can be | |
663 | quite handy in nasty debugging situations, which is what Verbose |
|
686 | quite handy in nasty debugging situations, which is what Verbose | |
664 | is for). |
|
687 | is for). | |
665 |
|
688 | |||
666 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
689 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in | |
667 | the command line as scripts to be loaded by embedded instances. |
|
690 | the command line as scripts to be loaded by embedded instances. | |
668 | Doing so has the potential for an infinite recursion if there are |
|
691 | Doing so has the potential for an infinite recursion if there are | |
669 | exceptions thrown in the process. This fixes a strange crash |
|
692 | exceptions thrown in the process. This fixes a strange crash | |
670 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
693 | reported by Philippe MULLER <muller-AT-irit.fr>. | |
671 |
|
694 | |||
672 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
695 | 2004-12-09 Fernando Perez <fperez@colorado.edu> | |
673 |
|
696 | |||
674 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
697 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support | |
675 | to reflect new names in matplotlib, which now expose the |
|
698 | to reflect new names in matplotlib, which now expose the | |
676 | matlab-compatible interface via a pylab module instead of the |
|
699 | matlab-compatible interface via a pylab module instead of the | |
677 | 'matlab' name. The new code is backwards compatible, so users of |
|
700 | 'matlab' name. The new code is backwards compatible, so users of | |
678 | all matplotlib versions are OK. Patch by J. Hunter. |
|
701 | all matplotlib versions are OK. Patch by J. Hunter. | |
679 |
|
702 | |||
680 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
703 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing | |
681 | of __init__ docstrings for instances (class docstrings are already |
|
704 | of __init__ docstrings for instances (class docstrings are already | |
682 | automatically printed). Instances with customized docstrings |
|
705 | automatically printed). Instances with customized docstrings | |
683 | (indep. of the class) are also recognized and all 3 separate |
|
706 | (indep. of the class) are also recognized and all 3 separate | |
684 | docstrings are printed (instance, class, constructor). After some |
|
707 | docstrings are printed (instance, class, constructor). After some | |
685 | comments/suggestions by J. Hunter. |
|
708 | comments/suggestions by J. Hunter. | |
686 |
|
709 | |||
687 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
710 | 2004-12-05 Fernando Perez <fperez@colorado.edu> | |
688 |
|
711 | |||
689 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
712 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying | |
690 | warnings when tab-completion fails and triggers an exception. |
|
713 | warnings when tab-completion fails and triggers an exception. | |
691 |
|
714 | |||
692 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
715 | 2004-12-03 Fernando Perez <fperez@colorado.edu> | |
693 |
|
716 | |||
694 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
717 | * IPython/Magic.py (magic_prun): Fix bug where an exception would | |
695 | be triggered when using 'run -p'. An incorrect option flag was |
|
718 | be triggered when using 'run -p'. An incorrect option flag was | |
696 | being set ('d' instead of 'D'). |
|
719 | being set ('d' instead of 'D'). | |
697 | (manpage): fix missing escaped \- sign. |
|
720 | (manpage): fix missing escaped \- sign. | |
698 |
|
721 | |||
699 | 2004-11-30 *** Released version 0.6.5 |
|
722 | 2004-11-30 *** Released version 0.6.5 | |
700 |
|
723 | |||
701 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
724 | 2004-11-30 Fernando Perez <fperez@colorado.edu> | |
702 |
|
725 | |||
703 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
726 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint | |
704 | setting with -d option. |
|
727 | setting with -d option. | |
705 |
|
728 | |||
706 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
729 | * setup.py (docfiles): Fix problem where the doc glob I was using | |
707 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
730 | was COMPLETELY BROKEN. It was giving the right files by pure | |
708 | accident, but failed once I tried to include ipython.el. Note: |
|
731 | accident, but failed once I tried to include ipython.el. Note: | |
709 | glob() does NOT allow you to do exclusion on multiple endings! |
|
732 | glob() does NOT allow you to do exclusion on multiple endings! | |
710 |
|
733 | |||
711 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
734 | 2004-11-29 Fernando Perez <fperez@colorado.edu> | |
712 |
|
735 | |||
713 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
736 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using | |
714 | the manpage as the source. Better formatting & consistency. |
|
737 | the manpage as the source. Better formatting & consistency. | |
715 |
|
738 | |||
716 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
739 | * IPython/Magic.py (magic_run): Added new -d option, to run | |
717 | scripts under the control of the python pdb debugger. Note that |
|
740 | scripts under the control of the python pdb debugger. Note that | |
718 | this required changing the %prun option -d to -D, to avoid a clash |
|
741 | this required changing the %prun option -d to -D, to avoid a clash | |
719 | (since %run must pass options to %prun, and getopt is too dumb to |
|
742 | (since %run must pass options to %prun, and getopt is too dumb to | |
720 | handle options with string values with embedded spaces). Thanks |
|
743 | handle options with string values with embedded spaces). Thanks | |
721 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
744 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. | |
722 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
745 | (magic_who_ls): added type matching to %who and %whos, so that one | |
723 | can filter their output to only include variables of certain |
|
746 | can filter their output to only include variables of certain | |
724 | types. Another suggestion by Matthew. |
|
747 | types. Another suggestion by Matthew. | |
725 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
748 | (magic_whos): Added memory summaries in kb and Mb for arrays. | |
726 | (magic_who): Improve formatting (break lines every 9 vars). |
|
749 | (magic_who): Improve formatting (break lines every 9 vars). | |
727 |
|
750 | |||
728 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
751 | 2004-11-28 Fernando Perez <fperez@colorado.edu> | |
729 |
|
752 | |||
730 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
753 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input | |
731 | cache when empty lines were present. |
|
754 | cache when empty lines were present. | |
732 |
|
755 | |||
733 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
756 | 2004-11-24 Fernando Perez <fperez@colorado.edu> | |
734 |
|
757 | |||
735 | * IPython/usage.py (__doc__): document the re-activated threading |
|
758 | * IPython/usage.py (__doc__): document the re-activated threading | |
736 | options for WX and GTK. |
|
759 | options for WX and GTK. | |
737 |
|
760 | |||
738 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
761 | 2004-11-23 Fernando Perez <fperez@colorado.edu> | |
739 |
|
762 | |||
740 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
763 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate | |
741 | the -wthread and -gthread options, along with a new -tk one to try |
|
764 | the -wthread and -gthread options, along with a new -tk one to try | |
742 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
765 | and coordinate Tk threading with wx/gtk. The tk support is very | |
743 | platform dependent, since it seems to require Tcl and Tk to be |
|
766 | platform dependent, since it seems to require Tcl and Tk to be | |
744 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
767 | built with threads (Fedora1/2 appears NOT to have it, but in | |
745 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
768 | Prabhu's Debian boxes it works OK). But even with some Tk | |
746 | limitations, this is a great improvement. |
|
769 | limitations, this is a great improvement. | |
747 |
|
770 | |||
748 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
771 | * IPython/Prompts.py (prompt_specials_color): Added \t for time | |
749 | info in user prompts. Patch by Prabhu. |
|
772 | info in user prompts. Patch by Prabhu. | |
750 |
|
773 | |||
751 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
774 | 2004-11-18 Fernando Perez <fperez@colorado.edu> | |
752 |
|
775 | |||
753 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
776 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 | |
754 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
777 | EOFErrors and bail, to avoid infinite loops if a non-terminating | |
755 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
778 | file is fed into ipython. Patch submitted in issue 19 by user, | |
756 | many thanks. |
|
779 | many thanks. | |
757 |
|
780 | |||
758 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
781 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger | |
759 | autoquote/parens in continuation prompts, which can cause lots of |
|
782 | autoquote/parens in continuation prompts, which can cause lots of | |
760 | problems. Closes roundup issue 20. |
|
783 | problems. Closes roundup issue 20. | |
761 |
|
784 | |||
762 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
785 | 2004-11-17 Fernando Perez <fperez@colorado.edu> | |
763 |
|
786 | |||
764 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
787 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, | |
765 | reported as debian bug #280505. I'm not sure my local changelog |
|
788 | reported as debian bug #280505. I'm not sure my local changelog | |
766 | entry has the proper debian format (Jack?). |
|
789 | entry has the proper debian format (Jack?). | |
767 |
|
790 | |||
768 | 2004-11-08 *** Released version 0.6.4 |
|
791 | 2004-11-08 *** Released version 0.6.4 | |
769 |
|
792 | |||
770 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
793 | 2004-11-08 Fernando Perez <fperez@colorado.edu> | |
771 |
|
794 | |||
772 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
795 | * IPython/iplib.py (init_readline): Fix exit message for Windows | |
773 | when readline is active. Thanks to a report by Eric Jones |
|
796 | when readline is active. Thanks to a report by Eric Jones | |
774 | <eric-AT-enthought.com>. |
|
797 | <eric-AT-enthought.com>. | |
775 |
|
798 | |||
776 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
799 | 2004-11-07 Fernando Perez <fperez@colorado.edu> | |
777 |
|
800 | |||
778 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
801 | * IPython/genutils.py (page): Add a trap for OSError exceptions, | |
779 | sometimes seen by win2k/cygwin users. |
|
802 | sometimes seen by win2k/cygwin users. | |
780 |
|
803 | |||
781 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
804 | 2004-11-06 Fernando Perez <fperez@colorado.edu> | |
782 |
|
805 | |||
783 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
806 | * IPython/iplib.py (interact): Change the handling of %Exit from | |
784 | trying to propagate a SystemExit to an internal ipython flag. |
|
807 | trying to propagate a SystemExit to an internal ipython flag. | |
785 | This is less elegant than using Python's exception mechanism, but |
|
808 | This is less elegant than using Python's exception mechanism, but | |
786 | I can't get that to work reliably with threads, so under -pylab |
|
809 | I can't get that to work reliably with threads, so under -pylab | |
787 | %Exit was hanging IPython. Cross-thread exception handling is |
|
810 | %Exit was hanging IPython. Cross-thread exception handling is | |
788 | really a bitch. Thaks to a bug report by Stephen Walton |
|
811 | really a bitch. Thaks to a bug report by Stephen Walton | |
789 | <stephen.walton-AT-csun.edu>. |
|
812 | <stephen.walton-AT-csun.edu>. | |
790 |
|
813 | |||
791 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
814 | 2004-11-04 Fernando Perez <fperez@colorado.edu> | |
792 |
|
815 | |||
793 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
816 | * IPython/iplib.py (raw_input_original): store a pointer to the | |
794 | true raw_input to harden against code which can modify it |
|
817 | true raw_input to harden against code which can modify it | |
795 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
818 | (wx.py.PyShell does this and would otherwise crash ipython). | |
796 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
819 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. | |
797 |
|
820 | |||
798 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
821 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for | |
799 | Ctrl-C problem, which does not mess up the input line. |
|
822 | Ctrl-C problem, which does not mess up the input line. | |
800 |
|
823 | |||
801 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
824 | 2004-11-03 Fernando Perez <fperez@colorado.edu> | |
802 |
|
825 | |||
803 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
826 | * IPython/Release.py: Changed licensing to BSD, in all files. | |
804 | (name): lowercase name for tarball/RPM release. |
|
827 | (name): lowercase name for tarball/RPM release. | |
805 |
|
828 | |||
806 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
829 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for | |
807 | use throughout ipython. |
|
830 | use throughout ipython. | |
808 |
|
831 | |||
809 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
832 | * IPython/Magic.py (Magic._ofind): Switch to using the new | |
810 | OInspect.getdoc() function. |
|
833 | OInspect.getdoc() function. | |
811 |
|
834 | |||
812 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
835 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution | |
813 | of the line currently being canceled via Ctrl-C. It's extremely |
|
836 | of the line currently being canceled via Ctrl-C. It's extremely | |
814 | ugly, but I don't know how to do it better (the problem is one of |
|
837 | ugly, but I don't know how to do it better (the problem is one of | |
815 | handling cross-thread exceptions). |
|
838 | handling cross-thread exceptions). | |
816 |
|
839 | |||
817 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
840 | 2004-10-28 Fernando Perez <fperez@colorado.edu> | |
818 |
|
841 | |||
819 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
842 | * IPython/Shell.py (signal_handler): add signal handlers to trap | |
820 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
843 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug | |
821 | report by Francesc Alted. |
|
844 | report by Francesc Alted. | |
822 |
|
845 | |||
823 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
846 | 2004-10-21 Fernando Perez <fperez@colorado.edu> | |
824 |
|
847 | |||
825 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
848 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ | |
826 | to % for pysh syntax extensions. |
|
849 | to % for pysh syntax extensions. | |
827 |
|
850 | |||
828 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
851 | 2004-10-09 Fernando Perez <fperez@colorado.edu> | |
829 |
|
852 | |||
830 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
853 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric | |
831 | arrays to print a more useful summary, without calling str(arr). |
|
854 | arrays to print a more useful summary, without calling str(arr). | |
832 | This avoids the problem of extremely lengthy computations which |
|
855 | This avoids the problem of extremely lengthy computations which | |
833 | occur if arr is large, and appear to the user as a system lockup |
|
856 | occur if arr is large, and appear to the user as a system lockup | |
834 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
857 | with 100% cpu activity. After a suggestion by Kristian Sandberg | |
835 | <Kristian.Sandberg@colorado.edu>. |
|
858 | <Kristian.Sandberg@colorado.edu>. | |
836 | (Magic.__init__): fix bug in global magic escapes not being |
|
859 | (Magic.__init__): fix bug in global magic escapes not being | |
837 | correctly set. |
|
860 | correctly set. | |
838 |
|
861 | |||
839 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
862 | 2004-10-08 Fernando Perez <fperez@colorado.edu> | |
840 |
|
863 | |||
841 | * IPython/Magic.py (__license__): change to absolute imports of |
|
864 | * IPython/Magic.py (__license__): change to absolute imports of | |
842 | ipython's own internal packages, to start adapting to the absolute |
|
865 | ipython's own internal packages, to start adapting to the absolute | |
843 | import requirement of PEP-328. |
|
866 | import requirement of PEP-328. | |
844 |
|
867 | |||
845 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
868 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all | |
846 | files, and standardize author/license marks through the Release |
|
869 | files, and standardize author/license marks through the Release | |
847 | module instead of having per/file stuff (except for files with |
|
870 | module instead of having per/file stuff (except for files with | |
848 | particular licenses, like the MIT/PSF-licensed codes). |
|
871 | particular licenses, like the MIT/PSF-licensed codes). | |
849 |
|
872 | |||
850 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
873 | * IPython/Debugger.py: remove dead code for python 2.1 | |
851 |
|
874 | |||
852 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
875 | 2004-10-04 Fernando Perez <fperez@colorado.edu> | |
853 |
|
876 | |||
854 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
877 | * IPython/iplib.py (ipmagic): New function for accessing magics | |
855 | via a normal python function call. |
|
878 | via a normal python function call. | |
856 |
|
879 | |||
857 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
880 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape | |
858 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
881 | from '@' to '%', to accomodate the new @decorator syntax of python | |
859 | 2.4. |
|
882 | 2.4. | |
860 |
|
883 | |||
861 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
884 | 2004-09-29 Fernando Perez <fperez@colorado.edu> | |
862 |
|
885 | |||
863 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
886 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to | |
864 | matplotlib.use to prevent running scripts which try to switch |
|
887 | matplotlib.use to prevent running scripts which try to switch | |
865 | interactive backends from within ipython. This will just crash |
|
888 | interactive backends from within ipython. This will just crash | |
866 | the python interpreter, so we can't allow it (but a detailed error |
|
889 | the python interpreter, so we can't allow it (but a detailed error | |
867 | is given to the user). |
|
890 | is given to the user). | |
868 |
|
891 | |||
869 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
892 | 2004-09-28 Fernando Perez <fperez@colorado.edu> | |
870 |
|
893 | |||
871 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
894 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): | |
872 | matplotlib-related fixes so that using @run with non-matplotlib |
|
895 | matplotlib-related fixes so that using @run with non-matplotlib | |
873 | scripts doesn't pop up spurious plot windows. This requires |
|
896 | scripts doesn't pop up spurious plot windows. This requires | |
874 | matplotlib >= 0.63, where I had to make some changes as well. |
|
897 | matplotlib >= 0.63, where I had to make some changes as well. | |
875 |
|
898 | |||
876 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
899 | * IPython/ipmaker.py (make_IPython): update version requirement to | |
877 | python 2.2. |
|
900 | python 2.2. | |
878 |
|
901 | |||
879 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
902 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional | |
880 | banner arg for embedded customization. |
|
903 | banner arg for embedded customization. | |
881 |
|
904 | |||
882 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
905 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all | |
883 | explicit uses of __IP as the IPython's instance name. Now things |
|
906 | explicit uses of __IP as the IPython's instance name. Now things | |
884 | are properly handled via the shell.name value. The actual code |
|
907 | are properly handled via the shell.name value. The actual code | |
885 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
908 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this | |
886 | is much better than before. I'll clean things completely when the |
|
909 | is much better than before. I'll clean things completely when the | |
887 | magic stuff gets a real overhaul. |
|
910 | magic stuff gets a real overhaul. | |
888 |
|
911 | |||
889 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
912 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in | |
890 | minor changes to debian dir. |
|
913 | minor changes to debian dir. | |
891 |
|
914 | |||
892 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
915 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a | |
893 | pointer to the shell itself in the interactive namespace even when |
|
916 | pointer to the shell itself in the interactive namespace even when | |
894 | a user-supplied dict is provided. This is needed for embedding |
|
917 | a user-supplied dict is provided. This is needed for embedding | |
895 | purposes (found by tests with Michel Sanner). |
|
918 | purposes (found by tests with Michel Sanner). | |
896 |
|
919 | |||
897 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
920 | 2004-09-27 Fernando Perez <fperez@colorado.edu> | |
898 |
|
921 | |||
899 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
922 | * IPython/UserConfig/ipythonrc: remove []{} from | |
900 | readline_remove_delims, so that things like [modname.<TAB> do |
|
923 | readline_remove_delims, so that things like [modname.<TAB> do | |
901 | proper completion. This disables [].TAB, but that's a less common |
|
924 | proper completion. This disables [].TAB, but that's a less common | |
902 | case than module names in list comprehensions, for example. |
|
925 | case than module names in list comprehensions, for example. | |
903 | Thanks to a report by Andrea Riciputi. |
|
926 | Thanks to a report by Andrea Riciputi. | |
904 |
|
927 | |||
905 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
928 | 2004-09-09 Fernando Perez <fperez@colorado.edu> | |
906 |
|
929 | |||
907 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
930 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid | |
908 | blocking problems in win32 and osx. Fix by John. |
|
931 | blocking problems in win32 and osx. Fix by John. | |
909 |
|
932 | |||
910 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
933 | 2004-09-08 Fernando Perez <fperez@colorado.edu> | |
911 |
|
934 | |||
912 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
935 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug | |
913 | for Win32 and OSX. Fix by John Hunter. |
|
936 | for Win32 and OSX. Fix by John Hunter. | |
914 |
|
937 | |||
915 | 2004-08-30 *** Released version 0.6.3 |
|
938 | 2004-08-30 *** Released version 0.6.3 | |
916 |
|
939 | |||
917 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
940 | 2004-08-30 Fernando Perez <fperez@colorado.edu> | |
918 |
|
941 | |||
919 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
942 | * setup.py (isfile): Add manpages to list of dependent files to be | |
920 | updated. |
|
943 | updated. | |
921 |
|
944 | |||
922 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
945 | 2004-08-27 Fernando Perez <fperez@colorado.edu> | |
923 |
|
946 | |||
924 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
947 | * IPython/Shell.py (start): I've disabled -wthread and -gthread | |
925 | for now. They don't really work with standalone WX/GTK code |
|
948 | for now. They don't really work with standalone WX/GTK code | |
926 | (though matplotlib IS working fine with both of those backends). |
|
949 | (though matplotlib IS working fine with both of those backends). | |
927 | This will neeed much more testing. I disabled most things with |
|
950 | This will neeed much more testing. I disabled most things with | |
928 | comments, so turning it back on later should be pretty easy. |
|
951 | comments, so turning it back on later should be pretty easy. | |
929 |
|
952 | |||
930 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
953 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental | |
931 | autocalling of expressions like r'foo', by modifying the line |
|
954 | autocalling of expressions like r'foo', by modifying the line | |
932 | split regexp. Closes |
|
955 | split regexp. Closes | |
933 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
956 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas | |
934 | Riley <ipythonbugs-AT-sabi.net>. |
|
957 | Riley <ipythonbugs-AT-sabi.net>. | |
935 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
958 | (InteractiveShell.mainloop): honor --nobanner with banner | |
936 | extensions. |
|
959 | extensions. | |
937 |
|
960 | |||
938 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
961 | * IPython/Shell.py: Significant refactoring of all classes, so | |
939 | that we can really support ALL matplotlib backends and threading |
|
962 | that we can really support ALL matplotlib backends and threading | |
940 | models (John spotted a bug with Tk which required this). Now we |
|
963 | models (John spotted a bug with Tk which required this). Now we | |
941 | should support single-threaded, WX-threads and GTK-threads, both |
|
964 | should support single-threaded, WX-threads and GTK-threads, both | |
942 | for generic code and for matplotlib. |
|
965 | for generic code and for matplotlib. | |
943 |
|
966 | |||
944 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
967 | * IPython/ipmaker.py (__call__): Changed -mpthread option to | |
945 | -pylab, to simplify things for users. Will also remove the pylab |
|
968 | -pylab, to simplify things for users. Will also remove the pylab | |
946 | profile, since now all of matplotlib configuration is directly |
|
969 | profile, since now all of matplotlib configuration is directly | |
947 | handled here. This also reduces startup time. |
|
970 | handled here. This also reduces startup time. | |
948 |
|
971 | |||
949 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
972 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of | |
950 | shell wasn't being correctly called. Also in IPShellWX. |
|
973 | shell wasn't being correctly called. Also in IPShellWX. | |
951 |
|
974 | |||
952 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
975 | * IPython/iplib.py (InteractiveShell.__init__): Added option to | |
953 | fine-tune banner. |
|
976 | fine-tune banner. | |
954 |
|
977 | |||
955 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
978 | * IPython/numutils.py (spike): Deprecate these spike functions, | |
956 | delete (long deprecated) gnuplot_exec handler. |
|
979 | delete (long deprecated) gnuplot_exec handler. | |
957 |
|
980 | |||
958 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
981 | 2004-08-26 Fernando Perez <fperez@colorado.edu> | |
959 |
|
982 | |||
960 | * ipython.1: Update for threading options, plus some others which |
|
983 | * ipython.1: Update for threading options, plus some others which | |
961 | were missing. |
|
984 | were missing. | |
962 |
|
985 | |||
963 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
986 | * IPython/ipmaker.py (__call__): Added -wthread option for | |
964 | wxpython thread handling. Make sure threading options are only |
|
987 | wxpython thread handling. Make sure threading options are only | |
965 | valid at the command line. |
|
988 | valid at the command line. | |
966 |
|
989 | |||
967 | * scripts/ipython: moved shell selection into a factory function |
|
990 | * scripts/ipython: moved shell selection into a factory function | |
968 | in Shell.py, to keep the starter script to a minimum. |
|
991 | in Shell.py, to keep the starter script to a minimum. | |
969 |
|
992 | |||
970 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
993 | 2004-08-25 Fernando Perez <fperez@colorado.edu> | |
971 |
|
994 | |||
972 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
995 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by | |
973 | John. Along with some recent changes he made to matplotlib, the |
|
996 | John. Along with some recent changes he made to matplotlib, the | |
974 | next versions of both systems should work very well together. |
|
997 | next versions of both systems should work very well together. | |
975 |
|
998 | |||
976 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
999 | 2004-08-24 Fernando Perez <fperez@colorado.edu> | |
977 |
|
1000 | |||
978 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
1001 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I | |
979 | tried to switch the profiling to using hotshot, but I'm getting |
|
1002 | tried to switch the profiling to using hotshot, but I'm getting | |
980 | strange errors from prof.runctx() there. I may be misreading the |
|
1003 | strange errors from prof.runctx() there. I may be misreading the | |
981 | docs, but it looks weird. For now the profiling code will |
|
1004 | docs, but it looks weird. For now the profiling code will | |
982 | continue to use the standard profiler. |
|
1005 | continue to use the standard profiler. | |
983 |
|
1006 | |||
984 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
1007 | 2004-08-23 Fernando Perez <fperez@colorado.edu> | |
985 |
|
1008 | |||
986 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
1009 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX | |
987 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
1010 | threaded shell, by John Hunter. It's not quite ready yet, but | |
988 | close. |
|
1011 | close. | |
989 |
|
1012 | |||
990 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
1013 | 2004-08-22 Fernando Perez <fperez@colorado.edu> | |
991 |
|
1014 | |||
992 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
1015 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also | |
993 | in Magic and ultraTB. |
|
1016 | in Magic and ultraTB. | |
994 |
|
1017 | |||
995 | * ipython.1: document threading options in manpage. |
|
1018 | * ipython.1: document threading options in manpage. | |
996 |
|
1019 | |||
997 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
1020 | * scripts/ipython: Changed name of -thread option to -gthread, | |
998 | since this is GTK specific. I want to leave the door open for a |
|
1021 | since this is GTK specific. I want to leave the door open for a | |
999 | -wthread option for WX, which will most likely be necessary. This |
|
1022 | -wthread option for WX, which will most likely be necessary. This | |
1000 | change affects usage and ipmaker as well. |
|
1023 | change affects usage and ipmaker as well. | |
1001 |
|
1024 | |||
1002 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
1025 | * IPython/Shell.py (matplotlib_shell): Add a factory function to | |
1003 | handle the matplotlib shell issues. Code by John Hunter |
|
1026 | handle the matplotlib shell issues. Code by John Hunter | |
1004 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
1027 | <jdhunter-AT-nitace.bsd.uchicago.edu>. | |
1005 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
1028 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's | |
1006 | broken (and disabled for end users) for now, but it puts the |
|
1029 | broken (and disabled for end users) for now, but it puts the | |
1007 | infrastructure in place. |
|
1030 | infrastructure in place. | |
1008 |
|
1031 | |||
1009 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
1032 | 2004-08-21 Fernando Perez <fperez@colorado.edu> | |
1010 |
|
1033 | |||
1011 | * ipythonrc-pylab: Add matplotlib support. |
|
1034 | * ipythonrc-pylab: Add matplotlib support. | |
1012 |
|
1035 | |||
1013 | * matplotlib_config.py: new files for matplotlib support, part of |
|
1036 | * matplotlib_config.py: new files for matplotlib support, part of | |
1014 | the pylab profile. |
|
1037 | the pylab profile. | |
1015 |
|
1038 | |||
1016 | * IPython/usage.py (__doc__): documented the threading options. |
|
1039 | * IPython/usage.py (__doc__): documented the threading options. | |
1017 |
|
1040 | |||
1018 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
1041 | 2004-08-20 Fernando Perez <fperez@colorado.edu> | |
1019 |
|
1042 | |||
1020 | * ipython: Modified the main calling routine to handle the -thread |
|
1043 | * ipython: Modified the main calling routine to handle the -thread | |
1021 | and -mpthread options. This needs to be done as a top-level hack, |
|
1044 | and -mpthread options. This needs to be done as a top-level hack, | |
1022 | because it determines which class to instantiate for IPython |
|
1045 | because it determines which class to instantiate for IPython | |
1023 | itself. |
|
1046 | itself. | |
1024 |
|
1047 | |||
1025 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
1048 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of | |
1026 | classes to support multithreaded GTK operation without blocking, |
|
1049 | classes to support multithreaded GTK operation without blocking, | |
1027 | and matplotlib with all backends. This is a lot of still very |
|
1050 | and matplotlib with all backends. This is a lot of still very | |
1028 | experimental code, and threads are tricky. So it may still have a |
|
1051 | experimental code, and threads are tricky. So it may still have a | |
1029 | few rough edges... This code owes a lot to |
|
1052 | few rough edges... This code owes a lot to | |
1030 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
1053 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by | |
1031 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
1054 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and | |
1032 | to John Hunter for all the matplotlib work. |
|
1055 | to John Hunter for all the matplotlib work. | |
1033 |
|
1056 | |||
1034 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
1057 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread | |
1035 | options for gtk thread and matplotlib support. |
|
1058 | options for gtk thread and matplotlib support. | |
1036 |
|
1059 | |||
1037 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
1060 | 2004-08-16 Fernando Perez <fperez@colorado.edu> | |
1038 |
|
1061 | |||
1039 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
1062 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger | |
1040 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
1063 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug | |
1041 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
1064 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. | |
1042 |
|
1065 | |||
1043 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
1066 | 2004-08-11 Fernando Perez <fperez@colorado.edu> | |
1044 |
|
1067 | |||
1045 | * setup.py (isfile): Fix build so documentation gets updated for |
|
1068 | * setup.py (isfile): Fix build so documentation gets updated for | |
1046 | rpms (it was only done for .tgz builds). |
|
1069 | rpms (it was only done for .tgz builds). | |
1047 |
|
1070 | |||
1048 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
1071 | 2004-08-10 Fernando Perez <fperez@colorado.edu> | |
1049 |
|
1072 | |||
1050 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
1073 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). | |
1051 |
|
1074 | |||
1052 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
1075 | * iplib.py : Silence syntax error exceptions in tab-completion. | |
1053 |
|
1076 | |||
1054 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
1077 | 2004-08-05 Fernando Perez <fperez@colorado.edu> | |
1055 |
|
1078 | |||
1056 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
1079 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set | |
1057 | 'color off' mark for continuation prompts. This was causing long |
|
1080 | 'color off' mark for continuation prompts. This was causing long | |
1058 | continuation lines to mis-wrap. |
|
1081 | continuation lines to mis-wrap. | |
1059 |
|
1082 | |||
1060 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
1083 | 2004-08-01 Fernando Perez <fperez@colorado.edu> | |
1061 |
|
1084 | |||
1062 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
1085 | * IPython/ipmaker.py (make_IPython): Allow the shell class used | |
1063 | for building ipython to be a parameter. All this is necessary |
|
1086 | for building ipython to be a parameter. All this is necessary | |
1064 | right now to have a multithreaded version, but this insane |
|
1087 | right now to have a multithreaded version, but this insane | |
1065 | non-design will be cleaned up soon. For now, it's a hack that |
|
1088 | non-design will be cleaned up soon. For now, it's a hack that | |
1066 | works. |
|
1089 | works. | |
1067 |
|
1090 | |||
1068 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
1091 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default | |
1069 | args in various places. No bugs so far, but it's a dangerous |
|
1092 | args in various places. No bugs so far, but it's a dangerous | |
1070 | practice. |
|
1093 | practice. | |
1071 |
|
1094 | |||
1072 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
1095 | 2004-07-31 Fernando Perez <fperez@colorado.edu> | |
1073 |
|
1096 | |||
1074 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
1097 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to | |
1075 | fix completion of files with dots in their names under most |
|
1098 | fix completion of files with dots in their names under most | |
1076 | profiles (pysh was OK because the completion order is different). |
|
1099 | profiles (pysh was OK because the completion order is different). | |
1077 |
|
1100 | |||
1078 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
1101 | 2004-07-27 Fernando Perez <fperez@colorado.edu> | |
1079 |
|
1102 | |||
1080 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
1103 | * IPython/iplib.py (InteractiveShell.__init__): build dict of | |
1081 | keywords manually, b/c the one in keyword.py was removed in python |
|
1104 | keywords manually, b/c the one in keyword.py was removed in python | |
1082 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
1105 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. | |
1083 | This is NOT a bug under python 2.3 and earlier. |
|
1106 | This is NOT a bug under python 2.3 and earlier. | |
1084 |
|
1107 | |||
1085 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1108 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1086 |
|
1109 | |||
1087 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
1110 | * IPython/ultraTB.py (VerboseTB.text): Add another | |
1088 | linecache.checkcache() call to try to prevent inspect.py from |
|
1111 | linecache.checkcache() call to try to prevent inspect.py from | |
1089 | crashing under python 2.3. I think this fixes |
|
1112 | crashing under python 2.3. I think this fixes | |
1090 | http://www.scipy.net/roundup/ipython/issue17. |
|
1113 | http://www.scipy.net/roundup/ipython/issue17. | |
1091 |
|
1114 | |||
1092 | 2004-07-26 *** Released version 0.6.2 |
|
1115 | 2004-07-26 *** Released version 0.6.2 | |
1093 |
|
1116 | |||
1094 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1117 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1095 |
|
1118 | |||
1096 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
1119 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would | |
1097 | fail for any number. |
|
1120 | fail for any number. | |
1098 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
1121 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for | |
1099 | empty bookmarks. |
|
1122 | empty bookmarks. | |
1100 |
|
1123 | |||
1101 | 2004-07-26 *** Released version 0.6.1 |
|
1124 | 2004-07-26 *** Released version 0.6.1 | |
1102 |
|
1125 | |||
1103 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
1126 | 2004-07-26 Fernando Perez <fperez@colorado.edu> | |
1104 |
|
1127 | |||
1105 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
1128 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. | |
1106 |
|
1129 | |||
1107 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
1130 | * IPython/iplib.py (protect_filename): Applied Ville's patch for | |
1108 | escaping '()[]{}' in filenames. |
|
1131 | escaping '()[]{}' in filenames. | |
1109 |
|
1132 | |||
1110 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
1133 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for | |
1111 | Python 2.2 users who lack a proper shlex.split. |
|
1134 | Python 2.2 users who lack a proper shlex.split. | |
1112 |
|
1135 | |||
1113 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
1136 | 2004-07-19 Fernando Perez <fperez@colorado.edu> | |
1114 |
|
1137 | |||
1115 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
1138 | * IPython/iplib.py (InteractiveShell.init_readline): Add support | |
1116 | for reading readline's init file. I follow the normal chain: |
|
1139 | for reading readline's init file. I follow the normal chain: | |
1117 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
1140 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a | |
1118 | report by Mike Heeter. This closes |
|
1141 | report by Mike Heeter. This closes | |
1119 | http://www.scipy.net/roundup/ipython/issue16. |
|
1142 | http://www.scipy.net/roundup/ipython/issue16. | |
1120 |
|
1143 | |||
1121 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
1144 | 2004-07-18 Fernando Perez <fperez@colorado.edu> | |
1122 |
|
1145 | |||
1123 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
1146 | * IPython/iplib.py (__init__): Add better handling of '\' under | |
1124 | Win32 for filenames. After a patch by Ville. |
|
1147 | Win32 for filenames. After a patch by Ville. | |
1125 |
|
1148 | |||
1126 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
1149 | 2004-07-17 Fernando Perez <fperez@colorado.edu> | |
1127 |
|
1150 | |||
1128 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
1151 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1129 | autocalling would be triggered for 'foo is bar' if foo is |
|
1152 | autocalling would be triggered for 'foo is bar' if foo is | |
1130 | callable. I also cleaned up the autocall detection code to use a |
|
1153 | callable. I also cleaned up the autocall detection code to use a | |
1131 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
1154 | regexp, which is faster. Bug reported by Alexander Schmolck. | |
1132 |
|
1155 | |||
1133 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
1156 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with | |
1134 | '?' in them would confuse the help system. Reported by Alex |
|
1157 | '?' in them would confuse the help system. Reported by Alex | |
1135 | Schmolck. |
|
1158 | Schmolck. | |
1136 |
|
1159 | |||
1137 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
1160 | 2004-07-16 Fernando Perez <fperez@colorado.edu> | |
1138 |
|
1161 | |||
1139 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
1162 | * IPython/GnuplotInteractive.py (__all__): added plot2. | |
1140 |
|
1163 | |||
1141 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
1164 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for | |
1142 | plotting dictionaries, lists or tuples of 1d arrays. |
|
1165 | plotting dictionaries, lists or tuples of 1d arrays. | |
1143 |
|
1166 | |||
1144 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
1167 | * IPython/Magic.py (Magic.magic_hist): small clenaups and | |
1145 | optimizations. |
|
1168 | optimizations. | |
1146 |
|
1169 | |||
1147 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
1170 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is | |
1148 | the information which was there from Janko's original IPP code: |
|
1171 | the information which was there from Janko's original IPP code: | |
1149 |
|
1172 | |||
1150 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
1173 | 03.05.99 20:53 porto.ifm.uni-kiel.de | |
1151 | --Started changelog. |
|
1174 | --Started changelog. | |
1152 | --make clear do what it say it does |
|
1175 | --make clear do what it say it does | |
1153 | --added pretty output of lines from inputcache |
|
1176 | --added pretty output of lines from inputcache | |
1154 | --Made Logger a mixin class, simplifies handling of switches |
|
1177 | --Made Logger a mixin class, simplifies handling of switches | |
1155 | --Added own completer class. .string<TAB> expands to last history |
|
1178 | --Added own completer class. .string<TAB> expands to last history | |
1156 | line which starts with string. The new expansion is also present |
|
1179 | line which starts with string. The new expansion is also present | |
1157 | with Ctrl-r from the readline library. But this shows, who this |
|
1180 | with Ctrl-r from the readline library. But this shows, who this | |
1158 | can be done for other cases. |
|
1181 | can be done for other cases. | |
1159 | --Added convention that all shell functions should accept a |
|
1182 | --Added convention that all shell functions should accept a | |
1160 | parameter_string This opens the door for different behaviour for |
|
1183 | parameter_string This opens the door for different behaviour for | |
1161 | each function. @cd is a good example of this. |
|
1184 | each function. @cd is a good example of this. | |
1162 |
|
1185 | |||
1163 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
1186 | 04.05.99 12:12 porto.ifm.uni-kiel.de | |
1164 | --added logfile rotation |
|
1187 | --added logfile rotation | |
1165 | --added new mainloop method which freezes first the namespace |
|
1188 | --added new mainloop method which freezes first the namespace | |
1166 |
|
1189 | |||
1167 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
1190 | 07.05.99 21:24 porto.ifm.uni-kiel.de | |
1168 | --added the docreader classes. Now there is a help system. |
|
1191 | --added the docreader classes. Now there is a help system. | |
1169 | -This is only a first try. Currently it's not easy to put new |
|
1192 | -This is only a first try. Currently it's not easy to put new | |
1170 | stuff in the indices. But this is the way to go. Info would be |
|
1193 | stuff in the indices. But this is the way to go. Info would be | |
1171 | better, but HTML is every where and not everybody has an info |
|
1194 | better, but HTML is every where and not everybody has an info | |
1172 | system installed and it's not so easy to change html-docs to info. |
|
1195 | system installed and it's not so easy to change html-docs to info. | |
1173 | --added global logfile option |
|
1196 | --added global logfile option | |
1174 | --there is now a hook for object inspection method pinfo needs to |
|
1197 | --there is now a hook for object inspection method pinfo needs to | |
1175 | be provided for this. Can be reached by two '??'. |
|
1198 | be provided for this. Can be reached by two '??'. | |
1176 |
|
1199 | |||
1177 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
1200 | 08.05.99 20:51 porto.ifm.uni-kiel.de | |
1178 | --added a README |
|
1201 | --added a README | |
1179 | --bug in rc file. Something has changed so functions in the rc |
|
1202 | --bug in rc file. Something has changed so functions in the rc | |
1180 | file need to reference the shell and not self. Not clear if it's a |
|
1203 | file need to reference the shell and not self. Not clear if it's a | |
1181 | bug or feature. |
|
1204 | bug or feature. | |
1182 | --changed rc file for new behavior |
|
1205 | --changed rc file for new behavior | |
1183 |
|
1206 | |||
1184 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
1207 | 2004-07-15 Fernando Perez <fperez@colorado.edu> | |
1185 |
|
1208 | |||
1186 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
1209 | * IPython/Logger.py (Logger.log): fixed recent bug where the input | |
1187 | cache was falling out of sync in bizarre manners when multi-line |
|
1210 | cache was falling out of sync in bizarre manners when multi-line | |
1188 | input was present. Minor optimizations and cleanup. |
|
1211 | input was present. Minor optimizations and cleanup. | |
1189 |
|
1212 | |||
1190 | (Logger): Remove old Changelog info for cleanup. This is the |
|
1213 | (Logger): Remove old Changelog info for cleanup. This is the | |
1191 | information which was there from Janko's original code: |
|
1214 | information which was there from Janko's original code: | |
1192 |
|
1215 | |||
1193 | Changes to Logger: - made the default log filename a parameter |
|
1216 | Changes to Logger: - made the default log filename a parameter | |
1194 |
|
1217 | |||
1195 | - put a check for lines beginning with !@? in log(). Needed |
|
1218 | - put a check for lines beginning with !@? in log(). Needed | |
1196 | (even if the handlers properly log their lines) for mid-session |
|
1219 | (even if the handlers properly log their lines) for mid-session | |
1197 | logging activation to work properly. Without this, lines logged |
|
1220 | logging activation to work properly. Without this, lines logged | |
1198 | in mid session, which get read from the cache, would end up |
|
1221 | in mid session, which get read from the cache, would end up | |
1199 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
1222 | 'bare' (with !@? in the open) in the log. Now they are caught | |
1200 | and prepended with a #. |
|
1223 | and prepended with a #. | |
1201 |
|
1224 | |||
1202 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
1225 | * IPython/iplib.py (InteractiveShell.init_readline): added check | |
1203 | in case MagicCompleter fails to be defined, so we don't crash. |
|
1226 | in case MagicCompleter fails to be defined, so we don't crash. | |
1204 |
|
1227 | |||
1205 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
1228 | 2004-07-13 Fernando Perez <fperez@colorado.edu> | |
1206 |
|
1229 | |||
1207 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
1230 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation | |
1208 | of EPS if the requested filename ends in '.eps'. |
|
1231 | of EPS if the requested filename ends in '.eps'. | |
1209 |
|
1232 | |||
1210 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
1233 | 2004-07-04 Fernando Perez <fperez@colorado.edu> | |
1211 |
|
1234 | |||
1212 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
1235 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix | |
1213 | escaping of quotes when calling the shell. |
|
1236 | escaping of quotes when calling the shell. | |
1214 |
|
1237 | |||
1215 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
1238 | 2004-07-02 Fernando Perez <fperez@colorado.edu> | |
1216 |
|
1239 | |||
1217 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
1240 | * IPython/Prompts.py (CachedOutput.update): Fix problem with | |
1218 | gettext not working because we were clobbering '_'. Fixes |
|
1241 | gettext not working because we were clobbering '_'. Fixes | |
1219 | http://www.scipy.net/roundup/ipython/issue6. |
|
1242 | http://www.scipy.net/roundup/ipython/issue6. | |
1220 |
|
1243 | |||
1221 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
1244 | 2004-07-01 Fernando Perez <fperez@colorado.edu> | |
1222 |
|
1245 | |||
1223 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
1246 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling | |
1224 | into @cd. Patch by Ville. |
|
1247 | into @cd. Patch by Ville. | |
1225 |
|
1248 | |||
1226 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
1249 | * IPython/iplib.py (InteractiveShell.post_config_initialization): | |
1227 | new function to store things after ipmaker runs. Patch by Ville. |
|
1250 | new function to store things after ipmaker runs. Patch by Ville. | |
1228 | Eventually this will go away once ipmaker is removed and the class |
|
1251 | Eventually this will go away once ipmaker is removed and the class | |
1229 | gets cleaned up, but for now it's ok. Key functionality here is |
|
1252 | gets cleaned up, but for now it's ok. Key functionality here is | |
1230 | the addition of the persistent storage mechanism, a dict for |
|
1253 | the addition of the persistent storage mechanism, a dict for | |
1231 | keeping data across sessions (for now just bookmarks, but more can |
|
1254 | keeping data across sessions (for now just bookmarks, but more can | |
1232 | be implemented later). |
|
1255 | be implemented later). | |
1233 |
|
1256 | |||
1234 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
1257 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, | |
1235 | persistent across sections. Patch by Ville, I modified it |
|
1258 | persistent across sections. Patch by Ville, I modified it | |
1236 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
1259 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also | |
1237 | added a '-l' option to list all bookmarks. |
|
1260 | added a '-l' option to list all bookmarks. | |
1238 |
|
1261 | |||
1239 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
1262 | * IPython/iplib.py (InteractiveShell.atexit_operations): new | |
1240 | center for cleanup. Registered with atexit.register(). I moved |
|
1263 | center for cleanup. Registered with atexit.register(). I moved | |
1241 | here the old exit_cleanup(). After a patch by Ville. |
|
1264 | here the old exit_cleanup(). After a patch by Ville. | |
1242 |
|
1265 | |||
1243 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
1266 | * IPython/Magic.py (get_py_filename): added '~' to the accepted | |
1244 | characters in the hacked shlex_split for python 2.2. |
|
1267 | characters in the hacked shlex_split for python 2.2. | |
1245 |
|
1268 | |||
1246 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
1269 | * IPython/iplib.py (file_matches): more fixes to filenames with | |
1247 | whitespace in them. It's not perfect, but limitations in python's |
|
1270 | whitespace in them. It's not perfect, but limitations in python's | |
1248 | readline make it impossible to go further. |
|
1271 | readline make it impossible to go further. | |
1249 |
|
1272 | |||
1250 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
1273 | 2004-06-29 Fernando Perez <fperez@colorado.edu> | |
1251 |
|
1274 | |||
1252 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
1275 | * IPython/iplib.py (file_matches): escape whitespace correctly in | |
1253 | filename completions. Bug reported by Ville. |
|
1276 | filename completions. Bug reported by Ville. | |
1254 |
|
1277 | |||
1255 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
1278 | 2004-06-28 Fernando Perez <fperez@colorado.edu> | |
1256 |
|
1279 | |||
1257 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
1280 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now | |
1258 | the history file will be called 'history-PROFNAME' (or just |
|
1281 | the history file will be called 'history-PROFNAME' (or just | |
1259 | 'history' if no profile is loaded). I was getting annoyed at |
|
1282 | 'history' if no profile is loaded). I was getting annoyed at | |
1260 | getting my Numerical work history clobbered by pysh sessions. |
|
1283 | getting my Numerical work history clobbered by pysh sessions. | |
1261 |
|
1284 | |||
1262 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
1285 | * IPython/iplib.py (InteractiveShell.__init__): Internal | |
1263 | getoutputerror() function so that we can honor the system_verbose |
|
1286 | getoutputerror() function so that we can honor the system_verbose | |
1264 | flag for _all_ system calls. I also added escaping of # |
|
1287 | flag for _all_ system calls. I also added escaping of # | |
1265 | characters here to avoid confusing Itpl. |
|
1288 | characters here to avoid confusing Itpl. | |
1266 |
|
1289 | |||
1267 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
1290 | * IPython/Magic.py (shlex_split): removed call to shell in | |
1268 | parse_options and replaced it with shlex.split(). The annoying |
|
1291 | parse_options and replaced it with shlex.split(). The annoying | |
1269 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
1292 | part was that in Python 2.2, shlex.split() doesn't exist, so I had | |
1270 | to backport it from 2.3, with several frail hacks (the shlex |
|
1293 | to backport it from 2.3, with several frail hacks (the shlex | |
1271 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
1294 | module is rather limited in 2.2). Thanks to a suggestion by Ville | |
1272 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
1295 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no | |
1273 | problem. |
|
1296 | problem. | |
1274 |
|
1297 | |||
1275 | (Magic.magic_system_verbose): new toggle to print the actual |
|
1298 | (Magic.magic_system_verbose): new toggle to print the actual | |
1276 | system calls made by ipython. Mainly for debugging purposes. |
|
1299 | system calls made by ipython. Mainly for debugging purposes. | |
1277 |
|
1300 | |||
1278 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
1301 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which | |
1279 | doesn't support persistence. Reported (and fix suggested) by |
|
1302 | doesn't support persistence. Reported (and fix suggested) by | |
1280 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
1303 | Travis Caldwell <travis_caldwell2000@yahoo.com>. | |
1281 |
|
1304 | |||
1282 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
1305 | 2004-06-26 Fernando Perez <fperez@colorado.edu> | |
1283 |
|
1306 | |||
1284 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
1307 | * IPython/Logger.py (Logger.log): fix to handle correctly empty | |
1285 | continue prompts. |
|
1308 | continue prompts. | |
1286 |
|
1309 | |||
1287 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
1310 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() | |
1288 | function (basically a big docstring) and a few more things here to |
|
1311 | function (basically a big docstring) and a few more things here to | |
1289 | speedup startup. pysh.py is now very lightweight. We want because |
|
1312 | speedup startup. pysh.py is now very lightweight. We want because | |
1290 | it gets execfile'd, while InterpreterExec gets imported, so |
|
1313 | it gets execfile'd, while InterpreterExec gets imported, so | |
1291 | byte-compilation saves time. |
|
1314 | byte-compilation saves time. | |
1292 |
|
1315 | |||
1293 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
1316 | 2004-06-25 Fernando Perez <fperez@colorado.edu> | |
1294 |
|
1317 | |||
1295 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
1318 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd | |
1296 | -NUM', which was recently broken. |
|
1319 | -NUM', which was recently broken. | |
1297 |
|
1320 | |||
1298 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
1321 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! | |
1299 | in multi-line input (but not !!, which doesn't make sense there). |
|
1322 | in multi-line input (but not !!, which doesn't make sense there). | |
1300 |
|
1323 | |||
1301 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
1324 | * IPython/UserConfig/ipythonrc: made autoindent on by default. | |
1302 | It's just too useful, and people can turn it off in the less |
|
1325 | It's just too useful, and people can turn it off in the less | |
1303 | common cases where it's a problem. |
|
1326 | common cases where it's a problem. | |
1304 |
|
1327 | |||
1305 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
1328 | 2004-06-24 Fernando Perez <fperez@colorado.edu> | |
1306 |
|
1329 | |||
1307 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
1330 | * IPython/iplib.py (InteractiveShell._prefilter): big change - | |
1308 | special syntaxes (like alias calling) is now allied in multi-line |
|
1331 | special syntaxes (like alias calling) is now allied in multi-line | |
1309 | input. This is still _very_ experimental, but it's necessary for |
|
1332 | input. This is still _very_ experimental, but it's necessary for | |
1310 | efficient shell usage combining python looping syntax with system |
|
1333 | efficient shell usage combining python looping syntax with system | |
1311 | calls. For now it's restricted to aliases, I don't think it |
|
1334 | calls. For now it's restricted to aliases, I don't think it | |
1312 | really even makes sense to have this for magics. |
|
1335 | really even makes sense to have this for magics. | |
1313 |
|
1336 | |||
1314 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
1337 | 2004-06-23 Fernando Perez <fperez@colorado.edu> | |
1315 |
|
1338 | |||
1316 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
1339 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added | |
1317 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
1340 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. | |
1318 |
|
1341 | |||
1319 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
1342 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle | |
1320 | extensions under Windows (after code sent by Gary Bishop). The |
|
1343 | extensions under Windows (after code sent by Gary Bishop). The | |
1321 | extensions considered 'executable' are stored in IPython's rc |
|
1344 | extensions considered 'executable' are stored in IPython's rc | |
1322 | structure as win_exec_ext. |
|
1345 | structure as win_exec_ext. | |
1323 |
|
1346 | |||
1324 | * IPython/genutils.py (shell): new function, like system() but |
|
1347 | * IPython/genutils.py (shell): new function, like system() but | |
1325 | without return value. Very useful for interactive shell work. |
|
1348 | without return value. Very useful for interactive shell work. | |
1326 |
|
1349 | |||
1327 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
1350 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to | |
1328 | delete aliases. |
|
1351 | delete aliases. | |
1329 |
|
1352 | |||
1330 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
1353 | * IPython/iplib.py (InteractiveShell.alias_table_update): make | |
1331 | sure that the alias table doesn't contain python keywords. |
|
1354 | sure that the alias table doesn't contain python keywords. | |
1332 |
|
1355 | |||
1333 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
1356 | 2004-06-21 Fernando Perez <fperez@colorado.edu> | |
1334 |
|
1357 | |||
1335 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
1358 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when | |
1336 | non-existent items are found in $PATH. Reported by Thorsten. |
|
1359 | non-existent items are found in $PATH. Reported by Thorsten. | |
1337 |
|
1360 | |||
1338 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
1361 | 2004-06-20 Fernando Perez <fperez@colorado.edu> | |
1339 |
|
1362 | |||
1340 | * IPython/iplib.py (complete): modified the completer so that the |
|
1363 | * IPython/iplib.py (complete): modified the completer so that the | |
1341 | order of priorities can be easily changed at runtime. |
|
1364 | order of priorities can be easily changed at runtime. | |
1342 |
|
1365 | |||
1343 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
1366 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): | |
1344 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
1367 | Modified to auto-execute all lines beginning with '~', '/' or '.'. | |
1345 |
|
1368 | |||
1346 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
1369 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to | |
1347 | expand Python variables prepended with $ in all system calls. The |
|
1370 | expand Python variables prepended with $ in all system calls. The | |
1348 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
1371 | same was done to InteractiveShell.handle_shell_escape. Now all | |
1349 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
1372 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the | |
1350 | expansion of python variables and expressions according to the |
|
1373 | expansion of python variables and expressions according to the | |
1351 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
1374 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. | |
1352 |
|
1375 | |||
1353 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
1376 | Though PEP-215 has been rejected, a similar (but simpler) one | |
1354 | seems like it will go into Python 2.4, PEP-292 - |
|
1377 | seems like it will go into Python 2.4, PEP-292 - | |
1355 | http://www.python.org/peps/pep-0292.html. |
|
1378 | http://www.python.org/peps/pep-0292.html. | |
1356 |
|
1379 | |||
1357 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
1380 | I'll keep the full syntax of PEP-215, since IPython has since the | |
1358 | start used Ka-Ping Yee's reference implementation discussed there |
|
1381 | start used Ka-Ping Yee's reference implementation discussed there | |
1359 | (Itpl), and I actually like the powerful semantics it offers. |
|
1382 | (Itpl), and I actually like the powerful semantics it offers. | |
1360 |
|
1383 | |||
1361 | In order to access normal shell variables, the $ has to be escaped |
|
1384 | In order to access normal shell variables, the $ has to be escaped | |
1362 | via an extra $. For example: |
|
1385 | via an extra $. For example: | |
1363 |
|
1386 | |||
1364 | In [7]: PATH='a python variable' |
|
1387 | In [7]: PATH='a python variable' | |
1365 |
|
1388 | |||
1366 | In [8]: !echo $PATH |
|
1389 | In [8]: !echo $PATH | |
1367 | a python variable |
|
1390 | a python variable | |
1368 |
|
1391 | |||
1369 | In [9]: !echo $$PATH |
|
1392 | In [9]: !echo $$PATH | |
1370 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
1393 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
1371 |
|
1394 | |||
1372 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
1395 | (Magic.parse_options): escape $ so the shell doesn't evaluate | |
1373 | things prematurely. |
|
1396 | things prematurely. | |
1374 |
|
1397 | |||
1375 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
1398 | * IPython/iplib.py (InteractiveShell.call_alias): added the | |
1376 | ability for aliases to expand python variables via $. |
|
1399 | ability for aliases to expand python variables via $. | |
1377 |
|
1400 | |||
1378 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
1401 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias | |
1379 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
1402 | system, now there's a @rehash/@rehashx pair of magics. These work | |
1380 | like the csh rehash command, and can be invoked at any time. They |
|
1403 | like the csh rehash command, and can be invoked at any time. They | |
1381 | build a table of aliases to everything in the user's $PATH |
|
1404 | build a table of aliases to everything in the user's $PATH | |
1382 | (@rehash uses everything, @rehashx is slower but only adds |
|
1405 | (@rehash uses everything, @rehashx is slower but only adds | |
1383 | executable files). With this, the pysh.py-based shell profile can |
|
1406 | executable files). With this, the pysh.py-based shell profile can | |
1384 | now simply call rehash upon startup, and full access to all |
|
1407 | now simply call rehash upon startup, and full access to all | |
1385 | programs in the user's path is obtained. |
|
1408 | programs in the user's path is obtained. | |
1386 |
|
1409 | |||
1387 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
1410 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias | |
1388 | functionality is now fully in place. I removed the old dynamic |
|
1411 | functionality is now fully in place. I removed the old dynamic | |
1389 | code generation based approach, in favor of a much lighter one |
|
1412 | code generation based approach, in favor of a much lighter one | |
1390 | based on a simple dict. The advantage is that this allows me to |
|
1413 | based on a simple dict. The advantage is that this allows me to | |
1391 | now have thousands of aliases with negligible cost (unthinkable |
|
1414 | now have thousands of aliases with negligible cost (unthinkable | |
1392 | with the old system). |
|
1415 | with the old system). | |
1393 |
|
1416 | |||
1394 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
1417 | 2004-06-19 Fernando Perez <fperez@colorado.edu> | |
1395 |
|
1418 | |||
1396 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
1419 | * IPython/iplib.py (__init__): extended MagicCompleter class to | |
1397 | also complete (last in priority) on user aliases. |
|
1420 | also complete (last in priority) on user aliases. | |
1398 |
|
1421 | |||
1399 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
1422 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in | |
1400 | call to eval. |
|
1423 | call to eval. | |
1401 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
1424 | (ItplNS.__init__): Added a new class which functions like Itpl, | |
1402 | but allows configuring the namespace for the evaluation to occur |
|
1425 | but allows configuring the namespace for the evaluation to occur | |
1403 | in. |
|
1426 | in. | |
1404 |
|
1427 | |||
1405 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
1428 | 2004-06-18 Fernando Perez <fperez@colorado.edu> | |
1406 |
|
1429 | |||
1407 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
1430 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a | |
1408 | better message when 'exit' or 'quit' are typed (a common newbie |
|
1431 | better message when 'exit' or 'quit' are typed (a common newbie | |
1409 | confusion). |
|
1432 | confusion). | |
1410 |
|
1433 | |||
1411 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
1434 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color | |
1412 | check for Windows users. |
|
1435 | check for Windows users. | |
1413 |
|
1436 | |||
1414 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
1437 | * IPython/iplib.py (InteractiveShell.user_setup): removed | |
1415 | disabling of colors for Windows. I'll test at runtime and issue a |
|
1438 | disabling of colors for Windows. I'll test at runtime and issue a | |
1416 | warning if Gary's readline isn't found, as to nudge users to |
|
1439 | warning if Gary's readline isn't found, as to nudge users to | |
1417 | download it. |
|
1440 | download it. | |
1418 |
|
1441 | |||
1419 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
1442 | 2004-06-16 Fernando Perez <fperez@colorado.edu> | |
1420 |
|
1443 | |||
1421 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
1444 | * IPython/genutils.py (Stream.__init__): changed to print errors | |
1422 | to sys.stderr. I had a circular dependency here. Now it's |
|
1445 | to sys.stderr. I had a circular dependency here. Now it's | |
1423 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
1446 | possible to run ipython as IDLE's shell (consider this pre-alpha, | |
1424 | since true stdout things end up in the starting terminal instead |
|
1447 | since true stdout things end up in the starting terminal instead | |
1425 | of IDLE's out). |
|
1448 | of IDLE's out). | |
1426 |
|
1449 | |||
1427 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
1450 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for | |
1428 | users who haven't # updated their prompt_in2 definitions. Remove |
|
1451 | users who haven't # updated their prompt_in2 definitions. Remove | |
1429 | eventually. |
|
1452 | eventually. | |
1430 | (multiple_replace): added credit to original ASPN recipe. |
|
1453 | (multiple_replace): added credit to original ASPN recipe. | |
1431 |
|
1454 | |||
1432 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
1455 | 2004-06-15 Fernando Perez <fperez@colorado.edu> | |
1433 |
|
1456 | |||
1434 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
1457 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the | |
1435 | list of auto-defined aliases. |
|
1458 | list of auto-defined aliases. | |
1436 |
|
1459 | |||
1437 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
1460 | 2004-06-13 Fernando Perez <fperez@colorado.edu> | |
1438 |
|
1461 | |||
1439 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
1462 | * setup.py (scriptfiles): Don't trigger win_post_install unless an | |
1440 | install was really requested (so setup.py can be used for other |
|
1463 | install was really requested (so setup.py can be used for other | |
1441 | things under Windows). |
|
1464 | things under Windows). | |
1442 |
|
1465 | |||
1443 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
1466 | 2004-06-10 Fernando Perez <fperez@colorado.edu> | |
1444 |
|
1467 | |||
1445 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
1468 | * IPython/Logger.py (Logger.create_log): Manually remove any old | |
1446 | backup, since os.remove may fail under Windows. Fixes bug |
|
1469 | backup, since os.remove may fail under Windows. Fixes bug | |
1447 | reported by Thorsten. |
|
1470 | reported by Thorsten. | |
1448 |
|
1471 | |||
1449 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
1472 | 2004-06-09 Fernando Perez <fperez@colorado.edu> | |
1450 |
|
1473 | |||
1451 | * examples/example-embed.py: fixed all references to %n (replaced |
|
1474 | * examples/example-embed.py: fixed all references to %n (replaced | |
1452 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
1475 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done | |
1453 | for all examples and the manual as well. |
|
1476 | for all examples and the manual as well. | |
1454 |
|
1477 | |||
1455 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
1478 | 2004-06-08 Fernando Perez <fperez@colorado.edu> | |
1456 |
|
1479 | |||
1457 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
1480 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt | |
1458 | alignment and color management. All 3 prompt subsystems now |
|
1481 | alignment and color management. All 3 prompt subsystems now | |
1459 | inherit from BasePrompt. |
|
1482 | inherit from BasePrompt. | |
1460 |
|
1483 | |||
1461 | * tools/release: updates for windows installer build and tag rpms |
|
1484 | * tools/release: updates for windows installer build and tag rpms | |
1462 | with python version (since paths are fixed). |
|
1485 | with python version (since paths are fixed). | |
1463 |
|
1486 | |||
1464 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
1487 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, | |
1465 | which will become eventually obsolete. Also fixed the default |
|
1488 | which will become eventually obsolete. Also fixed the default | |
1466 | prompt_in2 to use \D, so at least new users start with the correct |
|
1489 | prompt_in2 to use \D, so at least new users start with the correct | |
1467 | defaults. |
|
1490 | defaults. | |
1468 | WARNING: Users with existing ipythonrc files will need to apply |
|
1491 | WARNING: Users with existing ipythonrc files will need to apply | |
1469 | this fix manually! |
|
1492 | this fix manually! | |
1470 |
|
1493 | |||
1471 | * setup.py: make windows installer (.exe). This is finally the |
|
1494 | * setup.py: make windows installer (.exe). This is finally the | |
1472 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
1495 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, | |
1473 | which I hadn't included because it required Python 2.3 (or recent |
|
1496 | which I hadn't included because it required Python 2.3 (or recent | |
1474 | distutils). |
|
1497 | distutils). | |
1475 |
|
1498 | |||
1476 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
1499 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect | |
1477 | usage of new '\D' escape. |
|
1500 | usage of new '\D' escape. | |
1478 |
|
1501 | |||
1479 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
1502 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which | |
1480 | lacks os.getuid()) |
|
1503 | lacks os.getuid()) | |
1481 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
1504 | (CachedOutput.set_colors): Added the ability to turn coloring | |
1482 | on/off with @colors even for manually defined prompt colors. It |
|
1505 | on/off with @colors even for manually defined prompt colors. It | |
1483 | uses a nasty global, but it works safely and via the generic color |
|
1506 | uses a nasty global, but it works safely and via the generic color | |
1484 | handling mechanism. |
|
1507 | handling mechanism. | |
1485 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
1508 | (Prompt2.__init__): Introduced new escape '\D' for continuation | |
1486 | prompts. It represents the counter ('\#') as dots. |
|
1509 | prompts. It represents the counter ('\#') as dots. | |
1487 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
1510 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will | |
1488 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
1511 | need to update their ipythonrc files and replace '%n' with '\D' in | |
1489 | their prompt_in2 settings everywhere. Sorry, but there's |
|
1512 | their prompt_in2 settings everywhere. Sorry, but there's | |
1490 | otherwise no clean way to get all prompts to properly align. The |
|
1513 | otherwise no clean way to get all prompts to properly align. The | |
1491 | ipythonrc shipped with IPython has been updated. |
|
1514 | ipythonrc shipped with IPython has been updated. | |
1492 |
|
1515 | |||
1493 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
1516 | 2004-06-07 Fernando Perez <fperez@colorado.edu> | |
1494 |
|
1517 | |||
1495 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
1518 | * setup.py (isfile): Pass local_icons option to latex2html, so the | |
1496 | resulting HTML file is self-contained. Thanks to |
|
1519 | resulting HTML file is self-contained. Thanks to | |
1497 | dryice-AT-liu.com.cn for the tip. |
|
1520 | dryice-AT-liu.com.cn for the tip. | |
1498 |
|
1521 | |||
1499 | * pysh.py: I created a new profile 'shell', which implements a |
|
1522 | * pysh.py: I created a new profile 'shell', which implements a | |
1500 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
1523 | _rudimentary_ IPython-based shell. This is in NO WAY a realy | |
1501 | system shell, nor will it become one anytime soon. It's mainly |
|
1524 | system shell, nor will it become one anytime soon. It's mainly | |
1502 | meant to illustrate the use of the new flexible bash-like prompts. |
|
1525 | meant to illustrate the use of the new flexible bash-like prompts. | |
1503 | I guess it could be used by hardy souls for true shell management, |
|
1526 | I guess it could be used by hardy souls for true shell management, | |
1504 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
1527 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' | |
1505 | profile. This uses the InterpreterExec extension provided by |
|
1528 | profile. This uses the InterpreterExec extension provided by | |
1506 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
1529 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> | |
1507 |
|
1530 | |||
1508 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
1531 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly | |
1509 | auto-align itself with the length of the previous input prompt |
|
1532 | auto-align itself with the length of the previous input prompt | |
1510 | (taking into account the invisible color escapes). |
|
1533 | (taking into account the invisible color escapes). | |
1511 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
1534 | (CachedOutput.__init__): Large restructuring of this class. Now | |
1512 | all three prompts (primary1, primary2, output) are proper objects, |
|
1535 | all three prompts (primary1, primary2, output) are proper objects, | |
1513 | managed by the 'parent' CachedOutput class. The code is still a |
|
1536 | managed by the 'parent' CachedOutput class. The code is still a | |
1514 | bit hackish (all prompts share state via a pointer to the cache), |
|
1537 | bit hackish (all prompts share state via a pointer to the cache), | |
1515 | but it's overall far cleaner than before. |
|
1538 | but it's overall far cleaner than before. | |
1516 |
|
1539 | |||
1517 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
1540 | * IPython/genutils.py (getoutputerror): modified to add verbose, | |
1518 | debug and header options. This makes the interface of all getout* |
|
1541 | debug and header options. This makes the interface of all getout* | |
1519 | functions uniform. |
|
1542 | functions uniform. | |
1520 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
1543 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. | |
1521 |
|
1544 | |||
1522 | * IPython/Magic.py (Magic.default_option): added a function to |
|
1545 | * IPython/Magic.py (Magic.default_option): added a function to | |
1523 | allow registering default options for any magic command. This |
|
1546 | allow registering default options for any magic command. This | |
1524 | makes it easy to have profiles which customize the magics globally |
|
1547 | makes it easy to have profiles which customize the magics globally | |
1525 | for a certain use. The values set through this function are |
|
1548 | for a certain use. The values set through this function are | |
1526 | picked up by the parse_options() method, which all magics should |
|
1549 | picked up by the parse_options() method, which all magics should | |
1527 | use to parse their options. |
|
1550 | use to parse their options. | |
1528 |
|
1551 | |||
1529 | * IPython/genutils.py (warn): modified the warnings framework to |
|
1552 | * IPython/genutils.py (warn): modified the warnings framework to | |
1530 | use the Term I/O class. I'm trying to slowly unify all of |
|
1553 | use the Term I/O class. I'm trying to slowly unify all of | |
1531 | IPython's I/O operations to pass through Term. |
|
1554 | IPython's I/O operations to pass through Term. | |
1532 |
|
1555 | |||
1533 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
1556 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in | |
1534 | the secondary prompt to correctly match the length of the primary |
|
1557 | the secondary prompt to correctly match the length of the primary | |
1535 | one for any prompt. Now multi-line code will properly line up |
|
1558 | one for any prompt. Now multi-line code will properly line up | |
1536 | even for path dependent prompts, such as the new ones available |
|
1559 | even for path dependent prompts, such as the new ones available | |
1537 | via the prompt_specials. |
|
1560 | via the prompt_specials. | |
1538 |
|
1561 | |||
1539 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
1562 | 2004-06-06 Fernando Perez <fperez@colorado.edu> | |
1540 |
|
1563 | |||
1541 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
1564 | * IPython/Prompts.py (prompt_specials): Added the ability to have | |
1542 | bash-like special sequences in the prompts, which get |
|
1565 | bash-like special sequences in the prompts, which get | |
1543 | automatically expanded. Things like hostname, current working |
|
1566 | automatically expanded. Things like hostname, current working | |
1544 | directory and username are implemented already, but it's easy to |
|
1567 | directory and username are implemented already, but it's easy to | |
1545 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
1568 | add more in the future. Thanks to a patch by W.J. van der Laan | |
1546 | <gnufnork-AT-hetdigitalegat.nl> |
|
1569 | <gnufnork-AT-hetdigitalegat.nl> | |
1547 | (prompt_specials): Added color support for prompt strings, so |
|
1570 | (prompt_specials): Added color support for prompt strings, so | |
1548 | users can define arbitrary color setups for their prompts. |
|
1571 | users can define arbitrary color setups for their prompts. | |
1549 |
|
1572 | |||
1550 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
1573 | 2004-06-05 Fernando Perez <fperez@colorado.edu> | |
1551 |
|
1574 | |||
1552 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
1575 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific | |
1553 | code to load Gary Bishop's readline and configure it |
|
1576 | code to load Gary Bishop's readline and configure it | |
1554 | automatically. Thanks to Gary for help on this. |
|
1577 | automatically. Thanks to Gary for help on this. | |
1555 |
|
1578 | |||
1556 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
1579 | 2004-06-01 Fernando Perez <fperez@colorado.edu> | |
1557 |
|
1580 | |||
1558 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
1581 | * IPython/Logger.py (Logger.create_log): fix bug for logging | |
1559 | with no filename (previous fix was incomplete). |
|
1582 | with no filename (previous fix was incomplete). | |
1560 |
|
1583 | |||
1561 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
1584 | 2004-05-25 Fernando Perez <fperez@colorado.edu> | |
1562 |
|
1585 | |||
1563 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
1586 | * IPython/Magic.py (Magic.parse_options): fix bug where naked | |
1564 | parens would get passed to the shell. |
|
1587 | parens would get passed to the shell. | |
1565 |
|
1588 | |||
1566 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
1589 | 2004-05-20 Fernando Perez <fperez@colorado.edu> | |
1567 |
|
1590 | |||
1568 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
1591 | * IPython/Magic.py (Magic.magic_prun): changed default profile | |
1569 | sort order to 'time' (the more common profiling need). |
|
1592 | sort order to 'time' (the more common profiling need). | |
1570 |
|
1593 | |||
1571 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
1594 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache | |
1572 | so that source code shown is guaranteed in sync with the file on |
|
1595 | so that source code shown is guaranteed in sync with the file on | |
1573 | disk (also changed in psource). Similar fix to the one for |
|
1596 | disk (also changed in psource). Similar fix to the one for | |
1574 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
1597 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du | |
1575 | <yann.ledu-AT-noos.fr>. |
|
1598 | <yann.ledu-AT-noos.fr>. | |
1576 |
|
1599 | |||
1577 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
1600 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands | |
1578 | with a single option would not be correctly parsed. Closes |
|
1601 | with a single option would not be correctly parsed. Closes | |
1579 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
1602 | http://www.scipy.net/roundup/ipython/issue14. This bug had been | |
1580 | introduced in 0.6.0 (on 2004-05-06). |
|
1603 | introduced in 0.6.0 (on 2004-05-06). | |
1581 |
|
1604 | |||
1582 | 2004-05-13 *** Released version 0.6.0 |
|
1605 | 2004-05-13 *** Released version 0.6.0 | |
1583 |
|
1606 | |||
1584 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
1607 | 2004-05-13 Fernando Perez <fperez@colorado.edu> | |
1585 |
|
1608 | |||
1586 | * debian/: Added debian/ directory to CVS, so that debian support |
|
1609 | * debian/: Added debian/ directory to CVS, so that debian support | |
1587 | is publicly accessible. The debian package is maintained by Jack |
|
1610 | is publicly accessible. The debian package is maintained by Jack | |
1588 | Moffit <jack-AT-xiph.org>. |
|
1611 | Moffit <jack-AT-xiph.org>. | |
1589 |
|
1612 | |||
1590 | * Documentation: included the notes about an ipython-based system |
|
1613 | * Documentation: included the notes about an ipython-based system | |
1591 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
1614 | shell (the hypothetical 'pysh') into the new_design.pdf document, | |
1592 | so that these ideas get distributed to users along with the |
|
1615 | so that these ideas get distributed to users along with the | |
1593 | official documentation. |
|
1616 | official documentation. | |
1594 |
|
1617 | |||
1595 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
1618 | 2004-05-10 Fernando Perez <fperez@colorado.edu> | |
1596 |
|
1619 | |||
1597 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
1620 | * IPython/Logger.py (Logger.create_log): fix recently introduced | |
1598 | bug (misindented line) where logstart would fail when not given an |
|
1621 | bug (misindented line) where logstart would fail when not given an | |
1599 | explicit filename. |
|
1622 | explicit filename. | |
1600 |
|
1623 | |||
1601 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
1624 | 2004-05-09 Fernando Perez <fperez@colorado.edu> | |
1602 |
|
1625 | |||
1603 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
1626 | * IPython/Magic.py (Magic.parse_options): skip system call when | |
1604 | there are no options to look for. Faster, cleaner for the common |
|
1627 | there are no options to look for. Faster, cleaner for the common | |
1605 | case. |
|
1628 | case. | |
1606 |
|
1629 | |||
1607 | * Documentation: many updates to the manual: describing Windows |
|
1630 | * Documentation: many updates to the manual: describing Windows | |
1608 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
1631 | support better, Gnuplot updates, credits, misc small stuff. Also | |
1609 | updated the new_design doc a bit. |
|
1632 | updated the new_design doc a bit. | |
1610 |
|
1633 | |||
1611 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
1634 | 2004-05-06 *** Released version 0.6.0.rc1 | |
1612 |
|
1635 | |||
1613 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
1636 | 2004-05-06 Fernando Perez <fperez@colorado.edu> | |
1614 |
|
1637 | |||
1615 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
1638 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += | |
1616 | operations to use the vastly more efficient list/''.join() method. |
|
1639 | operations to use the vastly more efficient list/''.join() method. | |
1617 | (FormattedTB.text): Fix |
|
1640 | (FormattedTB.text): Fix | |
1618 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
1641 | http://www.scipy.net/roundup/ipython/issue12 - exception source | |
1619 | extract not updated after reload. Thanks to Mike Salib |
|
1642 | extract not updated after reload. Thanks to Mike Salib | |
1620 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
1643 | <msalib-AT-mit.edu> for pinning the source of the problem. | |
1621 | Fortunately, the solution works inside ipython and doesn't require |
|
1644 | Fortunately, the solution works inside ipython and doesn't require | |
1622 | any changes to python proper. |
|
1645 | any changes to python proper. | |
1623 |
|
1646 | |||
1624 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
1647 | * IPython/Magic.py (Magic.parse_options): Improved to process the | |
1625 | argument list as a true shell would (by actually using the |
|
1648 | argument list as a true shell would (by actually using the | |
1626 | underlying system shell). This way, all @magics automatically get |
|
1649 | underlying system shell). This way, all @magics automatically get | |
1627 | shell expansion for variables. Thanks to a comment by Alex |
|
1650 | shell expansion for variables. Thanks to a comment by Alex | |
1628 | Schmolck. |
|
1651 | Schmolck. | |
1629 |
|
1652 | |||
1630 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
1653 | 2004-04-04 Fernando Perez <fperez@colorado.edu> | |
1631 |
|
1654 | |||
1632 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
1655 | * IPython/iplib.py (InteractiveShell.interact): Added a special | |
1633 | trap for a debugger quit exception, which is basically impossible |
|
1656 | trap for a debugger quit exception, which is basically impossible | |
1634 | to handle by normal mechanisms, given what pdb does to the stack. |
|
1657 | to handle by normal mechanisms, given what pdb does to the stack. | |
1635 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
1658 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. | |
1636 |
|
1659 | |||
1637 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
1660 | 2004-04-03 Fernando Perez <fperez@colorado.edu> | |
1638 |
|
1661 | |||
1639 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
1662 | * IPython/genutils.py (Term): Standardized the names of the Term | |
1640 | class streams to cin/cout/cerr, following C++ naming conventions |
|
1663 | class streams to cin/cout/cerr, following C++ naming conventions | |
1641 | (I can't use in/out/err because 'in' is not a valid attribute |
|
1664 | (I can't use in/out/err because 'in' is not a valid attribute | |
1642 | name). |
|
1665 | name). | |
1643 |
|
1666 | |||
1644 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
1667 | * IPython/iplib.py (InteractiveShell.interact): don't increment | |
1645 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
1668 | the prompt if there's no user input. By Daniel 'Dang' Griffith | |
1646 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
1669 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from | |
1647 | Francois Pinard. |
|
1670 | Francois Pinard. | |
1648 |
|
1671 | |||
1649 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
1672 | 2004-04-02 Fernando Perez <fperez@colorado.edu> | |
1650 |
|
1673 | |||
1651 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
1674 | * IPython/genutils.py (Stream.__init__): Modified to survive at | |
1652 | least importing in contexts where stdin/out/err aren't true file |
|
1675 | least importing in contexts where stdin/out/err aren't true file | |
1653 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
1676 | objects, such as PyCrust (they lack fileno() and mode). However, | |
1654 | the recovery facilities which rely on these things existing will |
|
1677 | the recovery facilities which rely on these things existing will | |
1655 | not work. |
|
1678 | not work. | |
1656 |
|
1679 | |||
1657 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
1680 | 2004-04-01 Fernando Perez <fperez@colorado.edu> | |
1658 |
|
1681 | |||
1659 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
1682 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to | |
1660 | use the new getoutputerror() function, so it properly |
|
1683 | use the new getoutputerror() function, so it properly | |
1661 | distinguishes stdout/err. |
|
1684 | distinguishes stdout/err. | |
1662 |
|
1685 | |||
1663 | * IPython/genutils.py (getoutputerror): added a function to |
|
1686 | * IPython/genutils.py (getoutputerror): added a function to | |
1664 | capture separately the standard output and error of a command. |
|
1687 | capture separately the standard output and error of a command. | |
1665 | After a comment from dang on the mailing lists. This code is |
|
1688 | After a comment from dang on the mailing lists. This code is | |
1666 | basically a modified version of commands.getstatusoutput(), from |
|
1689 | basically a modified version of commands.getstatusoutput(), from | |
1667 | the standard library. |
|
1690 | the standard library. | |
1668 |
|
1691 | |||
1669 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
1692 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added | |
1670 | '!!' as a special syntax (shorthand) to access @sx. |
|
1693 | '!!' as a special syntax (shorthand) to access @sx. | |
1671 |
|
1694 | |||
1672 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
1695 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell | |
1673 | command and return its output as a list split on '\n'. |
|
1696 | command and return its output as a list split on '\n'. | |
1674 |
|
1697 | |||
1675 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
1698 | 2004-03-31 Fernando Perez <fperez@colorado.edu> | |
1676 |
|
1699 | |||
1677 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
1700 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ | |
1678 | method to dictionaries used as FakeModule instances if they lack |
|
1701 | method to dictionaries used as FakeModule instances if they lack | |
1679 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
1702 | it. At least pydoc in python2.3 breaks for runtime-defined | |
1680 | functions without this hack. At some point I need to _really_ |
|
1703 | functions without this hack. At some point I need to _really_ | |
1681 | understand what FakeModule is doing, because it's a gross hack. |
|
1704 | understand what FakeModule is doing, because it's a gross hack. | |
1682 | But it solves Arnd's problem for now... |
|
1705 | But it solves Arnd's problem for now... | |
1683 |
|
1706 | |||
1684 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
1707 | 2004-02-27 Fernando Perez <fperez@colorado.edu> | |
1685 |
|
1708 | |||
1686 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
1709 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' | |
1687 | mode would behave erratically. Also increased the number of |
|
1710 | mode would behave erratically. Also increased the number of | |
1688 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
1711 | possible logs in rotate mod to 999. Thanks to Rod Holland | |
1689 | <rhh@StructureLABS.com> for the report and fixes. |
|
1712 | <rhh@StructureLABS.com> for the report and fixes. | |
1690 |
|
1713 | |||
1691 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
1714 | 2004-02-26 Fernando Perez <fperez@colorado.edu> | |
1692 |
|
1715 | |||
1693 | * IPython/genutils.py (page): Check that the curses module really |
|
1716 | * IPython/genutils.py (page): Check that the curses module really | |
1694 | has the initscr attribute before trying to use it. For some |
|
1717 | has the initscr attribute before trying to use it. For some | |
1695 | reason, the Solaris curses module is missing this. I think this |
|
1718 | reason, the Solaris curses module is missing this. I think this | |
1696 | should be considered a Solaris python bug, but I'm not sure. |
|
1719 | should be considered a Solaris python bug, but I'm not sure. | |
1697 |
|
1720 | |||
1698 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
1721 | 2004-01-17 Fernando Perez <fperez@colorado.edu> | |
1699 |
|
1722 | |||
1700 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
1723 | * IPython/genutils.py (Stream.__init__): Changes to try to make | |
1701 | ipython robust against stdin/out/err being closed by the user. |
|
1724 | ipython robust against stdin/out/err being closed by the user. | |
1702 | This is 'user error' (and blocks a normal python session, at least |
|
1725 | This is 'user error' (and blocks a normal python session, at least | |
1703 | the stdout case). However, Ipython should be able to survive such |
|
1726 | the stdout case). However, Ipython should be able to survive such | |
1704 | instances of abuse as gracefully as possible. To simplify the |
|
1727 | instances of abuse as gracefully as possible. To simplify the | |
1705 | coding and maintain compatibility with Gary Bishop's Term |
|
1728 | coding and maintain compatibility with Gary Bishop's Term | |
1706 | contributions, I've made use of classmethods for this. I think |
|
1729 | contributions, I've made use of classmethods for this. I think | |
1707 | this introduces a dependency on python 2.2. |
|
1730 | this introduces a dependency on python 2.2. | |
1708 |
|
1731 | |||
1709 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
1732 | 2004-01-13 Fernando Perez <fperez@colorado.edu> | |
1710 |
|
1733 | |||
1711 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
1734 | * IPython/numutils.py (exp_safe): simplified the code a bit and | |
1712 | removed the need for importing the kinds module altogether. |
|
1735 | removed the need for importing the kinds module altogether. | |
1713 |
|
1736 | |||
1714 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
1737 | 2004-01-06 Fernando Perez <fperez@colorado.edu> | |
1715 |
|
1738 | |||
1716 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
1739 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system | |
1717 | a magic function instead, after some community feedback. No |
|
1740 | a magic function instead, after some community feedback. No | |
1718 | special syntax will exist for it, but its name is deliberately |
|
1741 | special syntax will exist for it, but its name is deliberately | |
1719 | very short. |
|
1742 | very short. | |
1720 |
|
1743 | |||
1721 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
1744 | 2003-12-20 Fernando Perez <fperez@colorado.edu> | |
1722 |
|
1745 | |||
1723 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
1746 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added | |
1724 | new functionality, to automagically assign the result of a shell |
|
1747 | new functionality, to automagically assign the result of a shell | |
1725 | command to a variable. I'll solicit some community feedback on |
|
1748 | command to a variable. I'll solicit some community feedback on | |
1726 | this before making it permanent. |
|
1749 | this before making it permanent. | |
1727 |
|
1750 | |||
1728 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
1751 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was | |
1729 | requested about callables for which inspect couldn't obtain a |
|
1752 | requested about callables for which inspect couldn't obtain a | |
1730 | proper argspec. Thanks to a crash report sent by Etienne |
|
1753 | proper argspec. Thanks to a crash report sent by Etienne | |
1731 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
1754 | Posthumus <etienne-AT-apple01.cs.vu.nl>. | |
1732 |
|
1755 | |||
1733 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
1756 | 2003-12-09 Fernando Perez <fperez@colorado.edu> | |
1734 |
|
1757 | |||
1735 | * IPython/genutils.py (page): patch for the pager to work across |
|
1758 | * IPython/genutils.py (page): patch for the pager to work across | |
1736 | various versions of Windows. By Gary Bishop. |
|
1759 | various versions of Windows. By Gary Bishop. | |
1737 |
|
1760 | |||
1738 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
1761 | 2003-12-04 Fernando Perez <fperez@colorado.edu> | |
1739 |
|
1762 | |||
1740 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
1763 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with | |
1741 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
1764 | Gnuplot.py version 1.7, whose internal names changed quite a bit. | |
1742 | While I tested this and it looks ok, there may still be corner |
|
1765 | While I tested this and it looks ok, there may still be corner | |
1743 | cases I've missed. |
|
1766 | cases I've missed. | |
1744 |
|
1767 | |||
1745 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
1768 | 2003-12-01 Fernando Perez <fperez@colorado.edu> | |
1746 |
|
1769 | |||
1747 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
1770 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug | |
1748 | where a line like 'p,q=1,2' would fail because the automagic |
|
1771 | where a line like 'p,q=1,2' would fail because the automagic | |
1749 | system would be triggered for @p. |
|
1772 | system would be triggered for @p. | |
1750 |
|
1773 | |||
1751 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
1774 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related | |
1752 | cleanups, code unmodified. |
|
1775 | cleanups, code unmodified. | |
1753 |
|
1776 | |||
1754 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
1777 | * IPython/genutils.py (Term): added a class for IPython to handle | |
1755 | output. In most cases it will just be a proxy for stdout/err, but |
|
1778 | output. In most cases it will just be a proxy for stdout/err, but | |
1756 | having this allows modifications to be made for some platforms, |
|
1779 | having this allows modifications to be made for some platforms, | |
1757 | such as handling color escapes under Windows. All of this code |
|
1780 | such as handling color escapes under Windows. All of this code | |
1758 | was contributed by Gary Bishop, with minor modifications by me. |
|
1781 | was contributed by Gary Bishop, with minor modifications by me. | |
1759 | The actual changes affect many files. |
|
1782 | The actual changes affect many files. | |
1760 |
|
1783 | |||
1761 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
1784 | 2003-11-30 Fernando Perez <fperez@colorado.edu> | |
1762 |
|
1785 | |||
1763 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
1786 | * IPython/iplib.py (file_matches): new completion code, courtesy | |
1764 | of Jeff Collins. This enables filename completion again under |
|
1787 | of Jeff Collins. This enables filename completion again under | |
1765 | python 2.3, which disabled it at the C level. |
|
1788 | python 2.3, which disabled it at the C level. | |
1766 |
|
1789 | |||
1767 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
1790 | 2003-11-11 Fernando Perez <fperez@colorado.edu> | |
1768 |
|
1791 | |||
1769 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
1792 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand | |
1770 | for Numeric.array(map(...)), but often convenient. |
|
1793 | for Numeric.array(map(...)), but often convenient. | |
1771 |
|
1794 | |||
1772 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
1795 | 2003-11-05 Fernando Perez <fperez@colorado.edu> | |
1773 |
|
1796 | |||
1774 | * IPython/numutils.py (frange): Changed a call from int() to |
|
1797 | * IPython/numutils.py (frange): Changed a call from int() to | |
1775 | int(round()) to prevent a problem reported with arange() in the |
|
1798 | int(round()) to prevent a problem reported with arange() in the | |
1776 | numpy list. |
|
1799 | numpy list. | |
1777 |
|
1800 | |||
1778 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
1801 | 2003-10-06 Fernando Perez <fperez@colorado.edu> | |
1779 |
|
1802 | |||
1780 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
1803 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to | |
1781 | prevent crashes if sys lacks an argv attribute (it happens with |
|
1804 | prevent crashes if sys lacks an argv attribute (it happens with | |
1782 | embedded interpreters which build a bare-bones sys module). |
|
1805 | embedded interpreters which build a bare-bones sys module). | |
1783 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
1806 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. | |
1784 |
|
1807 | |||
1785 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
1808 | 2003-09-24 Fernando Perez <fperez@colorado.edu> | |
1786 |
|
1809 | |||
1787 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
1810 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() | |
1788 | to protect against poorly written user objects where __getattr__ |
|
1811 | to protect against poorly written user objects where __getattr__ | |
1789 | raises exceptions other than AttributeError. Thanks to a bug |
|
1812 | raises exceptions other than AttributeError. Thanks to a bug | |
1790 | report by Oliver Sander <osander-AT-gmx.de>. |
|
1813 | report by Oliver Sander <osander-AT-gmx.de>. | |
1791 |
|
1814 | |||
1792 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
1815 | * IPython/FakeModule.py (FakeModule.__repr__): this method was | |
1793 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
1816 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. | |
1794 |
|
1817 | |||
1795 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
1818 | 2003-09-09 Fernando Perez <fperez@colorado.edu> | |
1796 |
|
1819 | |||
1797 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
1820 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where | |
1798 | unpacking a list whith a callable as first element would |
|
1821 | unpacking a list whith a callable as first element would | |
1799 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
1822 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery | |
1800 | Collins. |
|
1823 | Collins. | |
1801 |
|
1824 | |||
1802 | 2003-08-25 *** Released version 0.5.0 |
|
1825 | 2003-08-25 *** Released version 0.5.0 | |
1803 |
|
1826 | |||
1804 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
1827 | 2003-08-22 Fernando Perez <fperez@colorado.edu> | |
1805 |
|
1828 | |||
1806 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
1829 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of | |
1807 | improperly defined user exceptions. Thanks to feedback from Mark |
|
1830 | improperly defined user exceptions. Thanks to feedback from Mark | |
1808 | Russell <mrussell-AT-verio.net>. |
|
1831 | Russell <mrussell-AT-verio.net>. | |
1809 |
|
1832 | |||
1810 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
1833 | 2003-08-20 Fernando Perez <fperez@colorado.edu> | |
1811 |
|
1834 | |||
1812 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
1835 | * IPython/OInspect.py (Inspector.pinfo): changed String Form | |
1813 | printing so that it would print multi-line string forms starting |
|
1836 | printing so that it would print multi-line string forms starting | |
1814 | with a new line. This way the formatting is better respected for |
|
1837 | with a new line. This way the formatting is better respected for | |
1815 | objects which work hard to make nice string forms. |
|
1838 | objects which work hard to make nice string forms. | |
1816 |
|
1839 | |||
1817 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
1840 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where | |
1818 | autocall would overtake data access for objects with both |
|
1841 | autocall would overtake data access for objects with both | |
1819 | __getitem__ and __call__. |
|
1842 | __getitem__ and __call__. | |
1820 |
|
1843 | |||
1821 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
1844 | 2003-08-19 *** Released version 0.5.0-rc1 | |
1822 |
|
1845 | |||
1823 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
1846 | 2003-08-19 Fernando Perez <fperez@colorado.edu> | |
1824 |
|
1847 | |||
1825 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
1848 | * IPython/deep_reload.py (load_tail): single tiny change here | |
1826 | seems to fix the long-standing bug of dreload() failing to work |
|
1849 | seems to fix the long-standing bug of dreload() failing to work | |
1827 | for dotted names. But this module is pretty tricky, so I may have |
|
1850 | for dotted names. But this module is pretty tricky, so I may have | |
1828 | missed some subtlety. Needs more testing!. |
|
1851 | missed some subtlety. Needs more testing!. | |
1829 |
|
1852 | |||
1830 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
1853 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user | |
1831 | exceptions which have badly implemented __str__ methods. |
|
1854 | exceptions which have badly implemented __str__ methods. | |
1832 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
1855 | (VerboseTB.text): harden against inspect.getinnerframes crashing, | |
1833 | which I've been getting reports about from Python 2.3 users. I |
|
1856 | which I've been getting reports about from Python 2.3 users. I | |
1834 | wish I had a simple test case to reproduce the problem, so I could |
|
1857 | wish I had a simple test case to reproduce the problem, so I could | |
1835 | either write a cleaner workaround or file a bug report if |
|
1858 | either write a cleaner workaround or file a bug report if | |
1836 | necessary. |
|
1859 | necessary. | |
1837 |
|
1860 | |||
1838 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
1861 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after | |
1839 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
1862 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to | |
1840 | a bug report by Tjabo Kloppenburg. |
|
1863 | a bug report by Tjabo Kloppenburg. | |
1841 |
|
1864 | |||
1842 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
1865 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb | |
1843 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
1866 | crashes. Wrapped the pdb call in a blanket try/except, since pdb | |
1844 | seems rather unstable. Thanks to a bug report by Tjabo |
|
1867 | seems rather unstable. Thanks to a bug report by Tjabo | |
1845 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
1868 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. | |
1846 |
|
1869 | |||
1847 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
1870 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put | |
1848 | this out soon because of the critical fixes in the inner loop for |
|
1871 | this out soon because of the critical fixes in the inner loop for | |
1849 | generators. |
|
1872 | generators. | |
1850 |
|
1873 | |||
1851 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
1874 | * IPython/Magic.py (Magic.getargspec): removed. This (and | |
1852 | _get_def) have been obsoleted by OInspect for a long time, I |
|
1875 | _get_def) have been obsoleted by OInspect for a long time, I | |
1853 | hadn't noticed that they were dead code. |
|
1876 | hadn't noticed that they were dead code. | |
1854 | (Magic._ofind): restored _ofind functionality for a few literals |
|
1877 | (Magic._ofind): restored _ofind functionality for a few literals | |
1855 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
1878 | (those in ["''",'""','[]','{}','()']). But it won't work anymore | |
1856 | for things like "hello".capitalize?, since that would require a |
|
1879 | for things like "hello".capitalize?, since that would require a | |
1857 | potentially dangerous eval() again. |
|
1880 | potentially dangerous eval() again. | |
1858 |
|
1881 | |||
1859 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
1882 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the | |
1860 | logic a bit more to clean up the escapes handling and minimize the |
|
1883 | logic a bit more to clean up the escapes handling and minimize the | |
1861 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
1884 | use of _ofind to only necessary cases. The interactive 'feel' of | |
1862 | IPython should have improved quite a bit with the changes in |
|
1885 | IPython should have improved quite a bit with the changes in | |
1863 | _prefilter and _ofind (besides being far safer than before). |
|
1886 | _prefilter and _ofind (besides being far safer than before). | |
1864 |
|
1887 | |||
1865 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
1888 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather | |
1866 | obscure, never reported). Edit would fail to find the object to |
|
1889 | obscure, never reported). Edit would fail to find the object to | |
1867 | edit under some circumstances. |
|
1890 | edit under some circumstances. | |
1868 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
1891 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls | |
1869 | which were causing double-calling of generators. Those eval calls |
|
1892 | which were causing double-calling of generators. Those eval calls | |
1870 | were _very_ dangerous, since code with side effects could be |
|
1893 | were _very_ dangerous, since code with side effects could be | |
1871 | triggered. As they say, 'eval is evil'... These were the |
|
1894 | triggered. As they say, 'eval is evil'... These were the | |
1872 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
1895 | nastiest evals in IPython. Besides, _ofind is now far simpler, | |
1873 | and it should also be quite a bit faster. Its use of inspect is |
|
1896 | and it should also be quite a bit faster. Its use of inspect is | |
1874 | also safer, so perhaps some of the inspect-related crashes I've |
|
1897 | also safer, so perhaps some of the inspect-related crashes I've | |
1875 | seen lately with Python 2.3 might be taken care of. That will |
|
1898 | seen lately with Python 2.3 might be taken care of. That will | |
1876 | need more testing. |
|
1899 | need more testing. | |
1877 |
|
1900 | |||
1878 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
1901 | 2003-08-17 Fernando Perez <fperez@colorado.edu> | |
1879 |
|
1902 | |||
1880 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
1903 | * IPython/iplib.py (InteractiveShell._prefilter): significant | |
1881 | simplifications to the logic for handling user escapes. Faster |
|
1904 | simplifications to the logic for handling user escapes. Faster | |
1882 | and simpler code. |
|
1905 | and simpler code. | |
1883 |
|
1906 | |||
1884 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
1907 | 2003-08-14 Fernando Perez <fperez@colorado.edu> | |
1885 |
|
1908 | |||
1886 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
1909 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. | |
1887 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
1910 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, | |
1888 | but it should be quite a bit faster. And the recursive version |
|
1911 | but it should be quite a bit faster. And the recursive version | |
1889 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
1912 | generated O(log N) intermediate storage for all rank>1 arrays, | |
1890 | even if they were contiguous. |
|
1913 | even if they were contiguous. | |
1891 | (l1norm): Added this function. |
|
1914 | (l1norm): Added this function. | |
1892 | (norm): Added this function for arbitrary norms (including |
|
1915 | (norm): Added this function for arbitrary norms (including | |
1893 | l-infinity). l1 and l2 are still special cases for convenience |
|
1916 | l-infinity). l1 and l2 are still special cases for convenience | |
1894 | and speed. |
|
1917 | and speed. | |
1895 |
|
1918 | |||
1896 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
1919 | 2003-08-03 Fernando Perez <fperez@colorado.edu> | |
1897 |
|
1920 | |||
1898 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
1921 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string | |
1899 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
1922 | exceptions, which now raise PendingDeprecationWarnings in Python | |
1900 | 2.3. There were some in Magic and some in Gnuplot2. |
|
1923 | 2.3. There were some in Magic and some in Gnuplot2. | |
1901 |
|
1924 | |||
1902 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
1925 | 2003-06-30 Fernando Perez <fperez@colorado.edu> | |
1903 |
|
1926 | |||
1904 | * IPython/genutils.py (page): modified to call curses only for |
|
1927 | * IPython/genutils.py (page): modified to call curses only for | |
1905 | terminals where TERM=='xterm'. After problems under many other |
|
1928 | terminals where TERM=='xterm'. After problems under many other | |
1906 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
1929 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. | |
1907 |
|
1930 | |||
1908 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
1931 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which | |
1909 | would be triggered when readline was absent. This was just an old |
|
1932 | would be triggered when readline was absent. This was just an old | |
1910 | debugging statement I'd forgotten to take out. |
|
1933 | debugging statement I'd forgotten to take out. | |
1911 |
|
1934 | |||
1912 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
1935 | 2003-06-20 Fernando Perez <fperez@colorado.edu> | |
1913 |
|
1936 | |||
1914 | * IPython/genutils.py (clock): modified to return only user time |
|
1937 | * IPython/genutils.py (clock): modified to return only user time | |
1915 | (not counting system time), after a discussion on scipy. While |
|
1938 | (not counting system time), after a discussion on scipy. While | |
1916 | system time may be a useful quantity occasionally, it may much |
|
1939 | system time may be a useful quantity occasionally, it may much | |
1917 | more easily be skewed by occasional swapping or other similar |
|
1940 | more easily be skewed by occasional swapping or other similar | |
1918 | activity. |
|
1941 | activity. | |
1919 |
|
1942 | |||
1920 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
1943 | 2003-06-05 Fernando Perez <fperez@colorado.edu> | |
1921 |
|
1944 | |||
1922 | * IPython/numutils.py (identity): new function, for building |
|
1945 | * IPython/numutils.py (identity): new function, for building | |
1923 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
1946 | arbitrary rank Kronecker deltas (mostly backwards compatible with | |
1924 | Numeric.identity) |
|
1947 | Numeric.identity) | |
1925 |
|
1948 | |||
1926 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
1949 | 2003-06-03 Fernando Perez <fperez@colorado.edu> | |
1927 |
|
1950 | |||
1928 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
1951 | * IPython/iplib.py (InteractiveShell.handle_magic): protect | |
1929 | arguments passed to magics with spaces, to allow trailing '\' to |
|
1952 | arguments passed to magics with spaces, to allow trailing '\' to | |
1930 | work normally (mainly for Windows users). |
|
1953 | work normally (mainly for Windows users). | |
1931 |
|
1954 | |||
1932 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
1955 | 2003-05-29 Fernando Perez <fperez@colorado.edu> | |
1933 |
|
1956 | |||
1934 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
1957 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help | |
1935 | instead of pydoc.help. This fixes a bizarre behavior where |
|
1958 | instead of pydoc.help. This fixes a bizarre behavior where | |
1936 | printing '%s' % locals() would trigger the help system. Now |
|
1959 | printing '%s' % locals() would trigger the help system. Now | |
1937 | ipython behaves like normal python does. |
|
1960 | ipython behaves like normal python does. | |
1938 |
|
1961 | |||
1939 | Note that if one does 'from pydoc import help', the bizarre |
|
1962 | Note that if one does 'from pydoc import help', the bizarre | |
1940 | behavior returns, but this will also happen in normal python, so |
|
1963 | behavior returns, but this will also happen in normal python, so | |
1941 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
1964 | it's not an ipython bug anymore (it has to do with how pydoc.help | |
1942 | is implemented). |
|
1965 | is implemented). | |
1943 |
|
1966 | |||
1944 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
1967 | 2003-05-22 Fernando Perez <fperez@colorado.edu> | |
1945 |
|
1968 | |||
1946 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
1969 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to | |
1947 | return [] instead of None when nothing matches, also match to end |
|
1970 | return [] instead of None when nothing matches, also match to end | |
1948 | of line. Patch by Gary Bishop. |
|
1971 | of line. Patch by Gary Bishop. | |
1949 |
|
1972 | |||
1950 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
1973 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook | |
1951 | protection as before, for files passed on the command line. This |
|
1974 | protection as before, for files passed on the command line. This | |
1952 | prevents the CrashHandler from kicking in if user files call into |
|
1975 | prevents the CrashHandler from kicking in if user files call into | |
1953 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
1976 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of | |
1954 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
1977 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> | |
1955 |
|
1978 | |||
1956 | 2003-05-20 *** Released version 0.4.0 |
|
1979 | 2003-05-20 *** Released version 0.4.0 | |
1957 |
|
1980 | |||
1958 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
1981 | 2003-05-20 Fernando Perez <fperez@colorado.edu> | |
1959 |
|
1982 | |||
1960 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
1983 | * setup.py: added support for manpages. It's a bit hackish b/c of | |
1961 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
1984 | a bug in the way the bdist_rpm distutils target handles gzipped | |
1962 | manpages, but it works. After a patch by Jack. |
|
1985 | manpages, but it works. After a patch by Jack. | |
1963 |
|
1986 | |||
1964 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
1987 | 2003-05-19 Fernando Perez <fperez@colorado.edu> | |
1965 |
|
1988 | |||
1966 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
1989 | * IPython/numutils.py: added a mockup of the kinds module, since | |
1967 | it was recently removed from Numeric. This way, numutils will |
|
1990 | it was recently removed from Numeric. This way, numutils will | |
1968 | work for all users even if they are missing kinds. |
|
1991 | work for all users even if they are missing kinds. | |
1969 |
|
1992 | |||
1970 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
1993 | * IPython/Magic.py (Magic._ofind): Harden against an inspect | |
1971 | failure, which can occur with SWIG-wrapped extensions. After a |
|
1994 | failure, which can occur with SWIG-wrapped extensions. After a | |
1972 | crash report from Prabhu. |
|
1995 | crash report from Prabhu. | |
1973 |
|
1996 | |||
1974 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
1997 | 2003-05-16 Fernando Perez <fperez@colorado.edu> | |
1975 |
|
1998 | |||
1976 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
1999 | * IPython/iplib.py (InteractiveShell.excepthook): New method to | |
1977 | protect ipython from user code which may call directly |
|
2000 | protect ipython from user code which may call directly | |
1978 | sys.excepthook (this looks like an ipython crash to the user, even |
|
2001 | sys.excepthook (this looks like an ipython crash to the user, even | |
1979 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2002 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
1980 | This is especially important to help users of WxWindows, but may |
|
2003 | This is especially important to help users of WxWindows, but may | |
1981 | also be useful in other cases. |
|
2004 | also be useful in other cases. | |
1982 |
|
2005 | |||
1983 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
2006 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow | |
1984 | an optional tb_offset to be specified, and to preserve exception |
|
2007 | an optional tb_offset to be specified, and to preserve exception | |
1985 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
2008 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. | |
1986 |
|
2009 | |||
1987 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
2010 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! | |
1988 |
|
2011 | |||
1989 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
2012 | 2003-05-15 Fernando Perez <fperez@colorado.edu> | |
1990 |
|
2013 | |||
1991 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
2014 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when | |
1992 | installing for a new user under Windows. |
|
2015 | installing for a new user under Windows. | |
1993 |
|
2016 | |||
1994 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
2017 | 2003-05-12 Fernando Perez <fperez@colorado.edu> | |
1995 |
|
2018 | |||
1996 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
2019 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line | |
1997 | handler for Emacs comint-based lines. Currently it doesn't do |
|
2020 | handler for Emacs comint-based lines. Currently it doesn't do | |
1998 | much (but importantly, it doesn't update the history cache). In |
|
2021 | much (but importantly, it doesn't update the history cache). In | |
1999 | the future it may be expanded if Alex needs more functionality |
|
2022 | the future it may be expanded if Alex needs more functionality | |
2000 | there. |
|
2023 | there. | |
2001 |
|
2024 | |||
2002 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
2025 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform | |
2003 | info to crash reports. |
|
2026 | info to crash reports. | |
2004 |
|
2027 | |||
2005 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
2028 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, | |
2006 | just like Python's -c. Also fixed crash with invalid -color |
|
2029 | just like Python's -c. Also fixed crash with invalid -color | |
2007 | option value at startup. Thanks to Will French |
|
2030 | option value at startup. Thanks to Will French | |
2008 | <wfrench-AT-bestweb.net> for the bug report. |
|
2031 | <wfrench-AT-bestweb.net> for the bug report. | |
2009 |
|
2032 | |||
2010 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
2033 | 2003-05-09 Fernando Perez <fperez@colorado.edu> | |
2011 |
|
2034 | |||
2012 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
2035 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString | |
2013 | to EvalDict (it's a mapping, after all) and simplified its code |
|
2036 | to EvalDict (it's a mapping, after all) and simplified its code | |
2014 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
2037 | quite a bit, after a nice discussion on c.l.py where Gustavo | |
2015 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. |
|
2038 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. | |
2016 |
|
2039 | |||
2017 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
2040 | 2003-04-30 Fernando Perez <fperez@colorado.edu> | |
2018 |
|
2041 | |||
2019 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
2042 | * IPython/genutils.py (timings_out): modified it to reduce its | |
2020 | overhead in the common reps==1 case. |
|
2043 | overhead in the common reps==1 case. | |
2021 |
|
2044 | |||
2022 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
2045 | 2003-04-29 Fernando Perez <fperez@colorado.edu> | |
2023 |
|
2046 | |||
2024 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
2047 | * IPython/genutils.py (timings_out): Modified to use the resource | |
2025 | module, which avoids the wraparound problems of time.clock(). |
|
2048 | module, which avoids the wraparound problems of time.clock(). | |
2026 |
|
2049 | |||
2027 | 2003-04-17 *** Released version 0.2.15pre4 |
|
2050 | 2003-04-17 *** Released version 0.2.15pre4 | |
2028 |
|
2051 | |||
2029 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
2052 | 2003-04-17 Fernando Perez <fperez@colorado.edu> | |
2030 |
|
2053 | |||
2031 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
2054 | * setup.py (scriptfiles): Split windows-specific stuff over to a | |
2032 | separate file, in an attempt to have a Windows GUI installer. |
|
2055 | separate file, in an attempt to have a Windows GUI installer. | |
2033 | That didn't work, but part of the groundwork is done. |
|
2056 | That didn't work, but part of the groundwork is done. | |
2034 |
|
2057 | |||
2035 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
2058 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for | |
2036 | indent/unindent with 4 spaces. Particularly useful in combination |
|
2059 | indent/unindent with 4 spaces. Particularly useful in combination | |
2037 | with the new auto-indent option. |
|
2060 | with the new auto-indent option. | |
2038 |
|
2061 | |||
2039 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
2062 | 2003-04-16 Fernando Perez <fperez@colorado.edu> | |
2040 |
|
2063 | |||
2041 | * IPython/Magic.py: various replacements of self.rc for |
|
2064 | * IPython/Magic.py: various replacements of self.rc for | |
2042 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
2065 | self.shell.rc. A lot more remains to be done to fully disentangle | |
2043 | this class from the main Shell class. |
|
2066 | this class from the main Shell class. | |
2044 |
|
2067 | |||
2045 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
2068 | * IPython/GnuplotRuntime.py: added checks for mouse support so | |
2046 | that we don't try to enable it if the current gnuplot doesn't |
|
2069 | that we don't try to enable it if the current gnuplot doesn't | |
2047 | really support it. Also added checks so that we don't try to |
|
2070 | really support it. Also added checks so that we don't try to | |
2048 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
2071 | enable persist under Windows (where Gnuplot doesn't recognize the | |
2049 | option). |
|
2072 | option). | |
2050 |
|
2073 | |||
2051 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
2074 | * IPython/iplib.py (InteractiveShell.interact): Added optional | |
2052 | auto-indenting code, after a patch by King C. Shu |
|
2075 | auto-indenting code, after a patch by King C. Shu | |
2053 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
2076 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't | |
2054 | get along well with pasting indented code. If I ever figure out |
|
2077 | get along well with pasting indented code. If I ever figure out | |
2055 | how to make that part go well, it will become on by default. |
|
2078 | how to make that part go well, it will become on by default. | |
2056 |
|
2079 | |||
2057 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
2080 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would | |
2058 | crash ipython if there was an unmatched '%' in the user's prompt |
|
2081 | crash ipython if there was an unmatched '%' in the user's prompt | |
2059 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2082 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2060 |
|
2083 | |||
2061 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
2084 | * IPython/iplib.py (InteractiveShell.interact): removed the | |
2062 | ability to ask the user whether he wants to crash or not at the |
|
2085 | ability to ask the user whether he wants to crash or not at the | |
2063 | 'last line' exception handler. Calling functions at that point |
|
2086 | 'last line' exception handler. Calling functions at that point | |
2064 | changes the stack, and the error reports would have incorrect |
|
2087 | changes the stack, and the error reports would have incorrect | |
2065 | tracebacks. |
|
2088 | tracebacks. | |
2066 |
|
2089 | |||
2067 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
2090 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to | |
2068 | pass through a peger a pretty-printed form of any object. After a |
|
2091 | pass through a peger a pretty-printed form of any object. After a | |
2069 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
2092 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> | |
2070 |
|
2093 | |||
2071 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
2094 | 2003-04-14 Fernando Perez <fperez@colorado.edu> | |
2072 |
|
2095 | |||
2073 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
2096 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where | |
2074 | all files in ~ would be modified at first install (instead of |
|
2097 | all files in ~ would be modified at first install (instead of | |
2075 | ~/.ipython). This could be potentially disastrous, as the |
|
2098 | ~/.ipython). This could be potentially disastrous, as the | |
2076 | modification (make line-endings native) could damage binary files. |
|
2099 | modification (make line-endings native) could damage binary files. | |
2077 |
|
2100 | |||
2078 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
2101 | 2003-04-10 Fernando Perez <fperez@colorado.edu> | |
2079 |
|
2102 | |||
2080 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
2103 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to | |
2081 | handle only lines which are invalid python. This now means that |
|
2104 | handle only lines which are invalid python. This now means that | |
2082 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
2105 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins | |
2083 | for the bug report. |
|
2106 | for the bug report. | |
2084 |
|
2107 | |||
2085 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
2108 | 2003-04-01 Fernando Perez <fperez@colorado.edu> | |
2086 |
|
2109 | |||
2087 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
2110 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug | |
2088 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
2111 | where failing to set sys.last_traceback would crash pdb.pm(). | |
2089 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
2112 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug | |
2090 | report. |
|
2113 | report. | |
2091 |
|
2114 | |||
2092 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
2115 | 2003-03-25 Fernando Perez <fperez@colorado.edu> | |
2093 |
|
2116 | |||
2094 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
2117 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler | |
2095 | before printing it (it had a lot of spurious blank lines at the |
|
2118 | before printing it (it had a lot of spurious blank lines at the | |
2096 | end). |
|
2119 | end). | |
2097 |
|
2120 | |||
2098 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
2121 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr | |
2099 | output would be sent 21 times! Obviously people don't use this |
|
2122 | output would be sent 21 times! Obviously people don't use this | |
2100 | too often, or I would have heard about it. |
|
2123 | too often, or I would have heard about it. | |
2101 |
|
2124 | |||
2102 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
2125 | 2003-03-24 Fernando Perez <fperez@colorado.edu> | |
2103 |
|
2126 | |||
2104 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
2127 | * setup.py (scriptfiles): renamed the data_files parameter from | |
2105 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
2128 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink | |
2106 | for the patch. |
|
2129 | for the patch. | |
2107 |
|
2130 | |||
2108 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
2131 | 2003-03-20 Fernando Perez <fperez@colorado.edu> | |
2109 |
|
2132 | |||
2110 | * IPython/genutils.py (error): added error() and fatal() |
|
2133 | * IPython/genutils.py (error): added error() and fatal() | |
2111 | functions. |
|
2134 | functions. | |
2112 |
|
2135 | |||
2113 | 2003-03-18 *** Released version 0.2.15pre3 |
|
2136 | 2003-03-18 *** Released version 0.2.15pre3 | |
2114 |
|
2137 | |||
2115 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
2138 | 2003-03-18 Fernando Perez <fperez@colorado.edu> | |
2116 |
|
2139 | |||
2117 | * setupext/install_data_ext.py |
|
2140 | * setupext/install_data_ext.py | |
2118 | (install_data_ext.initialize_options): Class contributed by Jack |
|
2141 | (install_data_ext.initialize_options): Class contributed by Jack | |
2119 | Moffit for fixing the old distutils hack. He is sending this to |
|
2142 | Moffit for fixing the old distutils hack. He is sending this to | |
2120 | the distutils folks so in the future we may not need it as a |
|
2143 | the distutils folks so in the future we may not need it as a | |
2121 | private fix. |
|
2144 | private fix. | |
2122 |
|
2145 | |||
2123 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
2146 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's | |
2124 | changes for Debian packaging. See his patch for full details. |
|
2147 | changes for Debian packaging. See his patch for full details. | |
2125 | The old distutils hack of making the ipythonrc* files carry a |
|
2148 | The old distutils hack of making the ipythonrc* files carry a | |
2126 | bogus .py extension is gone, at last. Examples were moved to a |
|
2149 | bogus .py extension is gone, at last. Examples were moved to a | |
2127 | separate subdir under doc/, and the separate executable scripts |
|
2150 | separate subdir under doc/, and the separate executable scripts | |
2128 | now live in their own directory. Overall a great cleanup. The |
|
2151 | now live in their own directory. Overall a great cleanup. The | |
2129 | manual was updated to use the new files, and setup.py has been |
|
2152 | manual was updated to use the new files, and setup.py has been | |
2130 | fixed for this setup. |
|
2153 | fixed for this setup. | |
2131 |
|
2154 | |||
2132 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
2155 | * IPython/PyColorize.py (Parser.usage): made non-executable and | |
2133 | created a pycolor wrapper around it to be included as a script. |
|
2156 | created a pycolor wrapper around it to be included as a script. | |
2134 |
|
2157 | |||
2135 | 2003-03-12 *** Released version 0.2.15pre2 |
|
2158 | 2003-03-12 *** Released version 0.2.15pre2 | |
2136 |
|
2159 | |||
2137 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
2160 | 2003-03-12 Fernando Perez <fperez@colorado.edu> | |
2138 |
|
2161 | |||
2139 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
2162 | * IPython/ColorANSI.py (make_color_table): Finally fixed the | |
2140 | long-standing problem with garbage characters in some terminals. |
|
2163 | long-standing problem with garbage characters in some terminals. | |
2141 | The issue was really that the \001 and \002 escapes must _only_ be |
|
2164 | The issue was really that the \001 and \002 escapes must _only_ be | |
2142 | passed to input prompts (which call readline), but _never_ to |
|
2165 | passed to input prompts (which call readline), but _never_ to | |
2143 | normal text to be printed on screen. I changed ColorANSI to have |
|
2166 | normal text to be printed on screen. I changed ColorANSI to have | |
2144 | two classes: TermColors and InputTermColors, each with the |
|
2167 | two classes: TermColors and InputTermColors, each with the | |
2145 | appropriate escapes for input prompts or normal text. The code in |
|
2168 | appropriate escapes for input prompts or normal text. The code in | |
2146 | Prompts.py got slightly more complicated, but this very old and |
|
2169 | Prompts.py got slightly more complicated, but this very old and | |
2147 | annoying bug is finally fixed. |
|
2170 | annoying bug is finally fixed. | |
2148 |
|
2171 | |||
2149 | All the credit for nailing down the real origin of this problem |
|
2172 | All the credit for nailing down the real origin of this problem | |
2150 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
2173 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. | |
2151 | *Many* thanks to him for spending quite a bit of effort on this. |
|
2174 | *Many* thanks to him for spending quite a bit of effort on this. | |
2152 |
|
2175 | |||
2153 | 2003-03-05 *** Released version 0.2.15pre1 |
|
2176 | 2003-03-05 *** Released version 0.2.15pre1 | |
2154 |
|
2177 | |||
2155 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
2178 | 2003-03-03 Fernando Perez <fperez@colorado.edu> | |
2156 |
|
2179 | |||
2157 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
2180 | * IPython/FakeModule.py: Moved the former _FakeModule to a | |
2158 | separate file, because it's also needed by Magic (to fix a similar |
|
2181 | separate file, because it's also needed by Magic (to fix a similar | |
2159 | pickle-related issue in @run). |
|
2182 | pickle-related issue in @run). | |
2160 |
|
2183 | |||
2161 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
2184 | 2003-03-02 Fernando Perez <fperez@colorado.edu> | |
2162 |
|
2185 | |||
2163 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
2186 | * IPython/Magic.py (Magic.magic_autocall): new magic to control | |
2164 | the autocall option at runtime. |
|
2187 | the autocall option at runtime. | |
2165 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
2188 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns | |
2166 | across Magic.py to start separating Magic from InteractiveShell. |
|
2189 | across Magic.py to start separating Magic from InteractiveShell. | |
2167 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
2190 | (Magic._ofind): Fixed to return proper namespace for dotted | |
2168 | names. Before, a dotted name would always return 'not currently |
|
2191 | names. Before, a dotted name would always return 'not currently | |
2169 | defined', because it would find the 'parent'. s.x would be found, |
|
2192 | defined', because it would find the 'parent'. s.x would be found, | |
2170 | but since 'x' isn't defined by itself, it would get confused. |
|
2193 | but since 'x' isn't defined by itself, it would get confused. | |
2171 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
2194 | (Magic.magic_run): Fixed pickling problems reported by Ralf | |
2172 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
2195 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to | |
2173 | that I'd used when Mike Heeter reported similar issues at the |
|
2196 | that I'd used when Mike Heeter reported similar issues at the | |
2174 | top-level, but now for @run. It boils down to injecting the |
|
2197 | top-level, but now for @run. It boils down to injecting the | |
2175 | namespace where code is being executed with something that looks |
|
2198 | namespace where code is being executed with something that looks | |
2176 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
2199 | enough like a module to fool pickle.dump(). Since a pickle stores | |
2177 | a named reference to the importing module, we need this for |
|
2200 | a named reference to the importing module, we need this for | |
2178 | pickles to save something sensible. |
|
2201 | pickles to save something sensible. | |
2179 |
|
2202 | |||
2180 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
2203 | * IPython/ipmaker.py (make_IPython): added an autocall option. | |
2181 |
|
2204 | |||
2182 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
2205 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of | |
2183 | the auto-eval code. Now autocalling is an option, and the code is |
|
2206 | the auto-eval code. Now autocalling is an option, and the code is | |
2184 | also vastly safer. There is no more eval() involved at all. |
|
2207 | also vastly safer. There is no more eval() involved at all. | |
2185 |
|
2208 | |||
2186 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
2209 | 2003-03-01 Fernando Perez <fperez@colorado.edu> | |
2187 |
|
2210 | |||
2188 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
2211 | * IPython/Magic.py (Magic._ofind): Changed interface to return a | |
2189 | dict with named keys instead of a tuple. |
|
2212 | dict with named keys instead of a tuple. | |
2190 |
|
2213 | |||
2191 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
2214 | * IPython: Started using CVS for IPython as of 0.2.15pre1. | |
2192 |
|
2215 | |||
2193 | * setup.py (make_shortcut): Fixed message about directories |
|
2216 | * setup.py (make_shortcut): Fixed message about directories | |
2194 | created during Windows installation (the directories were ok, just |
|
2217 | created during Windows installation (the directories were ok, just | |
2195 | the printed message was misleading). Thanks to Chris Liechti |
|
2218 | the printed message was misleading). Thanks to Chris Liechti | |
2196 | <cliechti-AT-gmx.net> for the heads up. |
|
2219 | <cliechti-AT-gmx.net> for the heads up. | |
2197 |
|
2220 | |||
2198 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
2221 | 2003-02-21 Fernando Perez <fperez@colorado.edu> | |
2199 |
|
2222 | |||
2200 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
2223 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching | |
2201 | of ValueError exception when checking for auto-execution. This |
|
2224 | of ValueError exception when checking for auto-execution. This | |
2202 | one is raised by things like Numeric arrays arr.flat when the |
|
2225 | one is raised by things like Numeric arrays arr.flat when the | |
2203 | array is non-contiguous. |
|
2226 | array is non-contiguous. | |
2204 |
|
2227 | |||
2205 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
2228 | 2003-01-31 Fernando Perez <fperez@colorado.edu> | |
2206 |
|
2229 | |||
2207 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
2230 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would | |
2208 | not return any value at all (even though the command would get |
|
2231 | not return any value at all (even though the command would get | |
2209 | executed). |
|
2232 | executed). | |
2210 | (xsys): Flush stdout right after printing the command to ensure |
|
2233 | (xsys): Flush stdout right after printing the command to ensure | |
2211 | proper ordering of commands and command output in the total |
|
2234 | proper ordering of commands and command output in the total | |
2212 | output. |
|
2235 | output. | |
2213 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
2236 | (SystemExec/xsys/bq): Switched the names of xsys/bq and | |
2214 | system/getoutput as defaults. The old ones are kept for |
|
2237 | system/getoutput as defaults. The old ones are kept for | |
2215 | compatibility reasons, so no code which uses this library needs |
|
2238 | compatibility reasons, so no code which uses this library needs | |
2216 | changing. |
|
2239 | changing. | |
2217 |
|
2240 | |||
2218 | 2003-01-27 *** Released version 0.2.14 |
|
2241 | 2003-01-27 *** Released version 0.2.14 | |
2219 |
|
2242 | |||
2220 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
2243 | 2003-01-25 Fernando Perez <fperez@colorado.edu> | |
2221 |
|
2244 | |||
2222 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
2245 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where | |
2223 | functions defined in previous edit sessions could not be re-edited |
|
2246 | functions defined in previous edit sessions could not be re-edited | |
2224 | (because the temp files were immediately removed). Now temp files |
|
2247 | (because the temp files were immediately removed). Now temp files | |
2225 | are removed only at IPython's exit. |
|
2248 | are removed only at IPython's exit. | |
2226 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
2249 | (Magic.magic_run): Improved @run to perform shell-like expansions | |
2227 | on its arguments (~users and $VARS). With this, @run becomes more |
|
2250 | on its arguments (~users and $VARS). With this, @run becomes more | |
2228 | like a normal command-line. |
|
2251 | like a normal command-line. | |
2229 |
|
2252 | |||
2230 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
2253 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small | |
2231 | bugs related to embedding and cleaned up that code. A fairly |
|
2254 | bugs related to embedding and cleaned up that code. A fairly | |
2232 | important one was the impossibility to access the global namespace |
|
2255 | important one was the impossibility to access the global namespace | |
2233 | through the embedded IPython (only local variables were visible). |
|
2256 | through the embedded IPython (only local variables were visible). | |
2234 |
|
2257 | |||
2235 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
2258 | 2003-01-14 Fernando Perez <fperez@colorado.edu> | |
2236 |
|
2259 | |||
2237 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
2260 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed | |
2238 | auto-calling to be a bit more conservative. Now it doesn't get |
|
2261 | auto-calling to be a bit more conservative. Now it doesn't get | |
2239 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
2262 | triggered if any of '!=()<>' are in the rest of the input line, to | |
2240 | allow comparing callables. Thanks to Alex for the heads up. |
|
2263 | allow comparing callables. Thanks to Alex for the heads up. | |
2241 |
|
2264 | |||
2242 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
2265 | 2003-01-07 Fernando Perez <fperez@colorado.edu> | |
2243 |
|
2266 | |||
2244 | * IPython/genutils.py (page): fixed estimation of the number of |
|
2267 | * IPython/genutils.py (page): fixed estimation of the number of | |
2245 | lines in a string to be paged to simply count newlines. This |
|
2268 | lines in a string to be paged to simply count newlines. This | |
2246 | prevents over-guessing due to embedded escape sequences. A better |
|
2269 | prevents over-guessing due to embedded escape sequences. A better | |
2247 | long-term solution would involve stripping out the control chars |
|
2270 | long-term solution would involve stripping out the control chars | |
2248 | for the count, but it's potentially so expensive I just don't |
|
2271 | for the count, but it's potentially so expensive I just don't | |
2249 | think it's worth doing. |
|
2272 | think it's worth doing. | |
2250 |
|
2273 | |||
2251 | 2002-12-19 *** Released version 0.2.14pre50 |
|
2274 | 2002-12-19 *** Released version 0.2.14pre50 | |
2252 |
|
2275 | |||
2253 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
2276 | 2002-12-19 Fernando Perez <fperez@colorado.edu> | |
2254 |
|
2277 | |||
2255 | * tools/release (version): Changed release scripts to inform |
|
2278 | * tools/release (version): Changed release scripts to inform | |
2256 | Andrea and build a NEWS file with a list of recent changes. |
|
2279 | Andrea and build a NEWS file with a list of recent changes. | |
2257 |
|
2280 | |||
2258 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
2281 | * IPython/ColorANSI.py (__all__): changed terminal detection | |
2259 | code. Seems to work better for xterms without breaking |
|
2282 | code. Seems to work better for xterms without breaking | |
2260 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
2283 | konsole. Will need more testing to determine if WinXP and Mac OSX | |
2261 | also work ok. |
|
2284 | also work ok. | |
2262 |
|
2285 | |||
2263 | 2002-12-18 *** Released version 0.2.14pre49 |
|
2286 | 2002-12-18 *** Released version 0.2.14pre49 | |
2264 |
|
2287 | |||
2265 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
2288 | 2002-12-18 Fernando Perez <fperez@colorado.edu> | |
2266 |
|
2289 | |||
2267 | * Docs: added new info about Mac OSX, from Andrea. |
|
2290 | * Docs: added new info about Mac OSX, from Andrea. | |
2268 |
|
2291 | |||
2269 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
2292 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to | |
2270 | allow direct plotting of python strings whose format is the same |
|
2293 | allow direct plotting of python strings whose format is the same | |
2271 | of gnuplot data files. |
|
2294 | of gnuplot data files. | |
2272 |
|
2295 | |||
2273 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
2296 | 2002-12-16 Fernando Perez <fperez@colorado.edu> | |
2274 |
|
2297 | |||
2275 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
2298 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) | |
2276 | value of exit question to be acknowledged. |
|
2299 | value of exit question to be acknowledged. | |
2277 |
|
2300 | |||
2278 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
2301 | 2002-12-03 Fernando Perez <fperez@colorado.edu> | |
2279 |
|
2302 | |||
2280 | * IPython/ipmaker.py: removed generators, which had been added |
|
2303 | * IPython/ipmaker.py: removed generators, which had been added | |
2281 | by mistake in an earlier debugging run. This was causing trouble |
|
2304 | by mistake in an earlier debugging run. This was causing trouble | |
2282 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
2305 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> | |
2283 | for pointing this out. |
|
2306 | for pointing this out. | |
2284 |
|
2307 | |||
2285 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
2308 | 2002-11-17 Fernando Perez <fperez@colorado.edu> | |
2286 |
|
2309 | |||
2287 | * Manual: updated the Gnuplot section. |
|
2310 | * Manual: updated the Gnuplot section. | |
2288 |
|
2311 | |||
2289 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
2312 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with | |
2290 | a much better split of what goes in Runtime and what goes in |
|
2313 | a much better split of what goes in Runtime and what goes in | |
2291 | Interactive. |
|
2314 | Interactive. | |
2292 |
|
2315 | |||
2293 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
2316 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't | |
2294 | being imported from iplib. |
|
2317 | being imported from iplib. | |
2295 |
|
2318 | |||
2296 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
2319 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc | |
2297 | for command-passing. Now the global Gnuplot instance is called |
|
2320 | for command-passing. Now the global Gnuplot instance is called | |
2298 | 'gp' instead of 'g', which was really a far too fragile and |
|
2321 | 'gp' instead of 'g', which was really a far too fragile and | |
2299 | common name. |
|
2322 | common name. | |
2300 |
|
2323 | |||
2301 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
2324 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken | |
2302 | bounding boxes generated by Gnuplot for square plots. |
|
2325 | bounding boxes generated by Gnuplot for square plots. | |
2303 |
|
2326 | |||
2304 | * IPython/genutils.py (popkey): new function added. I should |
|
2327 | * IPython/genutils.py (popkey): new function added. I should | |
2305 | suggest this on c.l.py as a dict method, it seems useful. |
|
2328 | suggest this on c.l.py as a dict method, it seems useful. | |
2306 |
|
2329 | |||
2307 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
2330 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot | |
2308 | to transparently handle PostScript generation. MUCH better than |
|
2331 | to transparently handle PostScript generation. MUCH better than | |
2309 | the previous plot_eps/replot_eps (which I removed now). The code |
|
2332 | the previous plot_eps/replot_eps (which I removed now). The code | |
2310 | is also fairly clean and well documented now (including |
|
2333 | is also fairly clean and well documented now (including | |
2311 | docstrings). |
|
2334 | docstrings). | |
2312 |
|
2335 | |||
2313 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
2336 | 2002-11-13 Fernando Perez <fperez@colorado.edu> | |
2314 |
|
2337 | |||
2315 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
2338 | * IPython/Magic.py (Magic.magic_edit): fixed docstring | |
2316 | (inconsistent with options). |
|
2339 | (inconsistent with options). | |
2317 |
|
2340 | |||
2318 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
2341 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been | |
2319 | manually disabled, I don't know why. Fixed it. |
|
2342 | manually disabled, I don't know why. Fixed it. | |
2320 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
2343 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly | |
2321 | eps output. |
|
2344 | eps output. | |
2322 |
|
2345 | |||
2323 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
2346 | 2002-11-12 Fernando Perez <fperez@colorado.edu> | |
2324 |
|
2347 | |||
2325 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
2348 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they | |
2326 | don't propagate up to caller. Fixes crash reported by François |
|
2349 | don't propagate up to caller. Fixes crash reported by François | |
2327 | Pinard. |
|
2350 | Pinard. | |
2328 |
|
2351 | |||
2329 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
2352 | 2002-11-09 Fernando Perez <fperez@colorado.edu> | |
2330 |
|
2353 | |||
2331 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
2354 | * IPython/ipmaker.py (make_IPython): fixed problem with writing | |
2332 | history file for new users. |
|
2355 | history file for new users. | |
2333 | (make_IPython): fixed bug where initial install would leave the |
|
2356 | (make_IPython): fixed bug where initial install would leave the | |
2334 | user running in the .ipython dir. |
|
2357 | user running in the .ipython dir. | |
2335 | (make_IPython): fixed bug where config dir .ipython would be |
|
2358 | (make_IPython): fixed bug where config dir .ipython would be | |
2336 | created regardless of the given -ipythondir option. Thanks to Cory |
|
2359 | created regardless of the given -ipythondir option. Thanks to Cory | |
2337 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
2360 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. | |
2338 |
|
2361 | |||
2339 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
2362 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no | |
2340 | type confirmations. Will need to use it in all of IPython's code |
|
2363 | type confirmations. Will need to use it in all of IPython's code | |
2341 | consistently. |
|
2364 | consistently. | |
2342 |
|
2365 | |||
2343 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
2366 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the | |
2344 | context to print 31 lines instead of the default 5. This will make |
|
2367 | context to print 31 lines instead of the default 5. This will make | |
2345 | the crash reports extremely detailed in case the problem is in |
|
2368 | the crash reports extremely detailed in case the problem is in | |
2346 | libraries I don't have access to. |
|
2369 | libraries I don't have access to. | |
2347 |
|
2370 | |||
2348 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
2371 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last | |
2349 | line of defense' code to still crash, but giving users fair |
|
2372 | line of defense' code to still crash, but giving users fair | |
2350 | warning. I don't want internal errors to go unreported: if there's |
|
2373 | warning. I don't want internal errors to go unreported: if there's | |
2351 | an internal problem, IPython should crash and generate a full |
|
2374 | an internal problem, IPython should crash and generate a full | |
2352 | report. |
|
2375 | report. | |
2353 |
|
2376 | |||
2354 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
2377 | 2002-11-08 Fernando Perez <fperez@colorado.edu> | |
2355 |
|
2378 | |||
2356 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
2379 | * IPython/iplib.py (InteractiveShell.interact): added code to trap | |
2357 | otherwise uncaught exceptions which can appear if people set |
|
2380 | otherwise uncaught exceptions which can appear if people set | |
2358 | sys.stdout to something badly broken. Thanks to a crash report |
|
2381 | sys.stdout to something badly broken. Thanks to a crash report | |
2359 | from henni-AT-mail.brainbot.com. |
|
2382 | from henni-AT-mail.brainbot.com. | |
2360 |
|
2383 | |||
2361 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
2384 | 2002-11-04 Fernando Perez <fperez@colorado.edu> | |
2362 |
|
2385 | |||
2363 | * IPython/iplib.py (InteractiveShell.interact): added |
|
2386 | * IPython/iplib.py (InteractiveShell.interact): added | |
2364 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
2387 | __IPYTHON__active to the builtins. It's a flag which goes on when | |
2365 | the interaction starts and goes off again when it stops. This |
|
2388 | the interaction starts and goes off again when it stops. This | |
2366 | allows embedding code to detect being inside IPython. Before this |
|
2389 | allows embedding code to detect being inside IPython. Before this | |
2367 | was done via __IPYTHON__, but that only shows that an IPython |
|
2390 | was done via __IPYTHON__, but that only shows that an IPython | |
2368 | instance has been created. |
|
2391 | instance has been created. | |
2369 |
|
2392 | |||
2370 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
2393 | * IPython/Magic.py (Magic.magic_env): I realized that in a | |
2371 | UserDict, instance.data holds the data as a normal dict. So I |
|
2394 | UserDict, instance.data holds the data as a normal dict. So I | |
2372 | modified @env to return os.environ.data instead of rebuilding a |
|
2395 | modified @env to return os.environ.data instead of rebuilding a | |
2373 | dict by hand. |
|
2396 | dict by hand. | |
2374 |
|
2397 | |||
2375 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
2398 | 2002-11-02 Fernando Perez <fperez@colorado.edu> | |
2376 |
|
2399 | |||
2377 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
2400 | * IPython/genutils.py (warn): changed so that level 1 prints no | |
2378 | header. Level 2 is now the default (with 'WARNING' header, as |
|
2401 | header. Level 2 is now the default (with 'WARNING' header, as | |
2379 | before). I think I tracked all places where changes were needed in |
|
2402 | before). I think I tracked all places where changes were needed in | |
2380 | IPython, but outside code using the old level numbering may have |
|
2403 | IPython, but outside code using the old level numbering may have | |
2381 | broken. |
|
2404 | broken. | |
2382 |
|
2405 | |||
2383 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
2406 | * IPython/iplib.py (InteractiveShell.runcode): added this to | |
2384 | handle the tracebacks in SystemExit traps correctly. The previous |
|
2407 | handle the tracebacks in SystemExit traps correctly. The previous | |
2385 | code (through interact) was printing more of the stack than |
|
2408 | code (through interact) was printing more of the stack than | |
2386 | necessary, showing IPython internal code to the user. |
|
2409 | necessary, showing IPython internal code to the user. | |
2387 |
|
2410 | |||
2388 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
2411 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by | |
2389 | default. Now that the default at the confirmation prompt is yes, |
|
2412 | default. Now that the default at the confirmation prompt is yes, | |
2390 | it's not so intrusive. François' argument that ipython sessions |
|
2413 | it's not so intrusive. François' argument that ipython sessions | |
2391 | tend to be complex enough not to lose them from an accidental C-d, |
|
2414 | tend to be complex enough not to lose them from an accidental C-d, | |
2392 | is a valid one. |
|
2415 | is a valid one. | |
2393 |
|
2416 | |||
2394 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
2417 | * IPython/iplib.py (InteractiveShell.interact): added a | |
2395 | showtraceback() call to the SystemExit trap, and modified the exit |
|
2418 | showtraceback() call to the SystemExit trap, and modified the exit | |
2396 | confirmation to have yes as the default. |
|
2419 | confirmation to have yes as the default. | |
2397 |
|
2420 | |||
2398 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
2421 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from | |
2399 | this file. It's been gone from the code for a long time, this was |
|
2422 | this file. It's been gone from the code for a long time, this was | |
2400 | simply leftover junk. |
|
2423 | simply leftover junk. | |
2401 |
|
2424 | |||
2402 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
2425 | 2002-11-01 Fernando Perez <fperez@colorado.edu> | |
2403 |
|
2426 | |||
2404 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
2427 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option | |
2405 | added. If set, IPython now traps EOF and asks for |
|
2428 | added. If set, IPython now traps EOF and asks for | |
2406 | confirmation. After a request by François Pinard. |
|
2429 | confirmation. After a request by François Pinard. | |
2407 |
|
2430 | |||
2408 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
2431 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead | |
2409 | of @abort, and with a new (better) mechanism for handling the |
|
2432 | of @abort, and with a new (better) mechanism for handling the | |
2410 | exceptions. |
|
2433 | exceptions. | |
2411 |
|
2434 | |||
2412 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
2435 | 2002-10-27 Fernando Perez <fperez@colorado.edu> | |
2413 |
|
2436 | |||
2414 | * IPython/usage.py (__doc__): updated the --help information and |
|
2437 | * IPython/usage.py (__doc__): updated the --help information and | |
2415 | the ipythonrc file to indicate that -log generates |
|
2438 | the ipythonrc file to indicate that -log generates | |
2416 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
2439 | ./ipython.log. Also fixed the corresponding info in @logstart. | |
2417 | This and several other fixes in the manuals thanks to reports by |
|
2440 | This and several other fixes in the manuals thanks to reports by | |
2418 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
2441 | François Pinard <pinard-AT-iro.umontreal.ca>. | |
2419 |
|
2442 | |||
2420 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
2443 | * IPython/Logger.py (Logger.switch_log): Fixed error message to | |
2421 | refer to @logstart (instead of @log, which doesn't exist). |
|
2444 | refer to @logstart (instead of @log, which doesn't exist). | |
2422 |
|
2445 | |||
2423 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
2446 | * IPython/iplib.py (InteractiveShell._prefilter): fixed | |
2424 | AttributeError crash. Thanks to Christopher Armstrong |
|
2447 | AttributeError crash. Thanks to Christopher Armstrong | |
2425 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
2448 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been | |
2426 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
2449 | introduced recently (in 0.2.14pre37) with the fix to the eval | |
2427 | problem mentioned below. |
|
2450 | problem mentioned below. | |
2428 |
|
2451 | |||
2429 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
2452 | 2002-10-17 Fernando Perez <fperez@colorado.edu> | |
2430 |
|
2453 | |||
2431 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
2454 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows | |
2432 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
2455 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. | |
2433 |
|
2456 | |||
2434 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
2457 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to | |
2435 | this function to fix a problem reported by Alex Schmolck. He saw |
|
2458 | this function to fix a problem reported by Alex Schmolck. He saw | |
2436 | it with list comprehensions and generators, which were getting |
|
2459 | it with list comprehensions and generators, which were getting | |
2437 | called twice. The real problem was an 'eval' call in testing for |
|
2460 | called twice. The real problem was an 'eval' call in testing for | |
2438 | automagic which was evaluating the input line silently. |
|
2461 | automagic which was evaluating the input line silently. | |
2439 |
|
2462 | |||
2440 | This is a potentially very nasty bug, if the input has side |
|
2463 | This is a potentially very nasty bug, if the input has side | |
2441 | effects which must not be repeated. The code is much cleaner now, |
|
2464 | effects which must not be repeated. The code is much cleaner now, | |
2442 | without any blanket 'except' left and with a regexp test for |
|
2465 | without any blanket 'except' left and with a regexp test for | |
2443 | actual function names. |
|
2466 | actual function names. | |
2444 |
|
2467 | |||
2445 | But an eval remains, which I'm not fully comfortable with. I just |
|
2468 | But an eval remains, which I'm not fully comfortable with. I just | |
2446 | don't know how to find out if an expression could be a callable in |
|
2469 | don't know how to find out if an expression could be a callable in | |
2447 | the user's namespace without doing an eval on the string. However |
|
2470 | the user's namespace without doing an eval on the string. However | |
2448 | that string is now much more strictly checked so that no code |
|
2471 | that string is now much more strictly checked so that no code | |
2449 | slips by, so the eval should only happen for things that can |
|
2472 | slips by, so the eval should only happen for things that can | |
2450 | really be only function/method names. |
|
2473 | really be only function/method names. | |
2451 |
|
2474 | |||
2452 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
2475 | 2002-10-15 Fernando Perez <fperez@colorado.edu> | |
2453 |
|
2476 | |||
2454 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
2477 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac | |
2455 | OSX information to main manual, removed README_Mac_OSX file from |
|
2478 | OSX information to main manual, removed README_Mac_OSX file from | |
2456 | distribution. Also updated credits for recent additions. |
|
2479 | distribution. Also updated credits for recent additions. | |
2457 |
|
2480 | |||
2458 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
2481 | 2002-10-10 Fernando Perez <fperez@colorado.edu> | |
2459 |
|
2482 | |||
2460 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
2483 | * README_Mac_OSX: Added a README for Mac OSX users for fixing | |
2461 | terminal-related issues. Many thanks to Andrea Riciputi |
|
2484 | terminal-related issues. Many thanks to Andrea Riciputi | |
2462 | <andrea.riciputi-AT-libero.it> for writing it. |
|
2485 | <andrea.riciputi-AT-libero.it> for writing it. | |
2463 |
|
2486 | |||
2464 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
2487 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, | |
2465 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
2488 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. | |
2466 |
|
2489 | |||
2467 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
2490 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks | |
2468 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
2491 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad | |
2469 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
2492 | <syver-en-AT-online.no> who both submitted patches for this problem. | |
2470 |
|
2493 | |||
2471 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
2494 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for | |
2472 | global embedding to make sure that things don't overwrite user |
|
2495 | global embedding to make sure that things don't overwrite user | |
2473 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
2496 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> | |
2474 |
|
2497 | |||
2475 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
2498 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 | |
2476 | compatibility. Thanks to Hayden Callow |
|
2499 | compatibility. Thanks to Hayden Callow | |
2477 | <h.callow-AT-elec.canterbury.ac.nz> |
|
2500 | <h.callow-AT-elec.canterbury.ac.nz> | |
2478 |
|
2501 | |||
2479 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
2502 | 2002-10-04 Fernando Perez <fperez@colorado.edu> | |
2480 |
|
2503 | |||
2481 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
2504 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for | |
2482 | Gnuplot.File objects. |
|
2505 | Gnuplot.File objects. | |
2483 |
|
2506 | |||
2484 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
2507 | 2002-07-23 Fernando Perez <fperez@colorado.edu> | |
2485 |
|
2508 | |||
2486 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
2509 | * IPython/genutils.py (timing): Added timings() and timing() for | |
2487 | quick access to the most commonly needed data, the execution |
|
2510 | quick access to the most commonly needed data, the execution | |
2488 | times. Old timing() renamed to timings_out(). |
|
2511 | times. Old timing() renamed to timings_out(). | |
2489 |
|
2512 | |||
2490 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
2513 | 2002-07-18 Fernando Perez <fperez@colorado.edu> | |
2491 |
|
2514 | |||
2492 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
2515 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed | |
2493 | bug with nested instances disrupting the parent's tab completion. |
|
2516 | bug with nested instances disrupting the parent's tab completion. | |
2494 |
|
2517 | |||
2495 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
2518 | * IPython/iplib.py (all_completions): Added Alex Schmolck's | |
2496 | all_completions code to begin the emacs integration. |
|
2519 | all_completions code to begin the emacs integration. | |
2497 |
|
2520 | |||
2498 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
2521 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' | |
2499 | argument to allow titling individual arrays when plotting. |
|
2522 | argument to allow titling individual arrays when plotting. | |
2500 |
|
2523 | |||
2501 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
2524 | 2002-07-15 Fernando Perez <fperez@colorado.edu> | |
2502 |
|
2525 | |||
2503 | * setup.py (make_shortcut): changed to retrieve the value of |
|
2526 | * setup.py (make_shortcut): changed to retrieve the value of | |
2504 | 'Program Files' directory from the registry (this value changes in |
|
2527 | 'Program Files' directory from the registry (this value changes in | |
2505 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
2528 | non-english versions of Windows). Thanks to Thomas Fanslau | |
2506 | <tfanslau-AT-gmx.de> for the report. |
|
2529 | <tfanslau-AT-gmx.de> for the report. | |
2507 |
|
2530 | |||
2508 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
2531 | 2002-07-10 Fernando Perez <fperez@colorado.edu> | |
2509 |
|
2532 | |||
2510 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
2533 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for | |
2511 | a bug in pdb, which crashes if a line with only whitespace is |
|
2534 | a bug in pdb, which crashes if a line with only whitespace is | |
2512 | entered. Bug report submitted to sourceforge. |
|
2535 | entered. Bug report submitted to sourceforge. | |
2513 |
|
2536 | |||
2514 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
2537 | 2002-07-09 Fernando Perez <fperez@colorado.edu> | |
2515 |
|
2538 | |||
2516 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
2539 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when | |
2517 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
2540 | reporting exceptions (it's a bug in inspect.py, I just set a | |
2518 | workaround). |
|
2541 | workaround). | |
2519 |
|
2542 | |||
2520 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
2543 | 2002-07-08 Fernando Perez <fperez@colorado.edu> | |
2521 |
|
2544 | |||
2522 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
2545 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to | |
2523 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
2546 | __IPYTHON__ in __builtins__ to show up in user_ns. | |
2524 |
|
2547 | |||
2525 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
2548 | 2002-07-03 Fernando Perez <fperez@colorado.edu> | |
2526 |
|
2549 | |||
2527 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
2550 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed | |
2528 | name from @gp_set_instance to @gp_set_default. |
|
2551 | name from @gp_set_instance to @gp_set_default. | |
2529 |
|
2552 | |||
2530 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
2553 | * IPython/ipmaker.py (make_IPython): default editor value set to | |
2531 | '0' (a string), to match the rc file. Otherwise will crash when |
|
2554 | '0' (a string), to match the rc file. Otherwise will crash when | |
2532 | .strip() is called on it. |
|
2555 | .strip() is called on it. | |
2533 |
|
2556 | |||
2534 |
|
2557 | |||
2535 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
2558 | 2002-06-28 Fernando Perez <fperez@colorado.edu> | |
2536 |
|
2559 | |||
2537 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
2560 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing | |
2538 | of files in current directory when a file is executed via |
|
2561 | of files in current directory when a file is executed via | |
2539 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
2562 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. | |
2540 |
|
2563 | |||
2541 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
2564 | * setup.py (manfiles): fix for rpm builds, submitted by RA | |
2542 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
2565 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! | |
2543 |
|
2566 | |||
2544 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
2567 | * IPython/ipmaker.py (make_IPython): fixed lookup of default | |
2545 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
2568 | editor when set to '0'. Problem was, '0' evaluates to True (it's a | |
2546 | string!). A. Schmolck caught this one. |
|
2569 | string!). A. Schmolck caught this one. | |
2547 |
|
2570 | |||
2548 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
2571 | 2002-06-27 Fernando Perez <fperez@colorado.edu> | |
2549 |
|
2572 | |||
2550 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
2573 | * IPython/ipmaker.py (make_IPython): fixed bug when running user | |
2551 | defined files at the cmd line. __name__ wasn't being set to |
|
2574 | defined files at the cmd line. __name__ wasn't being set to | |
2552 | __main__. |
|
2575 | __main__. | |
2553 |
|
2576 | |||
2554 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
2577 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also | |
2555 | regular lists and tuples besides Numeric arrays. |
|
2578 | regular lists and tuples besides Numeric arrays. | |
2556 |
|
2579 | |||
2557 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
2580 | * IPython/Prompts.py (CachedOutput.__call__): Added output | |
2558 | supression for input ending with ';'. Similar to Mathematica and |
|
2581 | supression for input ending with ';'. Similar to Mathematica and | |
2559 | Matlab. The _* vars and Out[] list are still updated, just like |
|
2582 | Matlab. The _* vars and Out[] list are still updated, just like | |
2560 | Mathematica behaves. |
|
2583 | Mathematica behaves. | |
2561 |
|
2584 | |||
2562 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
2585 | 2002-06-25 Fernando Perez <fperez@colorado.edu> | |
2563 |
|
2586 | |||
2564 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
2587 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of | |
2565 | .ini extensions for profiels under Windows. |
|
2588 | .ini extensions for profiels under Windows. | |
2566 |
|
2589 | |||
2567 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
2590 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of | |
2568 | string form. Fix contributed by Alexander Schmolck |
|
2591 | string form. Fix contributed by Alexander Schmolck | |
2569 | <a.schmolck-AT-gmx.net> |
|
2592 | <a.schmolck-AT-gmx.net> | |
2570 |
|
2593 | |||
2571 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
2594 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a | |
2572 | pre-configured Gnuplot instance. |
|
2595 | pre-configured Gnuplot instance. | |
2573 |
|
2596 | |||
2574 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
2597 | 2002-06-21 Fernando Perez <fperez@colorado.edu> | |
2575 |
|
2598 | |||
2576 | * IPython/numutils.py (exp_safe): new function, works around the |
|
2599 | * IPython/numutils.py (exp_safe): new function, works around the | |
2577 | underflow problems in Numeric. |
|
2600 | underflow problems in Numeric. | |
2578 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
2601 | (log2): New fn. Safe log in base 2: returns exact integer answer | |
2579 | for exact integer powers of 2. |
|
2602 | for exact integer powers of 2. | |
2580 |
|
2603 | |||
2581 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
2604 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' | |
2582 | properly. |
|
2605 | properly. | |
2583 |
|
2606 | |||
2584 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
2607 | 2002-06-20 Fernando Perez <fperez@colorado.edu> | |
2585 |
|
2608 | |||
2586 | * IPython/genutils.py (timing): new function like |
|
2609 | * IPython/genutils.py (timing): new function like | |
2587 | Mathematica's. Similar to time_test, but returns more info. |
|
2610 | Mathematica's. Similar to time_test, but returns more info. | |
2588 |
|
2611 | |||
2589 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
2612 | 2002-06-18 Fernando Perez <fperez@colorado.edu> | |
2590 |
|
2613 | |||
2591 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
2614 | * IPython/Magic.py (Magic.magic_save): modified @save and @r | |
2592 | according to Mike Heeter's suggestions. |
|
2615 | according to Mike Heeter's suggestions. | |
2593 |
|
2616 | |||
2594 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
2617 | 2002-06-16 Fernando Perez <fperez@colorado.edu> | |
2595 |
|
2618 | |||
2596 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
2619 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot | |
2597 | system. GnuplotMagic is gone as a user-directory option. New files |
|
2620 | system. GnuplotMagic is gone as a user-directory option. New files | |
2598 | make it easier to use all the gnuplot stuff both from external |
|
2621 | make it easier to use all the gnuplot stuff both from external | |
2599 | programs as well as from IPython. Had to rewrite part of |
|
2622 | programs as well as from IPython. Had to rewrite part of | |
2600 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
2623 | hardcopy() b/c of a strange bug: often the ps files simply don't | |
2601 | get created, and require a repeat of the command (often several |
|
2624 | get created, and require a repeat of the command (often several | |
2602 | times). |
|
2625 | times). | |
2603 |
|
2626 | |||
2604 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
2627 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to | |
2605 | resolve output channel at call time, so that if sys.stderr has |
|
2628 | resolve output channel at call time, so that if sys.stderr has | |
2606 | been redirected by user this gets honored. |
|
2629 | been redirected by user this gets honored. | |
2607 |
|
2630 | |||
2608 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
2631 | 2002-06-13 Fernando Perez <fperez@colorado.edu> | |
2609 |
|
2632 | |||
2610 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
2633 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to | |
2611 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
2634 | IPShell. Kept a copy with the old names to avoid breaking people's | |
2612 | embedded code. |
|
2635 | embedded code. | |
2613 |
|
2636 | |||
2614 | * IPython/ipython: simplified it to the bare minimum after |
|
2637 | * IPython/ipython: simplified it to the bare minimum after | |
2615 | Holger's suggestions. Added info about how to use it in |
|
2638 | Holger's suggestions. Added info about how to use it in | |
2616 | PYTHONSTARTUP. |
|
2639 | PYTHONSTARTUP. | |
2617 |
|
2640 | |||
2618 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
2641 | * IPython/Shell.py (IPythonShell): changed the options passing | |
2619 | from a string with funky %s replacements to a straight list. Maybe |
|
2642 | from a string with funky %s replacements to a straight list. Maybe | |
2620 | a bit more typing, but it follows sys.argv conventions, so there's |
|
2643 | a bit more typing, but it follows sys.argv conventions, so there's | |
2621 | less special-casing to remember. |
|
2644 | less special-casing to remember. | |
2622 |
|
2645 | |||
2623 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
2646 | 2002-06-12 Fernando Perez <fperez@colorado.edu> | |
2624 |
|
2647 | |||
2625 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
2648 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat | |
2626 | command. Thanks to a suggestion by Mike Heeter. |
|
2649 | command. Thanks to a suggestion by Mike Heeter. | |
2627 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
2650 | (Magic.magic_pfile): added behavior to look at filenames if given | |
2628 | arg is not a defined object. |
|
2651 | arg is not a defined object. | |
2629 | (Magic.magic_save): New @save function to save code snippets. Also |
|
2652 | (Magic.magic_save): New @save function to save code snippets. Also | |
2630 | a Mike Heeter idea. |
|
2653 | a Mike Heeter idea. | |
2631 |
|
2654 | |||
2632 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
2655 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to | |
2633 | plot() and replot(). Much more convenient now, especially for |
|
2656 | plot() and replot(). Much more convenient now, especially for | |
2634 | interactive use. |
|
2657 | interactive use. | |
2635 |
|
2658 | |||
2636 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
2659 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to | |
2637 | filenames. |
|
2660 | filenames. | |
2638 |
|
2661 | |||
2639 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
2662 | 2002-06-02 Fernando Perez <fperez@colorado.edu> | |
2640 |
|
2663 | |||
2641 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
2664 | * IPython/Struct.py (Struct.__init__): modified to admit | |
2642 | initialization via another struct. |
|
2665 | initialization via another struct. | |
2643 |
|
2666 | |||
2644 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
2667 | * IPython/genutils.py (SystemExec.__init__): New stateful | |
2645 | interface to xsys and bq. Useful for writing system scripts. |
|
2668 | interface to xsys and bq. Useful for writing system scripts. | |
2646 |
|
2669 | |||
2647 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
2670 | 2002-05-30 Fernando Perez <fperez@colorado.edu> | |
2648 |
|
2671 | |||
2649 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
2672 | * MANIFEST.in: Changed docfile selection to exclude all the lyx | |
2650 | documents. This will make the user download smaller (it's getting |
|
2673 | documents. This will make the user download smaller (it's getting | |
2651 | too big). |
|
2674 | too big). | |
2652 |
|
2675 | |||
2653 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
2676 | 2002-05-29 Fernando Perez <fperez@colorado.edu> | |
2654 |
|
2677 | |||
2655 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
2678 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to | |
2656 | fix problems with shelve and pickle. Seems to work, but I don't |
|
2679 | fix problems with shelve and pickle. Seems to work, but I don't | |
2657 | know if corner cases break it. Thanks to Mike Heeter |
|
2680 | know if corner cases break it. Thanks to Mike Heeter | |
2658 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
2681 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. | |
2659 |
|
2682 | |||
2660 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
2683 | 2002-05-24 Fernando Perez <fperez@colorado.edu> | |
2661 |
|
2684 | |||
2662 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
2685 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in | |
2663 | macros having broken. |
|
2686 | macros having broken. | |
2664 |
|
2687 | |||
2665 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
2688 | 2002-05-21 Fernando Perez <fperez@colorado.edu> | |
2666 |
|
2689 | |||
2667 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
2690 | * IPython/Magic.py (Magic.magic_logstart): fixed recently | |
2668 | introduced logging bug: all history before logging started was |
|
2691 | introduced logging bug: all history before logging started was | |
2669 | being written one character per line! This came from the redesign |
|
2692 | being written one character per line! This came from the redesign | |
2670 | of the input history as a special list which slices to strings, |
|
2693 | of the input history as a special list which slices to strings, | |
2671 | not to lists. |
|
2694 | not to lists. | |
2672 |
|
2695 | |||
2673 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
2696 | 2002-05-20 Fernando Perez <fperez@colorado.edu> | |
2674 |
|
2697 | |||
2675 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
2698 | * IPython/Prompts.py (CachedOutput.__init__): made the color table | |
2676 | be an attribute of all classes in this module. The design of these |
|
2699 | be an attribute of all classes in this module. The design of these | |
2677 | classes needs some serious overhauling. |
|
2700 | classes needs some serious overhauling. | |
2678 |
|
2701 | |||
2679 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
2702 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug | |
2680 | which was ignoring '_' in option names. |
|
2703 | which was ignoring '_' in option names. | |
2681 |
|
2704 | |||
2682 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
2705 | * IPython/ultraTB.py (FormattedTB.__init__): Changed | |
2683 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
2706 | 'Verbose_novars' to 'Context' and made it the new default. It's a | |
2684 | bit more readable and also safer than verbose. |
|
2707 | bit more readable and also safer than verbose. | |
2685 |
|
2708 | |||
2686 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
2709 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of | |
2687 | triple-quoted strings. |
|
2710 | triple-quoted strings. | |
2688 |
|
2711 | |||
2689 | * IPython/OInspect.py (__all__): new module exposing the object |
|
2712 | * IPython/OInspect.py (__all__): new module exposing the object | |
2690 | introspection facilities. Now the corresponding magics are dummy |
|
2713 | introspection facilities. Now the corresponding magics are dummy | |
2691 | wrappers around this. Having this module will make it much easier |
|
2714 | wrappers around this. Having this module will make it much easier | |
2692 | to put these functions into our modified pdb. |
|
2715 | to put these functions into our modified pdb. | |
2693 | This new object inspector system uses the new colorizing module, |
|
2716 | This new object inspector system uses the new colorizing module, | |
2694 | so source code and other things are nicely syntax highlighted. |
|
2717 | so source code and other things are nicely syntax highlighted. | |
2695 |
|
2718 | |||
2696 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
2719 | 2002-05-18 Fernando Perez <fperez@colorado.edu> | |
2697 |
|
2720 | |||
2698 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
2721 | * IPython/ColorANSI.py: Split the coloring tools into a separate | |
2699 | module so I can use them in other code easier (they were part of |
|
2722 | module so I can use them in other code easier (they were part of | |
2700 | ultraTB). |
|
2723 | ultraTB). | |
2701 |
|
2724 | |||
2702 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
2725 | 2002-05-17 Fernando Perez <fperez@colorado.edu> | |
2703 |
|
2726 | |||
2704 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
2727 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
2705 | fixed it to set the global 'g' also to the called instance, as |
|
2728 | fixed it to set the global 'g' also to the called instance, as | |
2706 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
2729 | long as 'g' was still a gnuplot instance (so it doesn't overwrite | |
2707 | user's 'g' variables). |
|
2730 | user's 'g' variables). | |
2708 |
|
2731 | |||
2709 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
2732 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out | |
2710 | global variables (aliases to _ih,_oh) so that users which expect |
|
2733 | global variables (aliases to _ih,_oh) so that users which expect | |
2711 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
2734 | In[5] or Out[7] to work aren't unpleasantly surprised. | |
2712 | (InputList.__getslice__): new class to allow executing slices of |
|
2735 | (InputList.__getslice__): new class to allow executing slices of | |
2713 | input history directly. Very simple class, complements the use of |
|
2736 | input history directly. Very simple class, complements the use of | |
2714 | macros. |
|
2737 | macros. | |
2715 |
|
2738 | |||
2716 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
2739 | 2002-05-16 Fernando Perez <fperez@colorado.edu> | |
2717 |
|
2740 | |||
2718 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
2741 | * setup.py (docdirbase): make doc directory be just doc/IPython | |
2719 | without version numbers, it will reduce clutter for users. |
|
2742 | without version numbers, it will reduce clutter for users. | |
2720 |
|
2743 | |||
2721 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
2744 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to | |
2722 | execfile call to prevent possible memory leak. See for details: |
|
2745 | execfile call to prevent possible memory leak. See for details: | |
2723 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
2746 | http://mail.python.org/pipermail/python-list/2002-February/088476.html | |
2724 |
|
2747 | |||
2725 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
2748 | 2002-05-15 Fernando Perez <fperez@colorado.edu> | |
2726 |
|
2749 | |||
2727 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
2750 | * IPython/Magic.py (Magic.magic_psource): made the object | |
2728 | introspection names be more standard: pdoc, pdef, pfile and |
|
2751 | introspection names be more standard: pdoc, pdef, pfile and | |
2729 | psource. They all print/page their output, and it makes |
|
2752 | psource. They all print/page their output, and it makes | |
2730 | remembering them easier. Kept old names for compatibility as |
|
2753 | remembering them easier. Kept old names for compatibility as | |
2731 | aliases. |
|
2754 | aliases. | |
2732 |
|
2755 | |||
2733 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
2756 | 2002-05-14 Fernando Perez <fperez@colorado.edu> | |
2734 |
|
2757 | |||
2735 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
2758 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood | |
2736 | what the mouse problem was. The trick is to use gnuplot with temp |
|
2759 | what the mouse problem was. The trick is to use gnuplot with temp | |
2737 | files and NOT with pipes (for data communication), because having |
|
2760 | files and NOT with pipes (for data communication), because having | |
2738 | both pipes and the mouse on is bad news. |
|
2761 | both pipes and the mouse on is bad news. | |
2739 |
|
2762 | |||
2740 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
2763 | 2002-05-13 Fernando Perez <fperez@colorado.edu> | |
2741 |
|
2764 | |||
2742 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
2765 | * IPython/Magic.py (Magic._ofind): fixed namespace order search | |
2743 | bug. Information would be reported about builtins even when |
|
2766 | bug. Information would be reported about builtins even when | |
2744 | user-defined functions overrode them. |
|
2767 | user-defined functions overrode them. | |
2745 |
|
2768 | |||
2746 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
2769 | 2002-05-11 Fernando Perez <fperez@colorado.edu> | |
2747 |
|
2770 | |||
2748 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
2771 | * IPython/__init__.py (__all__): removed FlexCompleter from | |
2749 | __all__ so that things don't fail in platforms without readline. |
|
2772 | __all__ so that things don't fail in platforms without readline. | |
2750 |
|
2773 | |||
2751 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
2774 | 2002-05-10 Fernando Perez <fperez@colorado.edu> | |
2752 |
|
2775 | |||
2753 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
2776 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c | |
2754 | it requires Numeric, effectively making Numeric a dependency for |
|
2777 | it requires Numeric, effectively making Numeric a dependency for | |
2755 | IPython. |
|
2778 | IPython. | |
2756 |
|
2779 | |||
2757 | * Released 0.2.13 |
|
2780 | * Released 0.2.13 | |
2758 |
|
2781 | |||
2759 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
2782 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the | |
2760 | profiler interface. Now all the major options from the profiler |
|
2783 | profiler interface. Now all the major options from the profiler | |
2761 | module are directly supported in IPython, both for single |
|
2784 | module are directly supported in IPython, both for single | |
2762 | expressions (@prun) and for full programs (@run -p). |
|
2785 | expressions (@prun) and for full programs (@run -p). | |
2763 |
|
2786 | |||
2764 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
2787 | 2002-05-09 Fernando Perez <fperez@colorado.edu> | |
2765 |
|
2788 | |||
2766 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
2789 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of | |
2767 | magic properly formatted for screen. |
|
2790 | magic properly formatted for screen. | |
2768 |
|
2791 | |||
2769 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
2792 | * setup.py (make_shortcut): Changed things to put pdf version in | |
2770 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
2793 | doc/ instead of doc/manual (had to change lyxport a bit). | |
2771 |
|
2794 | |||
2772 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
2795 | * IPython/Magic.py (Profile.string_stats): made profile runs go | |
2773 | through pager (they are long and a pager allows searching, saving, |
|
2796 | through pager (they are long and a pager allows searching, saving, | |
2774 | etc.) |
|
2797 | etc.) | |
2775 |
|
2798 | |||
2776 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
2799 | 2002-05-08 Fernando Perez <fperez@colorado.edu> | |
2777 |
|
2800 | |||
2778 | * Released 0.2.12 |
|
2801 | * Released 0.2.12 | |
2779 |
|
2802 | |||
2780 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
2803 | 2002-05-06 Fernando Perez <fperez@colorado.edu> | |
2781 |
|
2804 | |||
2782 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
2805 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently | |
2783 | introduced); 'hist n1 n2' was broken. |
|
2806 | introduced); 'hist n1 n2' was broken. | |
2784 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
2807 | (Magic.magic_pdb): added optional on/off arguments to @pdb | |
2785 | (Magic.magic_run): added option -i to @run, which executes code in |
|
2808 | (Magic.magic_run): added option -i to @run, which executes code in | |
2786 | the IPython namespace instead of a clean one. Also added @irun as |
|
2809 | the IPython namespace instead of a clean one. Also added @irun as | |
2787 | an alias to @run -i. |
|
2810 | an alias to @run -i. | |
2788 |
|
2811 | |||
2789 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
2812 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): | |
2790 | fixed (it didn't really do anything, the namespaces were wrong). |
|
2813 | fixed (it didn't really do anything, the namespaces were wrong). | |
2791 |
|
2814 | |||
2792 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
2815 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 | |
2793 |
|
2816 | |||
2794 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
2817 | * IPython/__init__.py (__all__): Fixed package namespace, now | |
2795 | 'import IPython' does give access to IPython.<all> as |
|
2818 | 'import IPython' does give access to IPython.<all> as | |
2796 | expected. Also renamed __release__ to Release. |
|
2819 | expected. Also renamed __release__ to Release. | |
2797 |
|
2820 | |||
2798 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
2821 | * IPython/Debugger.py (__license__): created new Pdb class which | |
2799 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
2822 | functions like a drop-in for the normal pdb.Pdb but does NOT | |
2800 | import readline by default. This way it doesn't muck up IPython's |
|
2823 | import readline by default. This way it doesn't muck up IPython's | |
2801 | readline handling, and now tab-completion finally works in the |
|
2824 | readline handling, and now tab-completion finally works in the | |
2802 | debugger -- sort of. It completes things globally visible, but the |
|
2825 | debugger -- sort of. It completes things globally visible, but the | |
2803 | completer doesn't track the stack as pdb walks it. That's a bit |
|
2826 | completer doesn't track the stack as pdb walks it. That's a bit | |
2804 | tricky, and I'll have to implement it later. |
|
2827 | tricky, and I'll have to implement it later. | |
2805 |
|
2828 | |||
2806 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
2829 | 2002-05-05 Fernando Perez <fperez@colorado.edu> | |
2807 |
|
2830 | |||
2808 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
2831 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for | |
2809 | magic docstrings when printed via ? (explicit \'s were being |
|
2832 | magic docstrings when printed via ? (explicit \'s were being | |
2810 | printed). |
|
2833 | printed). | |
2811 |
|
2834 | |||
2812 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
2835 | * IPython/ipmaker.py (make_IPython): fixed namespace | |
2813 | identification bug. Now variables loaded via logs or command-line |
|
2836 | identification bug. Now variables loaded via logs or command-line | |
2814 | files are recognized in the interactive namespace by @who. |
|
2837 | files are recognized in the interactive namespace by @who. | |
2815 |
|
2838 | |||
2816 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
2839 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in | |
2817 | log replay system stemming from the string form of Structs. |
|
2840 | log replay system stemming from the string form of Structs. | |
2818 |
|
2841 | |||
2819 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
2842 | * IPython/Magic.py (Macro.__init__): improved macros to properly | |
2820 | handle magic commands in them. |
|
2843 | handle magic commands in them. | |
2821 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
2844 | (Magic.magic_logstart): usernames are now expanded so 'logstart | |
2822 | ~/mylog' now works. |
|
2845 | ~/mylog' now works. | |
2823 |
|
2846 | |||
2824 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
2847 | * IPython/iplib.py (complete): fixed bug where paths starting with | |
2825 | '/' would be completed as magic names. |
|
2848 | '/' would be completed as magic names. | |
2826 |
|
2849 | |||
2827 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
2850 | 2002-05-04 Fernando Perez <fperez@colorado.edu> | |
2828 |
|
2851 | |||
2829 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
2852 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to | |
2830 | allow running full programs under the profiler's control. |
|
2853 | allow running full programs under the profiler's control. | |
2831 |
|
2854 | |||
2832 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
2855 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars | |
2833 | mode to report exceptions verbosely but without formatting |
|
2856 | mode to report exceptions verbosely but without formatting | |
2834 | variables. This addresses the issue of ipython 'freezing' (it's |
|
2857 | variables. This addresses the issue of ipython 'freezing' (it's | |
2835 | not frozen, but caught in an expensive formatting loop) when huge |
|
2858 | not frozen, but caught in an expensive formatting loop) when huge | |
2836 | variables are in the context of an exception. |
|
2859 | variables are in the context of an exception. | |
2837 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
2860 | (VerboseTB.text): Added '--->' markers at line where exception was | |
2838 | triggered. Much clearer to read, especially in NoColor modes. |
|
2861 | triggered. Much clearer to read, especially in NoColor modes. | |
2839 |
|
2862 | |||
2840 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
2863 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been | |
2841 | implemented in reverse when changing to the new parse_options(). |
|
2864 | implemented in reverse when changing to the new parse_options(). | |
2842 |
|
2865 | |||
2843 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
2866 | 2002-05-03 Fernando Perez <fperez@colorado.edu> | |
2844 |
|
2867 | |||
2845 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
2868 | * IPython/Magic.py (Magic.parse_options): new function so that | |
2846 | magics can parse options easier. |
|
2869 | magics can parse options easier. | |
2847 | (Magic.magic_prun): new function similar to profile.run(), |
|
2870 | (Magic.magic_prun): new function similar to profile.run(), | |
2848 | suggested by Chris Hart. |
|
2871 | suggested by Chris Hart. | |
2849 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
2872 | (Magic.magic_cd): fixed behavior so that it only changes if | |
2850 | directory actually is in history. |
|
2873 | directory actually is in history. | |
2851 |
|
2874 | |||
2852 | * IPython/usage.py (__doc__): added information about potential |
|
2875 | * IPython/usage.py (__doc__): added information about potential | |
2853 | slowness of Verbose exception mode when there are huge data |
|
2876 | slowness of Verbose exception mode when there are huge data | |
2854 | structures to be formatted (thanks to Archie Paulson). |
|
2877 | structures to be formatted (thanks to Archie Paulson). | |
2855 |
|
2878 | |||
2856 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
2879 | * IPython/ipmaker.py (make_IPython): Changed default logging | |
2857 | (when simply called with -log) to use curr_dir/ipython.log in |
|
2880 | (when simply called with -log) to use curr_dir/ipython.log in | |
2858 | rotate mode. Fixed crash which was occuring with -log before |
|
2881 | rotate mode. Fixed crash which was occuring with -log before | |
2859 | (thanks to Jim Boyle). |
|
2882 | (thanks to Jim Boyle). | |
2860 |
|
2883 | |||
2861 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
2884 | 2002-05-01 Fernando Perez <fperez@colorado.edu> | |
2862 |
|
2885 | |||
2863 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
2886 | * Released 0.2.11 for these fixes (mainly the ultraTB one which | |
2864 | was nasty -- though somewhat of a corner case). |
|
2887 | was nasty -- though somewhat of a corner case). | |
2865 |
|
2888 | |||
2866 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
2889 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to | |
2867 | text (was a bug). |
|
2890 | text (was a bug). | |
2868 |
|
2891 | |||
2869 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
2892 | 2002-04-30 Fernando Perez <fperez@colorado.edu> | |
2870 |
|
2893 | |||
2871 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
2894 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add | |
2872 | a print after ^D or ^C from the user so that the In[] prompt |
|
2895 | a print after ^D or ^C from the user so that the In[] prompt | |
2873 | doesn't over-run the gnuplot one. |
|
2896 | doesn't over-run the gnuplot one. | |
2874 |
|
2897 | |||
2875 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
2898 | 2002-04-29 Fernando Perez <fperez@colorado.edu> | |
2876 |
|
2899 | |||
2877 | * Released 0.2.10 |
|
2900 | * Released 0.2.10 | |
2878 |
|
2901 | |||
2879 | * IPython/__release__.py (version): get date dynamically. |
|
2902 | * IPython/__release__.py (version): get date dynamically. | |
2880 |
|
2903 | |||
2881 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
2904 | * Misc. documentation updates thanks to Arnd's comments. Also ran | |
2882 | a full spellcheck on the manual (hadn't been done in a while). |
|
2905 | a full spellcheck on the manual (hadn't been done in a while). | |
2883 |
|
2906 | |||
2884 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
2907 | 2002-04-27 Fernando Perez <fperez@colorado.edu> | |
2885 |
|
2908 | |||
2886 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
2909 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where | |
2887 | starting a log in mid-session would reset the input history list. |
|
2910 | starting a log in mid-session would reset the input history list. | |
2888 |
|
2911 | |||
2889 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
2912 | 2002-04-26 Fernando Perez <fperez@colorado.edu> | |
2890 |
|
2913 | |||
2891 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
2914 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not | |
2892 | all files were being included in an update. Now anything in |
|
2915 | all files were being included in an update. Now anything in | |
2893 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
2916 | UserConfig that matches [A-Za-z]*.py will go (this excludes | |
2894 | __init__.py) |
|
2917 | __init__.py) | |
2895 |
|
2918 | |||
2896 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
2919 | 2002-04-25 Fernando Perez <fperez@colorado.edu> | |
2897 |
|
2920 | |||
2898 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
2921 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ | |
2899 | to __builtins__ so that any form of embedded or imported code can |
|
2922 | to __builtins__ so that any form of embedded or imported code can | |
2900 | test for being inside IPython. |
|
2923 | test for being inside IPython. | |
2901 |
|
2924 | |||
2902 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
2925 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): | |
2903 | changed to GnuplotMagic because it's now an importable module, |
|
2926 | changed to GnuplotMagic because it's now an importable module, | |
2904 | this makes the name follow that of the standard Gnuplot module. |
|
2927 | this makes the name follow that of the standard Gnuplot module. | |
2905 | GnuplotMagic can now be loaded at any time in mid-session. |
|
2928 | GnuplotMagic can now be loaded at any time in mid-session. | |
2906 |
|
2929 | |||
2907 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
2930 | 2002-04-24 Fernando Perez <fperez@colorado.edu> | |
2908 |
|
2931 | |||
2909 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
2932 | * IPython/numutils.py: removed SIUnits. It doesn't properly set | |
2910 | the globals (IPython has its own namespace) and the |
|
2933 | the globals (IPython has its own namespace) and the | |
2911 | PhysicalQuantity stuff is much better anyway. |
|
2934 | PhysicalQuantity stuff is much better anyway. | |
2912 |
|
2935 | |||
2913 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
2936 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot | |
2914 | embedding example to standard user directory for |
|
2937 | embedding example to standard user directory for | |
2915 | distribution. Also put it in the manual. |
|
2938 | distribution. Also put it in the manual. | |
2916 |
|
2939 | |||
2917 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
2940 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot | |
2918 | instance as first argument (so it doesn't rely on some obscure |
|
2941 | instance as first argument (so it doesn't rely on some obscure | |
2919 | hidden global). |
|
2942 | hidden global). | |
2920 |
|
2943 | |||
2921 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
2944 | * IPython/UserConfig/ipythonrc.py: put () back in accepted | |
2922 | delimiters. While it prevents ().TAB from working, it allows |
|
2945 | delimiters. While it prevents ().TAB from working, it allows | |
2923 | completions in open (... expressions. This is by far a more common |
|
2946 | completions in open (... expressions. This is by far a more common | |
2924 | case. |
|
2947 | case. | |
2925 |
|
2948 | |||
2926 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
2949 | 2002-04-23 Fernando Perez <fperez@colorado.edu> | |
2927 |
|
2950 | |||
2928 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
2951 | * IPython/Extensions/InterpreterPasteInput.py: new | |
2929 | syntax-processing module for pasting lines with >>> or ... at the |
|
2952 | syntax-processing module for pasting lines with >>> or ... at the | |
2930 | start. |
|
2953 | start. | |
2931 |
|
2954 | |||
2932 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
2955 | * IPython/Extensions/PhysicalQ_Interactive.py | |
2933 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
2956 | (PhysicalQuantityInteractive.__int__): fixed to work with either | |
2934 | Numeric or math. |
|
2957 | Numeric or math. | |
2935 |
|
2958 | |||
2936 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
2959 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the | |
2937 | provided profiles. Now we have: |
|
2960 | provided profiles. Now we have: | |
2938 | -math -> math module as * and cmath with its own namespace. |
|
2961 | -math -> math module as * and cmath with its own namespace. | |
2939 | -numeric -> Numeric as *, plus gnuplot & grace |
|
2962 | -numeric -> Numeric as *, plus gnuplot & grace | |
2940 | -physics -> same as before |
|
2963 | -physics -> same as before | |
2941 |
|
2964 | |||
2942 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
2965 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where | |
2943 | user-defined magics wouldn't be found by @magic if they were |
|
2966 | user-defined magics wouldn't be found by @magic if they were | |
2944 | defined as class methods. Also cleaned up the namespace search |
|
2967 | defined as class methods. Also cleaned up the namespace search | |
2945 | logic and the string building (to use %s instead of many repeated |
|
2968 | logic and the string building (to use %s instead of many repeated | |
2946 | string adds). |
|
2969 | string adds). | |
2947 |
|
2970 | |||
2948 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
2971 | * IPython/UserConfig/example-magic.py (magic_foo): updated example | |
2949 | of user-defined magics to operate with class methods (cleaner, in |
|
2972 | of user-defined magics to operate with class methods (cleaner, in | |
2950 | line with the gnuplot code). |
|
2973 | line with the gnuplot code). | |
2951 |
|
2974 | |||
2952 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
2975 | 2002-04-22 Fernando Perez <fperez@colorado.edu> | |
2953 |
|
2976 | |||
2954 | * setup.py: updated dependency list so that manual is updated when |
|
2977 | * setup.py: updated dependency list so that manual is updated when | |
2955 | all included files change. |
|
2978 | all included files change. | |
2956 |
|
2979 | |||
2957 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
2980 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring | |
2958 | the delimiter removal option (the fix is ugly right now). |
|
2981 | the delimiter removal option (the fix is ugly right now). | |
2959 |
|
2982 | |||
2960 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
2983 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load | |
2961 | all of the math profile (quicker loading, no conflict between |
|
2984 | all of the math profile (quicker loading, no conflict between | |
2962 | g-9.8 and g-gnuplot). |
|
2985 | g-9.8 and g-gnuplot). | |
2963 |
|
2986 | |||
2964 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
2987 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default | |
2965 | name of post-mortem files to IPython_crash_report.txt. |
|
2988 | name of post-mortem files to IPython_crash_report.txt. | |
2966 |
|
2989 | |||
2967 | * Cleanup/update of the docs. Added all the new readline info and |
|
2990 | * Cleanup/update of the docs. Added all the new readline info and | |
2968 | formatted all lists as 'real lists'. |
|
2991 | formatted all lists as 'real lists'. | |
2969 |
|
2992 | |||
2970 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
2993 | * IPython/ipmaker.py (make_IPython): removed now-obsolete | |
2971 | tab-completion options, since the full readline parse_and_bind is |
|
2994 | tab-completion options, since the full readline parse_and_bind is | |
2972 | now accessible. |
|
2995 | now accessible. | |
2973 |
|
2996 | |||
2974 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
2997 | * IPython/iplib.py (InteractiveShell.init_readline): Changed | |
2975 | handling of readline options. Now users can specify any string to |
|
2998 | handling of readline options. Now users can specify any string to | |
2976 | be passed to parse_and_bind(), as well as the delimiters to be |
|
2999 | be passed to parse_and_bind(), as well as the delimiters to be | |
2977 | removed. |
|
3000 | removed. | |
2978 | (InteractiveShell.__init__): Added __name__ to the global |
|
3001 | (InteractiveShell.__init__): Added __name__ to the global | |
2979 | namespace so that things like Itpl which rely on its existence |
|
3002 | namespace so that things like Itpl which rely on its existence | |
2980 | don't crash. |
|
3003 | don't crash. | |
2981 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
3004 | (InteractiveShell._prefilter): Defined the default with a _ so | |
2982 | that prefilter() is easier to override, while the default one |
|
3005 | that prefilter() is easier to override, while the default one | |
2983 | remains available. |
|
3006 | remains available. | |
2984 |
|
3007 | |||
2985 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
3008 | 2002-04-18 Fernando Perez <fperez@colorado.edu> | |
2986 |
|
3009 | |||
2987 | * Added information about pdb in the docs. |
|
3010 | * Added information about pdb in the docs. | |
2988 |
|
3011 | |||
2989 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
3012 | 2002-04-17 Fernando Perez <fperez@colorado.edu> | |
2990 |
|
3013 | |||
2991 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
3014 | * IPython/ipmaker.py (make_IPython): added rc_override option to | |
2992 | allow passing config options at creation time which may override |
|
3015 | allow passing config options at creation time which may override | |
2993 | anything set in the config files or command line. This is |
|
3016 | anything set in the config files or command line. This is | |
2994 | particularly useful for configuring embedded instances. |
|
3017 | particularly useful for configuring embedded instances. | |
2995 |
|
3018 | |||
2996 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
3019 | 2002-04-15 Fernando Perez <fperez@colorado.edu> | |
2997 |
|
3020 | |||
2998 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
3021 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could | |
2999 | crash embedded instances because of the input cache falling out of |
|
3022 | crash embedded instances because of the input cache falling out of | |
3000 | sync with the output counter. |
|
3023 | sync with the output counter. | |
3001 |
|
3024 | |||
3002 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
3025 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug | |
3003 | mode which calls pdb after an uncaught exception in IPython itself. |
|
3026 | mode which calls pdb after an uncaught exception in IPython itself. | |
3004 |
|
3027 | |||
3005 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
3028 | 2002-04-14 Fernando Perez <fperez@colorado.edu> | |
3006 |
|
3029 | |||
3007 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
3030 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up | |
3008 | readline, fix it back after each call. |
|
3031 | readline, fix it back after each call. | |
3009 |
|
3032 | |||
3010 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
3033 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private | |
3011 | method to force all access via __call__(), which guarantees that |
|
3034 | method to force all access via __call__(), which guarantees that | |
3012 | traceback references are properly deleted. |
|
3035 | traceback references are properly deleted. | |
3013 |
|
3036 | |||
3014 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
3037 | * IPython/Prompts.py (CachedOutput._display): minor fixes to | |
3015 | improve printing when pprint is in use. |
|
3038 | improve printing when pprint is in use. | |
3016 |
|
3039 | |||
3017 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
3040 | 2002-04-13 Fernando Perez <fperez@colorado.edu> | |
3018 |
|
3041 | |||
3019 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
3042 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit | |
3020 | exceptions aren't caught anymore. If the user triggers one, he |
|
3043 | exceptions aren't caught anymore. If the user triggers one, he | |
3021 | should know why he's doing it and it should go all the way up, |
|
3044 | should know why he's doing it and it should go all the way up, | |
3022 | just like any other exception. So now @abort will fully kill the |
|
3045 | just like any other exception. So now @abort will fully kill the | |
3023 | embedded interpreter and the embedding code (unless that happens |
|
3046 | embedded interpreter and the embedding code (unless that happens | |
3024 | to catch SystemExit). |
|
3047 | to catch SystemExit). | |
3025 |
|
3048 | |||
3026 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
3049 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag | |
3027 | and a debugger() method to invoke the interactive pdb debugger |
|
3050 | and a debugger() method to invoke the interactive pdb debugger | |
3028 | after printing exception information. Also added the corresponding |
|
3051 | after printing exception information. Also added the corresponding | |
3029 | -pdb option and @pdb magic to control this feature, and updated |
|
3052 | -pdb option and @pdb magic to control this feature, and updated | |
3030 | the docs. After a suggestion from Christopher Hart |
|
3053 | the docs. After a suggestion from Christopher Hart | |
3031 | (hart-AT-caltech.edu). |
|
3054 | (hart-AT-caltech.edu). | |
3032 |
|
3055 | |||
3033 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
3056 | 2002-04-12 Fernando Perez <fperez@colorado.edu> | |
3034 |
|
3057 | |||
3035 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
3058 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use | |
3036 | the exception handlers defined by the user (not the CrashHandler) |
|
3059 | the exception handlers defined by the user (not the CrashHandler) | |
3037 | so that user exceptions don't trigger an ipython bug report. |
|
3060 | so that user exceptions don't trigger an ipython bug report. | |
3038 |
|
3061 | |||
3039 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
3062 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme | |
3040 | configurable (it should have always been so). |
|
3063 | configurable (it should have always been so). | |
3041 |
|
3064 | |||
3042 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
3065 | 2002-03-26 Fernando Perez <fperez@colorado.edu> | |
3043 |
|
3066 | |||
3044 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
3067 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here | |
3045 | and there to fix embedding namespace issues. This should all be |
|
3068 | and there to fix embedding namespace issues. This should all be | |
3046 | done in a more elegant way. |
|
3069 | done in a more elegant way. | |
3047 |
|
3070 | |||
3048 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
3071 | 2002-03-25 Fernando Perez <fperez@colorado.edu> | |
3049 |
|
3072 | |||
3050 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
3073 | * IPython/genutils.py (get_home_dir): Try to make it work under | |
3051 | win9x also. |
|
3074 | win9x also. | |
3052 |
|
3075 | |||
3053 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
3076 | 2002-03-20 Fernando Perez <fperez@colorado.edu> | |
3054 |
|
3077 | |||
3055 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
3078 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave | |
3056 | sys.displayhook untouched upon __init__. |
|
3079 | sys.displayhook untouched upon __init__. | |
3057 |
|
3080 | |||
3058 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
3081 | 2002-03-19 Fernando Perez <fperez@colorado.edu> | |
3059 |
|
3082 | |||
3060 | * Released 0.2.9 (for embedding bug, basically). |
|
3083 | * Released 0.2.9 (for embedding bug, basically). | |
3061 |
|
3084 | |||
3062 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
3085 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit | |
3063 | exceptions so that enclosing shell's state can be restored. |
|
3086 | exceptions so that enclosing shell's state can be restored. | |
3064 |
|
3087 | |||
3065 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
3088 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize | |
3066 | naming conventions in the .ipython/ dir. |
|
3089 | naming conventions in the .ipython/ dir. | |
3067 |
|
3090 | |||
3068 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
3091 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' | |
3069 | from delimiters list so filenames with - in them get expanded. |
|
3092 | from delimiters list so filenames with - in them get expanded. | |
3070 |
|
3093 | |||
3071 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
3094 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with | |
3072 | sys.displayhook not being properly restored after an embedded call. |
|
3095 | sys.displayhook not being properly restored after an embedded call. | |
3073 |
|
3096 | |||
3074 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
3097 | 2002-03-18 Fernando Perez <fperez@colorado.edu> | |
3075 |
|
3098 | |||
3076 | * Released 0.2.8 |
|
3099 | * Released 0.2.8 | |
3077 |
|
3100 | |||
3078 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
3101 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where | |
3079 | some files weren't being included in a -upgrade. |
|
3102 | some files weren't being included in a -upgrade. | |
3080 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
3103 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous | |
3081 | on' so that the first tab completes. |
|
3104 | on' so that the first tab completes. | |
3082 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
3105 | (InteractiveShell.handle_magic): fixed bug with spaces around | |
3083 | quotes breaking many magic commands. |
|
3106 | quotes breaking many magic commands. | |
3084 |
|
3107 | |||
3085 | * setup.py: added note about ignoring the syntax error messages at |
|
3108 | * setup.py: added note about ignoring the syntax error messages at | |
3086 | installation. |
|
3109 | installation. | |
3087 |
|
3110 | |||
3088 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
3111 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished | |
3089 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
3112 | streamlining the gnuplot interface, now there's only one magic @gp. | |
3090 |
|
3113 | |||
3091 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
3114 | 2002-03-17 Fernando Perez <fperez@colorado.edu> | |
3092 |
|
3115 | |||
3093 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
3116 | * IPython/UserConfig/magic_gnuplot.py: new name for the | |
3094 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
3117 | example-magic_pm.py file. Much enhanced system, now with a shell | |
3095 | for communicating directly with gnuplot, one command at a time. |
|
3118 | for communicating directly with gnuplot, one command at a time. | |
3096 |
|
3119 | |||
3097 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
3120 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent | |
3098 | setting __name__=='__main__'. |
|
3121 | setting __name__=='__main__'. | |
3099 |
|
3122 | |||
3100 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
3123 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added | |
3101 | mini-shell for accessing gnuplot from inside ipython. Should |
|
3124 | mini-shell for accessing gnuplot from inside ipython. Should | |
3102 | extend it later for grace access too. Inspired by Arnd's |
|
3125 | extend it later for grace access too. Inspired by Arnd's | |
3103 | suggestion. |
|
3126 | suggestion. | |
3104 |
|
3127 | |||
3105 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
3128 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when | |
3106 | calling magic functions with () in their arguments. Thanks to Arnd |
|
3129 | calling magic functions with () in their arguments. Thanks to Arnd | |
3107 | Baecker for pointing this to me. |
|
3130 | Baecker for pointing this to me. | |
3108 |
|
3131 | |||
3109 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
3132 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse | |
3110 | infinitely for integer or complex arrays (only worked with floats). |
|
3133 | infinitely for integer or complex arrays (only worked with floats). | |
3111 |
|
3134 | |||
3112 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
3135 | 2002-03-16 Fernando Perez <fperez@colorado.edu> | |
3113 |
|
3136 | |||
3114 | * setup.py: Merged setup and setup_windows into a single script |
|
3137 | * setup.py: Merged setup and setup_windows into a single script | |
3115 | which properly handles things for windows users. |
|
3138 | which properly handles things for windows users. | |
3116 |
|
3139 | |||
3117 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
3140 | 2002-03-15 Fernando Perez <fperez@colorado.edu> | |
3118 |
|
3141 | |||
3119 | * Big change to the manual: now the magics are all automatically |
|
3142 | * Big change to the manual: now the magics are all automatically | |
3120 | documented. This information is generated from their docstrings |
|
3143 | documented. This information is generated from their docstrings | |
3121 | and put in a latex file included by the manual lyx file. This way |
|
3144 | and put in a latex file included by the manual lyx file. This way | |
3122 | we get always up to date information for the magics. The manual |
|
3145 | we get always up to date information for the magics. The manual | |
3123 | now also has proper version information, also auto-synced. |
|
3146 | now also has proper version information, also auto-synced. | |
3124 |
|
3147 | |||
3125 | For this to work, an undocumented --magic_docstrings option was added. |
|
3148 | For this to work, an undocumented --magic_docstrings option was added. | |
3126 |
|
3149 | |||
3127 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
3150 | 2002-03-13 Fernando Perez <fperez@colorado.edu> | |
3128 |
|
3151 | |||
3129 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
3152 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors | |
3130 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
3153 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. | |
3131 |
|
3154 | |||
3132 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
3155 | 2002-03-12 Fernando Perez <fperez@colorado.edu> | |
3133 |
|
3156 | |||
3134 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
3157 | * IPython/ultraTB.py (TermColors): changed color escapes again to | |
3135 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
3158 | fix the (old, reintroduced) line-wrapping bug. Basically, if | |
3136 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
3159 | \001..\002 aren't given in the color escapes, lines get wrapped | |
3137 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
3160 | weirdly. But giving those screws up old xterms and emacs terms. So | |
3138 | I added some logic for emacs terms to be ok, but I can't identify old |
|
3161 | I added some logic for emacs terms to be ok, but I can't identify old | |
3139 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
3162 | xterms separately ($TERM=='xterm' for many terminals, like konsole). | |
3140 |
|
3163 | |||
3141 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
3164 | 2002-03-10 Fernando Perez <fperez@colorado.edu> | |
3142 |
|
3165 | |||
3143 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
3166 | * IPython/usage.py (__doc__): Various documentation cleanups and | |
3144 | updates, both in usage docstrings and in the manual. |
|
3167 | updates, both in usage docstrings and in the manual. | |
3145 |
|
3168 | |||
3146 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
3169 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for | |
3147 | handling of caching. Set minimum acceptabe value for having a |
|
3170 | handling of caching. Set minimum acceptabe value for having a | |
3148 | cache at 20 values. |
|
3171 | cache at 20 values. | |
3149 |
|
3172 | |||
3150 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
3173 | * IPython/iplib.py (InteractiveShell.user_setup): moved the | |
3151 | install_first_time function to a method, renamed it and added an |
|
3174 | install_first_time function to a method, renamed it and added an | |
3152 | 'upgrade' mode. Now people can update their config directory with |
|
3175 | 'upgrade' mode. Now people can update their config directory with | |
3153 | a simple command line switch (-upgrade, also new). |
|
3176 | a simple command line switch (-upgrade, also new). | |
3154 |
|
3177 | |||
3155 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
3178 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to | |
3156 | @file (convenient for automagic users under Python >= 2.2). |
|
3179 | @file (convenient for automagic users under Python >= 2.2). | |
3157 | Removed @files (it seemed more like a plural than an abbrev. of |
|
3180 | Removed @files (it seemed more like a plural than an abbrev. of | |
3158 | 'file show'). |
|
3181 | 'file show'). | |
3159 |
|
3182 | |||
3160 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
3183 | * IPython/iplib.py (install_first_time): Fixed crash if there were | |
3161 | backup files ('~') in .ipython/ install directory. |
|
3184 | backup files ('~') in .ipython/ install directory. | |
3162 |
|
3185 | |||
3163 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
3186 | * IPython/ipmaker.py (make_IPython): fixes for new prompt | |
3164 | system. Things look fine, but these changes are fairly |
|
3187 | system. Things look fine, but these changes are fairly | |
3165 | intrusive. Test them for a few days. |
|
3188 | intrusive. Test them for a few days. | |
3166 |
|
3189 | |||
3167 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
3190 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of | |
3168 | the prompts system. Now all in/out prompt strings are user |
|
3191 | the prompts system. Now all in/out prompt strings are user | |
3169 | controllable. This is particularly useful for embedding, as one |
|
3192 | controllable. This is particularly useful for embedding, as one | |
3170 | can tag embedded instances with particular prompts. |
|
3193 | can tag embedded instances with particular prompts. | |
3171 |
|
3194 | |||
3172 | Also removed global use of sys.ps1/2, which now allows nested |
|
3195 | Also removed global use of sys.ps1/2, which now allows nested | |
3173 | embeddings without any problems. Added command-line options for |
|
3196 | embeddings without any problems. Added command-line options for | |
3174 | the prompt strings. |
|
3197 | the prompt strings. | |
3175 |
|
3198 | |||
3176 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
3199 | 2002-03-08 Fernando Perez <fperez@colorado.edu> | |
3177 |
|
3200 | |||
3178 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
3201 | * IPython/UserConfig/example-embed-short.py (ipshell): added | |
3179 | example file with the bare minimum code for embedding. |
|
3202 | example file with the bare minimum code for embedding. | |
3180 |
|
3203 | |||
3181 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
3204 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added | |
3182 | functionality for the embeddable shell to be activated/deactivated |
|
3205 | functionality for the embeddable shell to be activated/deactivated | |
3183 | either globally or at each call. |
|
3206 | either globally or at each call. | |
3184 |
|
3207 | |||
3185 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
3208 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of | |
3186 | rewriting the prompt with '--->' for auto-inputs with proper |
|
3209 | rewriting the prompt with '--->' for auto-inputs with proper | |
3187 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
3210 | coloring. Now the previous UGLY hack in handle_auto() is gone, and | |
3188 | this is handled by the prompts class itself, as it should. |
|
3211 | this is handled by the prompts class itself, as it should. | |
3189 |
|
3212 | |||
3190 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
3213 | 2002-03-05 Fernando Perez <fperez@colorado.edu> | |
3191 |
|
3214 | |||
3192 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
3215 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to | |
3193 | @logstart to avoid name clashes with the math log function. |
|
3216 | @logstart to avoid name clashes with the math log function. | |
3194 |
|
3217 | |||
3195 | * Big updates to X/Emacs section of the manual. |
|
3218 | * Big updates to X/Emacs section of the manual. | |
3196 |
|
3219 | |||
3197 | * Removed ipython_emacs. Milan explained to me how to pass |
|
3220 | * Removed ipython_emacs. Milan explained to me how to pass | |
3198 | arguments to ipython through Emacs. Some day I'm going to end up |
|
3221 | arguments to ipython through Emacs. Some day I'm going to end up | |
3199 | learning some lisp... |
|
3222 | learning some lisp... | |
3200 |
|
3223 | |||
3201 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
3224 | 2002-03-04 Fernando Perez <fperez@colorado.edu> | |
3202 |
|
3225 | |||
3203 | * IPython/ipython_emacs: Created script to be used as the |
|
3226 | * IPython/ipython_emacs: Created script to be used as the | |
3204 | py-python-command Emacs variable so we can pass IPython |
|
3227 | py-python-command Emacs variable so we can pass IPython | |
3205 | parameters. I can't figure out how to tell Emacs directly to pass |
|
3228 | parameters. I can't figure out how to tell Emacs directly to pass | |
3206 | parameters to IPython, so a dummy shell script will do it. |
|
3229 | parameters to IPython, so a dummy shell script will do it. | |
3207 |
|
3230 | |||
3208 | Other enhancements made for things to work better under Emacs' |
|
3231 | Other enhancements made for things to work better under Emacs' | |
3209 | various types of terminals. Many thanks to Milan Zamazal |
|
3232 | various types of terminals. Many thanks to Milan Zamazal | |
3210 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
3233 | <pdm-AT-zamazal.org> for all the suggestions and pointers. | |
3211 |
|
3234 | |||
3212 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
3235 | 2002-03-01 Fernando Perez <fperez@colorado.edu> | |
3213 |
|
3236 | |||
3214 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
3237 | * IPython/ipmaker.py (make_IPython): added a --readline! option so | |
3215 | that loading of readline is now optional. This gives better |
|
3238 | that loading of readline is now optional. This gives better | |
3216 | control to emacs users. |
|
3239 | control to emacs users. | |
3217 |
|
3240 | |||
3218 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
3241 | * IPython/ultraTB.py (__date__): Modified color escape sequences | |
3219 | and now things work fine under xterm and in Emacs' term buffers |
|
3242 | and now things work fine under xterm and in Emacs' term buffers | |
3220 | (though not shell ones). Well, in emacs you get colors, but all |
|
3243 | (though not shell ones). Well, in emacs you get colors, but all | |
3221 | seem to be 'light' colors (no difference between dark and light |
|
3244 | seem to be 'light' colors (no difference between dark and light | |
3222 | ones). But the garbage chars are gone, and also in xterms. It |
|
3245 | ones). But the garbage chars are gone, and also in xterms. It | |
3223 | seems that now I'm using 'cleaner' ansi sequences. |
|
3246 | seems that now I'm using 'cleaner' ansi sequences. | |
3224 |
|
3247 | |||
3225 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
3248 | 2002-02-21 Fernando Perez <fperez@colorado.edu> | |
3226 |
|
3249 | |||
3227 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
3250 | * Released 0.2.7 (mainly to publish the scoping fix). | |
3228 |
|
3251 | |||
3229 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
3252 | * IPython/Logger.py (Logger.logstate): added. A corresponding | |
3230 | @logstate magic was created. |
|
3253 | @logstate magic was created. | |
3231 |
|
3254 | |||
3232 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
3255 | * IPython/Magic.py: fixed nested scoping problem under Python | |
3233 | 2.1.x (automagic wasn't working). |
|
3256 | 2.1.x (automagic wasn't working). | |
3234 |
|
3257 | |||
3235 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
3258 | 2002-02-20 Fernando Perez <fperez@colorado.edu> | |
3236 |
|
3259 | |||
3237 | * Released 0.2.6. |
|
3260 | * Released 0.2.6. | |
3238 |
|
3261 | |||
3239 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
3262 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' | |
3240 | option so that logs can come out without any headers at all. |
|
3263 | option so that logs can come out without any headers at all. | |
3241 |
|
3264 | |||
3242 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
3265 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for | |
3243 | SciPy. |
|
3266 | SciPy. | |
3244 |
|
3267 | |||
3245 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
3268 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so | |
3246 | that embedded IPython calls don't require vars() to be explicitly |
|
3269 | that embedded IPython calls don't require vars() to be explicitly | |
3247 | passed. Now they are extracted from the caller's frame (code |
|
3270 | passed. Now they are extracted from the caller's frame (code | |
3248 | snatched from Eric Jones' weave). Added better documentation to |
|
3271 | snatched from Eric Jones' weave). Added better documentation to | |
3249 | the section on embedding and the example file. |
|
3272 | the section on embedding and the example file. | |
3250 |
|
3273 | |||
3251 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
3274 | * IPython/genutils.py (page): Changed so that under emacs, it just | |
3252 | prints the string. You can then page up and down in the emacs |
|
3275 | prints the string. You can then page up and down in the emacs | |
3253 | buffer itself. This is how the builtin help() works. |
|
3276 | buffer itself. This is how the builtin help() works. | |
3254 |
|
3277 | |||
3255 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
3278 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with | |
3256 | macro scoping: macros need to be executed in the user's namespace |
|
3279 | macro scoping: macros need to be executed in the user's namespace | |
3257 | to work as if they had been typed by the user. |
|
3280 | to work as if they had been typed by the user. | |
3258 |
|
3281 | |||
3259 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
3282 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they | |
3260 | execute automatically (no need to type 'exec...'). They then |
|
3283 | execute automatically (no need to type 'exec...'). They then | |
3261 | behave like 'true macros'. The printing system was also modified |
|
3284 | behave like 'true macros'. The printing system was also modified | |
3262 | for this to work. |
|
3285 | for this to work. | |
3263 |
|
3286 | |||
3264 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
3287 | 2002-02-19 Fernando Perez <fperez@colorado.edu> | |
3265 |
|
3288 | |||
3266 | * IPython/genutils.py (page_file): new function for paging files |
|
3289 | * IPython/genutils.py (page_file): new function for paging files | |
3267 | in an OS-independent way. Also necessary for file viewing to work |
|
3290 | in an OS-independent way. Also necessary for file viewing to work | |
3268 | well inside Emacs buffers. |
|
3291 | well inside Emacs buffers. | |
3269 | (page): Added checks for being in an emacs buffer. |
|
3292 | (page): Added checks for being in an emacs buffer. | |
3270 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
3293 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed | |
3271 | same bug in iplib. |
|
3294 | same bug in iplib. | |
3272 |
|
3295 | |||
3273 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
3296 | 2002-02-18 Fernando Perez <fperez@colorado.edu> | |
3274 |
|
3297 | |||
3275 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
3298 | * IPython/iplib.py (InteractiveShell.init_readline): modified use | |
3276 | of readline so that IPython can work inside an Emacs buffer. |
|
3299 | of readline so that IPython can work inside an Emacs buffer. | |
3277 |
|
3300 | |||
3278 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
3301 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to | |
3279 | method signatures (they weren't really bugs, but it looks cleaner |
|
3302 | method signatures (they weren't really bugs, but it looks cleaner | |
3280 | and keeps PyChecker happy). |
|
3303 | and keeps PyChecker happy). | |
3281 |
|
3304 | |||
3282 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
3305 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP | |
3283 | for implementing various user-defined hooks. Currently only |
|
3306 | for implementing various user-defined hooks. Currently only | |
3284 | display is done. |
|
3307 | display is done. | |
3285 |
|
3308 | |||
3286 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
3309 | * IPython/Prompts.py (CachedOutput._display): changed display | |
3287 | functions so that they can be dynamically changed by users easily. |
|
3310 | functions so that they can be dynamically changed by users easily. | |
3288 |
|
3311 | |||
3289 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
3312 | * IPython/Extensions/numeric_formats.py (num_display): added an | |
3290 | extension for printing NumPy arrays in flexible manners. It |
|
3313 | extension for printing NumPy arrays in flexible manners. It | |
3291 | doesn't do anything yet, but all the structure is in |
|
3314 | doesn't do anything yet, but all the structure is in | |
3292 | place. Ultimately the plan is to implement output format control |
|
3315 | place. Ultimately the plan is to implement output format control | |
3293 | like in Octave. |
|
3316 | like in Octave. | |
3294 |
|
3317 | |||
3295 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
3318 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic | |
3296 | methods are found at run-time by all the automatic machinery. |
|
3319 | methods are found at run-time by all the automatic machinery. | |
3297 |
|
3320 | |||
3298 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
3321 | 2002-02-17 Fernando Perez <fperez@colorado.edu> | |
3299 |
|
3322 | |||
3300 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
3323 | * setup_Windows.py (make_shortcut): documented. Cleaned up the | |
3301 | whole file a little. |
|
3324 | whole file a little. | |
3302 |
|
3325 | |||
3303 | * ToDo: closed this document. Now there's a new_design.lyx |
|
3326 | * ToDo: closed this document. Now there's a new_design.lyx | |
3304 | document for all new ideas. Added making a pdf of it for the |
|
3327 | document for all new ideas. Added making a pdf of it for the | |
3305 | end-user distro. |
|
3328 | end-user distro. | |
3306 |
|
3329 | |||
3307 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
3330 | * IPython/Logger.py (Logger.switch_log): Created this to replace | |
3308 | logon() and logoff(). It also fixes a nasty crash reported by |
|
3331 | logon() and logoff(). It also fixes a nasty crash reported by | |
3309 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
3332 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. | |
3310 |
|
3333 | |||
3311 | * IPython/iplib.py (complete): got auto-completion to work with |
|
3334 | * IPython/iplib.py (complete): got auto-completion to work with | |
3312 | automagic (I had wanted this for a long time). |
|
3335 | automagic (I had wanted this for a long time). | |
3313 |
|
3336 | |||
3314 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
3337 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias | |
3315 | to @file, since file() is now a builtin and clashes with automagic |
|
3338 | to @file, since file() is now a builtin and clashes with automagic | |
3316 | for @file. |
|
3339 | for @file. | |
3317 |
|
3340 | |||
3318 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
3341 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All | |
3319 | of this was previously in iplib, which had grown to more than 2000 |
|
3342 | of this was previously in iplib, which had grown to more than 2000 | |
3320 | lines, way too long. No new functionality, but it makes managing |
|
3343 | lines, way too long. No new functionality, but it makes managing | |
3321 | the code a bit easier. |
|
3344 | the code a bit easier. | |
3322 |
|
3345 | |||
3323 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
3346 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version | |
3324 | information to crash reports. |
|
3347 | information to crash reports. | |
3325 |
|
3348 | |||
3326 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
3349 | 2002-02-12 Fernando Perez <fperez@colorado.edu> | |
3327 |
|
3350 | |||
3328 | * Released 0.2.5. |
|
3351 | * Released 0.2.5. | |
3329 |
|
3352 | |||
3330 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
3353 | 2002-02-11 Fernando Perez <fperez@colorado.edu> | |
3331 |
|
3354 | |||
3332 | * Wrote a relatively complete Windows installer. It puts |
|
3355 | * Wrote a relatively complete Windows installer. It puts | |
3333 | everything in place, creates Start Menu entries and fixes the |
|
3356 | everything in place, creates Start Menu entries and fixes the | |
3334 | color issues. Nothing fancy, but it works. |
|
3357 | color issues. Nothing fancy, but it works. | |
3335 |
|
3358 | |||
3336 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
3359 | 2002-02-10 Fernando Perez <fperez@colorado.edu> | |
3337 |
|
3360 | |||
3338 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
3361 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an | |
3339 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
3362 | os.path.expanduser() call so that we can type @run ~/myfile.py and | |
3340 | have thigs work as expected. |
|
3363 | have thigs work as expected. | |
3341 |
|
3364 | |||
3342 | * IPython/genutils.py (page): fixed exception handling so things |
|
3365 | * IPython/genutils.py (page): fixed exception handling so things | |
3343 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
3366 | work both in Unix and Windows correctly. Quitting a pager triggers | |
3344 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
3367 | an IOError/broken pipe in Unix, and in windows not finding a pager | |
3345 | is also an IOError, so I had to actually look at the return value |
|
3368 | is also an IOError, so I had to actually look at the return value | |
3346 | of the exception, not just the exception itself. Should be ok now. |
|
3369 | of the exception, not just the exception itself. Should be ok now. | |
3347 |
|
3370 | |||
3348 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
3371 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): | |
3349 | modified to allow case-insensitive color scheme changes. |
|
3372 | modified to allow case-insensitive color scheme changes. | |
3350 |
|
3373 | |||
3351 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
3374 | 2002-02-09 Fernando Perez <fperez@colorado.edu> | |
3352 |
|
3375 | |||
3353 | * IPython/genutils.py (native_line_ends): new function to leave |
|
3376 | * IPython/genutils.py (native_line_ends): new function to leave | |
3354 | user config files with os-native line-endings. |
|
3377 | user config files with os-native line-endings. | |
3355 |
|
3378 | |||
3356 | * README and manual updates. |
|
3379 | * README and manual updates. | |
3357 |
|
3380 | |||
3358 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
3381 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes | |
3359 | instead of StringType to catch Unicode strings. |
|
3382 | instead of StringType to catch Unicode strings. | |
3360 |
|
3383 | |||
3361 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
3384 | * IPython/genutils.py (filefind): fixed bug for paths with | |
3362 | embedded spaces (very common in Windows). |
|
3385 | embedded spaces (very common in Windows). | |
3363 |
|
3386 | |||
3364 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
3387 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc | |
3365 | files under Windows, so that they get automatically associated |
|
3388 | files under Windows, so that they get automatically associated | |
3366 | with a text editor. Windows makes it a pain to handle |
|
3389 | with a text editor. Windows makes it a pain to handle | |
3367 | extension-less files. |
|
3390 | extension-less files. | |
3368 |
|
3391 | |||
3369 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
3392 | * IPython/iplib.py (InteractiveShell.init_readline): Made the | |
3370 | warning about readline only occur for Posix. In Windows there's no |
|
3393 | warning about readline only occur for Posix. In Windows there's no | |
3371 | way to get readline, so why bother with the warning. |
|
3394 | way to get readline, so why bother with the warning. | |
3372 |
|
3395 | |||
3373 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
3396 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ | |
3374 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
3397 | for __str__ instead of dir(self), since dir() changed in 2.2. | |
3375 |
|
3398 | |||
3376 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
3399 | * Ported to Windows! Tested on XP, I suspect it should work fine | |
3377 | on NT/2000, but I don't think it will work on 98 et al. That |
|
3400 | on NT/2000, but I don't think it will work on 98 et al. That | |
3378 | series of Windows is such a piece of junk anyway that I won't try |
|
3401 | series of Windows is such a piece of junk anyway that I won't try | |
3379 | porting it there. The XP port was straightforward, showed a few |
|
3402 | porting it there. The XP port was straightforward, showed a few | |
3380 | bugs here and there (fixed all), in particular some string |
|
3403 | bugs here and there (fixed all), in particular some string | |
3381 | handling stuff which required considering Unicode strings (which |
|
3404 | handling stuff which required considering Unicode strings (which | |
3382 | Windows uses). This is good, but hasn't been too tested :) No |
|
3405 | Windows uses). This is good, but hasn't been too tested :) No | |
3383 | fancy installer yet, I'll put a note in the manual so people at |
|
3406 | fancy installer yet, I'll put a note in the manual so people at | |
3384 | least make manually a shortcut. |
|
3407 | least make manually a shortcut. | |
3385 |
|
3408 | |||
3386 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
3409 | * IPython/iplib.py (Magic.magic_colors): Unified the color options | |
3387 | into a single one, "colors". This now controls both prompt and |
|
3410 | into a single one, "colors". This now controls both prompt and | |
3388 | exception color schemes, and can be changed both at startup |
|
3411 | exception color schemes, and can be changed both at startup | |
3389 | (either via command-line switches or via ipythonrc files) and at |
|
3412 | (either via command-line switches or via ipythonrc files) and at | |
3390 | runtime, with @colors. |
|
3413 | runtime, with @colors. | |
3391 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
3414 | (Magic.magic_run): renamed @prun to @run and removed the old | |
3392 | @run. The two were too similar to warrant keeping both. |
|
3415 | @run. The two were too similar to warrant keeping both. | |
3393 |
|
3416 | |||
3394 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
3417 | 2002-02-03 Fernando Perez <fperez@colorado.edu> | |
3395 |
|
3418 | |||
3396 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
3419 | * IPython/iplib.py (install_first_time): Added comment on how to | |
3397 | configure the color options for first-time users. Put a <return> |
|
3420 | configure the color options for first-time users. Put a <return> | |
3398 | request at the end so that small-terminal users get a chance to |
|
3421 | request at the end so that small-terminal users get a chance to | |
3399 | read the startup info. |
|
3422 | read the startup info. | |
3400 |
|
3423 | |||
3401 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
3424 | 2002-01-23 Fernando Perez <fperez@colorado.edu> | |
3402 |
|
3425 | |||
3403 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
3426 | * IPython/iplib.py (CachedOutput.update): Changed output memory | |
3404 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
3427 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For | |
3405 | input history we still use _i. Did this b/c these variable are |
|
3428 | input history we still use _i. Did this b/c these variable are | |
3406 | very commonly used in interactive work, so the less we need to |
|
3429 | very commonly used in interactive work, so the less we need to | |
3407 | type the better off we are. |
|
3430 | type the better off we are. | |
3408 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
3431 | (Magic.magic_prun): updated @prun to better handle the namespaces | |
3409 | the file will run in, including a fix for __name__ not being set |
|
3432 | the file will run in, including a fix for __name__ not being set | |
3410 | before. |
|
3433 | before. | |
3411 |
|
3434 | |||
3412 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
3435 | 2002-01-20 Fernando Perez <fperez@colorado.edu> | |
3413 |
|
3436 | |||
3414 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
3437 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of | |
3415 | extra garbage for Python 2.2. Need to look more carefully into |
|
3438 | extra garbage for Python 2.2. Need to look more carefully into | |
3416 | this later. |
|
3439 | this later. | |
3417 |
|
3440 | |||
3418 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
3441 | 2002-01-19 Fernando Perez <fperez@colorado.edu> | |
3419 |
|
3442 | |||
3420 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
3443 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to | |
3421 | display SyntaxError exceptions properly formatted when they occur |
|
3444 | display SyntaxError exceptions properly formatted when they occur | |
3422 | (they can be triggered by imported code). |
|
3445 | (they can be triggered by imported code). | |
3423 |
|
3446 | |||
3424 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
3447 | 2002-01-18 Fernando Perez <fperez@colorado.edu> | |
3425 |
|
3448 | |||
3426 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
3449 | * IPython/iplib.py (InteractiveShell.safe_execfile): now | |
3427 | SyntaxError exceptions are reported nicely formatted, instead of |
|
3450 | SyntaxError exceptions are reported nicely formatted, instead of | |
3428 | spitting out only offset information as before. |
|
3451 | spitting out only offset information as before. | |
3429 | (Magic.magic_prun): Added the @prun function for executing |
|
3452 | (Magic.magic_prun): Added the @prun function for executing | |
3430 | programs with command line args inside IPython. |
|
3453 | programs with command line args inside IPython. | |
3431 |
|
3454 | |||
3432 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
3455 | 2002-01-16 Fernando Perez <fperez@colorado.edu> | |
3433 |
|
3456 | |||
3434 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
3457 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist | |
3435 | to *not* include the last item given in a range. This brings their |
|
3458 | to *not* include the last item given in a range. This brings their | |
3436 | behavior in line with Python's slicing: |
|
3459 | behavior in line with Python's slicing: | |
3437 | a[n1:n2] -> a[n1]...a[n2-1] |
|
3460 | a[n1:n2] -> a[n1]...a[n2-1] | |
3438 | It may be a bit less convenient, but I prefer to stick to Python's |
|
3461 | It may be a bit less convenient, but I prefer to stick to Python's | |
3439 | conventions *everywhere*, so users never have to wonder. |
|
3462 | conventions *everywhere*, so users never have to wonder. | |
3440 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
3463 | (Magic.magic_macro): Added @macro function to ease the creation of | |
3441 | macros. |
|
3464 | macros. | |
3442 |
|
3465 | |||
3443 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
3466 | 2002-01-05 Fernando Perez <fperez@colorado.edu> | |
3444 |
|
3467 | |||
3445 | * Released 0.2.4. |
|
3468 | * Released 0.2.4. | |
3446 |
|
3469 | |||
3447 | * IPython/iplib.py (Magic.magic_pdef): |
|
3470 | * IPython/iplib.py (Magic.magic_pdef): | |
3448 | (InteractiveShell.safe_execfile): report magic lines and error |
|
3471 | (InteractiveShell.safe_execfile): report magic lines and error | |
3449 | lines without line numbers so one can easily copy/paste them for |
|
3472 | lines without line numbers so one can easily copy/paste them for | |
3450 | re-execution. |
|
3473 | re-execution. | |
3451 |
|
3474 | |||
3452 | * Updated manual with recent changes. |
|
3475 | * Updated manual with recent changes. | |
3453 |
|
3476 | |||
3454 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
3477 | * IPython/iplib.py (Magic.magic_oinfo): added constructor | |
3455 | docstring printing when class? is called. Very handy for knowing |
|
3478 | docstring printing when class? is called. Very handy for knowing | |
3456 | how to create class instances (as long as __init__ is well |
|
3479 | how to create class instances (as long as __init__ is well | |
3457 | documented, of course :) |
|
3480 | documented, of course :) | |
3458 | (Magic.magic_doc): print both class and constructor docstrings. |
|
3481 | (Magic.magic_doc): print both class and constructor docstrings. | |
3459 | (Magic.magic_pdef): give constructor info if passed a class and |
|
3482 | (Magic.magic_pdef): give constructor info if passed a class and | |
3460 | __call__ info for callable object instances. |
|
3483 | __call__ info for callable object instances. | |
3461 |
|
3484 | |||
3462 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
3485 | 2002-01-04 Fernando Perez <fperez@colorado.edu> | |
3463 |
|
3486 | |||
3464 | * Made deep_reload() off by default. It doesn't always work |
|
3487 | * Made deep_reload() off by default. It doesn't always work | |
3465 | exactly as intended, so it's probably safer to have it off. It's |
|
3488 | exactly as intended, so it's probably safer to have it off. It's | |
3466 | still available as dreload() anyway, so nothing is lost. |
|
3489 | still available as dreload() anyway, so nothing is lost. | |
3467 |
|
3490 | |||
3468 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
3491 | 2002-01-02 Fernando Perez <fperez@colorado.edu> | |
3469 |
|
3492 | |||
3470 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
3493 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, | |
3471 | so I wanted an updated release). |
|
3494 | so I wanted an updated release). | |
3472 |
|
3495 | |||
3473 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
3496 | 2001-12-27 Fernando Perez <fperez@colorado.edu> | |
3474 |
|
3497 | |||
3475 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
3498 | * IPython/iplib.py (InteractiveShell.interact): Added the original | |
3476 | code from 'code.py' for this module in order to change the |
|
3499 | code from 'code.py' for this module in order to change the | |
3477 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
3500 | handling of a KeyboardInterrupt. This was necessary b/c otherwise | |
3478 | the history cache would break when the user hit Ctrl-C, and |
|
3501 | the history cache would break when the user hit Ctrl-C, and | |
3479 | interact() offers no way to add any hooks to it. |
|
3502 | interact() offers no way to add any hooks to it. | |
3480 |
|
3503 | |||
3481 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
3504 | 2001-12-23 Fernando Perez <fperez@colorado.edu> | |
3482 |
|
3505 | |||
3483 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
3506 | * setup.py: added check for 'MANIFEST' before trying to remove | |
3484 | it. Thanks to Sean Reifschneider. |
|
3507 | it. Thanks to Sean Reifschneider. | |
3485 |
|
3508 | |||
3486 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
3509 | 2001-12-22 Fernando Perez <fperez@colorado.edu> | |
3487 |
|
3510 | |||
3488 | * Released 0.2.2. |
|
3511 | * Released 0.2.2. | |
3489 |
|
3512 | |||
3490 | * Finished (reasonably) writing the manual. Later will add the |
|
3513 | * Finished (reasonably) writing the manual. Later will add the | |
3491 | python-standard navigation stylesheets, but for the time being |
|
3514 | python-standard navigation stylesheets, but for the time being | |
3492 | it's fairly complete. Distribution will include html and pdf |
|
3515 | it's fairly complete. Distribution will include html and pdf | |
3493 | versions. |
|
3516 | versions. | |
3494 |
|
3517 | |||
3495 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
3518 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu | |
3496 | (MayaVi author). |
|
3519 | (MayaVi author). | |
3497 |
|
3520 | |||
3498 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
3521 | 2001-12-21 Fernando Perez <fperez@colorado.edu> | |
3499 |
|
3522 | |||
3500 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
3523 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a | |
3501 | good public release, I think (with the manual and the distutils |
|
3524 | good public release, I think (with the manual and the distutils | |
3502 | installer). The manual can use some work, but that can go |
|
3525 | installer). The manual can use some work, but that can go | |
3503 | slowly. Otherwise I think it's quite nice for end users. Next |
|
3526 | slowly. Otherwise I think it's quite nice for end users. Next | |
3504 | summer, rewrite the guts of it... |
|
3527 | summer, rewrite the guts of it... | |
3505 |
|
3528 | |||
3506 | * Changed format of ipythonrc files to use whitespace as the |
|
3529 | * Changed format of ipythonrc files to use whitespace as the | |
3507 | separator instead of an explicit '='. Cleaner. |
|
3530 | separator instead of an explicit '='. Cleaner. | |
3508 |
|
3531 | |||
3509 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
3532 | 2001-12-20 Fernando Perez <fperez@colorado.edu> | |
3510 |
|
3533 | |||
3511 | * Started a manual in LyX. For now it's just a quick merge of the |
|
3534 | * Started a manual in LyX. For now it's just a quick merge of the | |
3512 | various internal docstrings and READMEs. Later it may grow into a |
|
3535 | various internal docstrings and READMEs. Later it may grow into a | |
3513 | nice, full-blown manual. |
|
3536 | nice, full-blown manual. | |
3514 |
|
3537 | |||
3515 | * Set up a distutils based installer. Installation should now be |
|
3538 | * Set up a distutils based installer. Installation should now be | |
3516 | trivially simple for end-users. |
|
3539 | trivially simple for end-users. | |
3517 |
|
3540 | |||
3518 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
3541 | 2001-12-11 Fernando Perez <fperez@colorado.edu> | |
3519 |
|
3542 | |||
3520 | * Released 0.2.0. First public release, announced it at |
|
3543 | * Released 0.2.0. First public release, announced it at | |
3521 | comp.lang.python. From now on, just bugfixes... |
|
3544 | comp.lang.python. From now on, just bugfixes... | |
3522 |
|
3545 | |||
3523 | * Went through all the files, set copyright/license notices and |
|
3546 | * Went through all the files, set copyright/license notices and | |
3524 | cleaned up things. Ready for release. |
|
3547 | cleaned up things. Ready for release. | |
3525 |
|
3548 | |||
3526 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
3549 | 2001-12-10 Fernando Perez <fperez@colorado.edu> | |
3527 |
|
3550 | |||
3528 | * Changed the first-time installer not to use tarfiles. It's more |
|
3551 | * Changed the first-time installer not to use tarfiles. It's more | |
3529 | robust now and less unix-dependent. Also makes it easier for |
|
3552 | robust now and less unix-dependent. Also makes it easier for | |
3530 | people to later upgrade versions. |
|
3553 | people to later upgrade versions. | |
3531 |
|
3554 | |||
3532 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
3555 | * Changed @exit to @abort to reflect the fact that it's pretty | |
3533 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
3556 | brutal (a sys.exit()). The difference between @abort and Ctrl-D | |
3534 | becomes significant only when IPyhton is embedded: in that case, |
|
3557 | becomes significant only when IPyhton is embedded: in that case, | |
3535 | C-D closes IPython only, but @abort kills the enclosing program |
|
3558 | C-D closes IPython only, but @abort kills the enclosing program | |
3536 | too (unless it had called IPython inside a try catching |
|
3559 | too (unless it had called IPython inside a try catching | |
3537 | SystemExit). |
|
3560 | SystemExit). | |
3538 |
|
3561 | |||
3539 | * Created Shell module which exposes the actuall IPython Shell |
|
3562 | * Created Shell module which exposes the actuall IPython Shell | |
3540 | classes, currently the normal and the embeddable one. This at |
|
3563 | classes, currently the normal and the embeddable one. This at | |
3541 | least offers a stable interface we won't need to change when |
|
3564 | least offers a stable interface we won't need to change when | |
3542 | (later) the internals are rewritten. That rewrite will be confined |
|
3565 | (later) the internals are rewritten. That rewrite will be confined | |
3543 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
3566 | to iplib and ipmaker, but the Shell interface should remain as is. | |
3544 |
|
3567 | |||
3545 | * Added embed module which offers an embeddable IPShell object, |
|
3568 | * Added embed module which offers an embeddable IPShell object, | |
3546 | useful to fire up IPython *inside* a running program. Great for |
|
3569 | useful to fire up IPython *inside* a running program. Great for | |
3547 | debugging or dynamical data analysis. |
|
3570 | debugging or dynamical data analysis. | |
3548 |
|
3571 | |||
3549 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
3572 | 2001-12-08 Fernando Perez <fperez@colorado.edu> | |
3550 |
|
3573 | |||
3551 | * Fixed small bug preventing seeing info from methods of defined |
|
3574 | * Fixed small bug preventing seeing info from methods of defined | |
3552 | objects (incorrect namespace in _ofind()). |
|
3575 | objects (incorrect namespace in _ofind()). | |
3553 |
|
3576 | |||
3554 | * Documentation cleanup. Moved the main usage docstrings to a |
|
3577 | * Documentation cleanup. Moved the main usage docstrings to a | |
3555 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
3578 | separate file, usage.py (cleaner to maintain, and hopefully in the | |
3556 | future some perlpod-like way of producing interactive, man and |
|
3579 | future some perlpod-like way of producing interactive, man and | |
3557 | html docs out of it will be found). |
|
3580 | html docs out of it will be found). | |
3558 |
|
3581 | |||
3559 | * Added @profile to see your profile at any time. |
|
3582 | * Added @profile to see your profile at any time. | |
3560 |
|
3583 | |||
3561 | * Added @p as an alias for 'print'. It's especially convenient if |
|
3584 | * Added @p as an alias for 'print'. It's especially convenient if | |
3562 | using automagic ('p x' prints x). |
|
3585 | using automagic ('p x' prints x). | |
3563 |
|
3586 | |||
3564 | * Small cleanups and fixes after a pychecker run. |
|
3587 | * Small cleanups and fixes after a pychecker run. | |
3565 |
|
3588 | |||
3566 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
3589 | * Changed the @cd command to handle @cd - and @cd -<n> for | |
3567 | visiting any directory in _dh. |
|
3590 | visiting any directory in _dh. | |
3568 |
|
3591 | |||
3569 | * Introduced _dh, a history of visited directories. @dhist prints |
|
3592 | * Introduced _dh, a history of visited directories. @dhist prints | |
3570 | it out with numbers. |
|
3593 | it out with numbers. | |
3571 |
|
3594 | |||
3572 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
3595 | 2001-12-07 Fernando Perez <fperez@colorado.edu> | |
3573 |
|
3596 | |||
3574 | * Released 0.1.22 |
|
3597 | * Released 0.1.22 | |
3575 |
|
3598 | |||
3576 | * Made initialization a bit more robust against invalid color |
|
3599 | * Made initialization a bit more robust against invalid color | |
3577 | options in user input (exit, not traceback-crash). |
|
3600 | options in user input (exit, not traceback-crash). | |
3578 |
|
3601 | |||
3579 | * Changed the bug crash reporter to write the report only in the |
|
3602 | * Changed the bug crash reporter to write the report only in the | |
3580 | user's .ipython directory. That way IPython won't litter people's |
|
3603 | user's .ipython directory. That way IPython won't litter people's | |
3581 | hard disks with crash files all over the place. Also print on |
|
3604 | hard disks with crash files all over the place. Also print on | |
3582 | screen the necessary mail command. |
|
3605 | screen the necessary mail command. | |
3583 |
|
3606 | |||
3584 | * With the new ultraTB, implemented LightBG color scheme for light |
|
3607 | * With the new ultraTB, implemented LightBG color scheme for light | |
3585 | background terminals. A lot of people like white backgrounds, so I |
|
3608 | background terminals. A lot of people like white backgrounds, so I | |
3586 | guess we should at least give them something readable. |
|
3609 | guess we should at least give them something readable. | |
3587 |
|
3610 | |||
3588 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
3611 | 2001-12-06 Fernando Perez <fperez@colorado.edu> | |
3589 |
|
3612 | |||
3590 | * Modified the structure of ultraTB. Now there's a proper class |
|
3613 | * Modified the structure of ultraTB. Now there's a proper class | |
3591 | for tables of color schemes which allow adding schemes easily and |
|
3614 | for tables of color schemes which allow adding schemes easily and | |
3592 | switching the active scheme without creating a new instance every |
|
3615 | switching the active scheme without creating a new instance every | |
3593 | time (which was ridiculous). The syntax for creating new schemes |
|
3616 | time (which was ridiculous). The syntax for creating new schemes | |
3594 | is also cleaner. I think ultraTB is finally done, with a clean |
|
3617 | is also cleaner. I think ultraTB is finally done, with a clean | |
3595 | class structure. Names are also much cleaner (now there's proper |
|
3618 | class structure. Names are also much cleaner (now there's proper | |
3596 | color tables, no need for every variable to also have 'color' in |
|
3619 | color tables, no need for every variable to also have 'color' in | |
3597 | its name). |
|
3620 | its name). | |
3598 |
|
3621 | |||
3599 | * Broke down genutils into separate files. Now genutils only |
|
3622 | * Broke down genutils into separate files. Now genutils only | |
3600 | contains utility functions, and classes have been moved to their |
|
3623 | contains utility functions, and classes have been moved to their | |
3601 | own files (they had enough independent functionality to warrant |
|
3624 | own files (they had enough independent functionality to warrant | |
3602 | it): ConfigLoader, OutputTrap, Struct. |
|
3625 | it): ConfigLoader, OutputTrap, Struct. | |
3603 |
|
3626 | |||
3604 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
3627 | 2001-12-05 Fernando Perez <fperez@colorado.edu> | |
3605 |
|
3628 | |||
3606 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
3629 | * IPython turns 21! Released version 0.1.21, as a candidate for | |
3607 | public consumption. If all goes well, release in a few days. |
|
3630 | public consumption. If all goes well, release in a few days. | |
3608 |
|
3631 | |||
3609 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
3632 | * Fixed path bug (files in Extensions/ directory wouldn't be found | |
3610 | unless IPython/ was explicitly in sys.path). |
|
3633 | unless IPython/ was explicitly in sys.path). | |
3611 |
|
3634 | |||
3612 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
3635 | * Extended the FlexCompleter class as MagicCompleter to allow | |
3613 | completion of @-starting lines. |
|
3636 | completion of @-starting lines. | |
3614 |
|
3637 | |||
3615 | * Created __release__.py file as a central repository for release |
|
3638 | * Created __release__.py file as a central repository for release | |
3616 | info that other files can read from. |
|
3639 | info that other files can read from. | |
3617 |
|
3640 | |||
3618 | * Fixed small bug in logging: when logging was turned on in |
|
3641 | * Fixed small bug in logging: when logging was turned on in | |
3619 | mid-session, old lines with special meanings (!@?) were being |
|
3642 | mid-session, old lines with special meanings (!@?) were being | |
3620 | logged without the prepended comment, which is necessary since |
|
3643 | logged without the prepended comment, which is necessary since | |
3621 | they are not truly valid python syntax. This should make session |
|
3644 | they are not truly valid python syntax. This should make session | |
3622 | restores produce less errors. |
|
3645 | restores produce less errors. | |
3623 |
|
3646 | |||
3624 | * The namespace cleanup forced me to make a FlexCompleter class |
|
3647 | * The namespace cleanup forced me to make a FlexCompleter class | |
3625 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
3648 | which is nothing but a ripoff of rlcompleter, but with selectable | |
3626 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
3649 | namespace (rlcompleter only works in __main__.__dict__). I'll try | |
3627 | to submit a note to the authors to see if this change can be |
|
3650 | to submit a note to the authors to see if this change can be | |
3628 | incorporated in future rlcompleter releases (Dec.6: done) |
|
3651 | incorporated in future rlcompleter releases (Dec.6: done) | |
3629 |
|
3652 | |||
3630 | * More fixes to namespace handling. It was a mess! Now all |
|
3653 | * More fixes to namespace handling. It was a mess! Now all | |
3631 | explicit references to __main__.__dict__ are gone (except when |
|
3654 | explicit references to __main__.__dict__ are gone (except when | |
3632 | really needed) and everything is handled through the namespace |
|
3655 | really needed) and everything is handled through the namespace | |
3633 | dicts in the IPython instance. We seem to be getting somewhere |
|
3656 | dicts in the IPython instance. We seem to be getting somewhere | |
3634 | with this, finally... |
|
3657 | with this, finally... | |
3635 |
|
3658 | |||
3636 | * Small documentation updates. |
|
3659 | * Small documentation updates. | |
3637 |
|
3660 | |||
3638 | * Created the Extensions directory under IPython (with an |
|
3661 | * Created the Extensions directory under IPython (with an | |
3639 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
3662 | __init__.py). Put the PhysicalQ stuff there. This directory should | |
3640 | be used for all special-purpose extensions. |
|
3663 | be used for all special-purpose extensions. | |
3641 |
|
3664 | |||
3642 | * File renaming: |
|
3665 | * File renaming: | |
3643 | ipythonlib --> ipmaker |
|
3666 | ipythonlib --> ipmaker | |
3644 | ipplib --> iplib |
|
3667 | ipplib --> iplib | |
3645 | This makes a bit more sense in terms of what these files actually do. |
|
3668 | This makes a bit more sense in terms of what these files actually do. | |
3646 |
|
3669 | |||
3647 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
3670 | * Moved all the classes and functions in ipythonlib to ipplib, so | |
3648 | now ipythonlib only has make_IPython(). This will ease up its |
|
3671 | now ipythonlib only has make_IPython(). This will ease up its | |
3649 | splitting in smaller functional chunks later. |
|
3672 | splitting in smaller functional chunks later. | |
3650 |
|
3673 | |||
3651 | * Cleaned up (done, I think) output of @whos. Better column |
|
3674 | * Cleaned up (done, I think) output of @whos. Better column | |
3652 | formatting, and now shows str(var) for as much as it can, which is |
|
3675 | formatting, and now shows str(var) for as much as it can, which is | |
3653 | typically what one gets with a 'print var'. |
|
3676 | typically what one gets with a 'print var'. | |
3654 |
|
3677 | |||
3655 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
3678 | 2001-12-04 Fernando Perez <fperez@colorado.edu> | |
3656 |
|
3679 | |||
3657 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
3680 | * Fixed namespace problems. Now builtin/IPyhton/user names get | |
3658 | properly reported in their namespace. Internal namespace handling |
|
3681 | properly reported in their namespace. Internal namespace handling | |
3659 | is finally getting decent (not perfect yet, but much better than |
|
3682 | is finally getting decent (not perfect yet, but much better than | |
3660 | the ad-hoc mess we had). |
|
3683 | the ad-hoc mess we had). | |
3661 |
|
3684 | |||
3662 | * Removed -exit option. If people just want to run a python |
|
3685 | * Removed -exit option. If people just want to run a python | |
3663 | script, that's what the normal interpreter is for. Less |
|
3686 | script, that's what the normal interpreter is for. Less | |
3664 | unnecessary options, less chances for bugs. |
|
3687 | unnecessary options, less chances for bugs. | |
3665 |
|
3688 | |||
3666 | * Added a crash handler which generates a complete post-mortem if |
|
3689 | * Added a crash handler which generates a complete post-mortem if | |
3667 | IPython crashes. This will help a lot in tracking bugs down the |
|
3690 | IPython crashes. This will help a lot in tracking bugs down the | |
3668 | road. |
|
3691 | road. | |
3669 |
|
3692 | |||
3670 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
3693 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names | |
3671 | which were boud to functions being reassigned would bypass the |
|
3694 | which were boud to functions being reassigned would bypass the | |
3672 | logger, breaking the sync of _il with the prompt counter. This |
|
3695 | logger, breaking the sync of _il with the prompt counter. This | |
3673 | would then crash IPython later when a new line was logged. |
|
3696 | would then crash IPython later when a new line was logged. | |
3674 |
|
3697 | |||
3675 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
3698 | 2001-12-02 Fernando Perez <fperez@colorado.edu> | |
3676 |
|
3699 | |||
3677 | * Made IPython a package. This means people don't have to clutter |
|
3700 | * Made IPython a package. This means people don't have to clutter | |
3678 | their sys.path with yet another directory. Changed the INSTALL |
|
3701 | their sys.path with yet another directory. Changed the INSTALL | |
3679 | file accordingly. |
|
3702 | file accordingly. | |
3680 |
|
3703 | |||
3681 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
3704 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now | |
3682 | sorts its output (so @who shows it sorted) and @whos formats the |
|
3705 | sorts its output (so @who shows it sorted) and @whos formats the | |
3683 | table according to the width of the first column. Nicer, easier to |
|
3706 | table according to the width of the first column. Nicer, easier to | |
3684 | read. Todo: write a generic table_format() which takes a list of |
|
3707 | read. Todo: write a generic table_format() which takes a list of | |
3685 | lists and prints it nicely formatted, with optional row/column |
|
3708 | lists and prints it nicely formatted, with optional row/column | |
3686 | separators and proper padding and justification. |
|
3709 | separators and proper padding and justification. | |
3687 |
|
3710 | |||
3688 | * Released 0.1.20 |
|
3711 | * Released 0.1.20 | |
3689 |
|
3712 | |||
3690 | * Fixed bug in @log which would reverse the inputcache list (a |
|
3713 | * Fixed bug in @log which would reverse the inputcache list (a | |
3691 | copy operation was missing). |
|
3714 | copy operation was missing). | |
3692 |
|
3715 | |||
3693 | * Code cleanup. @config was changed to use page(). Better, since |
|
3716 | * Code cleanup. @config was changed to use page(). Better, since | |
3694 | its output is always quite long. |
|
3717 | its output is always quite long. | |
3695 |
|
3718 | |||
3696 | * Itpl is back as a dependency. I was having too many problems |
|
3719 | * Itpl is back as a dependency. I was having too many problems | |
3697 | getting the parametric aliases to work reliably, and it's just |
|
3720 | getting the parametric aliases to work reliably, and it's just | |
3698 | easier to code weird string operations with it than playing %()s |
|
3721 | easier to code weird string operations with it than playing %()s | |
3699 | games. It's only ~6k, so I don't think it's too big a deal. |
|
3722 | games. It's only ~6k, so I don't think it's too big a deal. | |
3700 |
|
3723 | |||
3701 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
3724 | * Found (and fixed) a very nasty bug with history. !lines weren't | |
3702 | getting cached, and the out of sync caches would crash |
|
3725 | getting cached, and the out of sync caches would crash | |
3703 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
3726 | IPython. Fixed it by reorganizing the prefilter/handlers/logger | |
3704 | division of labor a bit better. Bug fixed, cleaner structure. |
|
3727 | division of labor a bit better. Bug fixed, cleaner structure. | |
3705 |
|
3728 | |||
3706 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
3729 | 2001-12-01 Fernando Perez <fperez@colorado.edu> | |
3707 |
|
3730 | |||
3708 | * Released 0.1.19 |
|
3731 | * Released 0.1.19 | |
3709 |
|
3732 | |||
3710 | * Added option -n to @hist to prevent line number printing. Much |
|
3733 | * Added option -n to @hist to prevent line number printing. Much | |
3711 | easier to copy/paste code this way. |
|
3734 | easier to copy/paste code this way. | |
3712 |
|
3735 | |||
3713 | * Created global _il to hold the input list. Allows easy |
|
3736 | * Created global _il to hold the input list. Allows easy | |
3714 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
3737 | re-execution of blocks of code by slicing it (inspired by Janko's | |
3715 | comment on 'macros'). |
|
3738 | comment on 'macros'). | |
3716 |
|
3739 | |||
3717 | * Small fixes and doc updates. |
|
3740 | * Small fixes and doc updates. | |
3718 |
|
3741 | |||
3719 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
3742 | * Rewrote @history function (was @h). Renamed it to @hist, @h is | |
3720 | much too fragile with automagic. Handles properly multi-line |
|
3743 | much too fragile with automagic. Handles properly multi-line | |
3721 | statements and takes parameters. |
|
3744 | statements and takes parameters. | |
3722 |
|
3745 | |||
3723 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
3746 | 2001-11-30 Fernando Perez <fperez@colorado.edu> | |
3724 |
|
3747 | |||
3725 | * Version 0.1.18 released. |
|
3748 | * Version 0.1.18 released. | |
3726 |
|
3749 | |||
3727 | * Fixed nasty namespace bug in initial module imports. |
|
3750 | * Fixed nasty namespace bug in initial module imports. | |
3728 |
|
3751 | |||
3729 | * Added copyright/license notes to all code files (except |
|
3752 | * Added copyright/license notes to all code files (except | |
3730 | DPyGetOpt). For the time being, LGPL. That could change. |
|
3753 | DPyGetOpt). For the time being, LGPL. That could change. | |
3731 |
|
3754 | |||
3732 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
3755 | * Rewrote a much nicer README, updated INSTALL, cleaned up | |
3733 | ipythonrc-* samples. |
|
3756 | ipythonrc-* samples. | |
3734 |
|
3757 | |||
3735 | * Overall code/documentation cleanup. Basically ready for |
|
3758 | * Overall code/documentation cleanup. Basically ready for | |
3736 | release. Only remaining thing: licence decision (LGPL?). |
|
3759 | release. Only remaining thing: licence decision (LGPL?). | |
3737 |
|
3760 | |||
3738 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
3761 | * Converted load_config to a class, ConfigLoader. Now recursion | |
3739 | control is better organized. Doesn't include the same file twice. |
|
3762 | control is better organized. Doesn't include the same file twice. | |
3740 |
|
3763 | |||
3741 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
3764 | 2001-11-29 Fernando Perez <fperez@colorado.edu> | |
3742 |
|
3765 | |||
3743 | * Got input history working. Changed output history variables from |
|
3766 | * Got input history working. Changed output history variables from | |
3744 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
3767 | _p to _o so that _i is for input and _o for output. Just cleaner | |
3745 | convention. |
|
3768 | convention. | |
3746 |
|
3769 | |||
3747 | * Implemented parametric aliases. This pretty much allows the |
|
3770 | * Implemented parametric aliases. This pretty much allows the | |
3748 | alias system to offer full-blown shell convenience, I think. |
|
3771 | alias system to offer full-blown shell convenience, I think. | |
3749 |
|
3772 | |||
3750 | * Version 0.1.17 released, 0.1.18 opened. |
|
3773 | * Version 0.1.17 released, 0.1.18 opened. | |
3751 |
|
3774 | |||
3752 | * dot_ipython/ipythonrc (alias): added documentation. |
|
3775 | * dot_ipython/ipythonrc (alias): added documentation. | |
3753 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
3776 | (xcolor): Fixed small bug (xcolors -> xcolor) | |
3754 |
|
3777 | |||
3755 | * Changed the alias system. Now alias is a magic command to define |
|
3778 | * Changed the alias system. Now alias is a magic command to define | |
3756 | aliases just like the shell. Rationale: the builtin magics should |
|
3779 | aliases just like the shell. Rationale: the builtin magics should | |
3757 | be there for things deeply connected to IPython's |
|
3780 | be there for things deeply connected to IPython's | |
3758 | architecture. And this is a much lighter system for what I think |
|
3781 | architecture. And this is a much lighter system for what I think | |
3759 | is the really important feature: allowing users to define quickly |
|
3782 | is the really important feature: allowing users to define quickly | |
3760 | magics that will do shell things for them, so they can customize |
|
3783 | magics that will do shell things for them, so they can customize | |
3761 | IPython easily to match their work habits. If someone is really |
|
3784 | IPython easily to match their work habits. If someone is really | |
3762 | desperate to have another name for a builtin alias, they can |
|
3785 | desperate to have another name for a builtin alias, they can | |
3763 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
3786 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but | |
3764 | works. |
|
3787 | works. | |
3765 |
|
3788 | |||
3766 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
3789 | 2001-11-28 Fernando Perez <fperez@colorado.edu> | |
3767 |
|
3790 | |||
3768 | * Changed @file so that it opens the source file at the proper |
|
3791 | * Changed @file so that it opens the source file at the proper | |
3769 | line. Since it uses less, if your EDITOR environment is |
|
3792 | line. Since it uses less, if your EDITOR environment is | |
3770 | configured, typing v will immediately open your editor of choice |
|
3793 | configured, typing v will immediately open your editor of choice | |
3771 | right at the line where the object is defined. Not as quick as |
|
3794 | right at the line where the object is defined. Not as quick as | |
3772 | having a direct @edit command, but for all intents and purposes it |
|
3795 | having a direct @edit command, but for all intents and purposes it | |
3773 | works. And I don't have to worry about writing @edit to deal with |
|
3796 | works. And I don't have to worry about writing @edit to deal with | |
3774 | all the editors, less does that. |
|
3797 | all the editors, less does that. | |
3775 |
|
3798 | |||
3776 | * Version 0.1.16 released, 0.1.17 opened. |
|
3799 | * Version 0.1.16 released, 0.1.17 opened. | |
3777 |
|
3800 | |||
3778 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
3801 | * Fixed some nasty bugs in the page/page_dumb combo that could | |
3779 | crash IPython. |
|
3802 | crash IPython. | |
3780 |
|
3803 | |||
3781 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
3804 | 2001-11-27 Fernando Perez <fperez@colorado.edu> | |
3782 |
|
3805 | |||
3783 | * Version 0.1.15 released, 0.1.16 opened. |
|
3806 | * Version 0.1.15 released, 0.1.16 opened. | |
3784 |
|
3807 | |||
3785 | * Finally got ? and ?? to work for undefined things: now it's |
|
3808 | * Finally got ? and ?? to work for undefined things: now it's | |
3786 | possible to type {}.get? and get information about the get method |
|
3809 | possible to type {}.get? and get information about the get method | |
3787 | of dicts, or os.path? even if only os is defined (so technically |
|
3810 | of dicts, or os.path? even if only os is defined (so technically | |
3788 | os.path isn't). Works at any level. For example, after import os, |
|
3811 | os.path isn't). Works at any level. For example, after import os, | |
3789 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
3812 | os?, os.path?, os.path.abspath? all work. This is great, took some | |
3790 | work in _ofind. |
|
3813 | work in _ofind. | |
3791 |
|
3814 | |||
3792 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
3815 | * Fixed more bugs with logging. The sanest way to do it was to add | |
3793 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
3816 | to @log a 'mode' parameter. Killed two in one shot (this mode | |
3794 | option was a request of Janko's). I think it's finally clean |
|
3817 | option was a request of Janko's). I think it's finally clean | |
3795 | (famous last words). |
|
3818 | (famous last words). | |
3796 |
|
3819 | |||
3797 | * Added a page_dumb() pager which does a decent job of paging on |
|
3820 | * Added a page_dumb() pager which does a decent job of paging on | |
3798 | screen, if better things (like less) aren't available. One less |
|
3821 | screen, if better things (like less) aren't available. One less | |
3799 | unix dependency (someday maybe somebody will port this to |
|
3822 | unix dependency (someday maybe somebody will port this to | |
3800 | windows). |
|
3823 | windows). | |
3801 |
|
3824 | |||
3802 | * Fixed problem in magic_log: would lock of logging out if log |
|
3825 | * Fixed problem in magic_log: would lock of logging out if log | |
3803 | creation failed (because it would still think it had succeeded). |
|
3826 | creation failed (because it would still think it had succeeded). | |
3804 |
|
3827 | |||
3805 | * Improved the page() function using curses to auto-detect screen |
|
3828 | * Improved the page() function using curses to auto-detect screen | |
3806 | size. Now it can make a much better decision on whether to print |
|
3829 | size. Now it can make a much better decision on whether to print | |
3807 | or page a string. Option screen_length was modified: a value 0 |
|
3830 | or page a string. Option screen_length was modified: a value 0 | |
3808 | means auto-detect, and that's the default now. |
|
3831 | means auto-detect, and that's the default now. | |
3809 |
|
3832 | |||
3810 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
3833 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to | |
3811 | go out. I'll test it for a few days, then talk to Janko about |
|
3834 | go out. I'll test it for a few days, then talk to Janko about | |
3812 | licences and announce it. |
|
3835 | licences and announce it. | |
3813 |
|
3836 | |||
3814 | * Fixed the length of the auto-generated ---> prompt which appears |
|
3837 | * Fixed the length of the auto-generated ---> prompt which appears | |
3815 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
3838 | for auto-parens and auto-quotes. Getting this right isn't trivial, | |
3816 | with all the color escapes, different prompt types and optional |
|
3839 | with all the color escapes, different prompt types and optional | |
3817 | separators. But it seems to be working in all the combinations. |
|
3840 | separators. But it seems to be working in all the combinations. | |
3818 |
|
3841 | |||
3819 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
3842 | 2001-11-26 Fernando Perez <fperez@colorado.edu> | |
3820 |
|
3843 | |||
3821 | * Wrote a regexp filter to get option types from the option names |
|
3844 | * Wrote a regexp filter to get option types from the option names | |
3822 | string. This eliminates the need to manually keep two duplicate |
|
3845 | string. This eliminates the need to manually keep two duplicate | |
3823 | lists. |
|
3846 | lists. | |
3824 |
|
3847 | |||
3825 | * Removed the unneeded check_option_names. Now options are handled |
|
3848 | * Removed the unneeded check_option_names. Now options are handled | |
3826 | in a much saner manner and it's easy to visually check that things |
|
3849 | in a much saner manner and it's easy to visually check that things | |
3827 | are ok. |
|
3850 | are ok. | |
3828 |
|
3851 | |||
3829 | * Updated version numbers on all files I modified to carry a |
|
3852 | * Updated version numbers on all files I modified to carry a | |
3830 | notice so Janko and Nathan have clear version markers. |
|
3853 | notice so Janko and Nathan have clear version markers. | |
3831 |
|
3854 | |||
3832 | * Updated docstring for ultraTB with my changes. I should send |
|
3855 | * Updated docstring for ultraTB with my changes. I should send | |
3833 | this to Nathan. |
|
3856 | this to Nathan. | |
3834 |
|
3857 | |||
3835 | * Lots of small fixes. Ran everything through pychecker again. |
|
3858 | * Lots of small fixes. Ran everything through pychecker again. | |
3836 |
|
3859 | |||
3837 | * Made loading of deep_reload an cmd line option. If it's not too |
|
3860 | * Made loading of deep_reload an cmd line option. If it's not too | |
3838 | kosher, now people can just disable it. With -nodeep_reload it's |
|
3861 | kosher, now people can just disable it. With -nodeep_reload it's | |
3839 | still available as dreload(), it just won't overwrite reload(). |
|
3862 | still available as dreload(), it just won't overwrite reload(). | |
3840 |
|
3863 | |||
3841 | * Moved many options to the no| form (-opt and -noopt |
|
3864 | * Moved many options to the no| form (-opt and -noopt | |
3842 | accepted). Cleaner. |
|
3865 | accepted). Cleaner. | |
3843 |
|
3866 | |||
3844 | * Changed magic_log so that if called with no parameters, it uses |
|
3867 | * Changed magic_log so that if called with no parameters, it uses | |
3845 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
3868 | 'rotate' mode. That way auto-generated logs aren't automatically | |
3846 | over-written. For normal logs, now a backup is made if it exists |
|
3869 | over-written. For normal logs, now a backup is made if it exists | |
3847 | (only 1 level of backups). A new 'backup' mode was added to the |
|
3870 | (only 1 level of backups). A new 'backup' mode was added to the | |
3848 | Logger class to support this. This was a request by Janko. |
|
3871 | Logger class to support this. This was a request by Janko. | |
3849 |
|
3872 | |||
3850 | * Added @logoff/@logon to stop/restart an active log. |
|
3873 | * Added @logoff/@logon to stop/restart an active log. | |
3851 |
|
3874 | |||
3852 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
3875 | * Fixed a lot of bugs in log saving/replay. It was pretty | |
3853 | broken. Now special lines (!@,/) appear properly in the command |
|
3876 | broken. Now special lines (!@,/) appear properly in the command | |
3854 | history after a log replay. |
|
3877 | history after a log replay. | |
3855 |
|
3878 | |||
3856 | * Tried and failed to implement full session saving via pickle. My |
|
3879 | * Tried and failed to implement full session saving via pickle. My | |
3857 | idea was to pickle __main__.__dict__, but modules can't be |
|
3880 | idea was to pickle __main__.__dict__, but modules can't be | |
3858 | pickled. This would be a better alternative to replaying logs, but |
|
3881 | pickled. This would be a better alternative to replaying logs, but | |
3859 | seems quite tricky to get to work. Changed -session to be called |
|
3882 | seems quite tricky to get to work. Changed -session to be called | |
3860 | -logplay, which more accurately reflects what it does. And if we |
|
3883 | -logplay, which more accurately reflects what it does. And if we | |
3861 | ever get real session saving working, -session is now available. |
|
3884 | ever get real session saving working, -session is now available. | |
3862 |
|
3885 | |||
3863 | * Implemented color schemes for prompts also. As for tracebacks, |
|
3886 | * Implemented color schemes for prompts also. As for tracebacks, | |
3864 | currently only NoColor and Linux are supported. But now the |
|
3887 | currently only NoColor and Linux are supported. But now the | |
3865 | infrastructure is in place, based on a generic ColorScheme |
|
3888 | infrastructure is in place, based on a generic ColorScheme | |
3866 | class. So writing and activating new schemes both for the prompts |
|
3889 | class. So writing and activating new schemes both for the prompts | |
3867 | and the tracebacks should be straightforward. |
|
3890 | and the tracebacks should be straightforward. | |
3868 |
|
3891 | |||
3869 | * Version 0.1.13 released, 0.1.14 opened. |
|
3892 | * Version 0.1.13 released, 0.1.14 opened. | |
3870 |
|
3893 | |||
3871 | * Changed handling of options for output cache. Now counter is |
|
3894 | * Changed handling of options for output cache. Now counter is | |
3872 | hardwired starting at 1 and one specifies the maximum number of |
|
3895 | hardwired starting at 1 and one specifies the maximum number of | |
3873 | entries *in the outcache* (not the max prompt counter). This is |
|
3896 | entries *in the outcache* (not the max prompt counter). This is | |
3874 | much better, since many statements won't increase the cache |
|
3897 | much better, since many statements won't increase the cache | |
3875 | count. It also eliminated some confusing options, now there's only |
|
3898 | count. It also eliminated some confusing options, now there's only | |
3876 | one: cache_size. |
|
3899 | one: cache_size. | |
3877 |
|
3900 | |||
3878 | * Added 'alias' magic function and magic_alias option in the |
|
3901 | * Added 'alias' magic function and magic_alias option in the | |
3879 | ipythonrc file. Now the user can easily define whatever names he |
|
3902 | ipythonrc file. Now the user can easily define whatever names he | |
3880 | wants for the magic functions without having to play weird |
|
3903 | wants for the magic functions without having to play weird | |
3881 | namespace games. This gives IPython a real shell-like feel. |
|
3904 | namespace games. This gives IPython a real shell-like feel. | |
3882 |
|
3905 | |||
3883 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
3906 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit | |
3884 | @ or not). |
|
3907 | @ or not). | |
3885 |
|
3908 | |||
3886 | This was one of the last remaining 'visible' bugs (that I know |
|
3909 | This was one of the last remaining 'visible' bugs (that I know | |
3887 | of). I think if I can clean up the session loading so it works |
|
3910 | of). I think if I can clean up the session loading so it works | |
3888 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
3911 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first | |
3889 | about licensing). |
|
3912 | about licensing). | |
3890 |
|
3913 | |||
3891 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
3914 | 2001-11-25 Fernando Perez <fperez@colorado.edu> | |
3892 |
|
3915 | |||
3893 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
3916 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and | |
3894 | there's a cleaner distinction between what ? and ?? show. |
|
3917 | there's a cleaner distinction between what ? and ?? show. | |
3895 |
|
3918 | |||
3896 | * Added screen_length option. Now the user can define his own |
|
3919 | * Added screen_length option. Now the user can define his own | |
3897 | screen size for page() operations. |
|
3920 | screen size for page() operations. | |
3898 |
|
3921 | |||
3899 | * Implemented magic shell-like functions with automatic code |
|
3922 | * Implemented magic shell-like functions with automatic code | |
3900 | generation. Now adding another function is just a matter of adding |
|
3923 | generation. Now adding another function is just a matter of adding | |
3901 | an entry to a dict, and the function is dynamically generated at |
|
3924 | an entry to a dict, and the function is dynamically generated at | |
3902 | run-time. Python has some really cool features! |
|
3925 | run-time. Python has some really cool features! | |
3903 |
|
3926 | |||
3904 | * Renamed many options to cleanup conventions a little. Now all |
|
3927 | * Renamed many options to cleanup conventions a little. Now all | |
3905 | are lowercase, and only underscores where needed. Also in the code |
|
3928 | are lowercase, and only underscores where needed. Also in the code | |
3906 | option name tables are clearer. |
|
3929 | option name tables are clearer. | |
3907 |
|
3930 | |||
3908 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
3931 | * Changed prompts a little. Now input is 'In [n]:' instead of | |
3909 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
3932 | 'In[n]:='. This allows it the numbers to be aligned with the | |
3910 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
3933 | Out[n] numbers, and removes usage of ':=' which doesn't exist in | |
3911 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
3934 | Python (it was a Mathematica thing). The '...' continuation prompt | |
3912 | was also changed a little to align better. |
|
3935 | was also changed a little to align better. | |
3913 |
|
3936 | |||
3914 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
3937 | * Fixed bug when flushing output cache. Not all _p<n> variables | |
3915 | exist, so their deletion needs to be wrapped in a try: |
|
3938 | exist, so their deletion needs to be wrapped in a try: | |
3916 |
|
3939 | |||
3917 | * Figured out how to properly use inspect.formatargspec() (it |
|
3940 | * Figured out how to properly use inspect.formatargspec() (it | |
3918 | requires the args preceded by *). So I removed all the code from |
|
3941 | requires the args preceded by *). So I removed all the code from | |
3919 | _get_pdef in Magic, which was just replicating that. |
|
3942 | _get_pdef in Magic, which was just replicating that. | |
3920 |
|
3943 | |||
3921 | * Added test to prefilter to allow redefining magic function names |
|
3944 | * Added test to prefilter to allow redefining magic function names | |
3922 | as variables. This is ok, since the @ form is always available, |
|
3945 | as variables. This is ok, since the @ form is always available, | |
3923 | but whe should allow the user to define a variable called 'ls' if |
|
3946 | but whe should allow the user to define a variable called 'ls' if | |
3924 | he needs it. |
|
3947 | he needs it. | |
3925 |
|
3948 | |||
3926 | * Moved the ToDo information from README into a separate ToDo. |
|
3949 | * Moved the ToDo information from README into a separate ToDo. | |
3927 |
|
3950 | |||
3928 | * General code cleanup and small bugfixes. I think it's close to a |
|
3951 | * General code cleanup and small bugfixes. I think it's close to a | |
3929 | state where it can be released, obviously with a big 'beta' |
|
3952 | state where it can be released, obviously with a big 'beta' | |
3930 | warning on it. |
|
3953 | warning on it. | |
3931 |
|
3954 | |||
3932 | * Got the magic function split to work. Now all magics are defined |
|
3955 | * Got the magic function split to work. Now all magics are defined | |
3933 | in a separate class. It just organizes things a bit, and now |
|
3956 | in a separate class. It just organizes things a bit, and now | |
3934 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
3957 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it | |
3935 | was too long). |
|
3958 | was too long). | |
3936 |
|
3959 | |||
3937 | * Changed @clear to @reset to avoid potential confusions with |
|
3960 | * Changed @clear to @reset to avoid potential confusions with | |
3938 | the shell command clear. Also renamed @cl to @clear, which does |
|
3961 | the shell command clear. Also renamed @cl to @clear, which does | |
3939 | exactly what people expect it to from their shell experience. |
|
3962 | exactly what people expect it to from their shell experience. | |
3940 |
|
3963 | |||
3941 | Added a check to the @reset command (since it's so |
|
3964 | Added a check to the @reset command (since it's so | |
3942 | destructive, it's probably a good idea to ask for confirmation). |
|
3965 | destructive, it's probably a good idea to ask for confirmation). | |
3943 | But now reset only works for full namespace resetting. Since the |
|
3966 | But now reset only works for full namespace resetting. Since the | |
3944 | del keyword is already there for deleting a few specific |
|
3967 | del keyword is already there for deleting a few specific | |
3945 | variables, I don't see the point of having a redundant magic |
|
3968 | variables, I don't see the point of having a redundant magic | |
3946 | function for the same task. |
|
3969 | function for the same task. | |
3947 |
|
3970 | |||
3948 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
3971 | 2001-11-24 Fernando Perez <fperez@colorado.edu> | |
3949 |
|
3972 | |||
3950 | * Updated the builtin docs (esp. the ? ones). |
|
3973 | * Updated the builtin docs (esp. the ? ones). | |
3951 |
|
3974 | |||
3952 | * Ran all the code through pychecker. Not terribly impressed with |
|
3975 | * Ran all the code through pychecker. Not terribly impressed with | |
3953 | it: lots of spurious warnings and didn't really find anything of |
|
3976 | it: lots of spurious warnings and didn't really find anything of | |
3954 | substance (just a few modules being imported and not used). |
|
3977 | substance (just a few modules being imported and not used). | |
3955 |
|
3978 | |||
3956 | * Implemented the new ultraTB functionality into IPython. New |
|
3979 | * Implemented the new ultraTB functionality into IPython. New | |
3957 | option: xcolors. This chooses color scheme. xmode now only selects |
|
3980 | option: xcolors. This chooses color scheme. xmode now only selects | |
3958 | between Plain and Verbose. Better orthogonality. |
|
3981 | between Plain and Verbose. Better orthogonality. | |
3959 |
|
3982 | |||
3960 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
3983 | * Large rewrite of ultraTB. Much cleaner now, with a separation of | |
3961 | mode and color scheme for the exception handlers. Now it's |
|
3984 | mode and color scheme for the exception handlers. Now it's | |
3962 | possible to have the verbose traceback with no coloring. |
|
3985 | possible to have the verbose traceback with no coloring. | |
3963 |
|
3986 | |||
3964 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
3987 | 2001-11-23 Fernando Perez <fperez@colorado.edu> | |
3965 |
|
3988 | |||
3966 | * Version 0.1.12 released, 0.1.13 opened. |
|
3989 | * Version 0.1.12 released, 0.1.13 opened. | |
3967 |
|
3990 | |||
3968 | * Removed option to set auto-quote and auto-paren escapes by |
|
3991 | * Removed option to set auto-quote and auto-paren escapes by | |
3969 | user. The chances of breaking valid syntax are just too high. If |
|
3992 | user. The chances of breaking valid syntax are just too high. If | |
3970 | someone *really* wants, they can always dig into the code. |
|
3993 | someone *really* wants, they can always dig into the code. | |
3971 |
|
3994 | |||
3972 | * Made prompt separators configurable. |
|
3995 | * Made prompt separators configurable. | |
3973 |
|
3996 | |||
3974 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
3997 | 2001-11-22 Fernando Perez <fperez@colorado.edu> | |
3975 |
|
3998 | |||
3976 | * Small bugfixes in many places. |
|
3999 | * Small bugfixes in many places. | |
3977 |
|
4000 | |||
3978 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
4001 | * Removed the MyCompleter class from ipplib. It seemed redundant | |
3979 | with the C-p,C-n history search functionality. Less code to |
|
4002 | with the C-p,C-n history search functionality. Less code to | |
3980 | maintain. |
|
4003 | maintain. | |
3981 |
|
4004 | |||
3982 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
4005 | * Moved all the original ipython.py code into ipythonlib.py. Right | |
3983 | now it's just one big dump into a function called make_IPython, so |
|
4006 | now it's just one big dump into a function called make_IPython, so | |
3984 | no real modularity has been gained. But at least it makes the |
|
4007 | no real modularity has been gained. But at least it makes the | |
3985 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
4008 | wrapper script tiny, and since ipythonlib is a module, it gets | |
3986 | compiled and startup is much faster. |
|
4009 | compiled and startup is much faster. | |
3987 |
|
4010 | |||
3988 | This is a reasobably 'deep' change, so we should test it for a |
|
4011 | This is a reasobably 'deep' change, so we should test it for a | |
3989 | while without messing too much more with the code. |
|
4012 | while without messing too much more with the code. | |
3990 |
|
4013 | |||
3991 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
4014 | 2001-11-21 Fernando Perez <fperez@colorado.edu> | |
3992 |
|
4015 | |||
3993 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
4016 | * Version 0.1.11 released, 0.1.12 opened for further work. | |
3994 |
|
4017 | |||
3995 | * Removed dependency on Itpl. It was only needed in one place. It |
|
4018 | * Removed dependency on Itpl. It was only needed in one place. It | |
3996 | would be nice if this became part of python, though. It makes life |
|
4019 | would be nice if this became part of python, though. It makes life | |
3997 | *a lot* easier in some cases. |
|
4020 | *a lot* easier in some cases. | |
3998 |
|
4021 | |||
3999 | * Simplified the prefilter code a bit. Now all handlers are |
|
4022 | * Simplified the prefilter code a bit. Now all handlers are | |
4000 | expected to explicitly return a value (at least a blank string). |
|
4023 | expected to explicitly return a value (at least a blank string). | |
4001 |
|
4024 | |||
4002 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
4025 | * Heavy edits in ipplib. Removed the help system altogether. Now | |
4003 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
4026 | obj?/?? is used for inspecting objects, a magic @doc prints | |
4004 | docstrings, and full-blown Python help is accessed via the 'help' |
|
4027 | docstrings, and full-blown Python help is accessed via the 'help' | |
4005 | keyword. This cleans up a lot of code (less to maintain) and does |
|
4028 | keyword. This cleans up a lot of code (less to maintain) and does | |
4006 | the job. Since 'help' is now a standard Python component, might as |
|
4029 | the job. Since 'help' is now a standard Python component, might as | |
4007 | well use it and remove duplicate functionality. |
|
4030 | well use it and remove duplicate functionality. | |
4008 |
|
4031 | |||
4009 | Also removed the option to use ipplib as a standalone program. By |
|
4032 | Also removed the option to use ipplib as a standalone program. By | |
4010 | now it's too dependent on other parts of IPython to function alone. |
|
4033 | now it's too dependent on other parts of IPython to function alone. | |
4011 |
|
4034 | |||
4012 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
4035 | * Fixed bug in genutils.pager. It would crash if the pager was | |
4013 | exited immediately after opening (broken pipe). |
|
4036 | exited immediately after opening (broken pipe). | |
4014 |
|
4037 | |||
4015 | * Trimmed down the VerboseTB reporting a little. The header is |
|
4038 | * Trimmed down the VerboseTB reporting a little. The header is | |
4016 | much shorter now and the repeated exception arguments at the end |
|
4039 | much shorter now and the repeated exception arguments at the end | |
4017 | have been removed. For interactive use the old header seemed a bit |
|
4040 | have been removed. For interactive use the old header seemed a bit | |
4018 | excessive. |
|
4041 | excessive. | |
4019 |
|
4042 | |||
4020 | * Fixed small bug in output of @whos for variables with multi-word |
|
4043 | * Fixed small bug in output of @whos for variables with multi-word | |
4021 | types (only first word was displayed). |
|
4044 | types (only first word was displayed). | |
4022 |
|
4045 | |||
4023 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
4046 | 2001-11-17 Fernando Perez <fperez@colorado.edu> | |
4024 |
|
4047 | |||
4025 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
4048 | * Version 0.1.10 released, 0.1.11 opened for further work. | |
4026 |
|
4049 | |||
4027 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
4050 | * Modified dirs and friends. dirs now *returns* the stack (not | |
4028 | prints), so one can manipulate it as a variable. Convenient to |
|
4051 | prints), so one can manipulate it as a variable. Convenient to | |
4029 | travel along many directories. |
|
4052 | travel along many directories. | |
4030 |
|
4053 | |||
4031 | * Fixed bug in magic_pdef: would only work with functions with |
|
4054 | * Fixed bug in magic_pdef: would only work with functions with | |
4032 | arguments with default values. |
|
4055 | arguments with default values. | |
4033 |
|
4056 | |||
4034 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
4057 | 2001-11-14 Fernando Perez <fperez@colorado.edu> | |
4035 |
|
4058 | |||
4036 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
4059 | * Added the PhysicsInput stuff to dot_ipython so it ships as an | |
4037 | example with IPython. Various other minor fixes and cleanups. |
|
4060 | example with IPython. Various other minor fixes and cleanups. | |
4038 |
|
4061 | |||
4039 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
4062 | * Version 0.1.9 released, 0.1.10 opened for further work. | |
4040 |
|
4063 | |||
4041 | * Added sys.path to the list of directories searched in the |
|
4064 | * Added sys.path to the list of directories searched in the | |
4042 | execfile= option. It used to be the current directory and the |
|
4065 | execfile= option. It used to be the current directory and the | |
4043 | user's IPYTHONDIR only. |
|
4066 | user's IPYTHONDIR only. | |
4044 |
|
4067 | |||
4045 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
4068 | 2001-11-13 Fernando Perez <fperez@colorado.edu> | |
4046 |
|
4069 | |||
4047 | * Reinstated the raw_input/prefilter separation that Janko had |
|
4070 | * Reinstated the raw_input/prefilter separation that Janko had | |
4048 | initially. This gives a more convenient setup for extending the |
|
4071 | initially. This gives a more convenient setup for extending the | |
4049 | pre-processor from the outside: raw_input always gets a string, |
|
4072 | pre-processor from the outside: raw_input always gets a string, | |
4050 | and prefilter has to process it. We can then redefine prefilter |
|
4073 | and prefilter has to process it. We can then redefine prefilter | |
4051 | from the outside and implement extensions for special |
|
4074 | from the outside and implement extensions for special | |
4052 | purposes. |
|
4075 | purposes. | |
4053 |
|
4076 | |||
4054 | Today I got one for inputting PhysicalQuantity objects |
|
4077 | Today I got one for inputting PhysicalQuantity objects | |
4055 | (from Scientific) without needing any function calls at |
|
4078 | (from Scientific) without needing any function calls at | |
4056 | all. Extremely convenient, and it's all done as a user-level |
|
4079 | all. Extremely convenient, and it's all done as a user-level | |
4057 | extension (no IPython code was touched). Now instead of: |
|
4080 | extension (no IPython code was touched). Now instead of: | |
4058 | a = PhysicalQuantity(4.2,'m/s**2') |
|
4081 | a = PhysicalQuantity(4.2,'m/s**2') | |
4059 | one can simply say |
|
4082 | one can simply say | |
4060 | a = 4.2 m/s**2 |
|
4083 | a = 4.2 m/s**2 | |
4061 | or even |
|
4084 | or even | |
4062 | a = 4.2 m/s^2 |
|
4085 | a = 4.2 m/s^2 | |
4063 |
|
4086 | |||
4064 | I use this, but it's also a proof of concept: IPython really is |
|
4087 | I use this, but it's also a proof of concept: IPython really is | |
4065 | fully user-extensible, even at the level of the parsing of the |
|
4088 | fully user-extensible, even at the level of the parsing of the | |
4066 | command line. It's not trivial, but it's perfectly doable. |
|
4089 | command line. It's not trivial, but it's perfectly doable. | |
4067 |
|
4090 | |||
4068 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
4091 | * Added 'add_flip' method to inclusion conflict resolver. Fixes | |
4069 | the problem of modules being loaded in the inverse order in which |
|
4092 | the problem of modules being loaded in the inverse order in which | |
4070 | they were defined in |
|
4093 | they were defined in | |
4071 |
|
4094 | |||
4072 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
4095 | * Version 0.1.8 released, 0.1.9 opened for further work. | |
4073 |
|
4096 | |||
4074 | * Added magics pdef, source and file. They respectively show the |
|
4097 | * Added magics pdef, source and file. They respectively show the | |
4075 | definition line ('prototype' in C), source code and full python |
|
4098 | definition line ('prototype' in C), source code and full python | |
4076 | file for any callable object. The object inspector oinfo uses |
|
4099 | file for any callable object. The object inspector oinfo uses | |
4077 | these to show the same information. |
|
4100 | these to show the same information. | |
4078 |
|
4101 | |||
4079 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
4102 | * Version 0.1.7 released, 0.1.8 opened for further work. | |
4080 |
|
4103 | |||
4081 | * Separated all the magic functions into a class called Magic. The |
|
4104 | * Separated all the magic functions into a class called Magic. The | |
4082 | InteractiveShell class was becoming too big for Xemacs to handle |
|
4105 | InteractiveShell class was becoming too big for Xemacs to handle | |
4083 | (de-indenting a line would lock it up for 10 seconds while it |
|
4106 | (de-indenting a line would lock it up for 10 seconds while it | |
4084 | backtracked on the whole class!) |
|
4107 | backtracked on the whole class!) | |
4085 |
|
4108 | |||
4086 | FIXME: didn't work. It can be done, but right now namespaces are |
|
4109 | FIXME: didn't work. It can be done, but right now namespaces are | |
4087 | all messed up. Do it later (reverted it for now, so at least |
|
4110 | all messed up. Do it later (reverted it for now, so at least | |
4088 | everything works as before). |
|
4111 | everything works as before). | |
4089 |
|
4112 | |||
4090 | * Got the object introspection system (magic_oinfo) working! I |
|
4113 | * Got the object introspection system (magic_oinfo) working! I | |
4091 | think this is pretty much ready for release to Janko, so he can |
|
4114 | think this is pretty much ready for release to Janko, so he can | |
4092 | test it for a while and then announce it. Pretty much 100% of what |
|
4115 | test it for a while and then announce it. Pretty much 100% of what | |
4093 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
4116 | I wanted for the 'phase 1' release is ready. Happy, tired. | |
4094 |
|
4117 | |||
4095 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
4118 | 2001-11-12 Fernando Perez <fperez@colorado.edu> | |
4096 |
|
4119 | |||
4097 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
4120 | * Version 0.1.6 released, 0.1.7 opened for further work. | |
4098 |
|
4121 | |||
4099 | * Fixed bug in printing: it used to test for truth before |
|
4122 | * Fixed bug in printing: it used to test for truth before | |
4100 | printing, so 0 wouldn't print. Now checks for None. |
|
4123 | printing, so 0 wouldn't print. Now checks for None. | |
4101 |
|
4124 | |||
4102 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
4125 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c | |
4103 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
4126 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it | |
4104 | reaches by hand into the outputcache. Think of a better way to do |
|
4127 | reaches by hand into the outputcache. Think of a better way to do | |
4105 | this later. |
|
4128 | this later. | |
4106 |
|
4129 | |||
4107 | * Various small fixes thanks to Nathan's comments. |
|
4130 | * Various small fixes thanks to Nathan's comments. | |
4108 |
|
4131 | |||
4109 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
4132 | * Changed magic_pprint to magic_Pprint. This way it doesn't | |
4110 | collide with pprint() and the name is consistent with the command |
|
4133 | collide with pprint() and the name is consistent with the command | |
4111 | line option. |
|
4134 | line option. | |
4112 |
|
4135 | |||
4113 | * Changed prompt counter behavior to be fully like |
|
4136 | * Changed prompt counter behavior to be fully like | |
4114 | Mathematica's. That is, even input that doesn't return a result |
|
4137 | Mathematica's. That is, even input that doesn't return a result | |
4115 | raises the prompt counter. The old behavior was kind of confusing |
|
4138 | raises the prompt counter. The old behavior was kind of confusing | |
4116 | (getting the same prompt number several times if the operation |
|
4139 | (getting the same prompt number several times if the operation | |
4117 | didn't return a result). |
|
4140 | didn't return a result). | |
4118 |
|
4141 | |||
4119 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
4142 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). | |
4120 |
|
4143 | |||
4121 | * Fixed -Classic mode (wasn't working anymore). |
|
4144 | * Fixed -Classic mode (wasn't working anymore). | |
4122 |
|
4145 | |||
4123 | * Added colored prompts using Nathan's new code. Colors are |
|
4146 | * Added colored prompts using Nathan's new code. Colors are | |
4124 | currently hardwired, they can be user-configurable. For |
|
4147 | currently hardwired, they can be user-configurable. For | |
4125 | developers, they can be chosen in file ipythonlib.py, at the |
|
4148 | developers, they can be chosen in file ipythonlib.py, at the | |
4126 | beginning of the CachedOutput class def. |
|
4149 | beginning of the CachedOutput class def. | |
4127 |
|
4150 | |||
4128 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
4151 | 2001-11-11 Fernando Perez <fperez@colorado.edu> | |
4129 |
|
4152 | |||
4130 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
4153 | * Version 0.1.5 released, 0.1.6 opened for further work. | |
4131 |
|
4154 | |||
4132 | * Changed magic_env to *return* the environment as a dict (not to |
|
4155 | * Changed magic_env to *return* the environment as a dict (not to | |
4133 | print it). This way it prints, but it can also be processed. |
|
4156 | print it). This way it prints, but it can also be processed. | |
4134 |
|
4157 | |||
4135 | * Added Verbose exception reporting to interactive |
|
4158 | * Added Verbose exception reporting to interactive | |
4136 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
4159 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose | |
4137 | traceback. Had to make some changes to the ultraTB file. This is |
|
4160 | traceback. Had to make some changes to the ultraTB file. This is | |
4138 | probably the last 'big' thing in my mental todo list. This ties |
|
4161 | probably the last 'big' thing in my mental todo list. This ties | |
4139 | in with the next entry: |
|
4162 | in with the next entry: | |
4140 |
|
4163 | |||
4141 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
4164 | * Changed -Xi and -Xf to a single -xmode option. Now all the user | |
4142 | has to specify is Plain, Color or Verbose for all exception |
|
4165 | has to specify is Plain, Color or Verbose for all exception | |
4143 | handling. |
|
4166 | handling. | |
4144 |
|
4167 | |||
4145 | * Removed ShellServices option. All this can really be done via |
|
4168 | * Removed ShellServices option. All this can really be done via | |
4146 | the magic system. It's easier to extend, cleaner and has automatic |
|
4169 | the magic system. It's easier to extend, cleaner and has automatic | |
4147 | namespace protection and documentation. |
|
4170 | namespace protection and documentation. | |
4148 |
|
4171 | |||
4149 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
4172 | 2001-11-09 Fernando Perez <fperez@colorado.edu> | |
4150 |
|
4173 | |||
4151 | * Fixed bug in output cache flushing (missing parameter to |
|
4174 | * Fixed bug in output cache flushing (missing parameter to | |
4152 | __init__). Other small bugs fixed (found using pychecker). |
|
4175 | __init__). Other small bugs fixed (found using pychecker). | |
4153 |
|
4176 | |||
4154 | * Version 0.1.4 opened for bugfixing. |
|
4177 | * Version 0.1.4 opened for bugfixing. | |
4155 |
|
4178 | |||
4156 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
4179 | 2001-11-07 Fernando Perez <fperez@colorado.edu> | |
4157 |
|
4180 | |||
4158 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
4181 | * Version 0.1.3 released, mainly because of the raw_input bug. | |
4159 |
|
4182 | |||
4160 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
4183 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed | |
4161 | and when testing for whether things were callable, a call could |
|
4184 | and when testing for whether things were callable, a call could | |
4162 | actually be made to certain functions. They would get called again |
|
4185 | actually be made to certain functions. They would get called again | |
4163 | once 'really' executed, with a resulting double call. A disaster |
|
4186 | once 'really' executed, with a resulting double call. A disaster | |
4164 | in many cases (list.reverse() would never work!). |
|
4187 | in many cases (list.reverse() would never work!). | |
4165 |
|
4188 | |||
4166 | * Removed prefilter() function, moved its code to raw_input (which |
|
4189 | * Removed prefilter() function, moved its code to raw_input (which | |
4167 | after all was just a near-empty caller for prefilter). This saves |
|
4190 | after all was just a near-empty caller for prefilter). This saves | |
4168 | a function call on every prompt, and simplifies the class a tiny bit. |
|
4191 | a function call on every prompt, and simplifies the class a tiny bit. | |
4169 |
|
4192 | |||
4170 | * Fix _ip to __ip name in magic example file. |
|
4193 | * Fix _ip to __ip name in magic example file. | |
4171 |
|
4194 | |||
4172 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
4195 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should | |
4173 | work with non-gnu versions of tar. |
|
4196 | work with non-gnu versions of tar. | |
4174 |
|
4197 | |||
4175 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
4198 | 2001-11-06 Fernando Perez <fperez@colorado.edu> | |
4176 |
|
4199 | |||
4177 | * Version 0.1.2. Just to keep track of the recent changes. |
|
4200 | * Version 0.1.2. Just to keep track of the recent changes. | |
4178 |
|
4201 | |||
4179 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
4202 | * Fixed nasty bug in output prompt routine. It used to check 'if | |
4180 | arg != None...'. Problem is, this fails if arg implements a |
|
4203 | arg != None...'. Problem is, this fails if arg implements a | |
4181 | special comparison (__cmp__) which disallows comparing to |
|
4204 | special comparison (__cmp__) which disallows comparing to | |
4182 | None. Found it when trying to use the PhysicalQuantity module from |
|
4205 | None. Found it when trying to use the PhysicalQuantity module from | |
4183 | ScientificPython. |
|
4206 | ScientificPython. | |
4184 |
|
4207 | |||
4185 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
4208 | 2001-11-05 Fernando Perez <fperez@colorado.edu> | |
4186 |
|
4209 | |||
4187 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
4210 | * Also added dirs. Now the pushd/popd/dirs family functions | |
4188 | basically like the shell, with the added convenience of going home |
|
4211 | basically like the shell, with the added convenience of going home | |
4189 | when called with no args. |
|
4212 | when called with no args. | |
4190 |
|
4213 | |||
4191 | * pushd/popd slightly modified to mimic shell behavior more |
|
4214 | * pushd/popd slightly modified to mimic shell behavior more | |
4192 | closely. |
|
4215 | closely. | |
4193 |
|
4216 | |||
4194 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
4217 | * Added env,pushd,popd from ShellServices as magic functions. I | |
4195 | think the cleanest will be to port all desired functions from |
|
4218 | think the cleanest will be to port all desired functions from | |
4196 | ShellServices as magics and remove ShellServices altogether. This |
|
4219 | ShellServices as magics and remove ShellServices altogether. This | |
4197 | will provide a single, clean way of adding functionality |
|
4220 | will provide a single, clean way of adding functionality | |
4198 | (shell-type or otherwise) to IP. |
|
4221 | (shell-type or otherwise) to IP. | |
4199 |
|
4222 | |||
4200 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
4223 | 2001-11-04 Fernando Perez <fperez@colorado.edu> | |
4201 |
|
4224 | |||
4202 | * Added .ipython/ directory to sys.path. This way users can keep |
|
4225 | * Added .ipython/ directory to sys.path. This way users can keep | |
4203 | customizations there and access them via import. |
|
4226 | customizations there and access them via import. | |
4204 |
|
4227 | |||
4205 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
4228 | 2001-11-03 Fernando Perez <fperez@colorado.edu> | |
4206 |
|
4229 | |||
4207 | * Opened version 0.1.1 for new changes. |
|
4230 | * Opened version 0.1.1 for new changes. | |
4208 |
|
4231 | |||
4209 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
4232 | * Changed version number to 0.1.0: first 'public' release, sent to | |
4210 | Nathan and Janko. |
|
4233 | Nathan and Janko. | |
4211 |
|
4234 | |||
4212 | * Lots of small fixes and tweaks. |
|
4235 | * Lots of small fixes and tweaks. | |
4213 |
|
4236 | |||
4214 | * Minor changes to whos format. Now strings are shown, snipped if |
|
4237 | * Minor changes to whos format. Now strings are shown, snipped if | |
4215 | too long. |
|
4238 | too long. | |
4216 |
|
4239 | |||
4217 | * Changed ShellServices to work on __main__ so they show up in @who |
|
4240 | * Changed ShellServices to work on __main__ so they show up in @who | |
4218 |
|
4241 | |||
4219 | * Help also works with ? at the end of a line: |
|
4242 | * Help also works with ? at the end of a line: | |
4220 | ?sin and sin? |
|
4243 | ?sin and sin? | |
4221 | both produce the same effect. This is nice, as often I use the |
|
4244 | both produce the same effect. This is nice, as often I use the | |
4222 | tab-complete to find the name of a method, but I used to then have |
|
4245 | tab-complete to find the name of a method, but I used to then have | |
4223 | to go to the beginning of the line to put a ? if I wanted more |
|
4246 | to go to the beginning of the line to put a ? if I wanted more | |
4224 | info. Now I can just add the ? and hit return. Convenient. |
|
4247 | info. Now I can just add the ? and hit return. Convenient. | |
4225 |
|
4248 | |||
4226 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
4249 | 2001-11-02 Fernando Perez <fperez@colorado.edu> | |
4227 |
|
4250 | |||
4228 | * Python version check (>=2.1) added. |
|
4251 | * Python version check (>=2.1) added. | |
4229 |
|
4252 | |||
4230 | * Added LazyPython documentation. At this point the docs are quite |
|
4253 | * Added LazyPython documentation. At this point the docs are quite | |
4231 | a mess. A cleanup is in order. |
|
4254 | a mess. A cleanup is in order. | |
4232 |
|
4255 | |||
4233 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
4256 | * Auto-installer created. For some bizarre reason, the zipfiles | |
4234 | module isn't working on my system. So I made a tar version |
|
4257 | module isn't working on my system. So I made a tar version | |
4235 | (hopefully the command line options in various systems won't kill |
|
4258 | (hopefully the command line options in various systems won't kill | |
4236 | me). |
|
4259 | me). | |
4237 |
|
4260 | |||
4238 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
4261 | * Fixes to Struct in genutils. Now all dictionary-like methods are | |
4239 | protected (reasonably). |
|
4262 | protected (reasonably). | |
4240 |
|
4263 | |||
4241 | * Added pager function to genutils and changed ? to print usage |
|
4264 | * Added pager function to genutils and changed ? to print usage | |
4242 | note through it (it was too long). |
|
4265 | note through it (it was too long). | |
4243 |
|
4266 | |||
4244 | * Added the LazyPython functionality. Works great! I changed the |
|
4267 | * Added the LazyPython functionality. Works great! I changed the | |
4245 | auto-quote escape to ';', it's on home row and next to '. But |
|
4268 | auto-quote escape to ';', it's on home row and next to '. But | |
4246 | both auto-quote and auto-paren (still /) escapes are command-line |
|
4269 | both auto-quote and auto-paren (still /) escapes are command-line | |
4247 | parameters. |
|
4270 | parameters. | |
4248 |
|
4271 | |||
4249 |
|
4272 | |||
4250 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
4273 | 2001-11-01 Fernando Perez <fperez@colorado.edu> | |
4251 |
|
4274 | |||
4252 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
4275 | * Version changed to 0.0.7. Fairly large change: configuration now | |
4253 | is all stored in a directory, by default .ipython. There, all |
|
4276 | is all stored in a directory, by default .ipython. There, all | |
4254 | config files have normal looking names (not .names) |
|
4277 | config files have normal looking names (not .names) | |
4255 |
|
4278 | |||
4256 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
4279 | * Version 0.0.6 Released first to Lucas and Archie as a test | |
4257 | run. Since it's the first 'semi-public' release, change version to |
|
4280 | run. Since it's the first 'semi-public' release, change version to | |
4258 | > 0.0.6 for any changes now. |
|
4281 | > 0.0.6 for any changes now. | |
4259 |
|
4282 | |||
4260 | * Stuff I had put in the ipplib.py changelog: |
|
4283 | * Stuff I had put in the ipplib.py changelog: | |
4261 |
|
4284 | |||
4262 | Changes to InteractiveShell: |
|
4285 | Changes to InteractiveShell: | |
4263 |
|
4286 | |||
4264 | - Made the usage message a parameter. |
|
4287 | - Made the usage message a parameter. | |
4265 |
|
4288 | |||
4266 | - Require the name of the shell variable to be given. It's a bit |
|
4289 | - Require the name of the shell variable to be given. It's a bit | |
4267 | of a hack, but allows the name 'shell' not to be hardwire in the |
|
4290 | of a hack, but allows the name 'shell' not to be hardwire in the | |
4268 | magic (@) handler, which is problematic b/c it requires |
|
4291 | magic (@) handler, which is problematic b/c it requires | |
4269 | polluting the global namespace with 'shell'. This in turn is |
|
4292 | polluting the global namespace with 'shell'. This in turn is | |
4270 | fragile: if a user redefines a variable called shell, things |
|
4293 | fragile: if a user redefines a variable called shell, things | |
4271 | break. |
|
4294 | break. | |
4272 |
|
4295 | |||
4273 | - magic @: all functions available through @ need to be defined |
|
4296 | - magic @: all functions available through @ need to be defined | |
4274 | as magic_<name>, even though they can be called simply as |
|
4297 | as magic_<name>, even though they can be called simply as | |
4275 | @<name>. This allows the special command @magic to gather |
|
4298 | @<name>. This allows the special command @magic to gather | |
4276 | information automatically about all existing magic functions, |
|
4299 | information automatically about all existing magic functions, | |
4277 | even if they are run-time user extensions, by parsing the shell |
|
4300 | even if they are run-time user extensions, by parsing the shell | |
4278 | instance __dict__ looking for special magic_ names. |
|
4301 | instance __dict__ looking for special magic_ names. | |
4279 |
|
4302 | |||
4280 | - mainloop: added *two* local namespace parameters. This allows |
|
4303 | - mainloop: added *two* local namespace parameters. This allows | |
4281 | the class to differentiate between parameters which were there |
|
4304 | the class to differentiate between parameters which were there | |
4282 | before and after command line initialization was processed. This |
|
4305 | before and after command line initialization was processed. This | |
4283 | way, later @who can show things loaded at startup by the |
|
4306 | way, later @who can show things loaded at startup by the | |
4284 | user. This trick was necessary to make session saving/reloading |
|
4307 | user. This trick was necessary to make session saving/reloading | |
4285 | really work: ideally after saving/exiting/reloading a session, |
|
4308 | really work: ideally after saving/exiting/reloading a session, | |
4286 | *everythin* should look the same, including the output of @who. I |
|
4309 | *everythin* should look the same, including the output of @who. I | |
4287 | was only able to make this work with this double namespace |
|
4310 | was only able to make this work with this double namespace | |
4288 | trick. |
|
4311 | trick. | |
4289 |
|
4312 | |||
4290 | - added a header to the logfile which allows (almost) full |
|
4313 | - added a header to the logfile which allows (almost) full | |
4291 | session restoring. |
|
4314 | session restoring. | |
4292 |
|
4315 | |||
4293 | - prepend lines beginning with @ or !, with a and log |
|
4316 | - prepend lines beginning with @ or !, with a and log | |
4294 | them. Why? !lines: may be useful to know what you did @lines: |
|
4317 | them. Why? !lines: may be useful to know what you did @lines: | |
4295 | they may affect session state. So when restoring a session, at |
|
4318 | they may affect session state. So when restoring a session, at | |
4296 | least inform the user of their presence. I couldn't quite get |
|
4319 | least inform the user of their presence. I couldn't quite get | |
4297 | them to properly re-execute, but at least the user is warned. |
|
4320 | them to properly re-execute, but at least the user is warned. | |
4298 |
|
4321 | |||
4299 | * Started ChangeLog. |
|
4322 | * Started ChangeLog. |
General Comments 0
You need to be logged in to leave comments.
Login now