Show More
@@ -1,1116 +1,1143 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """IPython Shell classes. |
|
3 | 3 | |
|
4 | 4 | All the matplotlib support code was co-developed with John Hunter, |
|
5 | 5 | matplotlib's author. |
|
6 | 6 | |
|
7 |
$Id: Shell.py 2 |
|
|
7 | $Id: Shell.py 2577 2007-08-02 23:50:02Z fperez $""" | |
|
8 | 8 | |
|
9 | 9 | #***************************************************************************** |
|
10 | 10 | # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu> |
|
11 | 11 | # |
|
12 | 12 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | 13 | # the file COPYING, distributed as part of this software. |
|
14 | 14 | #***************************************************************************** |
|
15 | 15 | |
|
16 | 16 | from IPython import Release |
|
17 | 17 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
18 | 18 | __license__ = Release.license |
|
19 | 19 | |
|
20 | 20 | # Code begins |
|
21 | 21 | # Stdlib imports |
|
22 | 22 | import __builtin__ |
|
23 | 23 | import __main__ |
|
24 | 24 | import Queue |
|
25 | 25 | import inspect |
|
26 | 26 | import os |
|
27 | 27 | import sys |
|
28 | 28 | import thread |
|
29 | 29 | import threading |
|
30 | 30 | import time |
|
31 | 31 | |
|
32 | 32 | from signal import signal, SIGINT |
|
33 | 33 | |
|
34 | 34 | try: |
|
35 | 35 | import ctypes |
|
36 | 36 | HAS_CTYPES = True |
|
37 | 37 | except ImportError: |
|
38 | 38 | HAS_CTYPES = False |
|
39 | 39 | |
|
40 | 40 | # IPython imports |
|
41 | 41 | import IPython |
|
42 | from IPython import ultraTB | |
|
43 | from IPython.genutils import Term,warn,error,flag_calls | |
|
42 | from IPython import ultraTB, ipapi | |
|
43 | from IPython.genutils import Term,warn,error,flag_calls, ask_yes_no | |
|
44 | 44 | from IPython.iplib import InteractiveShell |
|
45 | 45 | from IPython.ipmaker import make_IPython |
|
46 | 46 | from IPython.Magic import Magic |
|
47 | 47 | from IPython.ipstruct import Struct |
|
48 | 48 | |
|
49 | 49 | # Globals |
|
50 | 50 | # global flag to pass around information about Ctrl-C without exceptions |
|
51 | 51 | KBINT = False |
|
52 | 52 | |
|
53 | 53 | # global flag to turn on/off Tk support. |
|
54 | 54 | USE_TK = False |
|
55 | 55 | |
|
56 | 56 | # ID for the main thread, used for cross-thread exceptions |
|
57 | 57 | MAIN_THREAD_ID = thread.get_ident() |
|
58 | 58 | |
|
59 | 59 | # Tag when runcode() is active, for exception handling |
|
60 | 60 | CODE_RUN = None |
|
61 | 61 | |
|
62 | 62 | #----------------------------------------------------------------------------- |
|
63 | 63 | # This class is trivial now, but I want to have it in to publish a clean |
|
64 | 64 | # interface. Later when the internals are reorganized, code that uses this |
|
65 | 65 | # shouldn't have to change. |
|
66 | 66 | |
|
67 | 67 | class IPShell: |
|
68 | 68 | """Create an IPython instance.""" |
|
69 | 69 | |
|
70 | 70 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
71 | 71 | debug=1,shell_class=InteractiveShell): |
|
72 | 72 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
73 | 73 | user_global_ns=user_global_ns, |
|
74 | 74 | debug=debug,shell_class=shell_class) |
|
75 | 75 | |
|
76 | 76 | def mainloop(self,sys_exit=0,banner=None): |
|
77 | 77 | self.IP.mainloop(banner) |
|
78 | 78 | if sys_exit: |
|
79 | 79 | sys.exit() |
|
80 | 80 | |
|
81 | 81 | #----------------------------------------------------------------------------- |
|
82 | def kill_embedded(self,parameter_s=''): | |
|
83 | """%kill_embedded : deactivate for good the current embedded IPython. | |
|
84 | ||
|
85 | This function (after asking for confirmation) sets an internal flag so that | |
|
86 | an embedded IPython will never activate again. This is useful to | |
|
87 | permanently disable a shell that is being called inside a loop: once you've | |
|
88 | figured out what you needed from it, you may then kill it and the program | |
|
89 | will then continue to run without the interactive shell interfering again. | |
|
90 | """ | |
|
91 | ||
|
92 | kill = ask_yes_no("Are you sure you want to kill this embedded instance " | |
|
93 | "(y/n)? [y/N] ",'n') | |
|
94 | if kill: | |
|
95 | self.shell.embedded_active = False | |
|
96 | print "This embedded IPython will not reactivate anymore once you exit." | |
|
97 | ||
|
82 | 98 | class IPShellEmbed: |
|
83 | 99 | """Allow embedding an IPython shell into a running program. |
|
84 | 100 | |
|
85 | 101 | Instances of this class are callable, with the __call__ method being an |
|
86 | 102 | alias to the embed() method of an InteractiveShell instance. |
|
87 | 103 | |
|
88 | 104 | Usage (see also the example-embed.py file for a running example): |
|
89 | 105 | |
|
90 | 106 | ipshell = IPShellEmbed([argv,banner,exit_msg,rc_override]) |
|
91 | 107 | |
|
92 | 108 | - argv: list containing valid command-line options for IPython, as they |
|
93 | 109 | would appear in sys.argv[1:]. |
|
94 | 110 | |
|
95 | 111 | For example, the following command-line options: |
|
96 | 112 | |
|
97 | 113 | $ ipython -prompt_in1 'Input <\\#>' -colors LightBG |
|
98 | 114 | |
|
99 | 115 | would be passed in the argv list as: |
|
100 | 116 | |
|
101 | 117 | ['-prompt_in1','Input <\\#>','-colors','LightBG'] |
|
102 | 118 | |
|
103 | 119 | - banner: string which gets printed every time the interpreter starts. |
|
104 | 120 | |
|
105 | 121 | - exit_msg: string which gets printed every time the interpreter exits. |
|
106 | 122 | |
|
107 | 123 | - rc_override: a dict or Struct of configuration options such as those |
|
108 | 124 | used by IPython. These options are read from your ~/.ipython/ipythonrc |
|
109 | 125 | file when the Shell object is created. Passing an explicit rc_override |
|
110 | 126 | dict with any options you want allows you to override those values at |
|
111 | 127 | creation time without having to modify the file. This way you can create |
|
112 | 128 | embeddable instances configured in any way you want without editing any |
|
113 | 129 | global files (thus keeping your interactive IPython configuration |
|
114 | 130 | unchanged). |
|
115 | 131 | |
|
116 | 132 | Then the ipshell instance can be called anywhere inside your code: |
|
117 | 133 | |
|
118 | 134 | ipshell(header='') -> Opens up an IPython shell. |
|
119 | 135 | |
|
120 | 136 | - header: string printed by the IPython shell upon startup. This can let |
|
121 | 137 | you know where in your code you are when dropping into the shell. Note |
|
122 | 138 | that 'banner' gets prepended to all calls, so header is used for |
|
123 | 139 | location-specific information. |
|
124 | 140 | |
|
125 | 141 | For more details, see the __call__ method below. |
|
126 | 142 | |
|
127 | 143 | When the IPython shell is exited with Ctrl-D, normal program execution |
|
128 | 144 | resumes. |
|
129 | 145 | |
|
130 | 146 | This functionality was inspired by a posting on comp.lang.python by cmkl |
|
131 | 147 | <cmkleffner@gmx.de> on Dec. 06/01 concerning similar uses of pyrepl, and |
|
132 | 148 | by the IDL stop/continue commands.""" |
|
133 | 149 | |
|
134 | 150 | def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None, |
|
135 | 151 | user_ns=None): |
|
136 | 152 | """Note that argv here is a string, NOT a list.""" |
|
137 | 153 | self.set_banner(banner) |
|
138 | 154 | self.set_exit_msg(exit_msg) |
|
139 | 155 | self.set_dummy_mode(0) |
|
140 | 156 | |
|
141 | 157 | # sys.displayhook is a global, we need to save the user's original |
|
142 | 158 | # Don't rely on __displayhook__, as the user may have changed that. |
|
143 | 159 | self.sys_displayhook_ori = sys.displayhook |
|
144 | 160 | |
|
145 | 161 | # save readline completer status |
|
146 | 162 | try: |
|
147 | 163 | #print 'Save completer',sys.ipcompleter # dbg |
|
148 | 164 | self.sys_ipcompleter_ori = sys.ipcompleter |
|
149 | 165 | except: |
|
150 | 166 | pass # not nested with IPython |
|
151 | 167 | |
|
152 | 168 | self.IP = make_IPython(argv,rc_override=rc_override, |
|
153 | 169 | embedded=True, |
|
154 | 170 | user_ns=user_ns) |
|
155 | 171 | |
|
172 | ip = ipapi.IPApi(self.IP) | |
|
173 | ip.expose_magic("kill_embedded",kill_embedded) | |
|
174 | ||
|
156 | 175 | # copy our own displayhook also |
|
157 | 176 | self.sys_displayhook_embed = sys.displayhook |
|
158 | 177 | # and leave the system's display hook clean |
|
159 | 178 | sys.displayhook = self.sys_displayhook_ori |
|
160 | 179 | # don't use the ipython crash handler so that user exceptions aren't |
|
161 | 180 | # trapped |
|
162 | 181 | sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, |
|
163 | 182 | mode = self.IP.rc.xmode, |
|
164 | 183 | call_pdb = self.IP.rc.pdb) |
|
165 | 184 | self.restore_system_completer() |
|
166 | 185 | |
|
167 | 186 | def restore_system_completer(self): |
|
168 | 187 | """Restores the readline completer which was in place. |
|
169 | 188 | |
|
170 | 189 | This allows embedded IPython within IPython not to disrupt the |
|
171 | 190 | parent's completion. |
|
172 | 191 | """ |
|
173 | 192 | |
|
174 | 193 | try: |
|
175 | 194 | self.IP.readline.set_completer(self.sys_ipcompleter_ori) |
|
176 | 195 | sys.ipcompleter = self.sys_ipcompleter_ori |
|
177 | 196 | except: |
|
178 | 197 | pass |
|
179 | 198 | |
|
180 | 199 | def __call__(self,header='',local_ns=None,global_ns=None,dummy=None): |
|
181 | 200 | """Activate the interactive interpreter. |
|
182 | 201 | |
|
183 | 202 | __call__(self,header='',local_ns=None,global_ns,dummy=None) -> Start |
|
184 | 203 | the interpreter shell with the given local and global namespaces, and |
|
185 | 204 | optionally print a header string at startup. |
|
186 | 205 | |
|
187 | 206 | The shell can be globally activated/deactivated using the |
|
188 | 207 | set/get_dummy_mode methods. This allows you to turn off a shell used |
|
189 | 208 | for debugging globally. |
|
190 | 209 | |
|
191 | 210 | However, *each* time you call the shell you can override the current |
|
192 | 211 | state of dummy_mode with the optional keyword parameter 'dummy'. For |
|
193 | 212 | example, if you set dummy mode on with IPShell.set_dummy_mode(1), you |
|
194 | 213 | can still have a specific call work by making it as IPShell(dummy=0). |
|
195 | 214 | |
|
196 | 215 | The optional keyword parameter dummy controls whether the call |
|
197 | 216 | actually does anything. """ |
|
198 | 217 | |
|
218 | # If the user has turned it off, go away | |
|
219 | if not self.IP.embedded_active: | |
|
220 | return | |
|
221 | ||
|
222 | # Normal exits from interactive mode set this flag, so the shell can't | |
|
223 | # re-enter (it checks this variable at the start of interactive mode). | |
|
224 | self.IP.exit_now = False | |
|
225 | ||
|
199 | 226 | # Allow the dummy parameter to override the global __dummy_mode |
|
200 | 227 | if dummy or (dummy != 0 and self.__dummy_mode): |
|
201 | 228 | return |
|
202 | 229 | |
|
203 | 230 | # Set global subsystems (display,completions) to our values |
|
204 | 231 | sys.displayhook = self.sys_displayhook_embed |
|
205 | 232 | if self.IP.has_readline: |
|
206 | 233 | self.IP.set_completer() |
|
207 | 234 | |
|
208 | 235 | if self.banner and header: |
|
209 | 236 | format = '%s\n%s\n' |
|
210 | 237 | else: |
|
211 | 238 | format = '%s%s\n' |
|
212 | 239 | banner = format % (self.banner,header) |
|
213 | 240 | |
|
214 | 241 | # Call the embedding code with a stack depth of 1 so it can skip over |
|
215 | 242 | # our call and get the original caller's namespaces. |
|
216 | 243 | self.IP.embed_mainloop(banner,local_ns,global_ns,stack_depth=1) |
|
217 | 244 | |
|
218 | 245 | if self.exit_msg: |
|
219 | 246 | print self.exit_msg |
|
220 | 247 | |
|
221 | 248 | # Restore global systems (display, completion) |
|
222 | 249 | sys.displayhook = self.sys_displayhook_ori |
|
223 | 250 | self.restore_system_completer() |
|
224 | 251 | |
|
225 | 252 | def set_dummy_mode(self,dummy): |
|
226 | 253 | """Sets the embeddable shell's dummy mode parameter. |
|
227 | 254 | |
|
228 | 255 | set_dummy_mode(dummy): dummy = 0 or 1. |
|
229 | 256 | |
|
230 | 257 | This parameter is persistent and makes calls to the embeddable shell |
|
231 | 258 | silently return without performing any action. This allows you to |
|
232 | 259 | globally activate or deactivate a shell you're using with a single call. |
|
233 | 260 | |
|
234 | 261 | If you need to manually""" |
|
235 | 262 | |
|
236 | 263 | if dummy not in [0,1,False,True]: |
|
237 | 264 | raise ValueError,'dummy parameter must be boolean' |
|
238 | 265 | self.__dummy_mode = dummy |
|
239 | 266 | |
|
240 | 267 | def get_dummy_mode(self): |
|
241 | 268 | """Return the current value of the dummy mode parameter. |
|
242 | 269 | """ |
|
243 | 270 | return self.__dummy_mode |
|
244 | 271 | |
|
245 | 272 | def set_banner(self,banner): |
|
246 | 273 | """Sets the global banner. |
|
247 | 274 | |
|
248 | 275 | This banner gets prepended to every header printed when the shell |
|
249 | 276 | instance is called.""" |
|
250 | 277 | |
|
251 | 278 | self.banner = banner |
|
252 | 279 | |
|
253 | 280 | def set_exit_msg(self,exit_msg): |
|
254 | 281 | """Sets the global exit_msg. |
|
255 | 282 | |
|
256 | 283 | This exit message gets printed upon exiting every time the embedded |
|
257 | 284 | shell is called. It is None by default. """ |
|
258 | 285 | |
|
259 | 286 | self.exit_msg = exit_msg |
|
260 | 287 | |
|
261 | 288 | #----------------------------------------------------------------------------- |
|
262 | 289 | if HAS_CTYPES: |
|
263 | 290 | # Add async exception support. Trick taken from: |
|
264 | 291 | # http://sebulba.wikispaces.com/recipe+thread2 |
|
265 | 292 | def _async_raise(tid, exctype): |
|
266 | 293 | """raises the exception, performs cleanup if needed""" |
|
267 | 294 | if not inspect.isclass(exctype): |
|
268 | 295 | raise TypeError("Only types can be raised (not instances)") |
|
269 | 296 | res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, |
|
270 | 297 | ctypes.py_object(exctype)) |
|
271 | 298 | if res == 0: |
|
272 | 299 | raise ValueError("invalid thread id") |
|
273 | 300 | elif res != 1: |
|
274 | 301 | # """if it returns a number greater than one, you're in trouble, |
|
275 | 302 | # and you should call it again with exc=NULL to revert the effect""" |
|
276 | 303 | ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) |
|
277 | 304 | raise SystemError("PyThreadState_SetAsyncExc failed") |
|
278 | 305 | |
|
279 | 306 | def sigint_handler (signum,stack_frame): |
|
280 | 307 | """Sigint handler for threaded apps. |
|
281 | 308 | |
|
282 | 309 | This is a horrible hack to pass information about SIGINT _without_ |
|
283 | 310 | using exceptions, since I haven't been able to properly manage |
|
284 | 311 | cross-thread exceptions in GTK/WX. In fact, I don't think it can be |
|
285 | 312 | done (or at least that's my understanding from a c.l.py thread where |
|
286 | 313 | this was discussed).""" |
|
287 | 314 | |
|
288 | 315 | global KBINT |
|
289 | 316 | |
|
290 | 317 | if CODE_RUN: |
|
291 | 318 | _async_raise(MAIN_THREAD_ID,KeyboardInterrupt) |
|
292 | 319 | else: |
|
293 | 320 | KBINT = True |
|
294 | 321 | print '\nKeyboardInterrupt - Press <Enter> to continue.', |
|
295 | 322 | Term.cout.flush() |
|
296 | 323 | |
|
297 | 324 | else: |
|
298 | 325 | def sigint_handler (signum,stack_frame): |
|
299 | 326 | """Sigint handler for threaded apps. |
|
300 | 327 | |
|
301 | 328 | This is a horrible hack to pass information about SIGINT _without_ |
|
302 | 329 | using exceptions, since I haven't been able to properly manage |
|
303 | 330 | cross-thread exceptions in GTK/WX. In fact, I don't think it can be |
|
304 | 331 | done (or at least that's my understanding from a c.l.py thread where |
|
305 | 332 | this was discussed).""" |
|
306 | 333 | |
|
307 | 334 | global KBINT |
|
308 | 335 | |
|
309 | 336 | print '\nKeyboardInterrupt - Press <Enter> to continue.', |
|
310 | 337 | Term.cout.flush() |
|
311 | 338 | # Set global flag so that runsource can know that Ctrl-C was hit |
|
312 | 339 | KBINT = True |
|
313 | 340 | |
|
314 | 341 | |
|
315 | 342 | class MTInteractiveShell(InteractiveShell): |
|
316 | 343 | """Simple multi-threaded shell.""" |
|
317 | 344 | |
|
318 | 345 | # Threading strategy taken from: |
|
319 | 346 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by Brian |
|
320 | 347 | # McErlean and John Finlay. Modified with corrections by Antoon Pardon, |
|
321 | 348 | # from the pygtk mailing list, to avoid lockups with system calls. |
|
322 | 349 | |
|
323 | 350 | # class attribute to indicate whether the class supports threads or not. |
|
324 | 351 | # Subclasses with thread support should override this as needed. |
|
325 | 352 | isthreaded = True |
|
326 | 353 | |
|
327 | 354 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
328 | 355 | user_ns=None,user_global_ns=None,banner2='',**kw): |
|
329 | 356 | """Similar to the normal InteractiveShell, but with threading control""" |
|
330 | 357 | |
|
331 | 358 | InteractiveShell.__init__(self,name,usage,rc,user_ns, |
|
332 | 359 | user_global_ns,banner2) |
|
333 | 360 | |
|
334 | 361 | # Locking control variable. We need to use a norma lock, not an RLock |
|
335 | 362 | # here. I'm not exactly sure why, it seems to me like it should be |
|
336 | 363 | # the opposite, but we deadlock with an RLock. Puzzled... |
|
337 | 364 | self.thread_ready = threading.Condition(threading.Lock()) |
|
338 | 365 | |
|
339 | 366 | # A queue to hold the code to be executed. A scalar variable is NOT |
|
340 | 367 | # enough, because uses like macros cause reentrancy. |
|
341 | 368 | self.code_queue = Queue.Queue() |
|
342 | 369 | |
|
343 | 370 | # Stuff to do at closing time |
|
344 | 371 | self._kill = False |
|
345 | 372 | on_kill = kw.get('on_kill') |
|
346 | 373 | if on_kill is None: |
|
347 | 374 | on_kill = [] |
|
348 | 375 | # Check that all things to kill are callable: |
|
349 | 376 | for t in on_kill: |
|
350 | 377 | if not callable(t): |
|
351 | 378 | raise TypeError,'on_kill must be a list of callables' |
|
352 | 379 | self.on_kill = on_kill |
|
353 | 380 | |
|
354 | 381 | def runsource(self, source, filename="<input>", symbol="single"): |
|
355 | 382 | """Compile and run some source in the interpreter. |
|
356 | 383 | |
|
357 | 384 | Modified version of code.py's runsource(), to handle threading issues. |
|
358 | 385 | See the original for full docstring details.""" |
|
359 | 386 | |
|
360 | 387 | global KBINT |
|
361 | 388 | |
|
362 | 389 | # If Ctrl-C was typed, we reset the flag and return right away |
|
363 | 390 | if KBINT: |
|
364 | 391 | KBINT = False |
|
365 | 392 | return False |
|
366 | 393 | |
|
367 | 394 | try: |
|
368 | 395 | code = self.compile(source, filename, symbol) |
|
369 | 396 | except (OverflowError, SyntaxError, ValueError): |
|
370 | 397 | # Case 1 |
|
371 | 398 | self.showsyntaxerror(filename) |
|
372 | 399 | return False |
|
373 | 400 | |
|
374 | 401 | if code is None: |
|
375 | 402 | # Case 2 |
|
376 | 403 | return True |
|
377 | 404 | |
|
378 | 405 | # Case 3 |
|
379 | 406 | # Store code in queue, so the execution thread can handle it. |
|
380 | 407 | |
|
381 | 408 | # Note that with macros and other applications, we MAY re-enter this |
|
382 | 409 | # section, so we have to acquire the lock with non-blocking semantics, |
|
383 | 410 | # else we deadlock. |
|
384 | 411 | got_lock = self.thread_ready.acquire(False) |
|
385 | 412 | self.code_queue.put(code) |
|
386 | 413 | if got_lock: |
|
387 | 414 | self.thread_ready.wait() # Wait until processed in timeout interval |
|
388 | 415 | self.thread_ready.release() |
|
389 | 416 | |
|
390 | 417 | return False |
|
391 | 418 | |
|
392 | 419 | def runcode(self): |
|
393 | 420 | """Execute a code object. |
|
394 | 421 | |
|
395 | 422 | Multithreaded wrapper around IPython's runcode().""" |
|
396 | 423 | |
|
397 | 424 | global CODE_RUN |
|
398 | 425 | |
|
399 | 426 | # Exceptions need to be raised differently depending on which thread is |
|
400 | 427 | # active |
|
401 | 428 | CODE_RUN = True |
|
402 | 429 | |
|
403 | 430 | # lock thread-protected stuff |
|
404 | 431 | got_lock = self.thread_ready.acquire(False) |
|
405 | 432 | |
|
406 | 433 | if self._kill: |
|
407 | 434 | print >>Term.cout, 'Closing threads...', |
|
408 | 435 | Term.cout.flush() |
|
409 | 436 | for tokill in self.on_kill: |
|
410 | 437 | tokill() |
|
411 | 438 | print >>Term.cout, 'Done.' |
|
412 | 439 | |
|
413 | 440 | # Install sigint handler. We do it every time to ensure that if user |
|
414 | 441 | # code modifies it, we restore our own handling. |
|
415 | 442 | try: |
|
416 | 443 | signal(SIGINT,sigint_handler) |
|
417 | 444 | except SystemError: |
|
418 | 445 | # This happens under Windows, which seems to have all sorts |
|
419 | 446 | # of problems with signal handling. Oh well... |
|
420 | 447 | pass |
|
421 | 448 | |
|
422 | 449 | # Flush queue of pending code by calling the run methood of the parent |
|
423 | 450 | # class with all items which may be in the queue. |
|
424 | 451 | while 1: |
|
425 | 452 | try: |
|
426 | 453 | code_to_run = self.code_queue.get_nowait() |
|
427 | 454 | except Queue.Empty: |
|
428 | 455 | break |
|
429 | 456 | if got_lock: |
|
430 | 457 | self.thread_ready.notify() |
|
431 | 458 | InteractiveShell.runcode(self,code_to_run) |
|
432 | 459 | else: |
|
433 | 460 | break |
|
434 | 461 | |
|
435 | 462 | # We're done with thread-protected variables |
|
436 | 463 | if got_lock: |
|
437 | 464 | self.thread_ready.release() |
|
438 | 465 | |
|
439 | 466 | # We're done... |
|
440 | 467 | CODE_RUN = False |
|
441 | 468 | # This MUST return true for gtk threading to work |
|
442 | 469 | return True |
|
443 | 470 | |
|
444 | 471 | def kill(self): |
|
445 | 472 | """Kill the thread, returning when it has been shut down.""" |
|
446 | 473 | got_lock = self.thread_ready.acquire(False) |
|
447 | 474 | self._kill = True |
|
448 | 475 | if got_lock: |
|
449 | 476 | self.thread_ready.release() |
|
450 | 477 | |
|
451 | 478 | class MatplotlibShellBase: |
|
452 | 479 | """Mixin class to provide the necessary modifications to regular IPython |
|
453 | 480 | shell classes for matplotlib support. |
|
454 | 481 | |
|
455 | 482 | Given Python's MRO, this should be used as the FIRST class in the |
|
456 | 483 | inheritance hierarchy, so that it overrides the relevant methods.""" |
|
457 | 484 | |
|
458 | 485 | def _matplotlib_config(self,name,user_ns): |
|
459 | 486 | """Return items needed to setup the user's shell with matplotlib""" |
|
460 | 487 | |
|
461 | 488 | # Initialize matplotlib to interactive mode always |
|
462 | 489 | import matplotlib |
|
463 | 490 | from matplotlib import backends |
|
464 | 491 | matplotlib.interactive(True) |
|
465 | 492 | |
|
466 | 493 | def use(arg): |
|
467 | 494 | """IPython wrapper for matplotlib's backend switcher. |
|
468 | 495 | |
|
469 | 496 | In interactive use, we can not allow switching to a different |
|
470 | 497 | interactive backend, since thread conflicts will most likely crash |
|
471 | 498 | the python interpreter. This routine does a safety check first, |
|
472 | 499 | and refuses to perform a dangerous switch. It still allows |
|
473 | 500 | switching to non-interactive backends.""" |
|
474 | 501 | |
|
475 | 502 | if arg in backends.interactive_bk and arg != self.mpl_backend: |
|
476 | 503 | m=('invalid matplotlib backend switch.\n' |
|
477 | 504 | 'This script attempted to switch to the interactive ' |
|
478 | 505 | 'backend: `%s`\n' |
|
479 | 506 | 'Your current choice of interactive backend is: `%s`\n\n' |
|
480 | 507 | 'Switching interactive matplotlib backends at runtime\n' |
|
481 | 508 | 'would crash the python interpreter, ' |
|
482 | 509 | 'and IPython has blocked it.\n\n' |
|
483 | 510 | 'You need to either change your choice of matplotlib backend\n' |
|
484 | 511 | 'by editing your .matplotlibrc file, or run this script as a \n' |
|
485 | 512 | 'standalone file from the command line, not using IPython.\n' % |
|
486 | 513 | (arg,self.mpl_backend) ) |
|
487 | 514 | raise RuntimeError, m |
|
488 | 515 | else: |
|
489 | 516 | self.mpl_use(arg) |
|
490 | 517 | self.mpl_use._called = True |
|
491 | 518 | |
|
492 | 519 | self.matplotlib = matplotlib |
|
493 | 520 | self.mpl_backend = matplotlib.rcParams['backend'] |
|
494 | 521 | |
|
495 | 522 | # we also need to block switching of interactive backends by use() |
|
496 | 523 | self.mpl_use = matplotlib.use |
|
497 | 524 | self.mpl_use._called = False |
|
498 | 525 | # overwrite the original matplotlib.use with our wrapper |
|
499 | 526 | matplotlib.use = use |
|
500 | 527 | |
|
501 | 528 | # This must be imported last in the matplotlib series, after |
|
502 | 529 | # backend/interactivity choices have been made |
|
503 | 530 | import matplotlib.pylab as pylab |
|
504 | 531 | self.pylab = pylab |
|
505 | 532 | |
|
506 | 533 | self.pylab.show._needmain = False |
|
507 | 534 | # We need to detect at runtime whether show() is called by the user. |
|
508 | 535 | # For this, we wrap it into a decorator which adds a 'called' flag. |
|
509 | 536 | self.pylab.draw_if_interactive = flag_calls(self.pylab.draw_if_interactive) |
|
510 | 537 | |
|
511 | 538 | # Build a user namespace initialized with matplotlib/matlab features. |
|
512 | 539 | user_ns = IPython.ipapi.make_user_ns(user_ns) |
|
513 | 540 | |
|
514 | 541 | exec ("import matplotlib\n" |
|
515 | 542 | "import matplotlib.pylab as pylab\n") in user_ns |
|
516 | 543 | |
|
517 | 544 | # Build matplotlib info banner |
|
518 | 545 | b=""" |
|
519 | 546 | Welcome to pylab, a matplotlib-based Python environment. |
|
520 | 547 | For more information, type 'help(pylab)'. |
|
521 | 548 | """ |
|
522 | 549 | return user_ns,b |
|
523 | 550 | |
|
524 | 551 | def mplot_exec(self,fname,*where,**kw): |
|
525 | 552 | """Execute a matplotlib script. |
|
526 | 553 | |
|
527 | 554 | This is a call to execfile(), but wrapped in safeties to properly |
|
528 | 555 | handle interactive rendering and backend switching.""" |
|
529 | 556 | |
|
530 | 557 | #print '*** Matplotlib runner ***' # dbg |
|
531 | 558 | # turn off rendering until end of script |
|
532 | 559 | isInteractive = self.matplotlib.rcParams['interactive'] |
|
533 | 560 | self.matplotlib.interactive(False) |
|
534 | 561 | self.safe_execfile(fname,*where,**kw) |
|
535 | 562 | self.matplotlib.interactive(isInteractive) |
|
536 | 563 | # make rendering call now, if the user tried to do it |
|
537 | 564 | if self.pylab.draw_if_interactive.called: |
|
538 | 565 | self.pylab.draw() |
|
539 | 566 | self.pylab.draw_if_interactive.called = False |
|
540 | 567 | |
|
541 | 568 | # if a backend switch was performed, reverse it now |
|
542 | 569 | if self.mpl_use._called: |
|
543 | 570 | self.matplotlib.rcParams['backend'] = self.mpl_backend |
|
544 | 571 | |
|
545 | 572 | def magic_run(self,parameter_s=''): |
|
546 | 573 | Magic.magic_run(self,parameter_s,runner=self.mplot_exec) |
|
547 | 574 | |
|
548 | 575 | # Fix the docstring so users see the original as well |
|
549 | 576 | magic_run.__doc__ = "%s\n%s" % (Magic.magic_run.__doc__, |
|
550 | 577 | "\n *** Modified %run for Matplotlib," |
|
551 | 578 | " with proper interactive handling ***") |
|
552 | 579 | |
|
553 | 580 | # Now we provide 2 versions of a matplotlib-aware IPython base shells, single |
|
554 | 581 | # and multithreaded. Note that these are meant for internal use, the IPShell* |
|
555 | 582 | # classes below are the ones meant for public consumption. |
|
556 | 583 | |
|
557 | 584 | class MatplotlibShell(MatplotlibShellBase,InteractiveShell): |
|
558 | 585 | """Single-threaded shell with matplotlib support.""" |
|
559 | 586 | |
|
560 | 587 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
561 | 588 | user_ns=None,user_global_ns=None,**kw): |
|
562 | 589 | user_ns,b2 = self._matplotlib_config(name,user_ns) |
|
563 | 590 | InteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, |
|
564 | 591 | banner2=b2,**kw) |
|
565 | 592 | |
|
566 | 593 | class MatplotlibMTShell(MatplotlibShellBase,MTInteractiveShell): |
|
567 | 594 | """Multi-threaded shell with matplotlib support.""" |
|
568 | 595 | |
|
569 | 596 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
570 | 597 | user_ns=None,user_global_ns=None, **kw): |
|
571 | 598 | user_ns,b2 = self._matplotlib_config(name,user_ns) |
|
572 | 599 | MTInteractiveShell.__init__(self,name,usage,rc,user_ns,user_global_ns, |
|
573 | 600 | banner2=b2,**kw) |
|
574 | 601 | |
|
575 | 602 | #----------------------------------------------------------------------------- |
|
576 | 603 | # Utility functions for the different GUI enabled IPShell* classes. |
|
577 | 604 | |
|
578 | 605 | def get_tk(): |
|
579 | 606 | """Tries to import Tkinter and returns a withdrawn Tkinter root |
|
580 | 607 | window. If Tkinter is already imported or not available, this |
|
581 | 608 | returns None. This function calls `hijack_tk` underneath. |
|
582 | 609 | """ |
|
583 | 610 | if not USE_TK or sys.modules.has_key('Tkinter'): |
|
584 | 611 | return None |
|
585 | 612 | else: |
|
586 | 613 | try: |
|
587 | 614 | import Tkinter |
|
588 | 615 | except ImportError: |
|
589 | 616 | return None |
|
590 | 617 | else: |
|
591 | 618 | hijack_tk() |
|
592 | 619 | r = Tkinter.Tk() |
|
593 | 620 | r.withdraw() |
|
594 | 621 | return r |
|
595 | 622 | |
|
596 | 623 | def hijack_tk(): |
|
597 | 624 | """Modifies Tkinter's mainloop with a dummy so when a module calls |
|
598 | 625 | mainloop, it does not block. |
|
599 | 626 | |
|
600 | 627 | """ |
|
601 | 628 | def misc_mainloop(self, n=0): |
|
602 | 629 | pass |
|
603 | 630 | def tkinter_mainloop(n=0): |
|
604 | 631 | pass |
|
605 | 632 | |
|
606 | 633 | import Tkinter |
|
607 | 634 | Tkinter.Misc.mainloop = misc_mainloop |
|
608 | 635 | Tkinter.mainloop = tkinter_mainloop |
|
609 | 636 | |
|
610 | 637 | def update_tk(tk): |
|
611 | 638 | """Updates the Tkinter event loop. This is typically called from |
|
612 | 639 | the respective WX or GTK mainloops. |
|
613 | 640 | """ |
|
614 | 641 | if tk: |
|
615 | 642 | tk.update() |
|
616 | 643 | |
|
617 | 644 | def hijack_wx(): |
|
618 | 645 | """Modifies wxPython's MainLoop with a dummy so user code does not |
|
619 | 646 | block IPython. The hijacked mainloop function is returned. |
|
620 | 647 | """ |
|
621 | 648 | def dummy_mainloop(*args, **kw): |
|
622 | 649 | pass |
|
623 | 650 | |
|
624 | 651 | try: |
|
625 | 652 | import wx |
|
626 | 653 | except ImportError: |
|
627 | 654 | # For very old versions of WX |
|
628 | 655 | import wxPython as wx |
|
629 | 656 | |
|
630 | 657 | ver = wx.__version__ |
|
631 | 658 | orig_mainloop = None |
|
632 | 659 | if ver[:3] >= '2.5': |
|
633 | 660 | import wx |
|
634 | 661 | if hasattr(wx, '_core_'): core = getattr(wx, '_core_') |
|
635 | 662 | elif hasattr(wx, '_core'): core = getattr(wx, '_core') |
|
636 | 663 | else: raise AttributeError('Could not find wx core module') |
|
637 | 664 | orig_mainloop = core.PyApp_MainLoop |
|
638 | 665 | core.PyApp_MainLoop = dummy_mainloop |
|
639 | 666 | elif ver[:3] == '2.4': |
|
640 | 667 | orig_mainloop = wx.wxc.wxPyApp_MainLoop |
|
641 | 668 | wx.wxc.wxPyApp_MainLoop = dummy_mainloop |
|
642 | 669 | else: |
|
643 | 670 | warn("Unable to find either wxPython version 2.4 or >= 2.5.") |
|
644 | 671 | return orig_mainloop |
|
645 | 672 | |
|
646 | 673 | def hijack_gtk(): |
|
647 | 674 | """Modifies pyGTK's mainloop with a dummy so user code does not |
|
648 | 675 | block IPython. This function returns the original `gtk.mainloop` |
|
649 | 676 | function that has been hijacked. |
|
650 | 677 | """ |
|
651 | 678 | def dummy_mainloop(*args, **kw): |
|
652 | 679 | pass |
|
653 | 680 | import gtk |
|
654 | 681 | if gtk.pygtk_version >= (2,4,0): orig_mainloop = gtk.main |
|
655 | 682 | else: orig_mainloop = gtk.mainloop |
|
656 | 683 | gtk.mainloop = dummy_mainloop |
|
657 | 684 | gtk.main = dummy_mainloop |
|
658 | 685 | return orig_mainloop |
|
659 | 686 | |
|
660 | 687 | #----------------------------------------------------------------------------- |
|
661 | 688 | # The IPShell* classes below are the ones meant to be run by external code as |
|
662 | 689 | # IPython instances. Note that unless a specific threading strategy is |
|
663 | 690 | # desired, the factory function start() below should be used instead (it |
|
664 | 691 | # selects the proper threaded class). |
|
665 | 692 | |
|
666 | 693 | class IPThread(threading.Thread): |
|
667 | 694 | def run(self): |
|
668 | 695 | self.IP.mainloop(self._banner) |
|
669 | 696 | self.IP.kill() |
|
670 | 697 | |
|
671 | 698 | class IPShellGTK(IPThread): |
|
672 | 699 | """Run a gtk mainloop() in a separate thread. |
|
673 | 700 | |
|
674 | 701 | Python commands can be passed to the thread where they will be executed. |
|
675 | 702 | This is implemented by periodically checking for passed code using a |
|
676 | 703 | GTK timeout callback.""" |
|
677 | 704 | |
|
678 | 705 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
679 | 706 | |
|
680 | 707 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
681 | 708 | debug=1,shell_class=MTInteractiveShell): |
|
682 | 709 | |
|
683 | 710 | import gtk |
|
684 | 711 | |
|
685 | 712 | self.gtk = gtk |
|
686 | 713 | self.gtk_mainloop = hijack_gtk() |
|
687 | 714 | |
|
688 | 715 | # Allows us to use both Tk and GTK. |
|
689 | 716 | self.tk = get_tk() |
|
690 | 717 | |
|
691 | 718 | if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit |
|
692 | 719 | else: mainquit = self.gtk.mainquit |
|
693 | 720 | |
|
694 | 721 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
695 | 722 | user_global_ns=user_global_ns, |
|
696 | 723 | debug=debug, |
|
697 | 724 | shell_class=shell_class, |
|
698 | 725 | on_kill=[mainquit]) |
|
699 | 726 | |
|
700 | 727 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
701 | 728 | # method only and .run() needs it. The actual value will be set by |
|
702 | 729 | # .mainloop(). |
|
703 | 730 | self._banner = None |
|
704 | 731 | |
|
705 | 732 | threading.Thread.__init__(self) |
|
706 | 733 | |
|
707 | 734 | def mainloop(self,sys_exit=0,banner=None): |
|
708 | 735 | |
|
709 | 736 | self._banner = banner |
|
710 | 737 | |
|
711 | 738 | if self.gtk.pygtk_version >= (2,4,0): |
|
712 | 739 | import gobject |
|
713 | 740 | gobject.idle_add(self.on_timer) |
|
714 | 741 | else: |
|
715 | 742 | self.gtk.idle_add(self.on_timer) |
|
716 | 743 | |
|
717 | 744 | if sys.platform != 'win32': |
|
718 | 745 | try: |
|
719 | 746 | if self.gtk.gtk_version[0] >= 2: |
|
720 | 747 | self.gtk.gdk.threads_init() |
|
721 | 748 | except AttributeError: |
|
722 | 749 | pass |
|
723 | 750 | except RuntimeError: |
|
724 | 751 | error('Your pyGTK likely has not been compiled with ' |
|
725 | 752 | 'threading support.\n' |
|
726 | 753 | 'The exception printout is below.\n' |
|
727 | 754 | 'You can either rebuild pyGTK with threads, or ' |
|
728 | 755 | 'try using \n' |
|
729 | 756 | 'matplotlib with a different backend (like Tk or WX).\n' |
|
730 | 757 | 'Note that matplotlib will most likely not work in its ' |
|
731 | 758 | 'current state!') |
|
732 | 759 | self.IP.InteractiveTB() |
|
733 | 760 | |
|
734 | 761 | self.start() |
|
735 | 762 | self.gtk.gdk.threads_enter() |
|
736 | 763 | self.gtk_mainloop() |
|
737 | 764 | self.gtk.gdk.threads_leave() |
|
738 | 765 | self.join() |
|
739 | 766 | |
|
740 | 767 | def on_timer(self): |
|
741 | 768 | """Called when GTK is idle. |
|
742 | 769 | |
|
743 | 770 | Must return True always, otherwise GTK stops calling it""" |
|
744 | 771 | |
|
745 | 772 | update_tk(self.tk) |
|
746 | 773 | self.IP.runcode() |
|
747 | 774 | time.sleep(0.01) |
|
748 | 775 | return True |
|
749 | 776 | |
|
750 | 777 | |
|
751 | 778 | class IPShellWX(IPThread): |
|
752 | 779 | """Run a wx mainloop() in a separate thread. |
|
753 | 780 | |
|
754 | 781 | Python commands can be passed to the thread where they will be executed. |
|
755 | 782 | This is implemented by periodically checking for passed code using a |
|
756 | 783 | GTK timeout callback.""" |
|
757 | 784 | |
|
758 | 785 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
759 | 786 | |
|
760 | 787 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
761 | 788 | debug=1,shell_class=MTInteractiveShell): |
|
762 | 789 | |
|
763 | 790 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
764 | 791 | user_global_ns=user_global_ns, |
|
765 | 792 | debug=debug, |
|
766 | 793 | shell_class=shell_class, |
|
767 | 794 | on_kill=[self.wxexit]) |
|
768 | 795 | |
|
769 | 796 | wantedwxversion=self.IP.rc.wxversion |
|
770 | 797 | if wantedwxversion!="0": |
|
771 | 798 | try: |
|
772 | 799 | import wxversion |
|
773 | 800 | except ImportError: |
|
774 | 801 | error('The wxversion module is needed for WX version selection') |
|
775 | 802 | else: |
|
776 | 803 | try: |
|
777 | 804 | wxversion.select(wantedwxversion) |
|
778 | 805 | except: |
|
779 | 806 | self.IP.InteractiveTB() |
|
780 | 807 | error('Requested wxPython version %s could not be loaded' % |
|
781 | 808 | wantedwxversion) |
|
782 | 809 | |
|
783 | 810 | import wx |
|
784 | 811 | |
|
785 | 812 | threading.Thread.__init__(self) |
|
786 | 813 | self.wx = wx |
|
787 | 814 | self.wx_mainloop = hijack_wx() |
|
788 | 815 | |
|
789 | 816 | # Allows us to use both Tk and GTK. |
|
790 | 817 | self.tk = get_tk() |
|
791 | 818 | |
|
792 | 819 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
793 | 820 | # method only and .run() needs it. The actual value will be set by |
|
794 | 821 | # .mainloop(). |
|
795 | 822 | self._banner = None |
|
796 | 823 | |
|
797 | 824 | self.app = None |
|
798 | 825 | |
|
799 | 826 | def wxexit(self, *args): |
|
800 | 827 | if self.app is not None: |
|
801 | 828 | self.app.agent.timer.Stop() |
|
802 | 829 | self.app.ExitMainLoop() |
|
803 | 830 | |
|
804 | 831 | def mainloop(self,sys_exit=0,banner=None): |
|
805 | 832 | |
|
806 | 833 | self._banner = banner |
|
807 | 834 | |
|
808 | 835 | self.start() |
|
809 | 836 | |
|
810 | 837 | class TimerAgent(self.wx.MiniFrame): |
|
811 | 838 | wx = self.wx |
|
812 | 839 | IP = self.IP |
|
813 | 840 | tk = self.tk |
|
814 | 841 | def __init__(self, parent, interval): |
|
815 | 842 | style = self.wx.DEFAULT_FRAME_STYLE | self.wx.TINY_CAPTION_HORIZ |
|
816 | 843 | self.wx.MiniFrame.__init__(self, parent, -1, ' ', pos=(200, 200), |
|
817 | 844 | size=(100, 100),style=style) |
|
818 | 845 | self.Show(False) |
|
819 | 846 | self.interval = interval |
|
820 | 847 | self.timerId = self.wx.NewId() |
|
821 | 848 | |
|
822 | 849 | def StartWork(self): |
|
823 | 850 | self.timer = self.wx.Timer(self, self.timerId) |
|
824 | 851 | self.wx.EVT_TIMER(self, self.timerId, self.OnTimer) |
|
825 | 852 | self.timer.Start(self.interval) |
|
826 | 853 | |
|
827 | 854 | def OnTimer(self, event): |
|
828 | 855 | update_tk(self.tk) |
|
829 | 856 | self.IP.runcode() |
|
830 | 857 | |
|
831 | 858 | class App(self.wx.App): |
|
832 | 859 | wx = self.wx |
|
833 | 860 | TIMEOUT = self.TIMEOUT |
|
834 | 861 | def OnInit(self): |
|
835 | 862 | 'Create the main window and insert the custom frame' |
|
836 | 863 | self.agent = TimerAgent(None, self.TIMEOUT) |
|
837 | 864 | self.agent.Show(False) |
|
838 | 865 | self.agent.StartWork() |
|
839 | 866 | return True |
|
840 | 867 | |
|
841 | 868 | self.app = App(redirect=False) |
|
842 | 869 | self.wx_mainloop(self.app) |
|
843 | 870 | self.join() |
|
844 | 871 | |
|
845 | 872 | |
|
846 | 873 | class IPShellQt(IPThread): |
|
847 | 874 | """Run a Qt event loop in a separate thread. |
|
848 | 875 | |
|
849 | 876 | Python commands can be passed to the thread where they will be executed. |
|
850 | 877 | This is implemented by periodically checking for passed code using a |
|
851 | 878 | Qt timer / slot.""" |
|
852 | 879 | |
|
853 | 880 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
854 | 881 | |
|
855 | 882 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
856 | 883 | debug=0,shell_class=MTInteractiveShell): |
|
857 | 884 | |
|
858 | 885 | import qt |
|
859 | 886 | |
|
860 | 887 | class newQApplication: |
|
861 | 888 | def __init__( self ): |
|
862 | 889 | self.QApplication = qt.QApplication |
|
863 | 890 | |
|
864 | 891 | def __call__( *args, **kwargs ): |
|
865 | 892 | return qt.qApp |
|
866 | 893 | |
|
867 | 894 | def exec_loop( *args, **kwargs ): |
|
868 | 895 | pass |
|
869 | 896 | |
|
870 | 897 | def __getattr__( self, name ): |
|
871 | 898 | return getattr( self.QApplication, name ) |
|
872 | 899 | |
|
873 | 900 | qt.QApplication = newQApplication() |
|
874 | 901 | |
|
875 | 902 | # Allows us to use both Tk and QT. |
|
876 | 903 | self.tk = get_tk() |
|
877 | 904 | |
|
878 | 905 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
879 | 906 | user_global_ns=user_global_ns, |
|
880 | 907 | debug=debug, |
|
881 | 908 | shell_class=shell_class, |
|
882 | 909 | on_kill=[qt.qApp.exit]) |
|
883 | 910 | |
|
884 | 911 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
885 | 912 | # method only and .run() needs it. The actual value will be set by |
|
886 | 913 | # .mainloop(). |
|
887 | 914 | self._banner = None |
|
888 | 915 | |
|
889 | 916 | threading.Thread.__init__(self) |
|
890 | 917 | |
|
891 | 918 | def mainloop(self,sys_exit=0,banner=None): |
|
892 | 919 | |
|
893 | 920 | import qt |
|
894 | 921 | |
|
895 | 922 | self._banner = banner |
|
896 | 923 | |
|
897 | 924 | if qt.QApplication.startingUp(): |
|
898 | 925 | a = qt.QApplication.QApplication(sys.argv) |
|
899 | 926 | self.timer = qt.QTimer() |
|
900 | 927 | qt.QObject.connect( self.timer, qt.SIGNAL( 'timeout()' ), self.on_timer ) |
|
901 | 928 | |
|
902 | 929 | self.start() |
|
903 | 930 | self.timer.start( self.TIMEOUT, True ) |
|
904 | 931 | while True: |
|
905 | 932 | if self.IP._kill: break |
|
906 | 933 | qt.qApp.exec_loop() |
|
907 | 934 | self.join() |
|
908 | 935 | |
|
909 | 936 | def on_timer(self): |
|
910 | 937 | update_tk(self.tk) |
|
911 | 938 | result = self.IP.runcode() |
|
912 | 939 | self.timer.start( self.TIMEOUT, True ) |
|
913 | 940 | return result |
|
914 | 941 | |
|
915 | 942 | |
|
916 | 943 | class IPShellQt4(IPThread): |
|
917 | 944 | """Run a Qt event loop in a separate thread. |
|
918 | 945 | |
|
919 | 946 | Python commands can be passed to the thread where they will be executed. |
|
920 | 947 | This is implemented by periodically checking for passed code using a |
|
921 | 948 | Qt timer / slot.""" |
|
922 | 949 | |
|
923 | 950 | TIMEOUT = 100 # Millisecond interval between timeouts. |
|
924 | 951 | |
|
925 | 952 | def __init__(self,argv=None,user_ns=None,user_global_ns=None, |
|
926 | 953 | debug=0,shell_class=MTInteractiveShell): |
|
927 | 954 | |
|
928 | 955 | from PyQt4 import QtCore, QtGui |
|
929 | 956 | |
|
930 | 957 | class newQApplication: |
|
931 | 958 | def __init__( self ): |
|
932 | 959 | self.QApplication = QtGui.QApplication |
|
933 | 960 | |
|
934 | 961 | def __call__( *args, **kwargs ): |
|
935 | 962 | return QtGui.qApp |
|
936 | 963 | |
|
937 | 964 | def exec_loop( *args, **kwargs ): |
|
938 | 965 | pass |
|
939 | 966 | |
|
940 | 967 | def __getattr__( self, name ): |
|
941 | 968 | return getattr( self.QApplication, name ) |
|
942 | 969 | |
|
943 | 970 | QtGui.QApplication = newQApplication() |
|
944 | 971 | |
|
945 | 972 | # Allows us to use both Tk and QT. |
|
946 | 973 | self.tk = get_tk() |
|
947 | 974 | |
|
948 | 975 | self.IP = make_IPython(argv,user_ns=user_ns, |
|
949 | 976 | user_global_ns=user_global_ns, |
|
950 | 977 | debug=debug, |
|
951 | 978 | shell_class=shell_class, |
|
952 | 979 | on_kill=[QtGui.qApp.exit]) |
|
953 | 980 | |
|
954 | 981 | # HACK: slot for banner in self; it will be passed to the mainloop |
|
955 | 982 | # method only and .run() needs it. The actual value will be set by |
|
956 | 983 | # .mainloop(). |
|
957 | 984 | self._banner = None |
|
958 | 985 | |
|
959 | 986 | threading.Thread.__init__(self) |
|
960 | 987 | |
|
961 | 988 | def mainloop(self,sys_exit=0,banner=None): |
|
962 | 989 | |
|
963 | 990 | from PyQt4 import QtCore, QtGui |
|
964 | 991 | |
|
965 | 992 | self._banner = banner |
|
966 | 993 | |
|
967 | 994 | if QtGui.QApplication.startingUp(): |
|
968 | 995 | a = QtGui.QApplication.QApplication(sys.argv) |
|
969 | 996 | self.timer = QtCore.QTimer() |
|
970 | 997 | QtCore.QObject.connect( self.timer, QtCore.SIGNAL( 'timeout()' ), self.on_timer ) |
|
971 | 998 | |
|
972 | 999 | self.start() |
|
973 | 1000 | self.timer.start( self.TIMEOUT ) |
|
974 | 1001 | while True: |
|
975 | 1002 | if self.IP._kill: break |
|
976 | 1003 | QtGui.qApp.exec_() |
|
977 | 1004 | self.join() |
|
978 | 1005 | |
|
979 | 1006 | def on_timer(self): |
|
980 | 1007 | update_tk(self.tk) |
|
981 | 1008 | result = self.IP.runcode() |
|
982 | 1009 | self.timer.start( self.TIMEOUT ) |
|
983 | 1010 | return result |
|
984 | 1011 | |
|
985 | 1012 | |
|
986 | 1013 | # A set of matplotlib public IPython shell classes, for single-threaded (Tk* |
|
987 | 1014 | # and FLTK*) and multithreaded (GTK*, WX* and Qt*) backends to use. |
|
988 | 1015 | def _load_pylab(user_ns): |
|
989 | 1016 | """Allow users to disable pulling all of pylab into the top-level |
|
990 | 1017 | namespace. |
|
991 | 1018 | |
|
992 | 1019 | This little utility must be called AFTER the actual ipython instance is |
|
993 | 1020 | running, since only then will the options file have been fully parsed.""" |
|
994 | 1021 | |
|
995 | 1022 | ip = IPython.ipapi.get() |
|
996 | 1023 | if ip.options.pylab_import_all: |
|
997 | 1024 | exec "from matplotlib.pylab import *" in user_ns |
|
998 | 1025 | |
|
999 | 1026 | class IPShellMatplotlib(IPShell): |
|
1000 | 1027 | """Subclass IPShell with MatplotlibShell as the internal shell. |
|
1001 | 1028 | |
|
1002 | 1029 | Single-threaded class, meant for the Tk* and FLTK* backends. |
|
1003 | 1030 | |
|
1004 | 1031 | Having this on a separate class simplifies the external driver code.""" |
|
1005 | 1032 | |
|
1006 | 1033 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
1007 | 1034 | IPShell.__init__(self,argv,user_ns,user_global_ns,debug, |
|
1008 | 1035 | shell_class=MatplotlibShell) |
|
1009 | 1036 | _load_pylab(self.IP.user_ns) |
|
1010 | 1037 | |
|
1011 | 1038 | class IPShellMatplotlibGTK(IPShellGTK): |
|
1012 | 1039 | """Subclass IPShellGTK with MatplotlibMTShell as the internal shell. |
|
1013 | 1040 | |
|
1014 | 1041 | Multi-threaded class, meant for the GTK* backends.""" |
|
1015 | 1042 | |
|
1016 | 1043 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
1017 | 1044 | IPShellGTK.__init__(self,argv,user_ns,user_global_ns,debug, |
|
1018 | 1045 | shell_class=MatplotlibMTShell) |
|
1019 | 1046 | _load_pylab(self.IP.user_ns) |
|
1020 | 1047 | |
|
1021 | 1048 | class IPShellMatplotlibWX(IPShellWX): |
|
1022 | 1049 | """Subclass IPShellWX with MatplotlibMTShell as the internal shell. |
|
1023 | 1050 | |
|
1024 | 1051 | Multi-threaded class, meant for the WX* backends.""" |
|
1025 | 1052 | |
|
1026 | 1053 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
1027 | 1054 | IPShellWX.__init__(self,argv,user_ns,user_global_ns,debug, |
|
1028 | 1055 | shell_class=MatplotlibMTShell) |
|
1029 | 1056 | _load_pylab(self.IP.user_ns) |
|
1030 | 1057 | |
|
1031 | 1058 | class IPShellMatplotlibQt(IPShellQt): |
|
1032 | 1059 | """Subclass IPShellQt with MatplotlibMTShell as the internal shell. |
|
1033 | 1060 | |
|
1034 | 1061 | Multi-threaded class, meant for the Qt* backends.""" |
|
1035 | 1062 | |
|
1036 | 1063 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
1037 | 1064 | IPShellQt.__init__(self,argv,user_ns,user_global_ns,debug, |
|
1038 | 1065 | shell_class=MatplotlibMTShell) |
|
1039 | 1066 | _load_pylab(self.IP.user_ns) |
|
1040 | 1067 | |
|
1041 | 1068 | class IPShellMatplotlibQt4(IPShellQt4): |
|
1042 | 1069 | """Subclass IPShellQt4 with MatplotlibMTShell as the internal shell. |
|
1043 | 1070 | |
|
1044 | 1071 | Multi-threaded class, meant for the Qt4* backends.""" |
|
1045 | 1072 | |
|
1046 | 1073 | def __init__(self,argv=None,user_ns=None,user_global_ns=None,debug=1): |
|
1047 | 1074 | IPShellQt4.__init__(self,argv,user_ns,user_global_ns,debug, |
|
1048 | 1075 | shell_class=MatplotlibMTShell) |
|
1049 | 1076 | _load_pylab(self.IP.user_ns) |
|
1050 | 1077 | |
|
1051 | 1078 | #----------------------------------------------------------------------------- |
|
1052 | 1079 | # Factory functions to actually start the proper thread-aware shell |
|
1053 | 1080 | |
|
1054 | 1081 | def _matplotlib_shell_class(): |
|
1055 | 1082 | """Factory function to handle shell class selection for matplotlib. |
|
1056 | 1083 | |
|
1057 | 1084 | The proper shell class to use depends on the matplotlib backend, since |
|
1058 | 1085 | each backend requires a different threading strategy.""" |
|
1059 | 1086 | |
|
1060 | 1087 | try: |
|
1061 | 1088 | import matplotlib |
|
1062 | 1089 | except ImportError: |
|
1063 | 1090 | error('matplotlib could NOT be imported! Starting normal IPython.') |
|
1064 | 1091 | sh_class = IPShell |
|
1065 | 1092 | else: |
|
1066 | 1093 | backend = matplotlib.rcParams['backend'] |
|
1067 | 1094 | if backend.startswith('GTK'): |
|
1068 | 1095 | sh_class = IPShellMatplotlibGTK |
|
1069 | 1096 | elif backend.startswith('WX'): |
|
1070 | 1097 | sh_class = IPShellMatplotlibWX |
|
1071 | 1098 | elif backend.startswith('Qt4'): |
|
1072 | 1099 | sh_class = IPShellMatplotlibQt4 |
|
1073 | 1100 | elif backend.startswith('Qt'): |
|
1074 | 1101 | sh_class = IPShellMatplotlibQt |
|
1075 | 1102 | else: |
|
1076 | 1103 | sh_class = IPShellMatplotlib |
|
1077 | 1104 | #print 'Using %s with the %s backend.' % (sh_class,backend) # dbg |
|
1078 | 1105 | return sh_class |
|
1079 | 1106 | |
|
1080 | 1107 | # This is the one which should be called by external code. |
|
1081 | 1108 | def start(user_ns = None): |
|
1082 | 1109 | """Return a running shell instance, dealing with threading options. |
|
1083 | 1110 | |
|
1084 | 1111 | This is a factory function which will instantiate the proper IPython shell |
|
1085 | 1112 | based on the user's threading choice. Such a selector is needed because |
|
1086 | 1113 | different GUI toolkits require different thread handling details.""" |
|
1087 | 1114 | |
|
1088 | 1115 | global USE_TK |
|
1089 | 1116 | # Crude sys.argv hack to extract the threading options. |
|
1090 | 1117 | argv = sys.argv |
|
1091 | 1118 | if len(argv) > 1: |
|
1092 | 1119 | if len(argv) > 2: |
|
1093 | 1120 | arg2 = argv[2] |
|
1094 | 1121 | if arg2.endswith('-tk'): |
|
1095 | 1122 | USE_TK = True |
|
1096 | 1123 | arg1 = argv[1] |
|
1097 | 1124 | if arg1.endswith('-gthread'): |
|
1098 | 1125 | shell = IPShellGTK |
|
1099 | 1126 | elif arg1.endswith( '-qthread' ): |
|
1100 | 1127 | shell = IPShellQt |
|
1101 | 1128 | elif arg1.endswith( '-q4thread' ): |
|
1102 | 1129 | shell = IPShellQt4 |
|
1103 | 1130 | elif arg1.endswith('-wthread'): |
|
1104 | 1131 | shell = IPShellWX |
|
1105 | 1132 | elif arg1.endswith('-pylab'): |
|
1106 | 1133 | shell = _matplotlib_shell_class() |
|
1107 | 1134 | else: |
|
1108 | 1135 | shell = IPShell |
|
1109 | 1136 | else: |
|
1110 | 1137 | shell = IPShell |
|
1111 | 1138 | return shell(user_ns = user_ns) |
|
1112 | 1139 | |
|
1113 | 1140 | # Some aliases for backwards compatibility |
|
1114 | 1141 | IPythonShell = IPShell |
|
1115 | 1142 | IPythonShellEmbed = IPShellEmbed |
|
1116 | 1143 | #************************ End of file <Shell.py> *************************** |
@@ -1,1850 +1,1850 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | General purpose utilities. |
|
4 | 4 | |
|
5 | 5 | This is a grab-bag of stuff I find useful in most programs I write. Some of |
|
6 | 6 | these things are also convenient when working at the command line. |
|
7 | 7 | |
|
8 |
$Id: genutils.py 25 |
|
|
8 | $Id: genutils.py 2577 2007-08-02 23:50:02Z fperez $""" | |
|
9 | 9 | |
|
10 | 10 | #***************************************************************************** |
|
11 | 11 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
|
12 | 12 | # |
|
13 | 13 | # Distributed under the terms of the BSD License. The full license is in |
|
14 | 14 | # the file COPYING, distributed as part of this software. |
|
15 | 15 | #***************************************************************************** |
|
16 | 16 | |
|
17 | 17 | from IPython import Release |
|
18 | 18 | __author__ = '%s <%s>' % Release.authors['Fernando'] |
|
19 | 19 | __license__ = Release.license |
|
20 | 20 | |
|
21 | 21 | #**************************************************************************** |
|
22 | 22 | # required modules from the Python standard library |
|
23 | 23 | import __main__ |
|
24 | 24 | import commands |
|
25 | 25 | import os |
|
26 | 26 | import re |
|
27 | 27 | import shlex |
|
28 | 28 | import shutil |
|
29 | 29 | import sys |
|
30 | 30 | import tempfile |
|
31 | 31 | import time |
|
32 | 32 | import types |
|
33 | 33 | import warnings |
|
34 | 34 | |
|
35 | 35 | # Other IPython utilities |
|
36 | 36 | import IPython |
|
37 | 37 | from IPython.Itpl import Itpl,itpl,printpl |
|
38 | 38 | from IPython import DPyGetOpt, platutils |
|
39 | 39 | from IPython.generics import result_display |
|
40 | 40 | from path import path |
|
41 | 41 | if os.name == "nt": |
|
42 | 42 | from IPython.winconsole import get_console_size |
|
43 | 43 | |
|
44 | 44 | #**************************************************************************** |
|
45 | 45 | # Exceptions |
|
46 | 46 | class Error(Exception): |
|
47 | 47 | """Base class for exceptions in this module.""" |
|
48 | 48 | pass |
|
49 | 49 | |
|
50 | 50 | #---------------------------------------------------------------------------- |
|
51 | 51 | class IOStream: |
|
52 | 52 | def __init__(self,stream,fallback): |
|
53 | 53 | if not hasattr(stream,'write') or not hasattr(stream,'flush'): |
|
54 | 54 | stream = fallback |
|
55 | 55 | self.stream = stream |
|
56 | 56 | self._swrite = stream.write |
|
57 | 57 | self.flush = stream.flush |
|
58 | 58 | |
|
59 | 59 | def write(self,data): |
|
60 | 60 | try: |
|
61 | 61 | self._swrite(data) |
|
62 | 62 | except: |
|
63 | 63 | try: |
|
64 | 64 | # print handles some unicode issues which may trip a plain |
|
65 | 65 | # write() call. Attempt to emulate write() by using a |
|
66 | 66 | # trailing comma |
|
67 | 67 | print >> self.stream, data, |
|
68 | 68 | except: |
|
69 | 69 | # if we get here, something is seriously broken. |
|
70 | 70 | print >> sys.stderr, \ |
|
71 | 71 | 'ERROR - failed to write data to stream:', self.stream |
|
72 | 72 | |
|
73 | 73 | def close(self): |
|
74 | 74 | pass |
|
75 | 75 | |
|
76 | 76 | |
|
77 | 77 | class IOTerm: |
|
78 | 78 | """ Term holds the file or file-like objects for handling I/O operations. |
|
79 | 79 | |
|
80 | 80 | These are normally just sys.stdin, sys.stdout and sys.stderr but for |
|
81 | 81 | Windows they can can replaced to allow editing the strings before they are |
|
82 | 82 | displayed.""" |
|
83 | 83 | |
|
84 | 84 | # In the future, having IPython channel all its I/O operations through |
|
85 | 85 | # this class will make it easier to embed it into other environments which |
|
86 | 86 | # are not a normal terminal (such as a GUI-based shell) |
|
87 | 87 | def __init__(self,cin=None,cout=None,cerr=None): |
|
88 | 88 | self.cin = IOStream(cin,sys.stdin) |
|
89 | 89 | self.cout = IOStream(cout,sys.stdout) |
|
90 | 90 | self.cerr = IOStream(cerr,sys.stderr) |
|
91 | 91 | |
|
92 | 92 | # Global variable to be used for all I/O |
|
93 | 93 | Term = IOTerm() |
|
94 | 94 | |
|
95 | 95 | import IPython.rlineimpl as readline |
|
96 | 96 | # Remake Term to use the readline i/o facilities |
|
97 | 97 | if sys.platform == 'win32' and readline.have_readline: |
|
98 | 98 | |
|
99 | 99 | Term = IOTerm(cout=readline._outputfile,cerr=readline._outputfile) |
|
100 | 100 | |
|
101 | 101 | |
|
102 | 102 | #**************************************************************************** |
|
103 | 103 | # Generic warning/error printer, used by everything else |
|
104 | 104 | def warn(msg,level=2,exit_val=1): |
|
105 | 105 | """Standard warning printer. Gives formatting consistency. |
|
106 | 106 | |
|
107 | 107 | Output is sent to Term.cerr (sys.stderr by default). |
|
108 | 108 | |
|
109 | 109 | Options: |
|
110 | 110 | |
|
111 | 111 | -level(2): allows finer control: |
|
112 | 112 | 0 -> Do nothing, dummy function. |
|
113 | 113 | 1 -> Print message. |
|
114 | 114 | 2 -> Print 'WARNING:' + message. (Default level). |
|
115 | 115 | 3 -> Print 'ERROR:' + message. |
|
116 | 116 | 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val). |
|
117 | 117 | |
|
118 | 118 | -exit_val (1): exit value returned by sys.exit() for a level 4 |
|
119 | 119 | warning. Ignored for all other levels.""" |
|
120 | 120 | |
|
121 | 121 | if level>0: |
|
122 | 122 | header = ['','','WARNING: ','ERROR: ','FATAL ERROR: '] |
|
123 | 123 | print >> Term.cerr, '%s%s' % (header[level],msg) |
|
124 | 124 | if level == 4: |
|
125 | 125 | print >> Term.cerr,'Exiting.\n' |
|
126 | 126 | sys.exit(exit_val) |
|
127 | 127 | |
|
128 | 128 | def info(msg): |
|
129 | 129 | """Equivalent to warn(msg,level=1).""" |
|
130 | 130 | |
|
131 | 131 | warn(msg,level=1) |
|
132 | 132 | |
|
133 | 133 | def error(msg): |
|
134 | 134 | """Equivalent to warn(msg,level=3).""" |
|
135 | 135 | |
|
136 | 136 | warn(msg,level=3) |
|
137 | 137 | |
|
138 | 138 | def fatal(msg,exit_val=1): |
|
139 | 139 | """Equivalent to warn(msg,exit_val=exit_val,level=4).""" |
|
140 | 140 | |
|
141 | 141 | warn(msg,exit_val=exit_val,level=4) |
|
142 | 142 | |
|
143 | 143 | #--------------------------------------------------------------------------- |
|
144 | 144 | # Debugging routines |
|
145 | 145 | # |
|
146 | 146 | def debugx(expr,pre_msg=''): |
|
147 | 147 | """Print the value of an expression from the caller's frame. |
|
148 | 148 | |
|
149 | 149 | Takes an expression, evaluates it in the caller's frame and prints both |
|
150 | 150 | the given expression and the resulting value (as well as a debug mark |
|
151 | 151 | indicating the name of the calling function. The input must be of a form |
|
152 | 152 | suitable for eval(). |
|
153 | 153 | |
|
154 | 154 | An optional message can be passed, which will be prepended to the printed |
|
155 | 155 | expr->value pair.""" |
|
156 | 156 | |
|
157 | 157 | cf = sys._getframe(1) |
|
158 | 158 | print '[DBG:%s] %s%s -> %r' % (cf.f_code.co_name,pre_msg,expr, |
|
159 | 159 | eval(expr,cf.f_globals,cf.f_locals)) |
|
160 | 160 | |
|
161 | 161 | # deactivate it by uncommenting the following line, which makes it a no-op |
|
162 | 162 | #def debugx(expr,pre_msg=''): pass |
|
163 | 163 | |
|
164 | 164 | #---------------------------------------------------------------------------- |
|
165 | 165 | StringTypes = types.StringTypes |
|
166 | 166 | |
|
167 | 167 | # Basic timing functionality |
|
168 | 168 | |
|
169 | 169 | # If possible (Unix), use the resource module instead of time.clock() |
|
170 | 170 | try: |
|
171 | 171 | import resource |
|
172 | 172 | def clocku(): |
|
173 | 173 | """clocku() -> floating point number |
|
174 | 174 | |
|
175 | 175 | Return the *USER* CPU time in seconds since the start of the process. |
|
176 | 176 | This is done via a call to resource.getrusage, so it avoids the |
|
177 | 177 | wraparound problems in time.clock().""" |
|
178 | 178 | |
|
179 | 179 | return resource.getrusage(resource.RUSAGE_SELF)[0] |
|
180 | 180 | |
|
181 | 181 | def clocks(): |
|
182 | 182 | """clocks() -> floating point number |
|
183 | 183 | |
|
184 | 184 | Return the *SYSTEM* CPU time in seconds since the start of the process. |
|
185 | 185 | This is done via a call to resource.getrusage, so it avoids the |
|
186 | 186 | wraparound problems in time.clock().""" |
|
187 | 187 | |
|
188 | 188 | return resource.getrusage(resource.RUSAGE_SELF)[1] |
|
189 | 189 | |
|
190 | 190 | def clock(): |
|
191 | 191 | """clock() -> floating point number |
|
192 | 192 | |
|
193 | 193 | Return the *TOTAL USER+SYSTEM* CPU time in seconds since the start of |
|
194 | 194 | the process. This is done via a call to resource.getrusage, so it |
|
195 | 195 | avoids the wraparound problems in time.clock().""" |
|
196 | 196 | |
|
197 | 197 | u,s = resource.getrusage(resource.RUSAGE_SELF)[:2] |
|
198 | 198 | return u+s |
|
199 | 199 | |
|
200 | 200 | def clock2(): |
|
201 | 201 | """clock2() -> (t_user,t_system) |
|
202 | 202 | |
|
203 | 203 | Similar to clock(), but return a tuple of user/system times.""" |
|
204 | 204 | return resource.getrusage(resource.RUSAGE_SELF)[:2] |
|
205 | 205 | |
|
206 | 206 | except ImportError: |
|
207 | 207 | # There is no distinction of user/system time under windows, so we just use |
|
208 | 208 | # time.clock() for everything... |
|
209 | 209 | clocku = clocks = clock = time.clock |
|
210 | 210 | def clock2(): |
|
211 | 211 | """Under windows, system CPU time can't be measured. |
|
212 | 212 | |
|
213 | 213 | This just returns clock() and zero.""" |
|
214 | 214 | return time.clock(),0.0 |
|
215 | 215 | |
|
216 | 216 | def timings_out(reps,func,*args,**kw): |
|
217 | 217 | """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output) |
|
218 | 218 | |
|
219 | 219 | Execute a function reps times, return a tuple with the elapsed total |
|
220 | 220 | CPU time in seconds, the time per call and the function's output. |
|
221 | 221 | |
|
222 | 222 | Under Unix, the return value is the sum of user+system time consumed by |
|
223 | 223 | the process, computed via the resource module. This prevents problems |
|
224 | 224 | related to the wraparound effect which the time.clock() function has. |
|
225 | 225 | |
|
226 | 226 | Under Windows the return value is in wall clock seconds. See the |
|
227 | 227 | documentation for the time module for more details.""" |
|
228 | 228 | |
|
229 | 229 | reps = int(reps) |
|
230 | 230 | assert reps >=1, 'reps must be >= 1' |
|
231 | 231 | if reps==1: |
|
232 | 232 | start = clock() |
|
233 | 233 | out = func(*args,**kw) |
|
234 | 234 | tot_time = clock()-start |
|
235 | 235 | else: |
|
236 | 236 | rng = xrange(reps-1) # the last time is executed separately to store output |
|
237 | 237 | start = clock() |
|
238 | 238 | for dummy in rng: func(*args,**kw) |
|
239 | 239 | out = func(*args,**kw) # one last time |
|
240 | 240 | tot_time = clock()-start |
|
241 | 241 | av_time = tot_time / reps |
|
242 | 242 | return tot_time,av_time,out |
|
243 | 243 | |
|
244 | 244 | def timings(reps,func,*args,**kw): |
|
245 | 245 | """timings(reps,func,*args,**kw) -> (t_total,t_per_call) |
|
246 | 246 | |
|
247 | 247 | Execute a function reps times, return a tuple with the elapsed total CPU |
|
248 | 248 | time in seconds and the time per call. These are just the first two values |
|
249 | 249 | in timings_out().""" |
|
250 | 250 | |
|
251 | 251 | return timings_out(reps,func,*args,**kw)[0:2] |
|
252 | 252 | |
|
253 | 253 | def timing(func,*args,**kw): |
|
254 | 254 | """timing(func,*args,**kw) -> t_total |
|
255 | 255 | |
|
256 | 256 | Execute a function once, return the elapsed total CPU time in |
|
257 | 257 | seconds. This is just the first value in timings_out().""" |
|
258 | 258 | |
|
259 | 259 | return timings_out(1,func,*args,**kw)[0] |
|
260 | 260 | |
|
261 | 261 | #**************************************************************************** |
|
262 | 262 | # file and system |
|
263 | 263 | |
|
264 | 264 | def arg_split(s,posix=False): |
|
265 | 265 | """Split a command line's arguments in a shell-like manner. |
|
266 | 266 | |
|
267 | 267 | This is a modified version of the standard library's shlex.split() |
|
268 | 268 | function, but with a default of posix=False for splitting, so that quotes |
|
269 | 269 | in inputs are respected.""" |
|
270 | 270 | |
|
271 | 271 | # XXX - there may be unicode-related problems here!!! I'm not sure that |
|
272 | 272 | # shlex is truly unicode-safe, so it might be necessary to do |
|
273 | 273 | # |
|
274 | 274 | # s = s.encode(sys.stdin.encoding) |
|
275 | 275 | # |
|
276 | 276 | # first, to ensure that shlex gets a normal string. Input from anyone who |
|
277 | 277 | # knows more about unicode and shlex than I would be good to have here... |
|
278 | 278 | lex = shlex.shlex(s, posix=posix) |
|
279 | 279 | lex.whitespace_split = True |
|
280 | 280 | return list(lex) |
|
281 | 281 | |
|
282 | 282 | def system(cmd,verbose=0,debug=0,header=''): |
|
283 | 283 | """Execute a system command, return its exit status. |
|
284 | 284 | |
|
285 | 285 | Options: |
|
286 | 286 | |
|
287 | 287 | - verbose (0): print the command to be executed. |
|
288 | 288 | |
|
289 | 289 | - debug (0): only print, do not actually execute. |
|
290 | 290 | |
|
291 | 291 | - header (''): Header to print on screen prior to the executed command (it |
|
292 | 292 | is only prepended to the command, no newlines are added). |
|
293 | 293 | |
|
294 | 294 | Note: a stateful version of this function is available through the |
|
295 | 295 | SystemExec class.""" |
|
296 | 296 | |
|
297 | 297 | stat = 0 |
|
298 | 298 | if verbose or debug: print header+cmd |
|
299 | 299 | sys.stdout.flush() |
|
300 | 300 | if not debug: stat = os.system(cmd) |
|
301 | 301 | return stat |
|
302 | 302 | |
|
303 | 303 | # This function is used by ipython in a lot of places to make system calls. |
|
304 | 304 | # We need it to be slightly different under win32, due to the vagaries of |
|
305 | 305 | # 'network shares'. A win32 override is below. |
|
306 | 306 | |
|
307 | 307 | def shell(cmd,verbose=0,debug=0,header=''): |
|
308 | 308 | """Execute a command in the system shell, always return None. |
|
309 | 309 | |
|
310 | 310 | Options: |
|
311 | 311 | |
|
312 | 312 | - verbose (0): print the command to be executed. |
|
313 | 313 | |
|
314 | 314 | - debug (0): only print, do not actually execute. |
|
315 | 315 | |
|
316 | 316 | - header (''): Header to print on screen prior to the executed command (it |
|
317 | 317 | is only prepended to the command, no newlines are added). |
|
318 | 318 | |
|
319 | 319 | Note: this is similar to genutils.system(), but it returns None so it can |
|
320 | 320 | be conveniently used in interactive loops without getting the return value |
|
321 | 321 | (typically 0) printed many times.""" |
|
322 | 322 | |
|
323 | 323 | stat = 0 |
|
324 | 324 | if verbose or debug: print header+cmd |
|
325 | 325 | # flush stdout so we don't mangle python's buffering |
|
326 | 326 | sys.stdout.flush() |
|
327 | 327 | |
|
328 | 328 | if not debug: |
|
329 | 329 | platutils.set_term_title("IPy:" + cmd) |
|
330 | 330 | os.system(cmd) |
|
331 | 331 | platutils.set_term_title("IPy:" + os.path.basename(os.getcwd())) |
|
332 | 332 | |
|
333 | 333 | # override shell() for win32 to deal with network shares |
|
334 | 334 | if os.name in ('nt','dos'): |
|
335 | 335 | |
|
336 | 336 | shell_ori = shell |
|
337 | 337 | |
|
338 | 338 | def shell(cmd,verbose=0,debug=0,header=''): |
|
339 | 339 | if os.getcwd().startswith(r"\\"): |
|
340 | 340 | path = os.getcwd() |
|
341 | 341 | # change to c drive (cannot be on UNC-share when issuing os.system, |
|
342 | 342 | # as cmd.exe cannot handle UNC addresses) |
|
343 | 343 | os.chdir("c:") |
|
344 | 344 | # issue pushd to the UNC-share and then run the command |
|
345 | 345 | try: |
|
346 | 346 | shell_ori('"pushd %s&&"'%path+cmd,verbose,debug,header) |
|
347 | 347 | finally: |
|
348 | 348 | os.chdir(path) |
|
349 | 349 | else: |
|
350 | 350 | shell_ori(cmd,verbose,debug,header) |
|
351 | 351 | |
|
352 | 352 | shell.__doc__ = shell_ori.__doc__ |
|
353 | 353 | |
|
354 | 354 | def getoutput(cmd,verbose=0,debug=0,header='',split=0): |
|
355 | 355 | """Dummy substitute for perl's backquotes. |
|
356 | 356 | |
|
357 | 357 | Executes a command and returns the output. |
|
358 | 358 | |
|
359 | 359 | Accepts the same arguments as system(), plus: |
|
360 | 360 | |
|
361 | 361 | - split(0): if true, the output is returned as a list split on newlines. |
|
362 | 362 | |
|
363 | 363 | Note: a stateful version of this function is available through the |
|
364 | 364 | SystemExec class. |
|
365 | 365 | |
|
366 | 366 | This is pretty much deprecated and rarely used, |
|
367 | 367 | genutils.getoutputerror may be what you need. |
|
368 | 368 | |
|
369 | 369 | """ |
|
370 | 370 | |
|
371 | 371 | if verbose or debug: print header+cmd |
|
372 | 372 | if not debug: |
|
373 | 373 | output = os.popen(cmd).read() |
|
374 | 374 | # stipping last \n is here for backwards compat. |
|
375 | 375 | if output.endswith('\n'): |
|
376 | 376 | output = output[:-1] |
|
377 | 377 | if split: |
|
378 | 378 | return output.split('\n') |
|
379 | 379 | else: |
|
380 | 380 | return output |
|
381 | 381 | |
|
382 | 382 | def getoutputerror(cmd,verbose=0,debug=0,header='',split=0): |
|
383 | 383 | """Return (standard output,standard error) of executing cmd in a shell. |
|
384 | 384 | |
|
385 | 385 | Accepts the same arguments as system(), plus: |
|
386 | 386 | |
|
387 | 387 | - split(0): if true, each of stdout/err is returned as a list split on |
|
388 | 388 | newlines. |
|
389 | 389 | |
|
390 | 390 | Note: a stateful version of this function is available through the |
|
391 | 391 | SystemExec class.""" |
|
392 | 392 | |
|
393 | 393 | if verbose or debug: print header+cmd |
|
394 | 394 | if not cmd: |
|
395 | 395 | if split: |
|
396 | 396 | return [],[] |
|
397 | 397 | else: |
|
398 | 398 | return '','' |
|
399 | 399 | if not debug: |
|
400 | 400 | pin,pout,perr = os.popen3(cmd) |
|
401 | 401 | tout = pout.read().rstrip() |
|
402 | 402 | terr = perr.read().rstrip() |
|
403 | 403 | pin.close() |
|
404 | 404 | pout.close() |
|
405 | 405 | perr.close() |
|
406 | 406 | if split: |
|
407 | 407 | return tout.split('\n'),terr.split('\n') |
|
408 | 408 | else: |
|
409 | 409 | return tout,terr |
|
410 | 410 | |
|
411 | 411 | # for compatibility with older naming conventions |
|
412 | 412 | xsys = system |
|
413 | 413 | bq = getoutput |
|
414 | 414 | |
|
415 | 415 | class SystemExec: |
|
416 | 416 | """Access the system and getoutput functions through a stateful interface. |
|
417 | 417 | |
|
418 | 418 | Note: here we refer to the system and getoutput functions from this |
|
419 | 419 | library, not the ones from the standard python library. |
|
420 | 420 | |
|
421 | 421 | This class offers the system and getoutput functions as methods, but the |
|
422 | 422 | verbose, debug and header parameters can be set for the instance (at |
|
423 | 423 | creation time or later) so that they don't need to be specified on each |
|
424 | 424 | call. |
|
425 | 425 | |
|
426 | 426 | For efficiency reasons, there's no way to override the parameters on a |
|
427 | 427 | per-call basis other than by setting instance attributes. If you need |
|
428 | 428 | local overrides, it's best to directly call system() or getoutput(). |
|
429 | 429 | |
|
430 | 430 | The following names are provided as alternate options: |
|
431 | 431 | - xsys: alias to system |
|
432 | 432 | - bq: alias to getoutput |
|
433 | 433 | |
|
434 | 434 | An instance can then be created as: |
|
435 | 435 | >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ') |
|
436 | 436 | |
|
437 | 437 | And used as: |
|
438 | 438 | >>> sysexec.xsys('pwd') |
|
439 | 439 | >>> dirlist = sysexec.bq('ls -l') |
|
440 | 440 | """ |
|
441 | 441 | |
|
442 | 442 | def __init__(self,verbose=0,debug=0,header='',split=0): |
|
443 | 443 | """Specify the instance's values for verbose, debug and header.""" |
|
444 | 444 | setattr_list(self,'verbose debug header split') |
|
445 | 445 | |
|
446 | 446 | def system(self,cmd): |
|
447 | 447 | """Stateful interface to system(), with the same keyword parameters.""" |
|
448 | 448 | |
|
449 | 449 | system(cmd,self.verbose,self.debug,self.header) |
|
450 | 450 | |
|
451 | 451 | def shell(self,cmd): |
|
452 | 452 | """Stateful interface to shell(), with the same keyword parameters.""" |
|
453 | 453 | |
|
454 | 454 | shell(cmd,self.verbose,self.debug,self.header) |
|
455 | 455 | |
|
456 | 456 | xsys = system # alias |
|
457 | 457 | |
|
458 | 458 | def getoutput(self,cmd): |
|
459 | 459 | """Stateful interface to getoutput().""" |
|
460 | 460 | |
|
461 | 461 | return getoutput(cmd,self.verbose,self.debug,self.header,self.split) |
|
462 | 462 | |
|
463 | 463 | def getoutputerror(self,cmd): |
|
464 | 464 | """Stateful interface to getoutputerror().""" |
|
465 | 465 | |
|
466 | 466 | return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split) |
|
467 | 467 | |
|
468 | 468 | bq = getoutput # alias |
|
469 | 469 | |
|
470 | 470 | #----------------------------------------------------------------------------- |
|
471 | 471 | def mutex_opts(dict,ex_op): |
|
472 | 472 | """Check for presence of mutually exclusive keys in a dict. |
|
473 | 473 | |
|
474 | 474 | Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]""" |
|
475 | 475 | for op1,op2 in ex_op: |
|
476 | 476 | if op1 in dict and op2 in dict: |
|
477 | 477 | raise ValueError,'\n*** ERROR in Arguments *** '\ |
|
478 | 478 | 'Options '+op1+' and '+op2+' are mutually exclusive.' |
|
479 | 479 | |
|
480 | 480 | #----------------------------------------------------------------------------- |
|
481 | 481 | def get_py_filename(name): |
|
482 | 482 | """Return a valid python filename in the current directory. |
|
483 | 483 | |
|
484 | 484 | If the given name is not a file, it adds '.py' and searches again. |
|
485 | 485 | Raises IOError with an informative message if the file isn't found.""" |
|
486 | 486 | |
|
487 | 487 | name = os.path.expanduser(name) |
|
488 | 488 | if not os.path.isfile(name) and not name.endswith('.py'): |
|
489 | 489 | name += '.py' |
|
490 | 490 | if os.path.isfile(name): |
|
491 | 491 | return name |
|
492 | 492 | else: |
|
493 | 493 | raise IOError,'File `%s` not found.' % name |
|
494 | 494 | |
|
495 | 495 | #----------------------------------------------------------------------------- |
|
496 | 496 | def filefind(fname,alt_dirs = None): |
|
497 | 497 | """Return the given filename either in the current directory, if it |
|
498 | 498 | exists, or in a specified list of directories. |
|
499 | 499 | |
|
500 | 500 | ~ expansion is done on all file and directory names. |
|
501 | 501 | |
|
502 | 502 | Upon an unsuccessful search, raise an IOError exception.""" |
|
503 | 503 | |
|
504 | 504 | if alt_dirs is None: |
|
505 | 505 | try: |
|
506 | 506 | alt_dirs = get_home_dir() |
|
507 | 507 | except HomeDirError: |
|
508 | 508 | alt_dirs = os.getcwd() |
|
509 | 509 | search = [fname] + list_strings(alt_dirs) |
|
510 | 510 | search = map(os.path.expanduser,search) |
|
511 | 511 | #print 'search list for',fname,'list:',search # dbg |
|
512 | 512 | fname = search[0] |
|
513 | 513 | if os.path.isfile(fname): |
|
514 | 514 | return fname |
|
515 | 515 | for direc in search[1:]: |
|
516 | 516 | testname = os.path.join(direc,fname) |
|
517 | 517 | #print 'testname',testname # dbg |
|
518 | 518 | if os.path.isfile(testname): |
|
519 | 519 | return testname |
|
520 | 520 | raise IOError,'File' + `fname` + \ |
|
521 | 521 | ' not found in current or supplied directories:' + `alt_dirs` |
|
522 | 522 | |
|
523 | 523 | #---------------------------------------------------------------------------- |
|
524 | 524 | def file_read(filename): |
|
525 | 525 | """Read a file and close it. Returns the file source.""" |
|
526 | 526 | fobj = open(filename,'r'); |
|
527 | 527 | source = fobj.read(); |
|
528 | 528 | fobj.close() |
|
529 | 529 | return source |
|
530 | 530 | |
|
531 | 531 | def file_readlines(filename): |
|
532 | 532 | """Read a file and close it. Returns the file source using readlines().""" |
|
533 | 533 | fobj = open(filename,'r'); |
|
534 | 534 | lines = fobj.readlines(); |
|
535 | 535 | fobj.close() |
|
536 | 536 | return lines |
|
537 | 537 | |
|
538 | 538 | #---------------------------------------------------------------------------- |
|
539 | 539 | def target_outdated(target,deps): |
|
540 | 540 | """Determine whether a target is out of date. |
|
541 | 541 | |
|
542 | 542 | target_outdated(target,deps) -> 1/0 |
|
543 | 543 | |
|
544 | 544 | deps: list of filenames which MUST exist. |
|
545 | 545 | target: single filename which may or may not exist. |
|
546 | 546 | |
|
547 | 547 | If target doesn't exist or is older than any file listed in deps, return |
|
548 | 548 | true, otherwise return false. |
|
549 | 549 | """ |
|
550 | 550 | try: |
|
551 | 551 | target_time = os.path.getmtime(target) |
|
552 | 552 | except os.error: |
|
553 | 553 | return 1 |
|
554 | 554 | for dep in deps: |
|
555 | 555 | dep_time = os.path.getmtime(dep) |
|
556 | 556 | if dep_time > target_time: |
|
557 | 557 | #print "For target",target,"Dep failed:",dep # dbg |
|
558 | 558 | #print "times (dep,tar):",dep_time,target_time # dbg |
|
559 | 559 | return 1 |
|
560 | 560 | return 0 |
|
561 | 561 | |
|
562 | 562 | #----------------------------------------------------------------------------- |
|
563 | 563 | def target_update(target,deps,cmd): |
|
564 | 564 | """Update a target with a given command given a list of dependencies. |
|
565 | 565 | |
|
566 | 566 | target_update(target,deps,cmd) -> runs cmd if target is outdated. |
|
567 | 567 | |
|
568 | 568 | This is just a wrapper around target_outdated() which calls the given |
|
569 | 569 | command if target is outdated.""" |
|
570 | 570 | |
|
571 | 571 | if target_outdated(target,deps): |
|
572 | 572 | xsys(cmd) |
|
573 | 573 | |
|
574 | 574 | #---------------------------------------------------------------------------- |
|
575 | 575 | def unquote_ends(istr): |
|
576 | 576 | """Remove a single pair of quotes from the endpoints of a string.""" |
|
577 | 577 | |
|
578 | 578 | if not istr: |
|
579 | 579 | return istr |
|
580 | 580 | if (istr[0]=="'" and istr[-1]=="'") or \ |
|
581 | 581 | (istr[0]=='"' and istr[-1]=='"'): |
|
582 | 582 | return istr[1:-1] |
|
583 | 583 | else: |
|
584 | 584 | return istr |
|
585 | 585 | |
|
586 | 586 | #---------------------------------------------------------------------------- |
|
587 | 587 | def process_cmdline(argv,names=[],defaults={},usage=''): |
|
588 | 588 | """ Process command-line options and arguments. |
|
589 | 589 | |
|
590 | 590 | Arguments: |
|
591 | 591 | |
|
592 | 592 | - argv: list of arguments, typically sys.argv. |
|
593 | 593 | |
|
594 | 594 | - names: list of option names. See DPyGetOpt docs for details on options |
|
595 | 595 | syntax. |
|
596 | 596 | |
|
597 | 597 | - defaults: dict of default values. |
|
598 | 598 | |
|
599 | 599 | - usage: optional usage notice to print if a wrong argument is passed. |
|
600 | 600 | |
|
601 | 601 | Return a dict of options and a list of free arguments.""" |
|
602 | 602 | |
|
603 | 603 | getopt = DPyGetOpt.DPyGetOpt() |
|
604 | 604 | getopt.setIgnoreCase(0) |
|
605 | 605 | getopt.parseConfiguration(names) |
|
606 | 606 | |
|
607 | 607 | try: |
|
608 | 608 | getopt.processArguments(argv) |
|
609 | 609 | except: |
|
610 | 610 | print usage |
|
611 | 611 | warn(`sys.exc_value`,level=4) |
|
612 | 612 | |
|
613 | 613 | defaults.update(getopt.optionValues) |
|
614 | 614 | args = getopt.freeValues |
|
615 | 615 | |
|
616 | 616 | return defaults,args |
|
617 | 617 | |
|
618 | 618 | #---------------------------------------------------------------------------- |
|
619 | 619 | def optstr2types(ostr): |
|
620 | 620 | """Convert a string of option names to a dict of type mappings. |
|
621 | 621 | |
|
622 | 622 | optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'} |
|
623 | 623 | |
|
624 | 624 | This is used to get the types of all the options in a string formatted |
|
625 | 625 | with the conventions of DPyGetOpt. The 'type' None is used for options |
|
626 | 626 | which are strings (they need no further conversion). This function's main |
|
627 | 627 | use is to get a typemap for use with read_dict(). |
|
628 | 628 | """ |
|
629 | 629 | |
|
630 | 630 | typeconv = {None:'',int:'',float:''} |
|
631 | 631 | typemap = {'s':None,'i':int,'f':float} |
|
632 | 632 | opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)') |
|
633 | 633 | |
|
634 | 634 | for w in ostr.split(): |
|
635 | 635 | oname,alias,otype = opt_re.match(w).groups() |
|
636 | 636 | if otype == '' or alias == '!': # simple switches are integers too |
|
637 | 637 | otype = 'i' |
|
638 | 638 | typeconv[typemap[otype]] += oname + ' ' |
|
639 | 639 | return typeconv |
|
640 | 640 | |
|
641 | 641 | #---------------------------------------------------------------------------- |
|
642 | 642 | def read_dict(filename,type_conv=None,**opt): |
|
643 | 643 | |
|
644 | 644 | """Read a dictionary of key=value pairs from an input file, optionally |
|
645 | 645 | performing conversions on the resulting values. |
|
646 | 646 | |
|
647 | 647 | read_dict(filename,type_conv,**opt) -> dict |
|
648 | 648 | |
|
649 | 649 | Only one value per line is accepted, the format should be |
|
650 | 650 | # optional comments are ignored |
|
651 | 651 | key value\n |
|
652 | 652 | |
|
653 | 653 | Args: |
|
654 | 654 | |
|
655 | 655 | - type_conv: A dictionary specifying which keys need to be converted to |
|
656 | 656 | which types. By default all keys are read as strings. This dictionary |
|
657 | 657 | should have as its keys valid conversion functions for strings |
|
658 | 658 | (int,long,float,complex, or your own). The value for each key |
|
659 | 659 | (converter) should be a whitespace separated string containing the names |
|
660 | 660 | of all the entries in the file to be converted using that function. For |
|
661 | 661 | keys to be left alone, use None as the conversion function (only needed |
|
662 | 662 | with purge=1, see below). |
|
663 | 663 | |
|
664 | 664 | - opt: dictionary with extra options as below (default in parens) |
|
665 | 665 | |
|
666 | 666 | purge(0): if set to 1, all keys *not* listed in type_conv are purged out |
|
667 | 667 | of the dictionary to be returned. If purge is going to be used, the |
|
668 | 668 | set of keys to be left as strings also has to be explicitly specified |
|
669 | 669 | using the (non-existent) conversion function None. |
|
670 | 670 | |
|
671 | 671 | fs(None): field separator. This is the key/value separator to be used |
|
672 | 672 | when parsing the file. The None default means any whitespace [behavior |
|
673 | 673 | of string.split()]. |
|
674 | 674 | |
|
675 | 675 | strip(0): if 1, strip string values of leading/trailinig whitespace. |
|
676 | 676 | |
|
677 | 677 | warn(1): warning level if requested keys are not found in file. |
|
678 | 678 | - 0: silently ignore. |
|
679 | 679 | - 1: inform but proceed. |
|
680 | 680 | - 2: raise KeyError exception. |
|
681 | 681 | |
|
682 | 682 | no_empty(0): if 1, remove keys with whitespace strings as a value. |
|
683 | 683 | |
|
684 | 684 | unique([]): list of keys (or space separated string) which can't be |
|
685 | 685 | repeated. If one such key is found in the file, each new instance |
|
686 | 686 | overwrites the previous one. For keys not listed here, the behavior is |
|
687 | 687 | to make a list of all appearances. |
|
688 | 688 | |
|
689 | 689 | Example: |
|
690 | 690 | If the input file test.ini has: |
|
691 | 691 | i 3 |
|
692 | 692 | x 4.5 |
|
693 | 693 | y 5.5 |
|
694 | 694 | s hi ho |
|
695 | 695 | Then: |
|
696 | 696 | |
|
697 | 697 | >>> type_conv={int:'i',float:'x',None:'s'} |
|
698 | 698 | >>> read_dict('test.ini') |
|
699 | 699 | {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'} |
|
700 | 700 | >>> read_dict('test.ini',type_conv) |
|
701 | 701 | {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'} |
|
702 | 702 | >>> read_dict('test.ini',type_conv,purge=1) |
|
703 | 703 | {'i': 3, 's': 'hi ho', 'x': 4.5} |
|
704 | 704 | """ |
|
705 | 705 | |
|
706 | 706 | # starting config |
|
707 | 707 | opt.setdefault('purge',0) |
|
708 | 708 | opt.setdefault('fs',None) # field sep defaults to any whitespace |
|
709 | 709 | opt.setdefault('strip',0) |
|
710 | 710 | opt.setdefault('warn',1) |
|
711 | 711 | opt.setdefault('no_empty',0) |
|
712 | 712 | opt.setdefault('unique','') |
|
713 | 713 | if type(opt['unique']) in StringTypes: |
|
714 | 714 | unique_keys = qw(opt['unique']) |
|
715 | 715 | elif type(opt['unique']) in (types.TupleType,types.ListType): |
|
716 | 716 | unique_keys = opt['unique'] |
|
717 | 717 | else: |
|
718 | 718 | raise ValueError, 'Unique keys must be given as a string, List or Tuple' |
|
719 | 719 | |
|
720 | 720 | dict = {} |
|
721 | 721 | # first read in table of values as strings |
|
722 | 722 | file = open(filename,'r') |
|
723 | 723 | for line in file.readlines(): |
|
724 | 724 | line = line.strip() |
|
725 | 725 | if len(line) and line[0]=='#': continue |
|
726 | 726 | if len(line)>0: |
|
727 | 727 | lsplit = line.split(opt['fs'],1) |
|
728 | 728 | try: |
|
729 | 729 | key,val = lsplit |
|
730 | 730 | except ValueError: |
|
731 | 731 | key,val = lsplit[0],'' |
|
732 | 732 | key = key.strip() |
|
733 | 733 | if opt['strip']: val = val.strip() |
|
734 | 734 | if val == "''" or val == '""': val = '' |
|
735 | 735 | if opt['no_empty'] and (val=='' or val.isspace()): |
|
736 | 736 | continue |
|
737 | 737 | # if a key is found more than once in the file, build a list |
|
738 | 738 | # unless it's in the 'unique' list. In that case, last found in file |
|
739 | 739 | # takes precedence. User beware. |
|
740 | 740 | try: |
|
741 | 741 | if dict[key] and key in unique_keys: |
|
742 | 742 | dict[key] = val |
|
743 | 743 | elif type(dict[key]) is types.ListType: |
|
744 | 744 | dict[key].append(val) |
|
745 | 745 | else: |
|
746 | 746 | dict[key] = [dict[key],val] |
|
747 | 747 | except KeyError: |
|
748 | 748 | dict[key] = val |
|
749 | 749 | # purge if requested |
|
750 | 750 | if opt['purge']: |
|
751 | 751 | accepted_keys = qwflat(type_conv.values()) |
|
752 | 752 | for key in dict.keys(): |
|
753 | 753 | if key in accepted_keys: continue |
|
754 | 754 | del(dict[key]) |
|
755 | 755 | # now convert if requested |
|
756 | 756 | if type_conv==None: return dict |
|
757 | 757 | conversions = type_conv.keys() |
|
758 | 758 | try: conversions.remove(None) |
|
759 | 759 | except: pass |
|
760 | 760 | for convert in conversions: |
|
761 | 761 | for val in qw(type_conv[convert]): |
|
762 | 762 | try: |
|
763 | 763 | dict[val] = convert(dict[val]) |
|
764 | 764 | except KeyError,e: |
|
765 | 765 | if opt['warn'] == 0: |
|
766 | 766 | pass |
|
767 | 767 | elif opt['warn'] == 1: |
|
768 | 768 | print >>sys.stderr, 'Warning: key',val,\ |
|
769 | 769 | 'not found in file',filename |
|
770 | 770 | elif opt['warn'] == 2: |
|
771 | 771 | raise KeyError,e |
|
772 | 772 | else: |
|
773 | 773 | raise ValueError,'Warning level must be 0,1 or 2' |
|
774 | 774 | |
|
775 | 775 | return dict |
|
776 | 776 | |
|
777 | 777 | #---------------------------------------------------------------------------- |
|
778 | 778 | def flag_calls(func): |
|
779 | 779 | """Wrap a function to detect and flag when it gets called. |
|
780 | 780 | |
|
781 | 781 | This is a decorator which takes a function and wraps it in a function with |
|
782 | 782 | a 'called' attribute. wrapper.called is initialized to False. |
|
783 | 783 | |
|
784 | 784 | The wrapper.called attribute is set to False right before each call to the |
|
785 | 785 | wrapped function, so if the call fails it remains False. After the call |
|
786 | 786 | completes, wrapper.called is set to True and the output is returned. |
|
787 | 787 | |
|
788 | 788 | Testing for truth in wrapper.called allows you to determine if a call to |
|
789 | 789 | func() was attempted and succeeded.""" |
|
790 | 790 | |
|
791 | 791 | def wrapper(*args,**kw): |
|
792 | 792 | wrapper.called = False |
|
793 | 793 | out = func(*args,**kw) |
|
794 | 794 | wrapper.called = True |
|
795 | 795 | return out |
|
796 | 796 | |
|
797 | 797 | wrapper.called = False |
|
798 | 798 | wrapper.__doc__ = func.__doc__ |
|
799 | 799 | return wrapper |
|
800 | 800 | |
|
801 | 801 | #---------------------------------------------------------------------------- |
|
802 | 802 | class HomeDirError(Error): |
|
803 | 803 | pass |
|
804 | 804 | |
|
805 | 805 | def get_home_dir(): |
|
806 | 806 | """Return the closest possible equivalent to a 'home' directory. |
|
807 | 807 | |
|
808 | 808 | We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH. |
|
809 | 809 | |
|
810 | 810 | Currently only Posix and NT are implemented, a HomeDirError exception is |
|
811 | 811 | raised for all other OSes. """ |
|
812 | 812 | |
|
813 | 813 | isdir = os.path.isdir |
|
814 | 814 | env = os.environ |
|
815 | 815 | |
|
816 | 816 | # first, check py2exe distribution root directory for _ipython. |
|
817 | 817 | # This overrides all. Normally does not exist. |
|
818 | 818 | |
|
819 | 819 | if '\\library.zip\\' in IPython.__file__.lower(): |
|
820 | 820 | root, rest = IPython.__file__.lower().split('library.zip') |
|
821 | 821 | if isdir(root + '_ipython'): |
|
822 | 822 | os.environ["IPYKITROOT"] = root.rstrip('\\') |
|
823 | 823 | return root |
|
824 | 824 | |
|
825 | 825 | try: |
|
826 | 826 | homedir = env['HOME'] |
|
827 | 827 | if not isdir(homedir): |
|
828 | 828 | # in case a user stuck some string which does NOT resolve to a |
|
829 | 829 | # valid path, it's as good as if we hadn't foud it |
|
830 | 830 | raise KeyError |
|
831 | 831 | return homedir |
|
832 | 832 | except KeyError: |
|
833 | 833 | if os.name == 'posix': |
|
834 | 834 | raise HomeDirError,'undefined $HOME, IPython can not proceed.' |
|
835 | 835 | elif os.name == 'nt': |
|
836 | 836 | # For some strange reason, win9x returns 'nt' for os.name. |
|
837 | 837 | try: |
|
838 | 838 | homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH']) |
|
839 | 839 | if not isdir(homedir): |
|
840 | 840 | homedir = os.path.join(env['USERPROFILE']) |
|
841 | 841 | if not isdir(homedir): |
|
842 | 842 | raise HomeDirError |
|
843 | 843 | return homedir |
|
844 | 844 | except: |
|
845 | 845 | try: |
|
846 | 846 | # Use the registry to get the 'My Documents' folder. |
|
847 | 847 | import _winreg as wreg |
|
848 | 848 | key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, |
|
849 | 849 | "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") |
|
850 | 850 | homedir = wreg.QueryValueEx(key,'Personal')[0] |
|
851 | 851 | key.Close() |
|
852 | 852 | if not isdir(homedir): |
|
853 | 853 | e = ('Invalid "Personal" folder registry key ' |
|
854 | 854 | 'typically "My Documents".\n' |
|
855 | 855 | 'Value: %s\n' |
|
856 | 856 | 'This is not a valid directory on your system.' % |
|
857 | 857 | homedir) |
|
858 | 858 | raise HomeDirError(e) |
|
859 | 859 | return homedir |
|
860 | 860 | except HomeDirError: |
|
861 | 861 | raise |
|
862 | 862 | except: |
|
863 | 863 | return 'C:\\' |
|
864 | 864 | elif os.name == 'dos': |
|
865 | 865 | # Desperate, may do absurd things in classic MacOS. May work under DOS. |
|
866 | 866 | return 'C:\\' |
|
867 | 867 | else: |
|
868 | 868 | raise HomeDirError,'support for your operating system not implemented.' |
|
869 | 869 | |
|
870 | 870 | #**************************************************************************** |
|
871 | 871 | # strings and text |
|
872 | 872 | |
|
873 | 873 | class LSString(str): |
|
874 | 874 | """String derivative with a special access attributes. |
|
875 | 875 | |
|
876 | 876 | These are normal strings, but with the special attributes: |
|
877 | 877 | |
|
878 | 878 | .l (or .list) : value as list (split on newlines). |
|
879 | 879 | .n (or .nlstr): original value (the string itself). |
|
880 | 880 | .s (or .spstr): value as whitespace-separated string. |
|
881 | 881 | .p (or .paths): list of path objects |
|
882 | 882 | |
|
883 | 883 | Any values which require transformations are computed only once and |
|
884 | 884 | cached. |
|
885 | 885 | |
|
886 | 886 | Such strings are very useful to efficiently interact with the shell, which |
|
887 | 887 | typically only understands whitespace-separated options for commands.""" |
|
888 | 888 | |
|
889 | 889 | def get_list(self): |
|
890 | 890 | try: |
|
891 | 891 | return self.__list |
|
892 | 892 | except AttributeError: |
|
893 | 893 | self.__list = self.split('\n') |
|
894 | 894 | return self.__list |
|
895 | 895 | |
|
896 | 896 | l = list = property(get_list) |
|
897 | 897 | |
|
898 | 898 | def get_spstr(self): |
|
899 | 899 | try: |
|
900 | 900 | return self.__spstr |
|
901 | 901 | except AttributeError: |
|
902 | 902 | self.__spstr = self.replace('\n',' ') |
|
903 | 903 | return self.__spstr |
|
904 | 904 | |
|
905 | 905 | s = spstr = property(get_spstr) |
|
906 | 906 | |
|
907 | 907 | def get_nlstr(self): |
|
908 | 908 | return self |
|
909 | 909 | |
|
910 | 910 | n = nlstr = property(get_nlstr) |
|
911 | 911 | |
|
912 | 912 | def get_paths(self): |
|
913 | 913 | try: |
|
914 | 914 | return self.__paths |
|
915 | 915 | except AttributeError: |
|
916 | 916 | self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)] |
|
917 | 917 | return self.__paths |
|
918 | 918 | |
|
919 | 919 | p = paths = property(get_paths) |
|
920 | 920 | |
|
921 | 921 | def print_lsstring(arg): |
|
922 | 922 | """ Prettier (non-repr-like) and more informative printer for LSString """ |
|
923 | 923 | print "LSString (.p, .n, .l, .s available). Value:" |
|
924 | 924 | print arg |
|
925 | 925 | |
|
926 | 926 | print_lsstring = result_display.when_type(LSString)(print_lsstring) |
|
927 | 927 | |
|
928 | 928 | #---------------------------------------------------------------------------- |
|
929 | 929 | class SList(list): |
|
930 | 930 | """List derivative with a special access attributes. |
|
931 | 931 | |
|
932 | 932 | These are normal lists, but with the special attributes: |
|
933 | 933 | |
|
934 | 934 | .l (or .list) : value as list (the list itself). |
|
935 | 935 | .n (or .nlstr): value as a string, joined on newlines. |
|
936 | 936 | .s (or .spstr): value as a string, joined on spaces. |
|
937 | 937 | .p (or .paths): list of path objects |
|
938 | 938 | |
|
939 | 939 | Any values which require transformations are computed only once and |
|
940 | 940 | cached.""" |
|
941 | 941 | |
|
942 | 942 | def get_list(self): |
|
943 | 943 | return self |
|
944 | 944 | |
|
945 | 945 | l = list = property(get_list) |
|
946 | 946 | |
|
947 | 947 | def get_spstr(self): |
|
948 | 948 | try: |
|
949 | 949 | return self.__spstr |
|
950 | 950 | except AttributeError: |
|
951 | 951 | self.__spstr = ' '.join(self) |
|
952 | 952 | return self.__spstr |
|
953 | 953 | |
|
954 | 954 | s = spstr = property(get_spstr) |
|
955 | 955 | |
|
956 | 956 | def get_nlstr(self): |
|
957 | 957 | try: |
|
958 | 958 | return self.__nlstr |
|
959 | 959 | except AttributeError: |
|
960 | 960 | self.__nlstr = '\n'.join(self) |
|
961 | 961 | return self.__nlstr |
|
962 | 962 | |
|
963 | 963 | n = nlstr = property(get_nlstr) |
|
964 | 964 | |
|
965 | 965 | def get_paths(self): |
|
966 | 966 | try: |
|
967 | 967 | return self.__paths |
|
968 | 968 | except AttributeError: |
|
969 | 969 | self.__paths = [path(p) for p in self if os.path.exists(p)] |
|
970 | 970 | return self.__paths |
|
971 | 971 | |
|
972 | 972 | p = paths = property(get_paths) |
|
973 | 973 | |
|
974 | 974 | #---------------------------------------------------------------------------- |
|
975 | 975 | def esc_quotes(strng): |
|
976 | 976 | """Return the input string with single and double quotes escaped out""" |
|
977 | 977 | |
|
978 | 978 | return strng.replace('"','\\"').replace("'","\\'") |
|
979 | 979 | |
|
980 | 980 | #---------------------------------------------------------------------------- |
|
981 | 981 | def make_quoted_expr(s): |
|
982 | 982 | """Return string s in appropriate quotes, using raw string if possible. |
|
983 | 983 | |
|
984 | 984 | Effectively this turns string: cd \ao\ao\ |
|
985 | 985 | to: r"cd \ao\ao\_"[:-1] |
|
986 | 986 | |
|
987 | 987 | Note the use of raw string and padding at the end to allow trailing backslash. |
|
988 | 988 | |
|
989 | 989 | """ |
|
990 | 990 | |
|
991 | 991 | tail = '' |
|
992 | 992 | tailpadding = '' |
|
993 | 993 | raw = '' |
|
994 | 994 | if "\\" in s: |
|
995 | 995 | raw = 'r' |
|
996 | 996 | if s.endswith('\\'): |
|
997 | 997 | tail = '[:-1]' |
|
998 | 998 | tailpadding = '_' |
|
999 | 999 | if '"' not in s: |
|
1000 | 1000 | quote = '"' |
|
1001 | 1001 | elif "'" not in s: |
|
1002 | 1002 | quote = "'" |
|
1003 | 1003 | elif '"""' not in s and not s.endswith('"'): |
|
1004 | 1004 | quote = '"""' |
|
1005 | 1005 | elif "'''" not in s and not s.endswith("'"): |
|
1006 | 1006 | quote = "'''" |
|
1007 | 1007 | else: |
|
1008 | 1008 | # give up, backslash-escaped string will do |
|
1009 | 1009 | return '"%s"' % esc_quotes(s) |
|
1010 | 1010 | res = itpl("$raw$quote$s$tailpadding$quote$tail") |
|
1011 | 1011 | return res |
|
1012 | 1012 | |
|
1013 | 1013 | |
|
1014 | 1014 | #---------------------------------------------------------------------------- |
|
1015 | 1015 | def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'): |
|
1016 | 1016 | """Take multiple lines of input. |
|
1017 | 1017 | |
|
1018 | 1018 | A list with each line of input as a separate element is returned when a |
|
1019 | 1019 | termination string is entered (defaults to a single '.'). Input can also |
|
1020 | 1020 | terminate via EOF (^D in Unix, ^Z-RET in Windows). |
|
1021 | 1021 | |
|
1022 | 1022 | Lines of input which end in \\ are joined into single entries (and a |
|
1023 | 1023 | secondary continuation prompt is issued as long as the user terminates |
|
1024 | 1024 | lines with \\). This allows entering very long strings which are still |
|
1025 | 1025 | meant to be treated as single entities. |
|
1026 | 1026 | """ |
|
1027 | 1027 | |
|
1028 | 1028 | try: |
|
1029 | 1029 | if header: |
|
1030 | 1030 | header += '\n' |
|
1031 | 1031 | lines = [raw_input(header + ps1)] |
|
1032 | 1032 | except EOFError: |
|
1033 | 1033 | return [] |
|
1034 | 1034 | terminate = [terminate_str] |
|
1035 | 1035 | try: |
|
1036 | 1036 | while lines[-1:] != terminate: |
|
1037 | 1037 | new_line = raw_input(ps1) |
|
1038 | 1038 | while new_line.endswith('\\'): |
|
1039 | 1039 | new_line = new_line[:-1] + raw_input(ps2) |
|
1040 | 1040 | lines.append(new_line) |
|
1041 | 1041 | |
|
1042 | 1042 | return lines[:-1] # don't return the termination command |
|
1043 | 1043 | except EOFError: |
|
1044 | 1044 | |
|
1045 | 1045 | return lines |
|
1046 | 1046 | |
|
1047 | 1047 | #---------------------------------------------------------------------------- |
|
1048 | 1048 | def raw_input_ext(prompt='', ps2='... '): |
|
1049 | 1049 | """Similar to raw_input(), but accepts extended lines if input ends with \\.""" |
|
1050 | 1050 | |
|
1051 | 1051 | line = raw_input(prompt) |
|
1052 | 1052 | while line.endswith('\\'): |
|
1053 | 1053 | line = line[:-1] + raw_input(ps2) |
|
1054 | 1054 | return line |
|
1055 | 1055 | |
|
1056 | 1056 | #---------------------------------------------------------------------------- |
|
1057 | 1057 | def ask_yes_no(prompt,default=None): |
|
1058 |
"""Asks a question and returns a |
|
|
1058 | """Asks a question and returns a boolean (y/n) answer. | |
|
1059 | 1059 | |
|
1060 | 1060 | If default is given (one of 'y','n'), it is used if the user input is |
|
1061 | 1061 | empty. Otherwise the question is repeated until an answer is given. |
|
1062 | 1062 | |
|
1063 | 1063 | An EOF is treated as the default answer. If there is no default, an |
|
1064 | 1064 | exception is raised to prevent infinite loops. |
|
1065 | 1065 | |
|
1066 | 1066 | Valid answers are: y/yes/n/no (match is not case sensitive).""" |
|
1067 | 1067 | |
|
1068 | 1068 | answers = {'y':True,'n':False,'yes':True,'no':False} |
|
1069 | 1069 | ans = None |
|
1070 | 1070 | while ans not in answers.keys(): |
|
1071 | 1071 | try: |
|
1072 | 1072 | ans = raw_input(prompt+' ').lower() |
|
1073 | 1073 | if not ans: # response was an empty string |
|
1074 | 1074 | ans = default |
|
1075 | 1075 | except KeyboardInterrupt: |
|
1076 | 1076 | pass |
|
1077 | 1077 | except EOFError: |
|
1078 | 1078 | if default in answers.keys(): |
|
1079 | 1079 | ans = default |
|
1080 | 1080 | |
|
1081 | 1081 | else: |
|
1082 | 1082 | raise |
|
1083 | 1083 | |
|
1084 | 1084 | return answers[ans] |
|
1085 | 1085 | |
|
1086 | 1086 | #---------------------------------------------------------------------------- |
|
1087 | 1087 | def marquee(txt='',width=78,mark='*'): |
|
1088 | 1088 | """Return the input string centered in a 'marquee'.""" |
|
1089 | 1089 | if not txt: |
|
1090 | 1090 | return (mark*width)[:width] |
|
1091 | 1091 | nmark = (width-len(txt)-2)/len(mark)/2 |
|
1092 | 1092 | if nmark < 0: nmark =0 |
|
1093 | 1093 | marks = mark*nmark |
|
1094 | 1094 | return '%s %s %s' % (marks,txt,marks) |
|
1095 | 1095 | |
|
1096 | 1096 | #---------------------------------------------------------------------------- |
|
1097 | 1097 | class EvalDict: |
|
1098 | 1098 | """ |
|
1099 | 1099 | Emulate a dict which evaluates its contents in the caller's frame. |
|
1100 | 1100 | |
|
1101 | 1101 | Usage: |
|
1102 | 1102 | >>>number = 19 |
|
1103 | 1103 | >>>text = "python" |
|
1104 | 1104 | >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict() |
|
1105 | 1105 | """ |
|
1106 | 1106 | |
|
1107 | 1107 | # This version is due to sismex01@hebmex.com on c.l.py, and is basically a |
|
1108 | 1108 | # modified (shorter) version of: |
|
1109 | 1109 | # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by |
|
1110 | 1110 | # Skip Montanaro (skip@pobox.com). |
|
1111 | 1111 | |
|
1112 | 1112 | def __getitem__(self, name): |
|
1113 | 1113 | frame = sys._getframe(1) |
|
1114 | 1114 | return eval(name, frame.f_globals, frame.f_locals) |
|
1115 | 1115 | |
|
1116 | 1116 | EvalString = EvalDict # for backwards compatibility |
|
1117 | 1117 | #---------------------------------------------------------------------------- |
|
1118 | 1118 | def qw(words,flat=0,sep=None,maxsplit=-1): |
|
1119 | 1119 | """Similar to Perl's qw() operator, but with some more options. |
|
1120 | 1120 | |
|
1121 | 1121 | qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit) |
|
1122 | 1122 | |
|
1123 | 1123 | words can also be a list itself, and with flat=1, the output will be |
|
1124 | 1124 | recursively flattened. Examples: |
|
1125 | 1125 | |
|
1126 | 1126 | >>> qw('1 2') |
|
1127 | 1127 | ['1', '2'] |
|
1128 | 1128 | >>> qw(['a b','1 2',['m n','p q']]) |
|
1129 | 1129 | [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]] |
|
1130 | 1130 | >>> qw(['a b','1 2',['m n','p q']],flat=1) |
|
1131 | 1131 | ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """ |
|
1132 | 1132 | |
|
1133 | 1133 | if type(words) in StringTypes: |
|
1134 | 1134 | return [word.strip() for word in words.split(sep,maxsplit) |
|
1135 | 1135 | if word and not word.isspace() ] |
|
1136 | 1136 | if flat: |
|
1137 | 1137 | return flatten(map(qw,words,[1]*len(words))) |
|
1138 | 1138 | return map(qw,words) |
|
1139 | 1139 | |
|
1140 | 1140 | #---------------------------------------------------------------------------- |
|
1141 | 1141 | def qwflat(words,sep=None,maxsplit=-1): |
|
1142 | 1142 | """Calls qw(words) in flat mode. It's just a convenient shorthand.""" |
|
1143 | 1143 | return qw(words,1,sep,maxsplit) |
|
1144 | 1144 | |
|
1145 | 1145 | #---------------------------------------------------------------------------- |
|
1146 | 1146 | def qw_lol(indata): |
|
1147 | 1147 | """qw_lol('a b') -> [['a','b']], |
|
1148 | 1148 | otherwise it's just a call to qw(). |
|
1149 | 1149 | |
|
1150 | 1150 | We need this to make sure the modules_some keys *always* end up as a |
|
1151 | 1151 | list of lists.""" |
|
1152 | 1152 | |
|
1153 | 1153 | if type(indata) in StringTypes: |
|
1154 | 1154 | return [qw(indata)] |
|
1155 | 1155 | else: |
|
1156 | 1156 | return qw(indata) |
|
1157 | 1157 | |
|
1158 | 1158 | #----------------------------------------------------------------------------- |
|
1159 | 1159 | def list_strings(arg): |
|
1160 | 1160 | """Always return a list of strings, given a string or list of strings |
|
1161 | 1161 | as input.""" |
|
1162 | 1162 | |
|
1163 | 1163 | if type(arg) in StringTypes: return [arg] |
|
1164 | 1164 | else: return arg |
|
1165 | 1165 | |
|
1166 | 1166 | #---------------------------------------------------------------------------- |
|
1167 | 1167 | def grep(pat,list,case=1): |
|
1168 | 1168 | """Simple minded grep-like function. |
|
1169 | 1169 | grep(pat,list) returns occurrences of pat in list, None on failure. |
|
1170 | 1170 | |
|
1171 | 1171 | It only does simple string matching, with no support for regexps. Use the |
|
1172 | 1172 | option case=0 for case-insensitive matching.""" |
|
1173 | 1173 | |
|
1174 | 1174 | # This is pretty crude. At least it should implement copying only references |
|
1175 | 1175 | # to the original data in case it's big. Now it copies the data for output. |
|
1176 | 1176 | out=[] |
|
1177 | 1177 | if case: |
|
1178 | 1178 | for term in list: |
|
1179 | 1179 | if term.find(pat)>-1: out.append(term) |
|
1180 | 1180 | else: |
|
1181 | 1181 | lpat=pat.lower() |
|
1182 | 1182 | for term in list: |
|
1183 | 1183 | if term.lower().find(lpat)>-1: out.append(term) |
|
1184 | 1184 | |
|
1185 | 1185 | if len(out): return out |
|
1186 | 1186 | else: return None |
|
1187 | 1187 | |
|
1188 | 1188 | #---------------------------------------------------------------------------- |
|
1189 | 1189 | def dgrep(pat,*opts): |
|
1190 | 1190 | """Return grep() on dir()+dir(__builtins__). |
|
1191 | 1191 | |
|
1192 | 1192 | A very common use of grep() when working interactively.""" |
|
1193 | 1193 | |
|
1194 | 1194 | return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts) |
|
1195 | 1195 | |
|
1196 | 1196 | #---------------------------------------------------------------------------- |
|
1197 | 1197 | def idgrep(pat): |
|
1198 | 1198 | """Case-insensitive dgrep()""" |
|
1199 | 1199 | |
|
1200 | 1200 | return dgrep(pat,0) |
|
1201 | 1201 | |
|
1202 | 1202 | #---------------------------------------------------------------------------- |
|
1203 | 1203 | def igrep(pat,list): |
|
1204 | 1204 | """Synonym for case-insensitive grep.""" |
|
1205 | 1205 | |
|
1206 | 1206 | return grep(pat,list,case=0) |
|
1207 | 1207 | |
|
1208 | 1208 | #---------------------------------------------------------------------------- |
|
1209 | 1209 | def indent(str,nspaces=4,ntabs=0): |
|
1210 | 1210 | """Indent a string a given number of spaces or tabstops. |
|
1211 | 1211 | |
|
1212 | 1212 | indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces. |
|
1213 | 1213 | """ |
|
1214 | 1214 | if str is None: |
|
1215 | 1215 | return |
|
1216 | 1216 | ind = '\t'*ntabs+' '*nspaces |
|
1217 | 1217 | outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind)) |
|
1218 | 1218 | if outstr.endswith(os.linesep+ind): |
|
1219 | 1219 | return outstr[:-len(ind)] |
|
1220 | 1220 | else: |
|
1221 | 1221 | return outstr |
|
1222 | 1222 | |
|
1223 | 1223 | #----------------------------------------------------------------------------- |
|
1224 | 1224 | def native_line_ends(filename,backup=1): |
|
1225 | 1225 | """Convert (in-place) a file to line-ends native to the current OS. |
|
1226 | 1226 | |
|
1227 | 1227 | If the optional backup argument is given as false, no backup of the |
|
1228 | 1228 | original file is left. """ |
|
1229 | 1229 | |
|
1230 | 1230 | backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'} |
|
1231 | 1231 | |
|
1232 | 1232 | bak_filename = filename + backup_suffixes[os.name] |
|
1233 | 1233 | |
|
1234 | 1234 | original = open(filename).read() |
|
1235 | 1235 | shutil.copy2(filename,bak_filename) |
|
1236 | 1236 | try: |
|
1237 | 1237 | new = open(filename,'wb') |
|
1238 | 1238 | new.write(os.linesep.join(original.splitlines())) |
|
1239 | 1239 | new.write(os.linesep) # ALWAYS put an eol at the end of the file |
|
1240 | 1240 | new.close() |
|
1241 | 1241 | except: |
|
1242 | 1242 | os.rename(bak_filename,filename) |
|
1243 | 1243 | if not backup: |
|
1244 | 1244 | try: |
|
1245 | 1245 | os.remove(bak_filename) |
|
1246 | 1246 | except: |
|
1247 | 1247 | pass |
|
1248 | 1248 | |
|
1249 | 1249 | #---------------------------------------------------------------------------- |
|
1250 | 1250 | def get_pager_cmd(pager_cmd = None): |
|
1251 | 1251 | """Return a pager command. |
|
1252 | 1252 | |
|
1253 | 1253 | Makes some attempts at finding an OS-correct one.""" |
|
1254 | 1254 | |
|
1255 | 1255 | if os.name == 'posix': |
|
1256 | 1256 | default_pager_cmd = 'less -r' # -r for color control sequences |
|
1257 | 1257 | elif os.name in ['nt','dos']: |
|
1258 | 1258 | default_pager_cmd = 'type' |
|
1259 | 1259 | |
|
1260 | 1260 | if pager_cmd is None: |
|
1261 | 1261 | try: |
|
1262 | 1262 | pager_cmd = os.environ['PAGER'] |
|
1263 | 1263 | except: |
|
1264 | 1264 | pager_cmd = default_pager_cmd |
|
1265 | 1265 | return pager_cmd |
|
1266 | 1266 | |
|
1267 | 1267 | #----------------------------------------------------------------------------- |
|
1268 | 1268 | def get_pager_start(pager,start): |
|
1269 | 1269 | """Return the string for paging files with an offset. |
|
1270 | 1270 | |
|
1271 | 1271 | This is the '+N' argument which less and more (under Unix) accept. |
|
1272 | 1272 | """ |
|
1273 | 1273 | |
|
1274 | 1274 | if pager in ['less','more']: |
|
1275 | 1275 | if start: |
|
1276 | 1276 | start_string = '+' + str(start) |
|
1277 | 1277 | else: |
|
1278 | 1278 | start_string = '' |
|
1279 | 1279 | else: |
|
1280 | 1280 | start_string = '' |
|
1281 | 1281 | return start_string |
|
1282 | 1282 | |
|
1283 | 1283 | #---------------------------------------------------------------------------- |
|
1284 | 1284 | # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch() |
|
1285 | 1285 | if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs': |
|
1286 | 1286 | import msvcrt |
|
1287 | 1287 | def page_more(): |
|
1288 | 1288 | """ Smart pausing between pages |
|
1289 | 1289 | |
|
1290 | 1290 | @return: True if need print more lines, False if quit |
|
1291 | 1291 | """ |
|
1292 | 1292 | Term.cout.write('---Return to continue, q to quit--- ') |
|
1293 | 1293 | ans = msvcrt.getch() |
|
1294 | 1294 | if ans in ("q", "Q"): |
|
1295 | 1295 | result = False |
|
1296 | 1296 | else: |
|
1297 | 1297 | result = True |
|
1298 | 1298 | Term.cout.write("\b"*37 + " "*37 + "\b"*37) |
|
1299 | 1299 | return result |
|
1300 | 1300 | else: |
|
1301 | 1301 | def page_more(): |
|
1302 | 1302 | ans = raw_input('---Return to continue, q to quit--- ') |
|
1303 | 1303 | if ans.lower().startswith('q'): |
|
1304 | 1304 | return False |
|
1305 | 1305 | else: |
|
1306 | 1306 | return True |
|
1307 | 1307 | |
|
1308 | 1308 | esc_re = re.compile(r"(\x1b[^m]+m)") |
|
1309 | 1309 | |
|
1310 | 1310 | def page_dumb(strng,start=0,screen_lines=25): |
|
1311 | 1311 | """Very dumb 'pager' in Python, for when nothing else works. |
|
1312 | 1312 | |
|
1313 | 1313 | Only moves forward, same interface as page(), except for pager_cmd and |
|
1314 | 1314 | mode.""" |
|
1315 | 1315 | |
|
1316 | 1316 | out_ln = strng.splitlines()[start:] |
|
1317 | 1317 | screens = chop(out_ln,screen_lines-1) |
|
1318 | 1318 | if len(screens) == 1: |
|
1319 | 1319 | print >>Term.cout, os.linesep.join(screens[0]) |
|
1320 | 1320 | else: |
|
1321 | 1321 | last_escape = "" |
|
1322 | 1322 | for scr in screens[0:-1]: |
|
1323 | 1323 | hunk = os.linesep.join(scr) |
|
1324 | 1324 | print >>Term.cout, last_escape + hunk |
|
1325 | 1325 | if not page_more(): |
|
1326 | 1326 | return |
|
1327 | 1327 | esc_list = esc_re.findall(hunk) |
|
1328 | 1328 | if len(esc_list) > 0: |
|
1329 | 1329 | last_escape = esc_list[-1] |
|
1330 | 1330 | print >>Term.cout, last_escape + os.linesep.join(screens[-1]) |
|
1331 | 1331 | |
|
1332 | 1332 | #---------------------------------------------------------------------------- |
|
1333 | 1333 | def page(strng,start=0,screen_lines=0,pager_cmd = None): |
|
1334 | 1334 | """Print a string, piping through a pager after a certain length. |
|
1335 | 1335 | |
|
1336 | 1336 | The screen_lines parameter specifies the number of *usable* lines of your |
|
1337 | 1337 | terminal screen (total lines minus lines you need to reserve to show other |
|
1338 | 1338 | information). |
|
1339 | 1339 | |
|
1340 | 1340 | If you set screen_lines to a number <=0, page() will try to auto-determine |
|
1341 | 1341 | your screen size and will only use up to (screen_size+screen_lines) for |
|
1342 | 1342 | printing, paging after that. That is, if you want auto-detection but need |
|
1343 | 1343 | to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for |
|
1344 | 1344 | auto-detection without any lines reserved simply use screen_lines = 0. |
|
1345 | 1345 | |
|
1346 | 1346 | If a string won't fit in the allowed lines, it is sent through the |
|
1347 | 1347 | specified pager command. If none given, look for PAGER in the environment, |
|
1348 | 1348 | and ultimately default to less. |
|
1349 | 1349 | |
|
1350 | 1350 | If no system pager works, the string is sent through a 'dumb pager' |
|
1351 | 1351 | written in python, very simplistic. |
|
1352 | 1352 | """ |
|
1353 | 1353 | |
|
1354 | 1354 | # Ugly kludge, but calling curses.initscr() flat out crashes in emacs |
|
1355 | 1355 | TERM = os.environ.get('TERM','dumb') |
|
1356 | 1356 | if TERM in ['dumb','emacs'] and os.name != 'nt': |
|
1357 | 1357 | print strng |
|
1358 | 1358 | return |
|
1359 | 1359 | # chop off the topmost part of the string we don't want to see |
|
1360 | 1360 | str_lines = strng.split(os.linesep)[start:] |
|
1361 | 1361 | str_toprint = os.linesep.join(str_lines) |
|
1362 | 1362 | num_newlines = len(str_lines) |
|
1363 | 1363 | len_str = len(str_toprint) |
|
1364 | 1364 | |
|
1365 | 1365 | # Dumb heuristics to guesstimate number of on-screen lines the string |
|
1366 | 1366 | # takes. Very basic, but good enough for docstrings in reasonable |
|
1367 | 1367 | # terminals. If someone later feels like refining it, it's not hard. |
|
1368 | 1368 | numlines = max(num_newlines,int(len_str/80)+1) |
|
1369 | 1369 | |
|
1370 | 1370 | if os.name == "nt": |
|
1371 | 1371 | screen_lines_def = get_console_size(defaulty=25)[1] |
|
1372 | 1372 | else: |
|
1373 | 1373 | screen_lines_def = 25 # default value if we can't auto-determine |
|
1374 | 1374 | |
|
1375 | 1375 | # auto-determine screen size |
|
1376 | 1376 | if screen_lines <= 0: |
|
1377 | 1377 | if TERM=='xterm': |
|
1378 | 1378 | try: |
|
1379 | 1379 | import curses |
|
1380 | 1380 | if hasattr(curses,'initscr'): |
|
1381 | 1381 | use_curses = 1 |
|
1382 | 1382 | else: |
|
1383 | 1383 | use_curses = 0 |
|
1384 | 1384 | except ImportError: |
|
1385 | 1385 | use_curses = 0 |
|
1386 | 1386 | else: |
|
1387 | 1387 | # curses causes problems on many terminals other than xterm. |
|
1388 | 1388 | use_curses = 0 |
|
1389 | 1389 | if use_curses: |
|
1390 | 1390 | scr = curses.initscr() |
|
1391 | 1391 | screen_lines_real,screen_cols = scr.getmaxyx() |
|
1392 | 1392 | curses.endwin() |
|
1393 | 1393 | screen_lines += screen_lines_real |
|
1394 | 1394 | #print '***Screen size:',screen_lines_real,'lines x',\ |
|
1395 | 1395 | #screen_cols,'columns.' # dbg |
|
1396 | 1396 | else: |
|
1397 | 1397 | screen_lines += screen_lines_def |
|
1398 | 1398 | |
|
1399 | 1399 | #print 'numlines',numlines,'screenlines',screen_lines # dbg |
|
1400 | 1400 | if numlines <= screen_lines : |
|
1401 | 1401 | #print '*** normal print' # dbg |
|
1402 | 1402 | print >>Term.cout, str_toprint |
|
1403 | 1403 | else: |
|
1404 | 1404 | # Try to open pager and default to internal one if that fails. |
|
1405 | 1405 | # All failure modes are tagged as 'retval=1', to match the return |
|
1406 | 1406 | # value of a failed system command. If any intermediate attempt |
|
1407 | 1407 | # sets retval to 1, at the end we resort to our own page_dumb() pager. |
|
1408 | 1408 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1409 | 1409 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1410 | 1410 | if os.name == 'nt': |
|
1411 | 1411 | if pager_cmd.startswith('type'): |
|
1412 | 1412 | # The default WinXP 'type' command is failing on complex strings. |
|
1413 | 1413 | retval = 1 |
|
1414 | 1414 | else: |
|
1415 | 1415 | tmpname = tempfile.mktemp('.txt') |
|
1416 | 1416 | tmpfile = file(tmpname,'wt') |
|
1417 | 1417 | tmpfile.write(strng) |
|
1418 | 1418 | tmpfile.close() |
|
1419 | 1419 | cmd = "%s < %s" % (pager_cmd,tmpname) |
|
1420 | 1420 | if os.system(cmd): |
|
1421 | 1421 | retval = 1 |
|
1422 | 1422 | else: |
|
1423 | 1423 | retval = None |
|
1424 | 1424 | os.remove(tmpname) |
|
1425 | 1425 | else: |
|
1426 | 1426 | try: |
|
1427 | 1427 | retval = None |
|
1428 | 1428 | # if I use popen4, things hang. No idea why. |
|
1429 | 1429 | #pager,shell_out = os.popen4(pager_cmd) |
|
1430 | 1430 | pager = os.popen(pager_cmd,'w') |
|
1431 | 1431 | pager.write(strng) |
|
1432 | 1432 | pager.close() |
|
1433 | 1433 | retval = pager.close() # success returns None |
|
1434 | 1434 | except IOError,msg: # broken pipe when user quits |
|
1435 | 1435 | if msg.args == (32,'Broken pipe'): |
|
1436 | 1436 | retval = None |
|
1437 | 1437 | else: |
|
1438 | 1438 | retval = 1 |
|
1439 | 1439 | except OSError: |
|
1440 | 1440 | # Other strange problems, sometimes seen in Win2k/cygwin |
|
1441 | 1441 | retval = 1 |
|
1442 | 1442 | if retval is not None: |
|
1443 | 1443 | page_dumb(strng,screen_lines=screen_lines) |
|
1444 | 1444 | |
|
1445 | 1445 | #---------------------------------------------------------------------------- |
|
1446 | 1446 | def page_file(fname,start = 0, pager_cmd = None): |
|
1447 | 1447 | """Page a file, using an optional pager command and starting line. |
|
1448 | 1448 | """ |
|
1449 | 1449 | |
|
1450 | 1450 | pager_cmd = get_pager_cmd(pager_cmd) |
|
1451 | 1451 | pager_cmd += ' ' + get_pager_start(pager_cmd,start) |
|
1452 | 1452 | |
|
1453 | 1453 | try: |
|
1454 | 1454 | if os.environ['TERM'] in ['emacs','dumb']: |
|
1455 | 1455 | raise EnvironmentError |
|
1456 | 1456 | xsys(pager_cmd + ' ' + fname) |
|
1457 | 1457 | except: |
|
1458 | 1458 | try: |
|
1459 | 1459 | if start > 0: |
|
1460 | 1460 | start -= 1 |
|
1461 | 1461 | page(open(fname).read(),start) |
|
1462 | 1462 | except: |
|
1463 | 1463 | print 'Unable to show file',`fname` |
|
1464 | 1464 | |
|
1465 | 1465 | #---------------------------------------------------------------------------- |
|
1466 | 1466 | def snip_print(str,width = 75,print_full = 0,header = ''): |
|
1467 | 1467 | """Print a string snipping the midsection to fit in width. |
|
1468 | 1468 | |
|
1469 | 1469 | print_full: mode control: |
|
1470 | 1470 | - 0: only snip long strings |
|
1471 | 1471 | - 1: send to page() directly. |
|
1472 | 1472 | - 2: snip long strings and ask for full length viewing with page() |
|
1473 | 1473 | Return 1 if snipping was necessary, 0 otherwise.""" |
|
1474 | 1474 | |
|
1475 | 1475 | if print_full == 1: |
|
1476 | 1476 | page(header+str) |
|
1477 | 1477 | return 0 |
|
1478 | 1478 | |
|
1479 | 1479 | print header, |
|
1480 | 1480 | if len(str) < width: |
|
1481 | 1481 | print str |
|
1482 | 1482 | snip = 0 |
|
1483 | 1483 | else: |
|
1484 | 1484 | whalf = int((width -5)/2) |
|
1485 | 1485 | print str[:whalf] + ' <...> ' + str[-whalf:] |
|
1486 | 1486 | snip = 1 |
|
1487 | 1487 | if snip and print_full == 2: |
|
1488 | 1488 | if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y': |
|
1489 | 1489 | page(str) |
|
1490 | 1490 | return snip |
|
1491 | 1491 | |
|
1492 | 1492 | #**************************************************************************** |
|
1493 | 1493 | # lists, dicts and structures |
|
1494 | 1494 | |
|
1495 | 1495 | def belong(candidates,checklist): |
|
1496 | 1496 | """Check whether a list of items appear in a given list of options. |
|
1497 | 1497 | |
|
1498 | 1498 | Returns a list of 1 and 0, one for each candidate given.""" |
|
1499 | 1499 | |
|
1500 | 1500 | return [x in checklist for x in candidates] |
|
1501 | 1501 | |
|
1502 | 1502 | #---------------------------------------------------------------------------- |
|
1503 | 1503 | def uniq_stable(elems): |
|
1504 | 1504 | """uniq_stable(elems) -> list |
|
1505 | 1505 | |
|
1506 | 1506 | Return from an iterable, a list of all the unique elements in the input, |
|
1507 | 1507 | but maintaining the order in which they first appear. |
|
1508 | 1508 | |
|
1509 | 1509 | A naive solution to this problem which just makes a dictionary with the |
|
1510 | 1510 | elements as keys fails to respect the stability condition, since |
|
1511 | 1511 | dictionaries are unsorted by nature. |
|
1512 | 1512 | |
|
1513 | 1513 | Note: All elements in the input must be valid dictionary keys for this |
|
1514 | 1514 | routine to work, as it internally uses a dictionary for efficiency |
|
1515 | 1515 | reasons.""" |
|
1516 | 1516 | |
|
1517 | 1517 | unique = [] |
|
1518 | 1518 | unique_dict = {} |
|
1519 | 1519 | for nn in elems: |
|
1520 | 1520 | if nn not in unique_dict: |
|
1521 | 1521 | unique.append(nn) |
|
1522 | 1522 | unique_dict[nn] = None |
|
1523 | 1523 | return unique |
|
1524 | 1524 | |
|
1525 | 1525 | #---------------------------------------------------------------------------- |
|
1526 | 1526 | class NLprinter: |
|
1527 | 1527 | """Print an arbitrarily nested list, indicating index numbers. |
|
1528 | 1528 | |
|
1529 | 1529 | An instance of this class called nlprint is available and callable as a |
|
1530 | 1530 | function. |
|
1531 | 1531 | |
|
1532 | 1532 | nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' |
|
1533 | 1533 | and using 'sep' to separate the index from the value. """ |
|
1534 | 1534 | |
|
1535 | 1535 | def __init__(self): |
|
1536 | 1536 | self.depth = 0 |
|
1537 | 1537 | |
|
1538 | 1538 | def __call__(self,lst,pos='',**kw): |
|
1539 | 1539 | """Prints the nested list numbering levels.""" |
|
1540 | 1540 | kw.setdefault('indent',' ') |
|
1541 | 1541 | kw.setdefault('sep',': ') |
|
1542 | 1542 | kw.setdefault('start',0) |
|
1543 | 1543 | kw.setdefault('stop',len(lst)) |
|
1544 | 1544 | # we need to remove start and stop from kw so they don't propagate |
|
1545 | 1545 | # into a recursive call for a nested list. |
|
1546 | 1546 | start = kw['start']; del kw['start'] |
|
1547 | 1547 | stop = kw['stop']; del kw['stop'] |
|
1548 | 1548 | if self.depth == 0 and 'header' in kw.keys(): |
|
1549 | 1549 | print kw['header'] |
|
1550 | 1550 | |
|
1551 | 1551 | for idx in range(start,stop): |
|
1552 | 1552 | elem = lst[idx] |
|
1553 | 1553 | if type(elem)==type([]): |
|
1554 | 1554 | self.depth += 1 |
|
1555 | 1555 | self.__call__(elem,itpl('$pos$idx,'),**kw) |
|
1556 | 1556 | self.depth -= 1 |
|
1557 | 1557 | else: |
|
1558 | 1558 | printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem') |
|
1559 | 1559 | |
|
1560 | 1560 | nlprint = NLprinter() |
|
1561 | 1561 | #---------------------------------------------------------------------------- |
|
1562 | 1562 | def all_belong(candidates,checklist): |
|
1563 | 1563 | """Check whether a list of items ALL appear in a given list of options. |
|
1564 | 1564 | |
|
1565 | 1565 | Returns a single 1 or 0 value.""" |
|
1566 | 1566 | |
|
1567 | 1567 | return 1-(0 in [x in checklist for x in candidates]) |
|
1568 | 1568 | |
|
1569 | 1569 | #---------------------------------------------------------------------------- |
|
1570 | 1570 | def sort_compare(lst1,lst2,inplace = 1): |
|
1571 | 1571 | """Sort and compare two lists. |
|
1572 | 1572 | |
|
1573 | 1573 | By default it does it in place, thus modifying the lists. Use inplace = 0 |
|
1574 | 1574 | to avoid that (at the cost of temporary copy creation).""" |
|
1575 | 1575 | if not inplace: |
|
1576 | 1576 | lst1 = lst1[:] |
|
1577 | 1577 | lst2 = lst2[:] |
|
1578 | 1578 | lst1.sort(); lst2.sort() |
|
1579 | 1579 | return lst1 == lst2 |
|
1580 | 1580 | |
|
1581 | 1581 | #---------------------------------------------------------------------------- |
|
1582 | 1582 | def mkdict(**kwargs): |
|
1583 | 1583 | """Return a dict from a keyword list. |
|
1584 | 1584 | |
|
1585 | 1585 | It's just syntactic sugar for making ditcionary creation more convenient: |
|
1586 | 1586 | # the standard way |
|
1587 | 1587 | >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 } |
|
1588 | 1588 | # a cleaner way |
|
1589 | 1589 | >>>data = dict(red=1, green=2, blue=3) |
|
1590 | 1590 | |
|
1591 | 1591 | If you need more than this, look at the Struct() class.""" |
|
1592 | 1592 | |
|
1593 | 1593 | return kwargs |
|
1594 | 1594 | |
|
1595 | 1595 | #---------------------------------------------------------------------------- |
|
1596 | 1596 | def list2dict(lst): |
|
1597 | 1597 | """Takes a list of (key,value) pairs and turns it into a dict.""" |
|
1598 | 1598 | |
|
1599 | 1599 | dic = {} |
|
1600 | 1600 | for k,v in lst: dic[k] = v |
|
1601 | 1601 | return dic |
|
1602 | 1602 | |
|
1603 | 1603 | #---------------------------------------------------------------------------- |
|
1604 | 1604 | def list2dict2(lst,default=''): |
|
1605 | 1605 | """Takes a list and turns it into a dict. |
|
1606 | 1606 | Much slower than list2dict, but more versatile. This version can take |
|
1607 | 1607 | lists with sublists of arbitrary length (including sclars).""" |
|
1608 | 1608 | |
|
1609 | 1609 | dic = {} |
|
1610 | 1610 | for elem in lst: |
|
1611 | 1611 | if type(elem) in (types.ListType,types.TupleType): |
|
1612 | 1612 | size = len(elem) |
|
1613 | 1613 | if size == 0: |
|
1614 | 1614 | pass |
|
1615 | 1615 | elif size == 1: |
|
1616 | 1616 | dic[elem] = default |
|
1617 | 1617 | else: |
|
1618 | 1618 | k,v = elem[0], elem[1:] |
|
1619 | 1619 | if len(v) == 1: v = v[0] |
|
1620 | 1620 | dic[k] = v |
|
1621 | 1621 | else: |
|
1622 | 1622 | dic[elem] = default |
|
1623 | 1623 | return dic |
|
1624 | 1624 | |
|
1625 | 1625 | #---------------------------------------------------------------------------- |
|
1626 | 1626 | def flatten(seq): |
|
1627 | 1627 | """Flatten a list of lists (NOT recursive, only works for 2d lists).""" |
|
1628 | 1628 | |
|
1629 | 1629 | return [x for subseq in seq for x in subseq] |
|
1630 | 1630 | |
|
1631 | 1631 | #---------------------------------------------------------------------------- |
|
1632 | 1632 | def get_slice(seq,start=0,stop=None,step=1): |
|
1633 | 1633 | """Get a slice of a sequence with variable step. Specify start,stop,step.""" |
|
1634 | 1634 | if stop == None: |
|
1635 | 1635 | stop = len(seq) |
|
1636 | 1636 | item = lambda i: seq[i] |
|
1637 | 1637 | return map(item,xrange(start,stop,step)) |
|
1638 | 1638 | |
|
1639 | 1639 | #---------------------------------------------------------------------------- |
|
1640 | 1640 | def chop(seq,size): |
|
1641 | 1641 | """Chop a sequence into chunks of the given size.""" |
|
1642 | 1642 | chunk = lambda i: seq[i:i+size] |
|
1643 | 1643 | return map(chunk,xrange(0,len(seq),size)) |
|
1644 | 1644 | |
|
1645 | 1645 | #---------------------------------------------------------------------------- |
|
1646 | 1646 | # with is a keyword as of python 2.5, so this function is renamed to withobj |
|
1647 | 1647 | # from its old 'with' name. |
|
1648 | 1648 | def with_obj(object, **args): |
|
1649 | 1649 | """Set multiple attributes for an object, similar to Pascal's with. |
|
1650 | 1650 | |
|
1651 | 1651 | Example: |
|
1652 | 1652 | with_obj(jim, |
|
1653 | 1653 | born = 1960, |
|
1654 | 1654 | haircolour = 'Brown', |
|
1655 | 1655 | eyecolour = 'Green') |
|
1656 | 1656 | |
|
1657 | 1657 | Credit: Greg Ewing, in |
|
1658 | 1658 | http://mail.python.org/pipermail/python-list/2001-May/040703.html. |
|
1659 | 1659 | |
|
1660 | 1660 | NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with' |
|
1661 | 1661 | has become a keyword for Python 2.5, so we had to rename it.""" |
|
1662 | 1662 | |
|
1663 | 1663 | object.__dict__.update(args) |
|
1664 | 1664 | |
|
1665 | 1665 | #---------------------------------------------------------------------------- |
|
1666 | 1666 | def setattr_list(obj,alist,nspace = None): |
|
1667 | 1667 | """Set a list of attributes for an object taken from a namespace. |
|
1668 | 1668 | |
|
1669 | 1669 | setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in |
|
1670 | 1670 | alist with their values taken from nspace, which must be a dict (something |
|
1671 | 1671 | like locals() will often do) If nspace isn't given, locals() of the |
|
1672 | 1672 | *caller* is used, so in most cases you can omit it. |
|
1673 | 1673 | |
|
1674 | 1674 | Note that alist can be given as a string, which will be automatically |
|
1675 | 1675 | split into a list on whitespace. If given as a list, it must be a list of |
|
1676 | 1676 | *strings* (the variable names themselves), not of variables.""" |
|
1677 | 1677 | |
|
1678 | 1678 | # this grabs the local variables from the *previous* call frame -- that is |
|
1679 | 1679 | # the locals from the function that called setattr_list(). |
|
1680 | 1680 | # - snipped from weave.inline() |
|
1681 | 1681 | if nspace is None: |
|
1682 | 1682 | call_frame = sys._getframe().f_back |
|
1683 | 1683 | nspace = call_frame.f_locals |
|
1684 | 1684 | |
|
1685 | 1685 | if type(alist) in StringTypes: |
|
1686 | 1686 | alist = alist.split() |
|
1687 | 1687 | for attr in alist: |
|
1688 | 1688 | val = eval(attr,nspace) |
|
1689 | 1689 | setattr(obj,attr,val) |
|
1690 | 1690 | |
|
1691 | 1691 | #---------------------------------------------------------------------------- |
|
1692 | 1692 | def getattr_list(obj,alist,*args): |
|
1693 | 1693 | """getattr_list(obj,alist[, default]) -> attribute list. |
|
1694 | 1694 | |
|
1695 | 1695 | Get a list of named attributes for an object. When a default argument is |
|
1696 | 1696 | given, it is returned when the attribute doesn't exist; without it, an |
|
1697 | 1697 | exception is raised in that case. |
|
1698 | 1698 | |
|
1699 | 1699 | Note that alist can be given as a string, which will be automatically |
|
1700 | 1700 | split into a list on whitespace. If given as a list, it must be a list of |
|
1701 | 1701 | *strings* (the variable names themselves), not of variables.""" |
|
1702 | 1702 | |
|
1703 | 1703 | if type(alist) in StringTypes: |
|
1704 | 1704 | alist = alist.split() |
|
1705 | 1705 | if args: |
|
1706 | 1706 | if len(args)==1: |
|
1707 | 1707 | default = args[0] |
|
1708 | 1708 | return map(lambda attr: getattr(obj,attr,default),alist) |
|
1709 | 1709 | else: |
|
1710 | 1710 | raise ValueError,'getattr_list() takes only one optional argument' |
|
1711 | 1711 | else: |
|
1712 | 1712 | return map(lambda attr: getattr(obj,attr),alist) |
|
1713 | 1713 | |
|
1714 | 1714 | #---------------------------------------------------------------------------- |
|
1715 | 1715 | def map_method(method,object_list,*argseq,**kw): |
|
1716 | 1716 | """map_method(method,object_list,*args,**kw) -> list |
|
1717 | 1717 | |
|
1718 | 1718 | Return a list of the results of applying the methods to the items of the |
|
1719 | 1719 | argument sequence(s). If more than one sequence is given, the method is |
|
1720 | 1720 | called with an argument list consisting of the corresponding item of each |
|
1721 | 1721 | sequence. All sequences must be of the same length. |
|
1722 | 1722 | |
|
1723 | 1723 | Keyword arguments are passed verbatim to all objects called. |
|
1724 | 1724 | |
|
1725 | 1725 | This is Python code, so it's not nearly as fast as the builtin map().""" |
|
1726 | 1726 | |
|
1727 | 1727 | out_list = [] |
|
1728 | 1728 | idx = 0 |
|
1729 | 1729 | for object in object_list: |
|
1730 | 1730 | try: |
|
1731 | 1731 | handler = getattr(object, method) |
|
1732 | 1732 | except AttributeError: |
|
1733 | 1733 | out_list.append(None) |
|
1734 | 1734 | else: |
|
1735 | 1735 | if argseq: |
|
1736 | 1736 | args = map(lambda lst:lst[idx],argseq) |
|
1737 | 1737 | #print 'ob',object,'hand',handler,'ar',args # dbg |
|
1738 | 1738 | out_list.append(handler(args,**kw)) |
|
1739 | 1739 | else: |
|
1740 | 1740 | out_list.append(handler(**kw)) |
|
1741 | 1741 | idx += 1 |
|
1742 | 1742 | return out_list |
|
1743 | 1743 | |
|
1744 | 1744 | #---------------------------------------------------------------------------- |
|
1745 | 1745 | def get_class_members(cls): |
|
1746 | 1746 | ret = dir(cls) |
|
1747 | 1747 | if hasattr(cls,'__bases__'): |
|
1748 | 1748 | for base in cls.__bases__: |
|
1749 | 1749 | ret.extend(get_class_members(base)) |
|
1750 | 1750 | return ret |
|
1751 | 1751 | |
|
1752 | 1752 | #---------------------------------------------------------------------------- |
|
1753 | 1753 | def dir2(obj): |
|
1754 | 1754 | """dir2(obj) -> list of strings |
|
1755 | 1755 | |
|
1756 | 1756 | Extended version of the Python builtin dir(), which does a few extra |
|
1757 | 1757 | checks, and supports common objects with unusual internals that confuse |
|
1758 | 1758 | dir(), such as Traits and PyCrust. |
|
1759 | 1759 | |
|
1760 | 1760 | This version is guaranteed to return only a list of true strings, whereas |
|
1761 | 1761 | dir() returns anything that objects inject into themselves, even if they |
|
1762 | 1762 | are later not really valid for attribute access (many extension libraries |
|
1763 | 1763 | have such bugs). |
|
1764 | 1764 | """ |
|
1765 | 1765 | |
|
1766 | 1766 | # Start building the attribute list via dir(), and then complete it |
|
1767 | 1767 | # with a few extra special-purpose calls. |
|
1768 | 1768 | words = dir(obj) |
|
1769 | 1769 | |
|
1770 | 1770 | if hasattr(obj,'__class__'): |
|
1771 | 1771 | words.append('__class__') |
|
1772 | 1772 | words.extend(get_class_members(obj.__class__)) |
|
1773 | 1773 | #if '__base__' in words: 1/0 |
|
1774 | 1774 | |
|
1775 | 1775 | # Some libraries (such as traits) may introduce duplicates, we want to |
|
1776 | 1776 | # track and clean this up if it happens |
|
1777 | 1777 | may_have_dupes = False |
|
1778 | 1778 | |
|
1779 | 1779 | # this is the 'dir' function for objects with Enthought's traits |
|
1780 | 1780 | if hasattr(obj, 'trait_names'): |
|
1781 | 1781 | try: |
|
1782 | 1782 | words.extend(obj.trait_names()) |
|
1783 | 1783 | may_have_dupes = True |
|
1784 | 1784 | except TypeError: |
|
1785 | 1785 | # This will happen if `obj` is a class and not an instance. |
|
1786 | 1786 | pass |
|
1787 | 1787 | |
|
1788 | 1788 | # Support for PyCrust-style _getAttributeNames magic method. |
|
1789 | 1789 | if hasattr(obj, '_getAttributeNames'): |
|
1790 | 1790 | try: |
|
1791 | 1791 | words.extend(obj._getAttributeNames()) |
|
1792 | 1792 | may_have_dupes = True |
|
1793 | 1793 | except TypeError: |
|
1794 | 1794 | # `obj` is a class and not an instance. Ignore |
|
1795 | 1795 | # this error. |
|
1796 | 1796 | pass |
|
1797 | 1797 | |
|
1798 | 1798 | if may_have_dupes: |
|
1799 | 1799 | # eliminate possible duplicates, as some traits may also |
|
1800 | 1800 | # appear as normal attributes in the dir() call. |
|
1801 | 1801 | words = list(set(words)) |
|
1802 | 1802 | words.sort() |
|
1803 | 1803 | |
|
1804 | 1804 | # filter out non-string attributes which may be stuffed by dir() calls |
|
1805 | 1805 | # and poor coding in third-party modules |
|
1806 | 1806 | return [w for w in words if isinstance(w, basestring)] |
|
1807 | 1807 | |
|
1808 | 1808 | #---------------------------------------------------------------------------- |
|
1809 | 1809 | def import_fail_info(mod_name,fns=None): |
|
1810 | 1810 | """Inform load failure for a module.""" |
|
1811 | 1811 | |
|
1812 | 1812 | if fns == None: |
|
1813 | 1813 | warn("Loading of %s failed.\n" % (mod_name,)) |
|
1814 | 1814 | else: |
|
1815 | 1815 | warn("Loading of %s from %s failed.\n" % (fns,mod_name)) |
|
1816 | 1816 | |
|
1817 | 1817 | #---------------------------------------------------------------------------- |
|
1818 | 1818 | # Proposed popitem() extension, written as a method |
|
1819 | 1819 | |
|
1820 | 1820 | |
|
1821 | 1821 | class NotGiven: pass |
|
1822 | 1822 | |
|
1823 | 1823 | def popkey(dct,key,default=NotGiven): |
|
1824 | 1824 | """Return dct[key] and delete dct[key]. |
|
1825 | 1825 | |
|
1826 | 1826 | If default is given, return it if dct[key] doesn't exist, otherwise raise |
|
1827 | 1827 | KeyError. """ |
|
1828 | 1828 | |
|
1829 | 1829 | try: |
|
1830 | 1830 | val = dct[key] |
|
1831 | 1831 | except KeyError: |
|
1832 | 1832 | if default is NotGiven: |
|
1833 | 1833 | raise |
|
1834 | 1834 | else: |
|
1835 | 1835 | return default |
|
1836 | 1836 | else: |
|
1837 | 1837 | del dct[key] |
|
1838 | 1838 | return val |
|
1839 | 1839 | |
|
1840 | 1840 | def wrap_deprecated(func, suggest = '<nothing>'): |
|
1841 | 1841 | def newFunc(*args, **kwargs): |
|
1842 | 1842 | warnings.warn("Call to deprecated function %s, use %s instead" % |
|
1843 | 1843 | ( func.__name__, suggest), |
|
1844 | 1844 | category=DeprecationWarning, |
|
1845 | 1845 | stacklevel = 2) |
|
1846 | 1846 | return func(*args, **kwargs) |
|
1847 | 1847 | return newFunc |
|
1848 | 1848 | |
|
1849 | 1849 | #*************************** end of file <genutils.py> ********************** |
|
1850 | 1850 |
@@ -1,2471 +1,2475 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | IPython -- An enhanced Interactive Python |
|
4 | 4 | |
|
5 | 5 | Requires Python 2.3 or newer. |
|
6 | 6 | |
|
7 | 7 | This file contains all the classes and helper functions specific to IPython. |
|
8 | 8 | |
|
9 |
$Id: iplib.py 257 |
|
|
9 | $Id: iplib.py 2577 2007-08-02 23:50:02Z fperez $ | |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | #***************************************************************************** |
|
13 | 13 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
14 | 14 | # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu> |
|
15 | 15 | # |
|
16 | 16 | # Distributed under the terms of the BSD License. The full license is in |
|
17 | 17 | # the file COPYING, distributed as part of this software. |
|
18 | 18 | # |
|
19 | 19 | # Note: this code originally subclassed code.InteractiveConsole from the |
|
20 | 20 | # Python standard library. Over time, all of that class has been copied |
|
21 | 21 | # verbatim here for modifications which could not be accomplished by |
|
22 | 22 | # subclassing. At this point, there are no dependencies at all on the code |
|
23 | 23 | # module anymore (it is not even imported). The Python License (sec. 2) |
|
24 | 24 | # allows for this, but it's always nice to acknowledge credit where credit is |
|
25 | 25 | # due. |
|
26 | 26 | #***************************************************************************** |
|
27 | 27 | |
|
28 | 28 | #**************************************************************************** |
|
29 | 29 | # Modules and globals |
|
30 | 30 | |
|
31 | 31 | from IPython import Release |
|
32 | 32 | __author__ = '%s <%s>\n%s <%s>' % \ |
|
33 | 33 | ( Release.authors['Janko'] + Release.authors['Fernando'] ) |
|
34 | 34 | __license__ = Release.license |
|
35 | 35 | __version__ = Release.version |
|
36 | 36 | |
|
37 | 37 | # Python standard modules |
|
38 | 38 | import __main__ |
|
39 | 39 | import __builtin__ |
|
40 | 40 | import StringIO |
|
41 | 41 | import bdb |
|
42 | 42 | import cPickle as pickle |
|
43 | 43 | import codeop |
|
44 | 44 | import exceptions |
|
45 | 45 | import glob |
|
46 | 46 | import inspect |
|
47 | 47 | import keyword |
|
48 | 48 | import new |
|
49 | 49 | import os |
|
50 | 50 | import pydoc |
|
51 | 51 | import re |
|
52 | 52 | import shutil |
|
53 | 53 | import string |
|
54 | 54 | import sys |
|
55 | 55 | import tempfile |
|
56 | 56 | import traceback |
|
57 | 57 | import types |
|
58 | 58 | import pickleshare |
|
59 | 59 | from sets import Set |
|
60 | 60 | from pprint import pprint, pformat |
|
61 | 61 | |
|
62 | 62 | # IPython's own modules |
|
63 | 63 | #import IPython |
|
64 | 64 | from IPython import Debugger,OInspect,PyColorize,ultraTB |
|
65 | 65 | from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names |
|
66 | 66 | from IPython.FakeModule import FakeModule |
|
67 | 67 | from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns |
|
68 | 68 | from IPython.Logger import Logger |
|
69 | 69 | from IPython.Magic import Magic |
|
70 | 70 | from IPython.Prompts import CachedOutput |
|
71 | 71 | from IPython.ipstruct import Struct |
|
72 | 72 | from IPython.background_jobs import BackgroundJobManager |
|
73 | 73 | from IPython.usage import cmd_line_usage,interactive_usage |
|
74 | 74 | from IPython.genutils import * |
|
75 | 75 | from IPython.strdispatch import StrDispatch |
|
76 | 76 | import IPython.ipapi |
|
77 | 77 | import IPython.history |
|
78 | 78 | import IPython.prefilter as prefilter |
|
79 | 79 | import IPython.shadowns |
|
80 | 80 | # Globals |
|
81 | 81 | |
|
82 | 82 | # store the builtin raw_input globally, and use this always, in case user code |
|
83 | 83 | # overwrites it (like wx.py.PyShell does) |
|
84 | 84 | raw_input_original = raw_input |
|
85 | 85 | |
|
86 | 86 | # compiled regexps for autoindent management |
|
87 | 87 | dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass') |
|
88 | 88 | |
|
89 | 89 | |
|
90 | 90 | #**************************************************************************** |
|
91 | 91 | # Some utility function definitions |
|
92 | 92 | |
|
93 | 93 | ini_spaces_re = re.compile(r'^(\s+)') |
|
94 | 94 | |
|
95 | 95 | def num_ini_spaces(strng): |
|
96 | 96 | """Return the number of initial spaces in a string""" |
|
97 | 97 | |
|
98 | 98 | ini_spaces = ini_spaces_re.match(strng) |
|
99 | 99 | if ini_spaces: |
|
100 | 100 | return ini_spaces.end() |
|
101 | 101 | else: |
|
102 | 102 | return 0 |
|
103 | 103 | |
|
104 | 104 | def softspace(file, newvalue): |
|
105 | 105 | """Copied from code.py, to remove the dependency""" |
|
106 | 106 | |
|
107 | 107 | oldvalue = 0 |
|
108 | 108 | try: |
|
109 | 109 | oldvalue = file.softspace |
|
110 | 110 | except AttributeError: |
|
111 | 111 | pass |
|
112 | 112 | try: |
|
113 | 113 | file.softspace = newvalue |
|
114 | 114 | except (AttributeError, TypeError): |
|
115 | 115 | # "attribute-less object" or "read-only attributes" |
|
116 | 116 | pass |
|
117 | 117 | return oldvalue |
|
118 | 118 | |
|
119 | 119 | |
|
120 | 120 | #**************************************************************************** |
|
121 | 121 | # Local use exceptions |
|
122 | 122 | class SpaceInInput(exceptions.Exception): pass |
|
123 | 123 | |
|
124 | 124 | |
|
125 | 125 | #**************************************************************************** |
|
126 | 126 | # Local use classes |
|
127 | 127 | class Bunch: pass |
|
128 | 128 | |
|
129 | 129 | class Undefined: pass |
|
130 | 130 | |
|
131 | 131 | class Quitter(object): |
|
132 | 132 | """Simple class to handle exit, similar to Python 2.5's. |
|
133 | 133 | |
|
134 | 134 | It handles exiting in an ipython-safe manner, which the one in Python 2.5 |
|
135 | 135 | doesn't do (obviously, since it doesn't know about ipython).""" |
|
136 | 136 | |
|
137 | 137 | def __init__(self,shell,name): |
|
138 | 138 | self.shell = shell |
|
139 | 139 | self.name = name |
|
140 | 140 | |
|
141 | 141 | def __repr__(self): |
|
142 | 142 | return 'Type %s() to exit.' % self.name |
|
143 | 143 | __str__ = __repr__ |
|
144 | 144 | |
|
145 | 145 | def __call__(self): |
|
146 | 146 | self.shell.exit() |
|
147 | 147 | |
|
148 | 148 | class InputList(list): |
|
149 | 149 | """Class to store user input. |
|
150 | 150 | |
|
151 | 151 | It's basically a list, but slices return a string instead of a list, thus |
|
152 | 152 | allowing things like (assuming 'In' is an instance): |
|
153 | 153 | |
|
154 | 154 | exec In[4:7] |
|
155 | 155 | |
|
156 | 156 | or |
|
157 | 157 | |
|
158 | 158 | exec In[5:9] + In[14] + In[21:25]""" |
|
159 | 159 | |
|
160 | 160 | def __getslice__(self,i,j): |
|
161 | 161 | return ''.join(list.__getslice__(self,i,j)) |
|
162 | 162 | |
|
163 | 163 | class SyntaxTB(ultraTB.ListTB): |
|
164 | 164 | """Extension which holds some state: the last exception value""" |
|
165 | 165 | |
|
166 | 166 | def __init__(self,color_scheme = 'NoColor'): |
|
167 | 167 | ultraTB.ListTB.__init__(self,color_scheme) |
|
168 | 168 | self.last_syntax_error = None |
|
169 | 169 | |
|
170 | 170 | def __call__(self, etype, value, elist): |
|
171 | 171 | self.last_syntax_error = value |
|
172 | 172 | ultraTB.ListTB.__call__(self,etype,value,elist) |
|
173 | 173 | |
|
174 | 174 | def clear_err_state(self): |
|
175 | 175 | """Return the current error state and clear it""" |
|
176 | 176 | e = self.last_syntax_error |
|
177 | 177 | self.last_syntax_error = None |
|
178 | 178 | return e |
|
179 | 179 | |
|
180 | 180 | #**************************************************************************** |
|
181 | 181 | # Main IPython class |
|
182 | 182 | |
|
183 | 183 | # FIXME: the Magic class is a mixin for now, and will unfortunately remain so |
|
184 | 184 | # until a full rewrite is made. I've cleaned all cross-class uses of |
|
185 | 185 | # attributes and methods, but too much user code out there relies on the |
|
186 | 186 | # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage. |
|
187 | 187 | # |
|
188 | 188 | # But at least now, all the pieces have been separated and we could, in |
|
189 | 189 | # principle, stop using the mixin. This will ease the transition to the |
|
190 | 190 | # chainsaw branch. |
|
191 | 191 | |
|
192 | 192 | # For reference, the following is the list of 'self.foo' uses in the Magic |
|
193 | 193 | # class as of 2005-12-28. These are names we CAN'T use in the main ipython |
|
194 | 194 | # class, to prevent clashes. |
|
195 | 195 | |
|
196 | 196 | # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind', |
|
197 | 197 | # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic', |
|
198 | 198 | # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell', |
|
199 | 199 | # 'self.value'] |
|
200 | 200 | |
|
201 | 201 | class InteractiveShell(object,Magic): |
|
202 | 202 | """An enhanced console for Python.""" |
|
203 | 203 | |
|
204 | 204 | # class attribute to indicate whether the class supports threads or not. |
|
205 | 205 | # Subclasses with thread support should override this as needed. |
|
206 | 206 | isthreaded = False |
|
207 | 207 | |
|
208 | 208 | def __init__(self,name,usage=None,rc=Struct(opts=None,args=None), |
|
209 | 209 | user_ns = None,user_global_ns=None,banner2='', |
|
210 | 210 | custom_exceptions=((),None),embedded=False): |
|
211 | 211 | |
|
212 | 212 | # log system |
|
213 | 213 | self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate') |
|
214 | 214 | |
|
215 | 215 | # some minimal strict typechecks. For some core data structures, I |
|
216 | 216 | # want actual basic python types, not just anything that looks like |
|
217 | 217 | # one. This is especially true for namespaces. |
|
218 | 218 | for ns in (user_ns,user_global_ns): |
|
219 | 219 | if ns is not None and type(ns) != types.DictType: |
|
220 | 220 | raise TypeError,'namespace must be a dictionary' |
|
221 | 221 | |
|
222 | 222 | # Job manager (for jobs run as background threads) |
|
223 | 223 | self.jobs = BackgroundJobManager() |
|
224 | 224 | |
|
225 | 225 | # Store the actual shell's name |
|
226 | 226 | self.name = name |
|
227 | 227 | |
|
228 | 228 | # We need to know whether the instance is meant for embedding, since |
|
229 | 229 | # global/local namespaces need to be handled differently in that case |
|
230 | 230 | self.embedded = embedded |
|
231 | if embedded: | |
|
232 | # Control variable so users can, from within the embedded instance, | |
|
233 | # permanently deactivate it. | |
|
234 | self.embedded_active = True | |
|
231 | 235 | |
|
232 | 236 | # command compiler |
|
233 | 237 | self.compile = codeop.CommandCompiler() |
|
234 | 238 | |
|
235 | 239 | # User input buffer |
|
236 | 240 | self.buffer = [] |
|
237 | 241 | |
|
238 | 242 | # Default name given in compilation of code |
|
239 | 243 | self.filename = '<ipython console>' |
|
240 | 244 | |
|
241 | 245 | # Install our own quitter instead of the builtins. For python2.3-2.4, |
|
242 | 246 | # this brings in behavior like 2.5, and for 2.5 it's identical. |
|
243 | 247 | __builtin__.exit = Quitter(self,'exit') |
|
244 | 248 | __builtin__.quit = Quitter(self,'quit') |
|
245 | 249 | |
|
246 | 250 | # Make an empty namespace, which extension writers can rely on both |
|
247 | 251 | # existing and NEVER being used by ipython itself. This gives them a |
|
248 | 252 | # convenient location for storing additional information and state |
|
249 | 253 | # their extensions may require, without fear of collisions with other |
|
250 | 254 | # ipython names that may develop later. |
|
251 | 255 | self.meta = Struct() |
|
252 | 256 | |
|
253 | 257 | # Create the namespace where the user will operate. user_ns is |
|
254 | 258 | # normally the only one used, and it is passed to the exec calls as |
|
255 | 259 | # the locals argument. But we do carry a user_global_ns namespace |
|
256 | 260 | # given as the exec 'globals' argument, This is useful in embedding |
|
257 | 261 | # situations where the ipython shell opens in a context where the |
|
258 | 262 | # distinction between locals and globals is meaningful. |
|
259 | 263 | |
|
260 | 264 | # FIXME. For some strange reason, __builtins__ is showing up at user |
|
261 | 265 | # level as a dict instead of a module. This is a manual fix, but I |
|
262 | 266 | # should really track down where the problem is coming from. Alex |
|
263 | 267 | # Schmolck reported this problem first. |
|
264 | 268 | |
|
265 | 269 | # A useful post by Alex Martelli on this topic: |
|
266 | 270 | # Re: inconsistent value from __builtins__ |
|
267 | 271 | # Von: Alex Martelli <aleaxit@yahoo.com> |
|
268 | 272 | # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends |
|
269 | 273 | # Gruppen: comp.lang.python |
|
270 | 274 | |
|
271 | 275 | # Michael Hohn <hohn@hooknose.lbl.gov> wrote: |
|
272 | 276 | # > >>> print type(builtin_check.get_global_binding('__builtins__')) |
|
273 | 277 | # > <type 'dict'> |
|
274 | 278 | # > >>> print type(__builtins__) |
|
275 | 279 | # > <type 'module'> |
|
276 | 280 | # > Is this difference in return value intentional? |
|
277 | 281 | |
|
278 | 282 | # Well, it's documented that '__builtins__' can be either a dictionary |
|
279 | 283 | # or a module, and it's been that way for a long time. Whether it's |
|
280 | 284 | # intentional (or sensible), I don't know. In any case, the idea is |
|
281 | 285 | # that if you need to access the built-in namespace directly, you |
|
282 | 286 | # should start with "import __builtin__" (note, no 's') which will |
|
283 | 287 | # definitely give you a module. Yeah, it's somewhat confusing:-(. |
|
284 | 288 | |
|
285 | 289 | # These routines return properly built dicts as needed by the rest of |
|
286 | 290 | # the code, and can also be used by extension writers to generate |
|
287 | 291 | # properly initialized namespaces. |
|
288 | 292 | user_ns = IPython.ipapi.make_user_ns(user_ns) |
|
289 | 293 | user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns) |
|
290 | 294 | |
|
291 | 295 | # Assign namespaces |
|
292 | 296 | # This is the namespace where all normal user variables live |
|
293 | 297 | self.user_ns = user_ns |
|
294 | 298 | # Embedded instances require a separate namespace for globals. |
|
295 | 299 | # Normally this one is unused by non-embedded instances. |
|
296 | 300 | self.user_global_ns = user_global_ns |
|
297 | 301 | # A namespace to keep track of internal data structures to prevent |
|
298 | 302 | # them from cluttering user-visible stuff. Will be updated later |
|
299 | 303 | self.internal_ns = {} |
|
300 | 304 | |
|
301 | 305 | # Namespace of system aliases. Each entry in the alias |
|
302 | 306 | # table must be a 2-tuple of the form (N,name), where N is the number |
|
303 | 307 | # of positional arguments of the alias. |
|
304 | 308 | self.alias_table = {} |
|
305 | 309 | |
|
306 | 310 | # A table holding all the namespaces IPython deals with, so that |
|
307 | 311 | # introspection facilities can search easily. |
|
308 | 312 | self.ns_table = {'user':user_ns, |
|
309 | 313 | 'user_global':user_global_ns, |
|
310 | 314 | 'alias':self.alias_table, |
|
311 | 315 | 'internal':self.internal_ns, |
|
312 | 316 | 'builtin':__builtin__.__dict__ |
|
313 | 317 | } |
|
314 | 318 | |
|
315 | 319 | # The user namespace MUST have a pointer to the shell itself. |
|
316 | 320 | self.user_ns[name] = self |
|
317 | 321 | |
|
318 | 322 | # We need to insert into sys.modules something that looks like a |
|
319 | 323 | # module but which accesses the IPython namespace, for shelve and |
|
320 | 324 | # pickle to work interactively. Normally they rely on getting |
|
321 | 325 | # everything out of __main__, but for embedding purposes each IPython |
|
322 | 326 | # instance has its own private namespace, so we can't go shoving |
|
323 | 327 | # everything into __main__. |
|
324 | 328 | |
|
325 | 329 | # note, however, that we should only do this for non-embedded |
|
326 | 330 | # ipythons, which really mimic the __main__.__dict__ with their own |
|
327 | 331 | # namespace. Embedded instances, on the other hand, should not do |
|
328 | 332 | # this because they need to manage the user local/global namespaces |
|
329 | 333 | # only, but they live within a 'normal' __main__ (meaning, they |
|
330 | 334 | # shouldn't overtake the execution environment of the script they're |
|
331 | 335 | # embedded in). |
|
332 | 336 | |
|
333 | 337 | if not embedded: |
|
334 | 338 | try: |
|
335 | 339 | main_name = self.user_ns['__name__'] |
|
336 | 340 | except KeyError: |
|
337 | 341 | raise KeyError,'user_ns dictionary MUST have a "__name__" key' |
|
338 | 342 | else: |
|
339 | 343 | #print "pickle hack in place" # dbg |
|
340 | 344 | #print 'main_name:',main_name # dbg |
|
341 | 345 | sys.modules[main_name] = FakeModule(self.user_ns) |
|
342 | 346 | |
|
343 | 347 | # List of input with multi-line handling. |
|
344 | 348 | # Fill its zero entry, user counter starts at 1 |
|
345 | 349 | self.input_hist = InputList(['\n']) |
|
346 | 350 | # This one will hold the 'raw' input history, without any |
|
347 | 351 | # pre-processing. This will allow users to retrieve the input just as |
|
348 | 352 | # it was exactly typed in by the user, with %hist -r. |
|
349 | 353 | self.input_hist_raw = InputList(['\n']) |
|
350 | 354 | |
|
351 | 355 | # list of visited directories |
|
352 | 356 | try: |
|
353 | 357 | self.dir_hist = [os.getcwd()] |
|
354 | 358 | except OSError: |
|
355 | 359 | self.dir_hist = [] |
|
356 | 360 | |
|
357 | 361 | # dict of output history |
|
358 | 362 | self.output_hist = {} |
|
359 | 363 | |
|
360 | 364 | # Get system encoding at startup time. Certain terminals (like Emacs |
|
361 | 365 | # under Win32 have it set to None, and we need to have a known valid |
|
362 | 366 | # encoding to use in the raw_input() method |
|
363 | 367 | self.stdin_encoding = sys.stdin.encoding or 'ascii' |
|
364 | 368 | |
|
365 | 369 | # dict of things NOT to alias (keywords, builtins and some magics) |
|
366 | 370 | no_alias = {} |
|
367 | 371 | no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias'] |
|
368 | 372 | for key in keyword.kwlist + no_alias_magics: |
|
369 | 373 | no_alias[key] = 1 |
|
370 | 374 | no_alias.update(__builtin__.__dict__) |
|
371 | 375 | self.no_alias = no_alias |
|
372 | 376 | |
|
373 | 377 | # make global variables for user access to these |
|
374 | 378 | self.user_ns['_ih'] = self.input_hist |
|
375 | 379 | self.user_ns['_oh'] = self.output_hist |
|
376 | 380 | self.user_ns['_dh'] = self.dir_hist |
|
377 | 381 | |
|
378 | 382 | # user aliases to input and output histories |
|
379 | 383 | self.user_ns['In'] = self.input_hist |
|
380 | 384 | self.user_ns['Out'] = self.output_hist |
|
381 | 385 | |
|
382 | 386 | self.user_ns['_sh'] = IPython.shadowns |
|
383 | 387 | # Object variable to store code object waiting execution. This is |
|
384 | 388 | # used mainly by the multithreaded shells, but it can come in handy in |
|
385 | 389 | # other situations. No need to use a Queue here, since it's a single |
|
386 | 390 | # item which gets cleared once run. |
|
387 | 391 | self.code_to_run = None |
|
388 | 392 | |
|
389 | 393 | # escapes for automatic behavior on the command line |
|
390 | 394 | self.ESC_SHELL = '!' |
|
391 | 395 | self.ESC_SH_CAP = '!!' |
|
392 | 396 | self.ESC_HELP = '?' |
|
393 | 397 | self.ESC_MAGIC = '%' |
|
394 | 398 | self.ESC_QUOTE = ',' |
|
395 | 399 | self.ESC_QUOTE2 = ';' |
|
396 | 400 | self.ESC_PAREN = '/' |
|
397 | 401 | |
|
398 | 402 | # And their associated handlers |
|
399 | 403 | self.esc_handlers = {self.ESC_PAREN : self.handle_auto, |
|
400 | 404 | self.ESC_QUOTE : self.handle_auto, |
|
401 | 405 | self.ESC_QUOTE2 : self.handle_auto, |
|
402 | 406 | self.ESC_MAGIC : self.handle_magic, |
|
403 | 407 | self.ESC_HELP : self.handle_help, |
|
404 | 408 | self.ESC_SHELL : self.handle_shell_escape, |
|
405 | 409 | self.ESC_SH_CAP : self.handle_shell_escape, |
|
406 | 410 | } |
|
407 | 411 | |
|
408 | 412 | # class initializations |
|
409 | 413 | Magic.__init__(self,self) |
|
410 | 414 | |
|
411 | 415 | # Python source parser/formatter for syntax highlighting |
|
412 | 416 | pyformat = PyColorize.Parser().format |
|
413 | 417 | self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors']) |
|
414 | 418 | |
|
415 | 419 | # hooks holds pointers used for user-side customizations |
|
416 | 420 | self.hooks = Struct() |
|
417 | 421 | |
|
418 | 422 | self.strdispatchers = {} |
|
419 | 423 | |
|
420 | 424 | # Set all default hooks, defined in the IPython.hooks module. |
|
421 | 425 | hooks = IPython.hooks |
|
422 | 426 | for hook_name in hooks.__all__: |
|
423 | 427 | # default hooks have priority 100, i.e. low; user hooks should have |
|
424 | 428 | # 0-100 priority |
|
425 | 429 | self.set_hook(hook_name,getattr(hooks,hook_name), 100) |
|
426 | 430 | #print "bound hook",hook_name |
|
427 | 431 | |
|
428 | 432 | # Flag to mark unconditional exit |
|
429 | 433 | self.exit_now = False |
|
430 | 434 | |
|
431 | 435 | self.usage_min = """\ |
|
432 | 436 | An enhanced console for Python. |
|
433 | 437 | Some of its features are: |
|
434 | 438 | - Readline support if the readline library is present. |
|
435 | 439 | - Tab completion in the local namespace. |
|
436 | 440 | - Logging of input, see command-line options. |
|
437 | 441 | - System shell escape via ! , eg !ls. |
|
438 | 442 | - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.) |
|
439 | 443 | - Keeps track of locally defined variables via %who, %whos. |
|
440 | 444 | - Show object information with a ? eg ?x or x? (use ?? for more info). |
|
441 | 445 | """ |
|
442 | 446 | if usage: self.usage = usage |
|
443 | 447 | else: self.usage = self.usage_min |
|
444 | 448 | |
|
445 | 449 | # Storage |
|
446 | 450 | self.rc = rc # This will hold all configuration information |
|
447 | 451 | self.pager = 'less' |
|
448 | 452 | # temporary files used for various purposes. Deleted at exit. |
|
449 | 453 | self.tempfiles = [] |
|
450 | 454 | |
|
451 | 455 | # Keep track of readline usage (later set by init_readline) |
|
452 | 456 | self.has_readline = False |
|
453 | 457 | |
|
454 | 458 | # template for logfile headers. It gets resolved at runtime by the |
|
455 | 459 | # logstart method. |
|
456 | 460 | self.loghead_tpl = \ |
|
457 | 461 | """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE *** |
|
458 | 462 | #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW |
|
459 | 463 | #log# opts = %s |
|
460 | 464 | #log# args = %s |
|
461 | 465 | #log# It is safe to make manual edits below here. |
|
462 | 466 | #log#----------------------------------------------------------------------- |
|
463 | 467 | """ |
|
464 | 468 | # for pushd/popd management |
|
465 | 469 | try: |
|
466 | 470 | self.home_dir = get_home_dir() |
|
467 | 471 | except HomeDirError,msg: |
|
468 | 472 | fatal(msg) |
|
469 | 473 | |
|
470 | 474 | self.dir_stack = [os.getcwd().replace(self.home_dir,'~')] |
|
471 | 475 | |
|
472 | 476 | # Functions to call the underlying shell. |
|
473 | 477 | |
|
474 | 478 | # The first is similar to os.system, but it doesn't return a value, |
|
475 | 479 | # and it allows interpolation of variables in the user's namespace. |
|
476 | 480 | self.system = lambda cmd: \ |
|
477 | 481 | shell(self.var_expand(cmd,depth=2), |
|
478 | 482 | header=self.rc.system_header, |
|
479 | 483 | verbose=self.rc.system_verbose) |
|
480 | 484 | |
|
481 | 485 | # These are for getoutput and getoutputerror: |
|
482 | 486 | self.getoutput = lambda cmd: \ |
|
483 | 487 | getoutput(self.var_expand(cmd,depth=2), |
|
484 | 488 | header=self.rc.system_header, |
|
485 | 489 | verbose=self.rc.system_verbose) |
|
486 | 490 | |
|
487 | 491 | self.getoutputerror = lambda cmd: \ |
|
488 | 492 | getoutputerror(self.var_expand(cmd,depth=2), |
|
489 | 493 | header=self.rc.system_header, |
|
490 | 494 | verbose=self.rc.system_verbose) |
|
491 | 495 | |
|
492 | 496 | |
|
493 | 497 | # keep track of where we started running (mainly for crash post-mortem) |
|
494 | 498 | self.starting_dir = os.getcwd() |
|
495 | 499 | |
|
496 | 500 | # Various switches which can be set |
|
497 | 501 | self.CACHELENGTH = 5000 # this is cheap, it's just text |
|
498 | 502 | self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__ |
|
499 | 503 | self.banner2 = banner2 |
|
500 | 504 | |
|
501 | 505 | # TraceBack handlers: |
|
502 | 506 | |
|
503 | 507 | # Syntax error handler. |
|
504 | 508 | self.SyntaxTB = SyntaxTB(color_scheme='NoColor') |
|
505 | 509 | |
|
506 | 510 | # The interactive one is initialized with an offset, meaning we always |
|
507 | 511 | # want to remove the topmost item in the traceback, which is our own |
|
508 | 512 | # internal code. Valid modes: ['Plain','Context','Verbose'] |
|
509 | 513 | self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain', |
|
510 | 514 | color_scheme='NoColor', |
|
511 | 515 | tb_offset = 1) |
|
512 | 516 | |
|
513 | 517 | # IPython itself shouldn't crash. This will produce a detailed |
|
514 | 518 | # post-mortem if it does. But we only install the crash handler for |
|
515 | 519 | # non-threaded shells, the threaded ones use a normal verbose reporter |
|
516 | 520 | # and lose the crash handler. This is because exceptions in the main |
|
517 | 521 | # thread (such as in GUI code) propagate directly to sys.excepthook, |
|
518 | 522 | # and there's no point in printing crash dumps for every user exception. |
|
519 | 523 | if self.isthreaded: |
|
520 | 524 | ipCrashHandler = ultraTB.FormattedTB() |
|
521 | 525 | else: |
|
522 | 526 | from IPython import CrashHandler |
|
523 | 527 | ipCrashHandler = CrashHandler.IPythonCrashHandler(self) |
|
524 | 528 | self.set_crash_handler(ipCrashHandler) |
|
525 | 529 | |
|
526 | 530 | # and add any custom exception handlers the user may have specified |
|
527 | 531 | self.set_custom_exc(*custom_exceptions) |
|
528 | 532 | |
|
529 | 533 | # indentation management |
|
530 | 534 | self.autoindent = False |
|
531 | 535 | self.indent_current_nsp = 0 |
|
532 | 536 | |
|
533 | 537 | # Make some aliases automatically |
|
534 | 538 | # Prepare list of shell aliases to auto-define |
|
535 | 539 | if os.name == 'posix': |
|
536 | 540 | auto_alias = ('mkdir mkdir', 'rmdir rmdir', |
|
537 | 541 | 'mv mv -i','rm rm -i','cp cp -i', |
|
538 | 542 | 'cat cat','less less','clear clear', |
|
539 | 543 | # a better ls |
|
540 | 544 | 'ls ls -F', |
|
541 | 545 | # long ls |
|
542 | 546 | 'll ls -lF') |
|
543 | 547 | # Extra ls aliases with color, which need special treatment on BSD |
|
544 | 548 | # variants |
|
545 | 549 | ls_extra = ( # color ls |
|
546 | 550 | 'lc ls -F -o --color', |
|
547 | 551 | # ls normal files only |
|
548 | 552 | 'lf ls -F -o --color %l | grep ^-', |
|
549 | 553 | # ls symbolic links |
|
550 | 554 | 'lk ls -F -o --color %l | grep ^l', |
|
551 | 555 | # directories or links to directories, |
|
552 | 556 | 'ldir ls -F -o --color %l | grep /$', |
|
553 | 557 | # things which are executable |
|
554 | 558 | 'lx ls -F -o --color %l | grep ^-..x', |
|
555 | 559 | ) |
|
556 | 560 | # The BSDs don't ship GNU ls, so they don't understand the |
|
557 | 561 | # --color switch out of the box |
|
558 | 562 | if 'bsd' in sys.platform: |
|
559 | 563 | ls_extra = ( # ls normal files only |
|
560 | 564 | 'lf ls -lF | grep ^-', |
|
561 | 565 | # ls symbolic links |
|
562 | 566 | 'lk ls -lF | grep ^l', |
|
563 | 567 | # directories or links to directories, |
|
564 | 568 | 'ldir ls -lF | grep /$', |
|
565 | 569 | # things which are executable |
|
566 | 570 | 'lx ls -lF | grep ^-..x', |
|
567 | 571 | ) |
|
568 | 572 | auto_alias = auto_alias + ls_extra |
|
569 | 573 | elif os.name in ['nt','dos']: |
|
570 | 574 | auto_alias = ('dir dir /on', 'ls dir /on', |
|
571 | 575 | 'ddir dir /ad /on', 'ldir dir /ad /on', |
|
572 | 576 | 'mkdir mkdir','rmdir rmdir','echo echo', |
|
573 | 577 | 'ren ren','cls cls','copy copy') |
|
574 | 578 | else: |
|
575 | 579 | auto_alias = () |
|
576 | 580 | self.auto_alias = [s.split(None,1) for s in auto_alias] |
|
577 | 581 | # Call the actual (public) initializer |
|
578 | 582 | self.init_auto_alias() |
|
579 | 583 | |
|
580 | 584 | # Produce a public API instance |
|
581 | 585 | self.api = IPython.ipapi.IPApi(self) |
|
582 | 586 | |
|
583 | 587 | # track which builtins we add, so we can clean up later |
|
584 | 588 | self.builtins_added = {} |
|
585 | 589 | # This method will add the necessary builtins for operation, but |
|
586 | 590 | # tracking what it did via the builtins_added dict. |
|
587 | 591 | self.add_builtins() |
|
588 | 592 | |
|
589 | 593 | # end __init__ |
|
590 | 594 | |
|
591 | 595 | def var_expand(self,cmd,depth=0): |
|
592 | 596 | """Expand python variables in a string. |
|
593 | 597 | |
|
594 | 598 | The depth argument indicates how many frames above the caller should |
|
595 | 599 | be walked to look for the local namespace where to expand variables. |
|
596 | 600 | |
|
597 | 601 | The global namespace for expansion is always the user's interactive |
|
598 | 602 | namespace. |
|
599 | 603 | """ |
|
600 | 604 | |
|
601 | 605 | return str(ItplNS(cmd.replace('#','\#'), |
|
602 | 606 | self.user_ns, # globals |
|
603 | 607 | # Skip our own frame in searching for locals: |
|
604 | 608 | sys._getframe(depth+1).f_locals # locals |
|
605 | 609 | )) |
|
606 | 610 | |
|
607 | 611 | def pre_config_initialization(self): |
|
608 | 612 | """Pre-configuration init method |
|
609 | 613 | |
|
610 | 614 | This is called before the configuration files are processed to |
|
611 | 615 | prepare the services the config files might need. |
|
612 | 616 | |
|
613 | 617 | self.rc already has reasonable default values at this point. |
|
614 | 618 | """ |
|
615 | 619 | rc = self.rc |
|
616 | 620 | try: |
|
617 | 621 | self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db") |
|
618 | 622 | except exceptions.UnicodeDecodeError: |
|
619 | 623 | print "Your ipythondir can't be decoded to unicode!" |
|
620 | 624 | print "Please set HOME environment variable to something that" |
|
621 | 625 | print r"only has ASCII characters, e.g. c:\home" |
|
622 | 626 | print "Now it is",rc.ipythondir |
|
623 | 627 | sys.exit() |
|
624 | 628 | self.shadowhist = IPython.history.ShadowHist(self.db) |
|
625 | 629 | |
|
626 | 630 | |
|
627 | 631 | def post_config_initialization(self): |
|
628 | 632 | """Post configuration init method |
|
629 | 633 | |
|
630 | 634 | This is called after the configuration files have been processed to |
|
631 | 635 | 'finalize' the initialization.""" |
|
632 | 636 | |
|
633 | 637 | rc = self.rc |
|
634 | 638 | |
|
635 | 639 | # Object inspector |
|
636 | 640 | self.inspector = OInspect.Inspector(OInspect.InspectColors, |
|
637 | 641 | PyColorize.ANSICodeColors, |
|
638 | 642 | 'NoColor', |
|
639 | 643 | rc.object_info_string_level) |
|
640 | 644 | |
|
641 | 645 | self.rl_next_input = None |
|
642 | 646 | self.rl_do_indent = False |
|
643 | 647 | # Load readline proper |
|
644 | 648 | if rc.readline: |
|
645 | 649 | self.init_readline() |
|
646 | 650 | |
|
647 | 651 | |
|
648 | 652 | # local shortcut, this is used a LOT |
|
649 | 653 | self.log = self.logger.log |
|
650 | 654 | |
|
651 | 655 | # Initialize cache, set in/out prompts and printing system |
|
652 | 656 | self.outputcache = CachedOutput(self, |
|
653 | 657 | rc.cache_size, |
|
654 | 658 | rc.pprint, |
|
655 | 659 | input_sep = rc.separate_in, |
|
656 | 660 | output_sep = rc.separate_out, |
|
657 | 661 | output_sep2 = rc.separate_out2, |
|
658 | 662 | ps1 = rc.prompt_in1, |
|
659 | 663 | ps2 = rc.prompt_in2, |
|
660 | 664 | ps_out = rc.prompt_out, |
|
661 | 665 | pad_left = rc.prompts_pad_left) |
|
662 | 666 | |
|
663 | 667 | # user may have over-ridden the default print hook: |
|
664 | 668 | try: |
|
665 | 669 | self.outputcache.__class__.display = self.hooks.display |
|
666 | 670 | except AttributeError: |
|
667 | 671 | pass |
|
668 | 672 | |
|
669 | 673 | # I don't like assigning globally to sys, because it means when |
|
670 | 674 | # embedding instances, each embedded instance overrides the previous |
|
671 | 675 | # choice. But sys.displayhook seems to be called internally by exec, |
|
672 | 676 | # so I don't see a way around it. We first save the original and then |
|
673 | 677 | # overwrite it. |
|
674 | 678 | self.sys_displayhook = sys.displayhook |
|
675 | 679 | sys.displayhook = self.outputcache |
|
676 | 680 | |
|
677 | 681 | # Set user colors (don't do it in the constructor above so that it |
|
678 | 682 | # doesn't crash if colors option is invalid) |
|
679 | 683 | self.magic_colors(rc.colors) |
|
680 | 684 | |
|
681 | 685 | # Set calling of pdb on exceptions |
|
682 | 686 | self.call_pdb = rc.pdb |
|
683 | 687 | |
|
684 | 688 | # Load user aliases |
|
685 | 689 | for alias in rc.alias: |
|
686 | 690 | self.magic_alias(alias) |
|
687 | 691 | self.hooks.late_startup_hook() |
|
688 | 692 | |
|
689 | 693 | batchrun = False |
|
690 | 694 | for batchfile in [path(arg) for arg in self.rc.args |
|
691 | 695 | if arg.lower().endswith('.ipy')]: |
|
692 | 696 | if not batchfile.isfile(): |
|
693 | 697 | print "No such batch file:", batchfile |
|
694 | 698 | continue |
|
695 | 699 | self.api.runlines(batchfile.text()) |
|
696 | 700 | batchrun = True |
|
697 | 701 | if batchrun: |
|
698 | 702 | self.exit_now = True |
|
699 | 703 | |
|
700 | 704 | def add_builtins(self): |
|
701 | 705 | """Store ipython references into the builtin namespace. |
|
702 | 706 | |
|
703 | 707 | Some parts of ipython operate via builtins injected here, which hold a |
|
704 | 708 | reference to IPython itself.""" |
|
705 | 709 | |
|
706 | 710 | # TODO: deprecate all except _ip; 'jobs' should be installed |
|
707 | 711 | # by an extension and the rest are under _ip, ipalias is redundant |
|
708 | 712 | builtins_new = dict(__IPYTHON__ = self, |
|
709 | 713 | ip_set_hook = self.set_hook, |
|
710 | 714 | jobs = self.jobs, |
|
711 | 715 | ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'), |
|
712 | 716 | ipalias = wrap_deprecated(self.ipalias), |
|
713 | 717 | ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'), |
|
714 | 718 | _ip = self.api |
|
715 | 719 | ) |
|
716 | 720 | for biname,bival in builtins_new.items(): |
|
717 | 721 | try: |
|
718 | 722 | # store the orignal value so we can restore it |
|
719 | 723 | self.builtins_added[biname] = __builtin__.__dict__[biname] |
|
720 | 724 | except KeyError: |
|
721 | 725 | # or mark that it wasn't defined, and we'll just delete it at |
|
722 | 726 | # cleanup |
|
723 | 727 | self.builtins_added[biname] = Undefined |
|
724 | 728 | __builtin__.__dict__[biname] = bival |
|
725 | 729 | |
|
726 | 730 | # Keep in the builtins a flag for when IPython is active. We set it |
|
727 | 731 | # with setdefault so that multiple nested IPythons don't clobber one |
|
728 | 732 | # another. Each will increase its value by one upon being activated, |
|
729 | 733 | # which also gives us a way to determine the nesting level. |
|
730 | 734 | __builtin__.__dict__.setdefault('__IPYTHON__active',0) |
|
731 | 735 | |
|
732 | 736 | def clean_builtins(self): |
|
733 | 737 | """Remove any builtins which might have been added by add_builtins, or |
|
734 | 738 | restore overwritten ones to their previous values.""" |
|
735 | 739 | for biname,bival in self.builtins_added.items(): |
|
736 | 740 | if bival is Undefined: |
|
737 | 741 | del __builtin__.__dict__[biname] |
|
738 | 742 | else: |
|
739 | 743 | __builtin__.__dict__[biname] = bival |
|
740 | 744 | self.builtins_added.clear() |
|
741 | 745 | |
|
742 | 746 | def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None): |
|
743 | 747 | """set_hook(name,hook) -> sets an internal IPython hook. |
|
744 | 748 | |
|
745 | 749 | IPython exposes some of its internal API as user-modifiable hooks. By |
|
746 | 750 | adding your function to one of these hooks, you can modify IPython's |
|
747 | 751 | behavior to call at runtime your own routines.""" |
|
748 | 752 | |
|
749 | 753 | # At some point in the future, this should validate the hook before it |
|
750 | 754 | # accepts it. Probably at least check that the hook takes the number |
|
751 | 755 | # of args it's supposed to. |
|
752 | 756 | |
|
753 | 757 | f = new.instancemethod(hook,self,self.__class__) |
|
754 | 758 | |
|
755 | 759 | # check if the hook is for strdispatcher first |
|
756 | 760 | if str_key is not None: |
|
757 | 761 | sdp = self.strdispatchers.get(name, StrDispatch()) |
|
758 | 762 | sdp.add_s(str_key, f, priority ) |
|
759 | 763 | self.strdispatchers[name] = sdp |
|
760 | 764 | return |
|
761 | 765 | if re_key is not None: |
|
762 | 766 | sdp = self.strdispatchers.get(name, StrDispatch()) |
|
763 | 767 | sdp.add_re(re.compile(re_key), f, priority ) |
|
764 | 768 | self.strdispatchers[name] = sdp |
|
765 | 769 | return |
|
766 | 770 | |
|
767 | 771 | dp = getattr(self.hooks, name, None) |
|
768 | 772 | if name not in IPython.hooks.__all__: |
|
769 | 773 | print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ ) |
|
770 | 774 | if not dp: |
|
771 | 775 | dp = IPython.hooks.CommandChainDispatcher() |
|
772 | 776 | |
|
773 | 777 | try: |
|
774 | 778 | dp.add(f,priority) |
|
775 | 779 | except AttributeError: |
|
776 | 780 | # it was not commandchain, plain old func - replace |
|
777 | 781 | dp = f |
|
778 | 782 | |
|
779 | 783 | setattr(self.hooks,name, dp) |
|
780 | 784 | |
|
781 | 785 | |
|
782 | 786 | #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__)) |
|
783 | 787 | |
|
784 | 788 | def set_crash_handler(self,crashHandler): |
|
785 | 789 | """Set the IPython crash handler. |
|
786 | 790 | |
|
787 | 791 | This must be a callable with a signature suitable for use as |
|
788 | 792 | sys.excepthook.""" |
|
789 | 793 | |
|
790 | 794 | # Install the given crash handler as the Python exception hook |
|
791 | 795 | sys.excepthook = crashHandler |
|
792 | 796 | |
|
793 | 797 | # The instance will store a pointer to this, so that runtime code |
|
794 | 798 | # (such as magics) can access it. This is because during the |
|
795 | 799 | # read-eval loop, it gets temporarily overwritten (to deal with GUI |
|
796 | 800 | # frameworks). |
|
797 | 801 | self.sys_excepthook = sys.excepthook |
|
798 | 802 | |
|
799 | 803 | |
|
800 | 804 | def set_custom_exc(self,exc_tuple,handler): |
|
801 | 805 | """set_custom_exc(exc_tuple,handler) |
|
802 | 806 | |
|
803 | 807 | Set a custom exception handler, which will be called if any of the |
|
804 | 808 | exceptions in exc_tuple occur in the mainloop (specifically, in the |
|
805 | 809 | runcode() method. |
|
806 | 810 | |
|
807 | 811 | Inputs: |
|
808 | 812 | |
|
809 | 813 | - exc_tuple: a *tuple* of valid exceptions to call the defined |
|
810 | 814 | handler for. It is very important that you use a tuple, and NOT A |
|
811 | 815 | LIST here, because of the way Python's except statement works. If |
|
812 | 816 | you only want to trap a single exception, use a singleton tuple: |
|
813 | 817 | |
|
814 | 818 | exc_tuple == (MyCustomException,) |
|
815 | 819 | |
|
816 | 820 | - handler: this must be defined as a function with the following |
|
817 | 821 | basic interface: def my_handler(self,etype,value,tb). |
|
818 | 822 | |
|
819 | 823 | This will be made into an instance method (via new.instancemethod) |
|
820 | 824 | of IPython itself, and it will be called if any of the exceptions |
|
821 | 825 | listed in the exc_tuple are caught. If the handler is None, an |
|
822 | 826 | internal basic one is used, which just prints basic info. |
|
823 | 827 | |
|
824 | 828 | WARNING: by putting in your own exception handler into IPython's main |
|
825 | 829 | execution loop, you run a very good chance of nasty crashes. This |
|
826 | 830 | facility should only be used if you really know what you are doing.""" |
|
827 | 831 | |
|
828 | 832 | assert type(exc_tuple)==type(()) , \ |
|
829 | 833 | "The custom exceptions must be given AS A TUPLE." |
|
830 | 834 | |
|
831 | 835 | def dummy_handler(self,etype,value,tb): |
|
832 | 836 | print '*** Simple custom exception handler ***' |
|
833 | 837 | print 'Exception type :',etype |
|
834 | 838 | print 'Exception value:',value |
|
835 | 839 | print 'Traceback :',tb |
|
836 | 840 | print 'Source code :','\n'.join(self.buffer) |
|
837 | 841 | |
|
838 | 842 | if handler is None: handler = dummy_handler |
|
839 | 843 | |
|
840 | 844 | self.CustomTB = new.instancemethod(handler,self,self.__class__) |
|
841 | 845 | self.custom_exceptions = exc_tuple |
|
842 | 846 | |
|
843 | 847 | def set_custom_completer(self,completer,pos=0): |
|
844 | 848 | """set_custom_completer(completer,pos=0) |
|
845 | 849 | |
|
846 | 850 | Adds a new custom completer function. |
|
847 | 851 | |
|
848 | 852 | The position argument (defaults to 0) is the index in the completers |
|
849 | 853 | list where you want the completer to be inserted.""" |
|
850 | 854 | |
|
851 | 855 | newcomp = new.instancemethod(completer,self.Completer, |
|
852 | 856 | self.Completer.__class__) |
|
853 | 857 | self.Completer.matchers.insert(pos,newcomp) |
|
854 | 858 | |
|
855 | 859 | def set_completer(self): |
|
856 | 860 | """reset readline's completer to be our own.""" |
|
857 | 861 | self.readline.set_completer(self.Completer.complete) |
|
858 | 862 | |
|
859 | 863 | def _get_call_pdb(self): |
|
860 | 864 | return self._call_pdb |
|
861 | 865 | |
|
862 | 866 | def _set_call_pdb(self,val): |
|
863 | 867 | |
|
864 | 868 | if val not in (0,1,False,True): |
|
865 | 869 | raise ValueError,'new call_pdb value must be boolean' |
|
866 | 870 | |
|
867 | 871 | # store value in instance |
|
868 | 872 | self._call_pdb = val |
|
869 | 873 | |
|
870 | 874 | # notify the actual exception handlers |
|
871 | 875 | self.InteractiveTB.call_pdb = val |
|
872 | 876 | if self.isthreaded: |
|
873 | 877 | try: |
|
874 | 878 | self.sys_excepthook.call_pdb = val |
|
875 | 879 | except: |
|
876 | 880 | warn('Failed to activate pdb for threaded exception handler') |
|
877 | 881 | |
|
878 | 882 | call_pdb = property(_get_call_pdb,_set_call_pdb,None, |
|
879 | 883 | 'Control auto-activation of pdb at exceptions') |
|
880 | 884 | |
|
881 | 885 | |
|
882 | 886 | # These special functions get installed in the builtin namespace, to |
|
883 | 887 | # provide programmatic (pure python) access to magics, aliases and system |
|
884 | 888 | # calls. This is important for logging, user scripting, and more. |
|
885 | 889 | |
|
886 | 890 | # We are basically exposing, via normal python functions, the three |
|
887 | 891 | # mechanisms in which ipython offers special call modes (magics for |
|
888 | 892 | # internal control, aliases for direct system access via pre-selected |
|
889 | 893 | # names, and !cmd for calling arbitrary system commands). |
|
890 | 894 | |
|
891 | 895 | def ipmagic(self,arg_s): |
|
892 | 896 | """Call a magic function by name. |
|
893 | 897 | |
|
894 | 898 | Input: a string containing the name of the magic function to call and any |
|
895 | 899 | additional arguments to be passed to the magic. |
|
896 | 900 | |
|
897 | 901 | ipmagic('name -opt foo bar') is equivalent to typing at the ipython |
|
898 | 902 | prompt: |
|
899 | 903 | |
|
900 | 904 | In[1]: %name -opt foo bar |
|
901 | 905 | |
|
902 | 906 | To call a magic without arguments, simply use ipmagic('name'). |
|
903 | 907 | |
|
904 | 908 | This provides a proper Python function to call IPython's magics in any |
|
905 | 909 | valid Python code you can type at the interpreter, including loops and |
|
906 | 910 | compound statements. It is added by IPython to the Python builtin |
|
907 | 911 | namespace upon initialization.""" |
|
908 | 912 | |
|
909 | 913 | args = arg_s.split(' ',1) |
|
910 | 914 | magic_name = args[0] |
|
911 | 915 | magic_name = magic_name.lstrip(self.ESC_MAGIC) |
|
912 | 916 | |
|
913 | 917 | try: |
|
914 | 918 | magic_args = args[1] |
|
915 | 919 | except IndexError: |
|
916 | 920 | magic_args = '' |
|
917 | 921 | fn = getattr(self,'magic_'+magic_name,None) |
|
918 | 922 | if fn is None: |
|
919 | 923 | error("Magic function `%s` not found." % magic_name) |
|
920 | 924 | else: |
|
921 | 925 | magic_args = self.var_expand(magic_args,1) |
|
922 | 926 | return fn(magic_args) |
|
923 | 927 | |
|
924 | 928 | def ipalias(self,arg_s): |
|
925 | 929 | """Call an alias by name. |
|
926 | 930 | |
|
927 | 931 | Input: a string containing the name of the alias to call and any |
|
928 | 932 | additional arguments to be passed to the magic. |
|
929 | 933 | |
|
930 | 934 | ipalias('name -opt foo bar') is equivalent to typing at the ipython |
|
931 | 935 | prompt: |
|
932 | 936 | |
|
933 | 937 | In[1]: name -opt foo bar |
|
934 | 938 | |
|
935 | 939 | To call an alias without arguments, simply use ipalias('name'). |
|
936 | 940 | |
|
937 | 941 | This provides a proper Python function to call IPython's aliases in any |
|
938 | 942 | valid Python code you can type at the interpreter, including loops and |
|
939 | 943 | compound statements. It is added by IPython to the Python builtin |
|
940 | 944 | namespace upon initialization.""" |
|
941 | 945 | |
|
942 | 946 | args = arg_s.split(' ',1) |
|
943 | 947 | alias_name = args[0] |
|
944 | 948 | try: |
|
945 | 949 | alias_args = args[1] |
|
946 | 950 | except IndexError: |
|
947 | 951 | alias_args = '' |
|
948 | 952 | if alias_name in self.alias_table: |
|
949 | 953 | self.call_alias(alias_name,alias_args) |
|
950 | 954 | else: |
|
951 | 955 | error("Alias `%s` not found." % alias_name) |
|
952 | 956 | |
|
953 | 957 | def ipsystem(self,arg_s): |
|
954 | 958 | """Make a system call, using IPython.""" |
|
955 | 959 | |
|
956 | 960 | self.system(arg_s) |
|
957 | 961 | |
|
958 | 962 | def complete(self,text): |
|
959 | 963 | """Return a sorted list of all possible completions on text. |
|
960 | 964 | |
|
961 | 965 | Inputs: |
|
962 | 966 | |
|
963 | 967 | - text: a string of text to be completed on. |
|
964 | 968 | |
|
965 | 969 | This is a wrapper around the completion mechanism, similar to what |
|
966 | 970 | readline does at the command line when the TAB key is hit. By |
|
967 | 971 | exposing it as a method, it can be used by other non-readline |
|
968 | 972 | environments (such as GUIs) for text completion. |
|
969 | 973 | |
|
970 | 974 | Simple usage example: |
|
971 | 975 | |
|
972 | 976 | In [1]: x = 'hello' |
|
973 | 977 | |
|
974 | 978 | In [2]: __IP.complete('x.l') |
|
975 | 979 | Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']""" |
|
976 | 980 | |
|
977 | 981 | complete = self.Completer.complete |
|
978 | 982 | state = 0 |
|
979 | 983 | # use a dict so we get unique keys, since ipyhton's multiple |
|
980 | 984 | # completers can return duplicates. When we make 2.4 a requirement, |
|
981 | 985 | # start using sets instead, which are faster. |
|
982 | 986 | comps = {} |
|
983 | 987 | while True: |
|
984 | 988 | newcomp = complete(text,state,line_buffer=text) |
|
985 | 989 | if newcomp is None: |
|
986 | 990 | break |
|
987 | 991 | comps[newcomp] = 1 |
|
988 | 992 | state += 1 |
|
989 | 993 | outcomps = comps.keys() |
|
990 | 994 | outcomps.sort() |
|
991 | 995 | return outcomps |
|
992 | 996 | |
|
993 | 997 | def set_completer_frame(self, frame=None): |
|
994 | 998 | if frame: |
|
995 | 999 | self.Completer.namespace = frame.f_locals |
|
996 | 1000 | self.Completer.global_namespace = frame.f_globals |
|
997 | 1001 | else: |
|
998 | 1002 | self.Completer.namespace = self.user_ns |
|
999 | 1003 | self.Completer.global_namespace = self.user_global_ns |
|
1000 | 1004 | |
|
1001 | 1005 | def init_auto_alias(self): |
|
1002 | 1006 | """Define some aliases automatically. |
|
1003 | 1007 | |
|
1004 | 1008 | These are ALL parameter-less aliases""" |
|
1005 | 1009 | |
|
1006 | 1010 | for alias,cmd in self.auto_alias: |
|
1007 | 1011 | self.alias_table[alias] = (0,cmd) |
|
1008 | 1012 | |
|
1009 | 1013 | def alias_table_validate(self,verbose=0): |
|
1010 | 1014 | """Update information about the alias table. |
|
1011 | 1015 | |
|
1012 | 1016 | In particular, make sure no Python keywords/builtins are in it.""" |
|
1013 | 1017 | |
|
1014 | 1018 | no_alias = self.no_alias |
|
1015 | 1019 | for k in self.alias_table.keys(): |
|
1016 | 1020 | if k in no_alias: |
|
1017 | 1021 | del self.alias_table[k] |
|
1018 | 1022 | if verbose: |
|
1019 | 1023 | print ("Deleting alias <%s>, it's a Python " |
|
1020 | 1024 | "keyword or builtin." % k) |
|
1021 | 1025 | |
|
1022 | 1026 | def set_autoindent(self,value=None): |
|
1023 | 1027 | """Set the autoindent flag, checking for readline support. |
|
1024 | 1028 | |
|
1025 | 1029 | If called with no arguments, it acts as a toggle.""" |
|
1026 | 1030 | |
|
1027 | 1031 | if not self.has_readline: |
|
1028 | 1032 | if os.name == 'posix': |
|
1029 | 1033 | warn("The auto-indent feature requires the readline library") |
|
1030 | 1034 | self.autoindent = 0 |
|
1031 | 1035 | return |
|
1032 | 1036 | if value is None: |
|
1033 | 1037 | self.autoindent = not self.autoindent |
|
1034 | 1038 | else: |
|
1035 | 1039 | self.autoindent = value |
|
1036 | 1040 | |
|
1037 | 1041 | def rc_set_toggle(self,rc_field,value=None): |
|
1038 | 1042 | """Set or toggle a field in IPython's rc config. structure. |
|
1039 | 1043 | |
|
1040 | 1044 | If called with no arguments, it acts as a toggle. |
|
1041 | 1045 | |
|
1042 | 1046 | If called with a non-existent field, the resulting AttributeError |
|
1043 | 1047 | exception will propagate out.""" |
|
1044 | 1048 | |
|
1045 | 1049 | rc_val = getattr(self.rc,rc_field) |
|
1046 | 1050 | if value is None: |
|
1047 | 1051 | value = not rc_val |
|
1048 | 1052 | setattr(self.rc,rc_field,value) |
|
1049 | 1053 | |
|
1050 | 1054 | def user_setup(self,ipythondir,rc_suffix,mode='install'): |
|
1051 | 1055 | """Install the user configuration directory. |
|
1052 | 1056 | |
|
1053 | 1057 | Can be called when running for the first time or to upgrade the user's |
|
1054 | 1058 | .ipython/ directory with the mode parameter. Valid modes are 'install' |
|
1055 | 1059 | and 'upgrade'.""" |
|
1056 | 1060 | |
|
1057 | 1061 | def wait(): |
|
1058 | 1062 | try: |
|
1059 | 1063 | raw_input("Please press <RETURN> to start IPython.") |
|
1060 | 1064 | except EOFError: |
|
1061 | 1065 | print >> Term.cout |
|
1062 | 1066 | print '*'*70 |
|
1063 | 1067 | |
|
1064 | 1068 | cwd = os.getcwd() # remember where we started |
|
1065 | 1069 | glb = glob.glob |
|
1066 | 1070 | print '*'*70 |
|
1067 | 1071 | if mode == 'install': |
|
1068 | 1072 | print \ |
|
1069 | 1073 | """Welcome to IPython. I will try to create a personal configuration directory |
|
1070 | 1074 | where you can customize many aspects of IPython's functionality in:\n""" |
|
1071 | 1075 | else: |
|
1072 | 1076 | print 'I am going to upgrade your configuration in:' |
|
1073 | 1077 | |
|
1074 | 1078 | print ipythondir |
|
1075 | 1079 | |
|
1076 | 1080 | rcdirend = os.path.join('IPython','UserConfig') |
|
1077 | 1081 | cfg = lambda d: os.path.join(d,rcdirend) |
|
1078 | 1082 | try: |
|
1079 | 1083 | rcdir = filter(os.path.isdir,map(cfg,sys.path))[0] |
|
1080 | 1084 | except IOError: |
|
1081 | 1085 | warning = """ |
|
1082 | 1086 | Installation error. IPython's directory was not found. |
|
1083 | 1087 | |
|
1084 | 1088 | Check the following: |
|
1085 | 1089 | |
|
1086 | 1090 | The ipython/IPython directory should be in a directory belonging to your |
|
1087 | 1091 | PYTHONPATH environment variable (that is, it should be in a directory |
|
1088 | 1092 | belonging to sys.path). You can copy it explicitly there or just link to it. |
|
1089 | 1093 | |
|
1090 | 1094 | IPython will proceed with builtin defaults. |
|
1091 | 1095 | """ |
|
1092 | 1096 | warn(warning) |
|
1093 | 1097 | wait() |
|
1094 | 1098 | return |
|
1095 | 1099 | |
|
1096 | 1100 | if mode == 'install': |
|
1097 | 1101 | try: |
|
1098 | 1102 | shutil.copytree(rcdir,ipythondir) |
|
1099 | 1103 | os.chdir(ipythondir) |
|
1100 | 1104 | rc_files = glb("ipythonrc*") |
|
1101 | 1105 | for rc_file in rc_files: |
|
1102 | 1106 | os.rename(rc_file,rc_file+rc_suffix) |
|
1103 | 1107 | except: |
|
1104 | 1108 | warning = """ |
|
1105 | 1109 | |
|
1106 | 1110 | There was a problem with the installation: |
|
1107 | 1111 | %s |
|
1108 | 1112 | Try to correct it or contact the developers if you think it's a bug. |
|
1109 | 1113 | IPython will proceed with builtin defaults.""" % sys.exc_info()[1] |
|
1110 | 1114 | warn(warning) |
|
1111 | 1115 | wait() |
|
1112 | 1116 | return |
|
1113 | 1117 | |
|
1114 | 1118 | elif mode == 'upgrade': |
|
1115 | 1119 | try: |
|
1116 | 1120 | os.chdir(ipythondir) |
|
1117 | 1121 | except: |
|
1118 | 1122 | print """ |
|
1119 | 1123 | Can not upgrade: changing to directory %s failed. Details: |
|
1120 | 1124 | %s |
|
1121 | 1125 | """ % (ipythondir,sys.exc_info()[1]) |
|
1122 | 1126 | wait() |
|
1123 | 1127 | return |
|
1124 | 1128 | else: |
|
1125 | 1129 | sources = glb(os.path.join(rcdir,'[A-Za-z]*')) |
|
1126 | 1130 | for new_full_path in sources: |
|
1127 | 1131 | new_filename = os.path.basename(new_full_path) |
|
1128 | 1132 | if new_filename.startswith('ipythonrc'): |
|
1129 | 1133 | new_filename = new_filename + rc_suffix |
|
1130 | 1134 | # The config directory should only contain files, skip any |
|
1131 | 1135 | # directories which may be there (like CVS) |
|
1132 | 1136 | if os.path.isdir(new_full_path): |
|
1133 | 1137 | continue |
|
1134 | 1138 | if os.path.exists(new_filename): |
|
1135 | 1139 | old_file = new_filename+'.old' |
|
1136 | 1140 | if os.path.exists(old_file): |
|
1137 | 1141 | os.remove(old_file) |
|
1138 | 1142 | os.rename(new_filename,old_file) |
|
1139 | 1143 | shutil.copy(new_full_path,new_filename) |
|
1140 | 1144 | else: |
|
1141 | 1145 | raise ValueError,'unrecognized mode for install:',`mode` |
|
1142 | 1146 | |
|
1143 | 1147 | # Fix line-endings to those native to each platform in the config |
|
1144 | 1148 | # directory. |
|
1145 | 1149 | try: |
|
1146 | 1150 | os.chdir(ipythondir) |
|
1147 | 1151 | except: |
|
1148 | 1152 | print """ |
|
1149 | 1153 | Problem: changing to directory %s failed. |
|
1150 | 1154 | Details: |
|
1151 | 1155 | %s |
|
1152 | 1156 | |
|
1153 | 1157 | Some configuration files may have incorrect line endings. This should not |
|
1154 | 1158 | cause any problems during execution. """ % (ipythondir,sys.exc_info()[1]) |
|
1155 | 1159 | wait() |
|
1156 | 1160 | else: |
|
1157 | 1161 | for fname in glb('ipythonrc*'): |
|
1158 | 1162 | try: |
|
1159 | 1163 | native_line_ends(fname,backup=0) |
|
1160 | 1164 | except IOError: |
|
1161 | 1165 | pass |
|
1162 | 1166 | |
|
1163 | 1167 | if mode == 'install': |
|
1164 | 1168 | print """ |
|
1165 | 1169 | Successful installation! |
|
1166 | 1170 | |
|
1167 | 1171 | Please read the sections 'Initial Configuration' and 'Quick Tips' in the |
|
1168 | 1172 | IPython manual (there are both HTML and PDF versions supplied with the |
|
1169 | 1173 | distribution) to make sure that your system environment is properly configured |
|
1170 | 1174 | to take advantage of IPython's features. |
|
1171 | 1175 | |
|
1172 | 1176 | Important note: the configuration system has changed! The old system is |
|
1173 | 1177 | still in place, but its setting may be partly overridden by the settings in |
|
1174 | 1178 | "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file |
|
1175 | 1179 | if some of the new settings bother you. |
|
1176 | 1180 | |
|
1177 | 1181 | """ |
|
1178 | 1182 | else: |
|
1179 | 1183 | print """ |
|
1180 | 1184 | Successful upgrade! |
|
1181 | 1185 | |
|
1182 | 1186 | All files in your directory: |
|
1183 | 1187 | %(ipythondir)s |
|
1184 | 1188 | which would have been overwritten by the upgrade were backed up with a .old |
|
1185 | 1189 | extension. If you had made particular customizations in those files you may |
|
1186 | 1190 | want to merge them back into the new files.""" % locals() |
|
1187 | 1191 | wait() |
|
1188 | 1192 | os.chdir(cwd) |
|
1189 | 1193 | # end user_setup() |
|
1190 | 1194 | |
|
1191 | 1195 | def atexit_operations(self): |
|
1192 | 1196 | """This will be executed at the time of exit. |
|
1193 | 1197 | |
|
1194 | 1198 | Saving of persistent data should be performed here. """ |
|
1195 | 1199 | |
|
1196 | 1200 | #print '*** IPython exit cleanup ***' # dbg |
|
1197 | 1201 | # input history |
|
1198 | 1202 | self.savehist() |
|
1199 | 1203 | |
|
1200 | 1204 | # Cleanup all tempfiles left around |
|
1201 | 1205 | for tfile in self.tempfiles: |
|
1202 | 1206 | try: |
|
1203 | 1207 | os.unlink(tfile) |
|
1204 | 1208 | except OSError: |
|
1205 | 1209 | pass |
|
1206 | 1210 | |
|
1207 | 1211 | self.hooks.shutdown_hook() |
|
1208 | 1212 | |
|
1209 | 1213 | def savehist(self): |
|
1210 | 1214 | """Save input history to a file (via readline library).""" |
|
1211 | 1215 | try: |
|
1212 | 1216 | self.readline.write_history_file(self.histfile) |
|
1213 | 1217 | except: |
|
1214 | 1218 | print 'Unable to save IPython command history to file: ' + \ |
|
1215 | 1219 | `self.histfile` |
|
1216 | 1220 | |
|
1217 | 1221 | def reloadhist(self): |
|
1218 | 1222 | """Reload the input history from disk file.""" |
|
1219 | 1223 | |
|
1220 | 1224 | if self.has_readline: |
|
1221 | 1225 | self.readline.clear_history() |
|
1222 | 1226 | self.readline.read_history_file(self.shell.histfile) |
|
1223 | 1227 | |
|
1224 | 1228 | def history_saving_wrapper(self, func): |
|
1225 | 1229 | """ Wrap func for readline history saving |
|
1226 | 1230 | |
|
1227 | 1231 | Convert func into callable that saves & restores |
|
1228 | 1232 | history around the call """ |
|
1229 | 1233 | |
|
1230 | 1234 | if not self.has_readline: |
|
1231 | 1235 | return func |
|
1232 | 1236 | |
|
1233 | 1237 | def wrapper(): |
|
1234 | 1238 | self.savehist() |
|
1235 | 1239 | try: |
|
1236 | 1240 | func() |
|
1237 | 1241 | finally: |
|
1238 | 1242 | readline.read_history_file(self.histfile) |
|
1239 | 1243 | return wrapper |
|
1240 | 1244 | |
|
1241 | 1245 | |
|
1242 | 1246 | def pre_readline(self): |
|
1243 | 1247 | """readline hook to be used at the start of each line. |
|
1244 | 1248 | |
|
1245 | 1249 | Currently it handles auto-indent only.""" |
|
1246 | 1250 | |
|
1247 | 1251 | #debugx('self.indent_current_nsp','pre_readline:') |
|
1248 | 1252 | |
|
1249 | 1253 | if self.rl_do_indent: |
|
1250 | 1254 | self.readline.insert_text(self.indent_current_str()) |
|
1251 | 1255 | if self.rl_next_input is not None: |
|
1252 | 1256 | self.readline.insert_text(self.rl_next_input) |
|
1253 | 1257 | self.rl_next_input = None |
|
1254 | 1258 | |
|
1255 | 1259 | def init_readline(self): |
|
1256 | 1260 | """Command history completion/saving/reloading.""" |
|
1257 | 1261 | |
|
1258 | 1262 | import IPython.rlineimpl as readline |
|
1259 | 1263 | if not readline.have_readline: |
|
1260 | 1264 | self.has_readline = 0 |
|
1261 | 1265 | self.readline = None |
|
1262 | 1266 | # no point in bugging windows users with this every time: |
|
1263 | 1267 | warn('Readline services not available on this platform.') |
|
1264 | 1268 | else: |
|
1265 | 1269 | sys.modules['readline'] = readline |
|
1266 | 1270 | import atexit |
|
1267 | 1271 | from IPython.completer import IPCompleter |
|
1268 | 1272 | self.Completer = IPCompleter(self, |
|
1269 | 1273 | self.user_ns, |
|
1270 | 1274 | self.user_global_ns, |
|
1271 | 1275 | self.rc.readline_omit__names, |
|
1272 | 1276 | self.alias_table) |
|
1273 | 1277 | sdisp = self.strdispatchers.get('complete_command', StrDispatch()) |
|
1274 | 1278 | self.strdispatchers['complete_command'] = sdisp |
|
1275 | 1279 | self.Completer.custom_completers = sdisp |
|
1276 | 1280 | # Platform-specific configuration |
|
1277 | 1281 | if os.name == 'nt': |
|
1278 | 1282 | self.readline_startup_hook = readline.set_pre_input_hook |
|
1279 | 1283 | else: |
|
1280 | 1284 | self.readline_startup_hook = readline.set_startup_hook |
|
1281 | 1285 | |
|
1282 | 1286 | # Load user's initrc file (readline config) |
|
1283 | 1287 | inputrc_name = os.environ.get('INPUTRC') |
|
1284 | 1288 | if inputrc_name is None: |
|
1285 | 1289 | home_dir = get_home_dir() |
|
1286 | 1290 | if home_dir is not None: |
|
1287 | 1291 | inputrc_name = os.path.join(home_dir,'.inputrc') |
|
1288 | 1292 | if os.path.isfile(inputrc_name): |
|
1289 | 1293 | try: |
|
1290 | 1294 | readline.read_init_file(inputrc_name) |
|
1291 | 1295 | except: |
|
1292 | 1296 | warn('Problems reading readline initialization file <%s>' |
|
1293 | 1297 | % inputrc_name) |
|
1294 | 1298 | |
|
1295 | 1299 | self.has_readline = 1 |
|
1296 | 1300 | self.readline = readline |
|
1297 | 1301 | # save this in sys so embedded copies can restore it properly |
|
1298 | 1302 | sys.ipcompleter = self.Completer.complete |
|
1299 | 1303 | self.set_completer() |
|
1300 | 1304 | |
|
1301 | 1305 | # Configure readline according to user's prefs |
|
1302 | 1306 | for rlcommand in self.rc.readline_parse_and_bind: |
|
1303 | 1307 | readline.parse_and_bind(rlcommand) |
|
1304 | 1308 | |
|
1305 | 1309 | # remove some chars from the delimiters list |
|
1306 | 1310 | delims = readline.get_completer_delims() |
|
1307 | 1311 | delims = delims.translate(string._idmap, |
|
1308 | 1312 | self.rc.readline_remove_delims) |
|
1309 | 1313 | readline.set_completer_delims(delims) |
|
1310 | 1314 | # otherwise we end up with a monster history after a while: |
|
1311 | 1315 | readline.set_history_length(1000) |
|
1312 | 1316 | try: |
|
1313 | 1317 | #print '*** Reading readline history' # dbg |
|
1314 | 1318 | readline.read_history_file(self.histfile) |
|
1315 | 1319 | except IOError: |
|
1316 | 1320 | pass # It doesn't exist yet. |
|
1317 | 1321 | |
|
1318 | 1322 | atexit.register(self.atexit_operations) |
|
1319 | 1323 | del atexit |
|
1320 | 1324 | |
|
1321 | 1325 | # Configure auto-indent for all platforms |
|
1322 | 1326 | self.set_autoindent(self.rc.autoindent) |
|
1323 | 1327 | |
|
1324 | 1328 | def ask_yes_no(self,prompt,default=True): |
|
1325 | 1329 | if self.rc.quiet: |
|
1326 | 1330 | return True |
|
1327 | 1331 | return ask_yes_no(prompt,default) |
|
1328 | 1332 | |
|
1329 | 1333 | def _should_recompile(self,e): |
|
1330 | 1334 | """Utility routine for edit_syntax_error""" |
|
1331 | 1335 | |
|
1332 | 1336 | if e.filename in ('<ipython console>','<input>','<string>', |
|
1333 | 1337 | '<console>','<BackgroundJob compilation>', |
|
1334 | 1338 | None): |
|
1335 | 1339 | |
|
1336 | 1340 | return False |
|
1337 | 1341 | try: |
|
1338 | 1342 | if (self.rc.autoedit_syntax and |
|
1339 | 1343 | not self.ask_yes_no('Return to editor to correct syntax error? ' |
|
1340 | 1344 | '[Y/n] ','y')): |
|
1341 | 1345 | return False |
|
1342 | 1346 | except EOFError: |
|
1343 | 1347 | return False |
|
1344 | 1348 | |
|
1345 | 1349 | def int0(x): |
|
1346 | 1350 | try: |
|
1347 | 1351 | return int(x) |
|
1348 | 1352 | except TypeError: |
|
1349 | 1353 | return 0 |
|
1350 | 1354 | # always pass integer line and offset values to editor hook |
|
1351 | 1355 | self.hooks.fix_error_editor(e.filename, |
|
1352 | 1356 | int0(e.lineno),int0(e.offset),e.msg) |
|
1353 | 1357 | return True |
|
1354 | 1358 | |
|
1355 | 1359 | def edit_syntax_error(self): |
|
1356 | 1360 | """The bottom half of the syntax error handler called in the main loop. |
|
1357 | 1361 | |
|
1358 | 1362 | Loop until syntax error is fixed or user cancels. |
|
1359 | 1363 | """ |
|
1360 | 1364 | |
|
1361 | 1365 | while self.SyntaxTB.last_syntax_error: |
|
1362 | 1366 | # copy and clear last_syntax_error |
|
1363 | 1367 | err = self.SyntaxTB.clear_err_state() |
|
1364 | 1368 | if not self._should_recompile(err): |
|
1365 | 1369 | return |
|
1366 | 1370 | try: |
|
1367 | 1371 | # may set last_syntax_error again if a SyntaxError is raised |
|
1368 | 1372 | self.safe_execfile(err.filename,self.user_ns) |
|
1369 | 1373 | except: |
|
1370 | 1374 | self.showtraceback() |
|
1371 | 1375 | else: |
|
1372 | 1376 | try: |
|
1373 | 1377 | f = file(err.filename) |
|
1374 | 1378 | try: |
|
1375 | 1379 | sys.displayhook(f.read()) |
|
1376 | 1380 | finally: |
|
1377 | 1381 | f.close() |
|
1378 | 1382 | except: |
|
1379 | 1383 | self.showtraceback() |
|
1380 | 1384 | |
|
1381 | 1385 | def showsyntaxerror(self, filename=None): |
|
1382 | 1386 | """Display the syntax error that just occurred. |
|
1383 | 1387 | |
|
1384 | 1388 | This doesn't display a stack trace because there isn't one. |
|
1385 | 1389 | |
|
1386 | 1390 | If a filename is given, it is stuffed in the exception instead |
|
1387 | 1391 | of what was there before (because Python's parser always uses |
|
1388 | 1392 | "<string>" when reading from a string). |
|
1389 | 1393 | """ |
|
1390 | 1394 | etype, value, last_traceback = sys.exc_info() |
|
1391 | 1395 | |
|
1392 | 1396 | # See note about these variables in showtraceback() below |
|
1393 | 1397 | sys.last_type = etype |
|
1394 | 1398 | sys.last_value = value |
|
1395 | 1399 | sys.last_traceback = last_traceback |
|
1396 | 1400 | |
|
1397 | 1401 | if filename and etype is SyntaxError: |
|
1398 | 1402 | # Work hard to stuff the correct filename in the exception |
|
1399 | 1403 | try: |
|
1400 | 1404 | msg, (dummy_filename, lineno, offset, line) = value |
|
1401 | 1405 | except: |
|
1402 | 1406 | # Not the format we expect; leave it alone |
|
1403 | 1407 | pass |
|
1404 | 1408 | else: |
|
1405 | 1409 | # Stuff in the right filename |
|
1406 | 1410 | try: |
|
1407 | 1411 | # Assume SyntaxError is a class exception |
|
1408 | 1412 | value = SyntaxError(msg, (filename, lineno, offset, line)) |
|
1409 | 1413 | except: |
|
1410 | 1414 | # If that failed, assume SyntaxError is a string |
|
1411 | 1415 | value = msg, (filename, lineno, offset, line) |
|
1412 | 1416 | self.SyntaxTB(etype,value,[]) |
|
1413 | 1417 | |
|
1414 | 1418 | def debugger(self,force=False): |
|
1415 | 1419 | """Call the pydb/pdb debugger. |
|
1416 | 1420 | |
|
1417 | 1421 | Keywords: |
|
1418 | 1422 | |
|
1419 | 1423 | - force(False): by default, this routine checks the instance call_pdb |
|
1420 | 1424 | flag and does not actually invoke the debugger if the flag is false. |
|
1421 | 1425 | The 'force' option forces the debugger to activate even if the flag |
|
1422 | 1426 | is false. |
|
1423 | 1427 | """ |
|
1424 | 1428 | |
|
1425 | 1429 | if not (force or self.call_pdb): |
|
1426 | 1430 | return |
|
1427 | 1431 | |
|
1428 | 1432 | if not hasattr(sys,'last_traceback'): |
|
1429 | 1433 | error('No traceback has been produced, nothing to debug.') |
|
1430 | 1434 | return |
|
1431 | 1435 | |
|
1432 | 1436 | # use pydb if available |
|
1433 | 1437 | if Debugger.has_pydb: |
|
1434 | 1438 | from pydb import pm |
|
1435 | 1439 | else: |
|
1436 | 1440 | # fallback to our internal debugger |
|
1437 | 1441 | pm = lambda : self.InteractiveTB.debugger(force=True) |
|
1438 | 1442 | self.history_saving_wrapper(pm)() |
|
1439 | 1443 | |
|
1440 | 1444 | def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None): |
|
1441 | 1445 | """Display the exception that just occurred. |
|
1442 | 1446 | |
|
1443 | 1447 | If nothing is known about the exception, this is the method which |
|
1444 | 1448 | should be used throughout the code for presenting user tracebacks, |
|
1445 | 1449 | rather than directly invoking the InteractiveTB object. |
|
1446 | 1450 | |
|
1447 | 1451 | A specific showsyntaxerror() also exists, but this method can take |
|
1448 | 1452 | care of calling it if needed, so unless you are explicitly catching a |
|
1449 | 1453 | SyntaxError exception, don't try to analyze the stack manually and |
|
1450 | 1454 | simply call this method.""" |
|
1451 | 1455 | |
|
1452 | 1456 | |
|
1453 | 1457 | # Though this won't be called by syntax errors in the input line, |
|
1454 | 1458 | # there may be SyntaxError cases whith imported code. |
|
1455 | 1459 | |
|
1456 | 1460 | |
|
1457 | 1461 | if exc_tuple is None: |
|
1458 | 1462 | etype, value, tb = sys.exc_info() |
|
1459 | 1463 | else: |
|
1460 | 1464 | etype, value, tb = exc_tuple |
|
1461 | 1465 | |
|
1462 | 1466 | if etype is SyntaxError: |
|
1463 | 1467 | self.showsyntaxerror(filename) |
|
1464 | 1468 | else: |
|
1465 | 1469 | # WARNING: these variables are somewhat deprecated and not |
|
1466 | 1470 | # necessarily safe to use in a threaded environment, but tools |
|
1467 | 1471 | # like pdb depend on their existence, so let's set them. If we |
|
1468 | 1472 | # find problems in the field, we'll need to revisit their use. |
|
1469 | 1473 | sys.last_type = etype |
|
1470 | 1474 | sys.last_value = value |
|
1471 | 1475 | sys.last_traceback = tb |
|
1472 | 1476 | |
|
1473 | 1477 | if etype in self.custom_exceptions: |
|
1474 | 1478 | self.CustomTB(etype,value,tb) |
|
1475 | 1479 | else: |
|
1476 | 1480 | self.InteractiveTB(etype,value,tb,tb_offset=tb_offset) |
|
1477 | 1481 | if self.InteractiveTB.call_pdb and self.has_readline: |
|
1478 | 1482 | # pdb mucks up readline, fix it back |
|
1479 | 1483 | self.set_completer() |
|
1480 | 1484 | |
|
1481 | 1485 | |
|
1482 | 1486 | def mainloop(self,banner=None): |
|
1483 | 1487 | """Creates the local namespace and starts the mainloop. |
|
1484 | 1488 | |
|
1485 | 1489 | If an optional banner argument is given, it will override the |
|
1486 | 1490 | internally created default banner.""" |
|
1487 | 1491 | |
|
1488 | 1492 | if self.rc.c: # Emulate Python's -c option |
|
1489 | 1493 | self.exec_init_cmd() |
|
1490 | 1494 | if banner is None: |
|
1491 | 1495 | if not self.rc.banner: |
|
1492 | 1496 | banner = '' |
|
1493 | 1497 | # banner is string? Use it directly! |
|
1494 | 1498 | elif isinstance(self.rc.banner,basestring): |
|
1495 | 1499 | banner = self.rc.banner |
|
1496 | 1500 | else: |
|
1497 | 1501 | banner = self.BANNER+self.banner2 |
|
1498 | 1502 | |
|
1499 | 1503 | self.interact(banner) |
|
1500 | 1504 | |
|
1501 | 1505 | def exec_init_cmd(self): |
|
1502 | 1506 | """Execute a command given at the command line. |
|
1503 | 1507 | |
|
1504 | 1508 | This emulates Python's -c option.""" |
|
1505 | 1509 | |
|
1506 | 1510 | #sys.argv = ['-c'] |
|
1507 | 1511 | self.push(self.prefilter(self.rc.c, False)) |
|
1508 | 1512 | self.exit_now = True |
|
1509 | 1513 | |
|
1510 | 1514 | def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0): |
|
1511 | 1515 | """Embeds IPython into a running python program. |
|
1512 | 1516 | |
|
1513 | 1517 | Input: |
|
1514 | 1518 | |
|
1515 | 1519 | - header: An optional header message can be specified. |
|
1516 | 1520 | |
|
1517 | 1521 | - local_ns, global_ns: working namespaces. If given as None, the |
|
1518 | 1522 | IPython-initialized one is updated with __main__.__dict__, so that |
|
1519 | 1523 | program variables become visible but user-specific configuration |
|
1520 | 1524 | remains possible. |
|
1521 | 1525 | |
|
1522 | 1526 | - stack_depth: specifies how many levels in the stack to go to |
|
1523 | 1527 | looking for namespaces (when local_ns and global_ns are None). This |
|
1524 | 1528 | allows an intermediate caller to make sure that this function gets |
|
1525 | 1529 | the namespace from the intended level in the stack. By default (0) |
|
1526 | 1530 | it will get its locals and globals from the immediate caller. |
|
1527 | 1531 | |
|
1528 | 1532 | Warning: it's possible to use this in a program which is being run by |
|
1529 | 1533 | IPython itself (via %run), but some funny things will happen (a few |
|
1530 | 1534 | globals get overwritten). In the future this will be cleaned up, as |
|
1531 | 1535 | there is no fundamental reason why it can't work perfectly.""" |
|
1532 | 1536 | |
|
1533 | 1537 | # Get locals and globals from caller |
|
1534 | 1538 | if local_ns is None or global_ns is None: |
|
1535 | 1539 | call_frame = sys._getframe(stack_depth).f_back |
|
1536 | 1540 | |
|
1537 | 1541 | if local_ns is None: |
|
1538 | 1542 | local_ns = call_frame.f_locals |
|
1539 | 1543 | if global_ns is None: |
|
1540 | 1544 | global_ns = call_frame.f_globals |
|
1541 | 1545 | |
|
1542 | 1546 | # Update namespaces and fire up interpreter |
|
1543 | 1547 | |
|
1544 | 1548 | # The global one is easy, we can just throw it in |
|
1545 | 1549 | self.user_global_ns = global_ns |
|
1546 | 1550 | |
|
1547 | 1551 | # but the user/local one is tricky: ipython needs it to store internal |
|
1548 | 1552 | # data, but we also need the locals. We'll copy locals in the user |
|
1549 | 1553 | # one, but will track what got copied so we can delete them at exit. |
|
1550 | 1554 | # This is so that a later embedded call doesn't see locals from a |
|
1551 | 1555 | # previous call (which most likely existed in a separate scope). |
|
1552 | 1556 | local_varnames = local_ns.keys() |
|
1553 | 1557 | self.user_ns.update(local_ns) |
|
1554 | 1558 | |
|
1555 | 1559 | # Patch for global embedding to make sure that things don't overwrite |
|
1556 | 1560 | # user globals accidentally. Thanks to Richard <rxe@renre-europe.com> |
|
1557 | 1561 | # FIXME. Test this a bit more carefully (the if.. is new) |
|
1558 | 1562 | if local_ns is None and global_ns is None: |
|
1559 | 1563 | self.user_global_ns.update(__main__.__dict__) |
|
1560 | 1564 | |
|
1561 | 1565 | # make sure the tab-completer has the correct frame information, so it |
|
1562 | 1566 | # actually completes using the frame's locals/globals |
|
1563 | 1567 | self.set_completer_frame() |
|
1564 | 1568 | |
|
1565 | 1569 | # before activating the interactive mode, we need to make sure that |
|
1566 | 1570 | # all names in the builtin namespace needed by ipython point to |
|
1567 | 1571 | # ourselves, and not to other instances. |
|
1568 | 1572 | self.add_builtins() |
|
1569 | ||
|
1573 | ||
|
1570 | 1574 | self.interact(header) |
|
1571 | 1575 | |
|
1572 | 1576 | # now, purge out the user namespace from anything we might have added |
|
1573 | 1577 | # from the caller's local namespace |
|
1574 | 1578 | delvar = self.user_ns.pop |
|
1575 | 1579 | for var in local_varnames: |
|
1576 | 1580 | delvar(var,None) |
|
1577 | 1581 | # and clean builtins we may have overridden |
|
1578 | 1582 | self.clean_builtins() |
|
1579 | 1583 | |
|
1580 | 1584 | def interact(self, banner=None): |
|
1581 | 1585 | """Closely emulate the interactive Python console. |
|
1582 | 1586 | |
|
1583 | 1587 | The optional banner argument specify the banner to print |
|
1584 | 1588 | before the first interaction; by default it prints a banner |
|
1585 | 1589 | similar to the one printed by the real Python interpreter, |
|
1586 | 1590 | followed by the current class name in parentheses (so as not |
|
1587 | 1591 | to confuse this with the real interpreter -- since it's so |
|
1588 | 1592 | close!). |
|
1589 | 1593 | |
|
1590 | 1594 | """ |
|
1591 | 1595 | |
|
1592 | 1596 | if self.exit_now: |
|
1593 | 1597 | # batch run -> do not interact |
|
1594 | 1598 | return |
|
1595 | 1599 | cprt = 'Type "copyright", "credits" or "license" for more information.' |
|
1596 | 1600 | if banner is None: |
|
1597 | 1601 | self.write("Python %s on %s\n%s\n(%s)\n" % |
|
1598 | 1602 | (sys.version, sys.platform, cprt, |
|
1599 | 1603 | self.__class__.__name__)) |
|
1600 | 1604 | else: |
|
1601 | 1605 | self.write(banner) |
|
1602 | 1606 | |
|
1603 | 1607 | more = 0 |
|
1604 | 1608 | |
|
1605 | 1609 | # Mark activity in the builtins |
|
1606 | 1610 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
1607 | 1611 | |
|
1608 | 1612 | if readline.have_readline: |
|
1609 | 1613 | self.readline_startup_hook(self.pre_readline) |
|
1610 | 1614 | # exit_now is set by a call to %Exit or %Quit |
|
1611 | 1615 | |
|
1612 | 1616 | while not self.exit_now: |
|
1613 | 1617 | if more: |
|
1614 | 1618 | prompt = self.hooks.generate_prompt(True) |
|
1615 | 1619 | if self.autoindent: |
|
1616 | 1620 | self.rl_do_indent = True |
|
1617 | 1621 | |
|
1618 | 1622 | else: |
|
1619 | 1623 | prompt = self.hooks.generate_prompt(False) |
|
1620 | 1624 | try: |
|
1621 | 1625 | line = self.raw_input(prompt,more) |
|
1622 | 1626 | if self.exit_now: |
|
1623 | 1627 | # quick exit on sys.std[in|out] close |
|
1624 | 1628 | break |
|
1625 | 1629 | if self.autoindent: |
|
1626 | 1630 | self.rl_do_indent = False |
|
1627 | 1631 | |
|
1628 | 1632 | except KeyboardInterrupt: |
|
1629 | 1633 | self.write('\nKeyboardInterrupt\n') |
|
1630 | 1634 | self.resetbuffer() |
|
1631 | 1635 | # keep cache in sync with the prompt counter: |
|
1632 | 1636 | self.outputcache.prompt_count -= 1 |
|
1633 | 1637 | |
|
1634 | 1638 | if self.autoindent: |
|
1635 | 1639 | self.indent_current_nsp = 0 |
|
1636 | 1640 | more = 0 |
|
1637 | 1641 | except EOFError: |
|
1638 | 1642 | if self.autoindent: |
|
1639 | 1643 | self.rl_do_indent = False |
|
1640 | 1644 | self.readline_startup_hook(None) |
|
1641 | 1645 | self.write('\n') |
|
1642 | 1646 | self.exit() |
|
1643 | 1647 | except bdb.BdbQuit: |
|
1644 | 1648 | warn('The Python debugger has exited with a BdbQuit exception.\n' |
|
1645 | 1649 | 'Because of how pdb handles the stack, it is impossible\n' |
|
1646 | 1650 | 'for IPython to properly format this particular exception.\n' |
|
1647 | 1651 | 'IPython will resume normal operation.') |
|
1648 | 1652 | except: |
|
1649 | 1653 | # exceptions here are VERY RARE, but they can be triggered |
|
1650 | 1654 | # asynchronously by signal handlers, for example. |
|
1651 | 1655 | self.showtraceback() |
|
1652 | 1656 | else: |
|
1653 | 1657 | more = self.push(line) |
|
1654 | 1658 | if (self.SyntaxTB.last_syntax_error and |
|
1655 | 1659 | self.rc.autoedit_syntax): |
|
1656 | 1660 | self.edit_syntax_error() |
|
1657 | 1661 | |
|
1658 | 1662 | # We are off again... |
|
1659 | 1663 | __builtin__.__dict__['__IPYTHON__active'] -= 1 |
|
1660 | 1664 | |
|
1661 | 1665 | def excepthook(self, etype, value, tb): |
|
1662 | 1666 | """One more defense for GUI apps that call sys.excepthook. |
|
1663 | 1667 | |
|
1664 | 1668 | GUI frameworks like wxPython trap exceptions and call |
|
1665 | 1669 | sys.excepthook themselves. I guess this is a feature that |
|
1666 | 1670 | enables them to keep running after exceptions that would |
|
1667 | 1671 | otherwise kill their mainloop. This is a bother for IPython |
|
1668 | 1672 | which excepts to catch all of the program exceptions with a try: |
|
1669 | 1673 | except: statement. |
|
1670 | 1674 | |
|
1671 | 1675 | Normally, IPython sets sys.excepthook to a CrashHandler instance, so if |
|
1672 | 1676 | any app directly invokes sys.excepthook, it will look to the user like |
|
1673 | 1677 | IPython crashed. In order to work around this, we can disable the |
|
1674 | 1678 | CrashHandler and replace it with this excepthook instead, which prints a |
|
1675 | 1679 | regular traceback using our InteractiveTB. In this fashion, apps which |
|
1676 | 1680 | call sys.excepthook will generate a regular-looking exception from |
|
1677 | 1681 | IPython, and the CrashHandler will only be triggered by real IPython |
|
1678 | 1682 | crashes. |
|
1679 | 1683 | |
|
1680 | 1684 | This hook should be used sparingly, only in places which are not likely |
|
1681 | 1685 | to be true IPython errors. |
|
1682 | 1686 | """ |
|
1683 | 1687 | self.showtraceback((etype,value,tb),tb_offset=0) |
|
1684 | 1688 | |
|
1685 | 1689 | def expand_aliases(self,fn,rest): |
|
1686 | 1690 | """ Expand multiple levels of aliases: |
|
1687 | 1691 | |
|
1688 | 1692 | if: |
|
1689 | 1693 | |
|
1690 | 1694 | alias foo bar /tmp |
|
1691 | 1695 | alias baz foo |
|
1692 | 1696 | |
|
1693 | 1697 | then: |
|
1694 | 1698 | |
|
1695 | 1699 | baz huhhahhei -> bar /tmp huhhahhei |
|
1696 | 1700 | |
|
1697 | 1701 | """ |
|
1698 | 1702 | line = fn + " " + rest |
|
1699 | 1703 | |
|
1700 | 1704 | done = Set() |
|
1701 | 1705 | while 1: |
|
1702 | 1706 | pre,fn,rest = prefilter.splitUserInput(line, |
|
1703 | 1707 | prefilter.shell_line_split) |
|
1704 | 1708 | if fn in self.alias_table: |
|
1705 | 1709 | if fn in done: |
|
1706 | 1710 | warn("Cyclic alias definition, repeated '%s'" % fn) |
|
1707 | 1711 | return "" |
|
1708 | 1712 | done.add(fn) |
|
1709 | 1713 | |
|
1710 | 1714 | l2 = self.transform_alias(fn,rest) |
|
1711 | 1715 | # dir -> dir |
|
1712 | 1716 | # print "alias",line, "->",l2 #dbg |
|
1713 | 1717 | if l2 == line: |
|
1714 | 1718 | break |
|
1715 | 1719 | # ls -> ls -F should not recurse forever |
|
1716 | 1720 | if l2.split(None,1)[0] == line.split(None,1)[0]: |
|
1717 | 1721 | line = l2 |
|
1718 | 1722 | break |
|
1719 | 1723 | |
|
1720 | 1724 | line=l2 |
|
1721 | 1725 | |
|
1722 | 1726 | |
|
1723 | 1727 | # print "al expand to",line #dbg |
|
1724 | 1728 | else: |
|
1725 | 1729 | break |
|
1726 | 1730 | |
|
1727 | 1731 | return line |
|
1728 | 1732 | |
|
1729 | 1733 | def transform_alias(self, alias,rest=''): |
|
1730 | 1734 | """ Transform alias to system command string. |
|
1731 | 1735 | """ |
|
1732 | 1736 | nargs,cmd = self.alias_table[alias] |
|
1733 | 1737 | if ' ' in cmd and os.path.isfile(cmd): |
|
1734 | 1738 | cmd = '"%s"' % cmd |
|
1735 | 1739 | |
|
1736 | 1740 | # Expand the %l special to be the user's input line |
|
1737 | 1741 | if cmd.find('%l') >= 0: |
|
1738 | 1742 | cmd = cmd.replace('%l',rest) |
|
1739 | 1743 | rest = '' |
|
1740 | 1744 | if nargs==0: |
|
1741 | 1745 | # Simple, argument-less aliases |
|
1742 | 1746 | cmd = '%s %s' % (cmd,rest) |
|
1743 | 1747 | else: |
|
1744 | 1748 | # Handle aliases with positional arguments |
|
1745 | 1749 | args = rest.split(None,nargs) |
|
1746 | 1750 | if len(args)< nargs: |
|
1747 | 1751 | error('Alias <%s> requires %s arguments, %s given.' % |
|
1748 | 1752 | (alias,nargs,len(args))) |
|
1749 | 1753 | return None |
|
1750 | 1754 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
|
1751 | 1755 | # Now call the macro, evaluating in the user's namespace |
|
1752 | 1756 | #print 'new command: <%r>' % cmd # dbg |
|
1753 | 1757 | return cmd |
|
1754 | 1758 | |
|
1755 | 1759 | def call_alias(self,alias,rest=''): |
|
1756 | 1760 | """Call an alias given its name and the rest of the line. |
|
1757 | 1761 | |
|
1758 | 1762 | This is only used to provide backwards compatibility for users of |
|
1759 | 1763 | ipalias(), use of which is not recommended for anymore.""" |
|
1760 | 1764 | |
|
1761 | 1765 | # Now call the macro, evaluating in the user's namespace |
|
1762 | 1766 | cmd = self.transform_alias(alias, rest) |
|
1763 | 1767 | try: |
|
1764 | 1768 | self.system(cmd) |
|
1765 | 1769 | except: |
|
1766 | 1770 | self.showtraceback() |
|
1767 | 1771 | |
|
1768 | 1772 | def indent_current_str(self): |
|
1769 | 1773 | """return the current level of indentation as a string""" |
|
1770 | 1774 | return self.indent_current_nsp * ' ' |
|
1771 | 1775 | |
|
1772 | 1776 | def autoindent_update(self,line): |
|
1773 | 1777 | """Keep track of the indent level.""" |
|
1774 | 1778 | |
|
1775 | 1779 | #debugx('line') |
|
1776 | 1780 | #debugx('self.indent_current_nsp') |
|
1777 | 1781 | if self.autoindent: |
|
1778 | 1782 | if line: |
|
1779 | 1783 | inisp = num_ini_spaces(line) |
|
1780 | 1784 | if inisp < self.indent_current_nsp: |
|
1781 | 1785 | self.indent_current_nsp = inisp |
|
1782 | 1786 | |
|
1783 | 1787 | if line[-1] == ':': |
|
1784 | 1788 | self.indent_current_nsp += 4 |
|
1785 | 1789 | elif dedent_re.match(line): |
|
1786 | 1790 | self.indent_current_nsp -= 4 |
|
1787 | 1791 | else: |
|
1788 | 1792 | self.indent_current_nsp = 0 |
|
1789 | 1793 | def runlines(self,lines): |
|
1790 | 1794 | """Run a string of one or more lines of source. |
|
1791 | 1795 | |
|
1792 | 1796 | This method is capable of running a string containing multiple source |
|
1793 | 1797 | lines, as if they had been entered at the IPython prompt. Since it |
|
1794 | 1798 | exposes IPython's processing machinery, the given strings can contain |
|
1795 | 1799 | magic calls (%magic), special shell access (!cmd), etc.""" |
|
1796 | 1800 | |
|
1797 | 1801 | # We must start with a clean buffer, in case this is run from an |
|
1798 | 1802 | # interactive IPython session (via a magic, for example). |
|
1799 | 1803 | self.resetbuffer() |
|
1800 | 1804 | lines = lines.split('\n') |
|
1801 | 1805 | more = 0 |
|
1802 | 1806 | |
|
1803 | 1807 | for line in lines: |
|
1804 | 1808 | # skip blank lines so we don't mess up the prompt counter, but do |
|
1805 | 1809 | # NOT skip even a blank line if we are in a code block (more is |
|
1806 | 1810 | # true) |
|
1807 | 1811 | |
|
1808 | 1812 | |
|
1809 | 1813 | if line or more: |
|
1810 | 1814 | # push to raw history, so hist line numbers stay in sync |
|
1811 | 1815 | self.input_hist_raw.append("# " + line + "\n") |
|
1812 | 1816 | more = self.push(self.prefilter(line,more)) |
|
1813 | 1817 | # IPython's runsource returns None if there was an error |
|
1814 | 1818 | # compiling the code. This allows us to stop processing right |
|
1815 | 1819 | # away, so the user gets the error message at the right place. |
|
1816 | 1820 | if more is None: |
|
1817 | 1821 | break |
|
1818 | 1822 | # final newline in case the input didn't have it, so that the code |
|
1819 | 1823 | # actually does get executed |
|
1820 | 1824 | if more: |
|
1821 | 1825 | self.push('\n') |
|
1822 | 1826 | |
|
1823 | 1827 | def runsource(self, source, filename='<input>', symbol='single'): |
|
1824 | 1828 | """Compile and run some source in the interpreter. |
|
1825 | 1829 | |
|
1826 | 1830 | Arguments are as for compile_command(). |
|
1827 | 1831 | |
|
1828 | 1832 | One several things can happen: |
|
1829 | 1833 | |
|
1830 | 1834 | 1) The input is incorrect; compile_command() raised an |
|
1831 | 1835 | exception (SyntaxError or OverflowError). A syntax traceback |
|
1832 | 1836 | will be printed by calling the showsyntaxerror() method. |
|
1833 | 1837 | |
|
1834 | 1838 | 2) The input is incomplete, and more input is required; |
|
1835 | 1839 | compile_command() returned None. Nothing happens. |
|
1836 | 1840 | |
|
1837 | 1841 | 3) The input is complete; compile_command() returned a code |
|
1838 | 1842 | object. The code is executed by calling self.runcode() (which |
|
1839 | 1843 | also handles run-time exceptions, except for SystemExit). |
|
1840 | 1844 | |
|
1841 | 1845 | The return value is: |
|
1842 | 1846 | |
|
1843 | 1847 | - True in case 2 |
|
1844 | 1848 | |
|
1845 | 1849 | - False in the other cases, unless an exception is raised, where |
|
1846 | 1850 | None is returned instead. This can be used by external callers to |
|
1847 | 1851 | know whether to continue feeding input or not. |
|
1848 | 1852 | |
|
1849 | 1853 | The return value can be used to decide whether to use sys.ps1 or |
|
1850 | 1854 | sys.ps2 to prompt the next line.""" |
|
1851 | 1855 | |
|
1852 | 1856 | # if the source code has leading blanks, add 'if 1:\n' to it |
|
1853 | 1857 | # this allows execution of indented pasted code. It is tempting |
|
1854 | 1858 | # to add '\n' at the end of source to run commands like ' a=1' |
|
1855 | 1859 | # directly, but this fails for more complicated scenarios |
|
1856 | 1860 | if source[:1] in [' ', '\t']: |
|
1857 | 1861 | source = 'if 1:\n%s' % source |
|
1858 | 1862 | |
|
1859 | 1863 | try: |
|
1860 | 1864 | code = self.compile(source,filename,symbol) |
|
1861 | 1865 | except (OverflowError, SyntaxError, ValueError): |
|
1862 | 1866 | # Case 1 |
|
1863 | 1867 | self.showsyntaxerror(filename) |
|
1864 | 1868 | return None |
|
1865 | 1869 | |
|
1866 | 1870 | if code is None: |
|
1867 | 1871 | # Case 2 |
|
1868 | 1872 | return True |
|
1869 | 1873 | |
|
1870 | 1874 | # Case 3 |
|
1871 | 1875 | # We store the code object so that threaded shells and |
|
1872 | 1876 | # custom exception handlers can access all this info if needed. |
|
1873 | 1877 | # The source corresponding to this can be obtained from the |
|
1874 | 1878 | # buffer attribute as '\n'.join(self.buffer). |
|
1875 | 1879 | self.code_to_run = code |
|
1876 | 1880 | # now actually execute the code object |
|
1877 | 1881 | if self.runcode(code) == 0: |
|
1878 | 1882 | return False |
|
1879 | 1883 | else: |
|
1880 | 1884 | return None |
|
1881 | 1885 | |
|
1882 | 1886 | def runcode(self,code_obj): |
|
1883 | 1887 | """Execute a code object. |
|
1884 | 1888 | |
|
1885 | 1889 | When an exception occurs, self.showtraceback() is called to display a |
|
1886 | 1890 | traceback. |
|
1887 | 1891 | |
|
1888 | 1892 | Return value: a flag indicating whether the code to be run completed |
|
1889 | 1893 | successfully: |
|
1890 | 1894 | |
|
1891 | 1895 | - 0: successful execution. |
|
1892 | 1896 | - 1: an error occurred. |
|
1893 | 1897 | """ |
|
1894 | 1898 | |
|
1895 | 1899 | # Set our own excepthook in case the user code tries to call it |
|
1896 | 1900 | # directly, so that the IPython crash handler doesn't get triggered |
|
1897 | 1901 | old_excepthook,sys.excepthook = sys.excepthook, self.excepthook |
|
1898 | 1902 | |
|
1899 | 1903 | # we save the original sys.excepthook in the instance, in case config |
|
1900 | 1904 | # code (such as magics) needs access to it. |
|
1901 | 1905 | self.sys_excepthook = old_excepthook |
|
1902 | 1906 | outflag = 1 # happens in more places, so it's easier as default |
|
1903 | 1907 | try: |
|
1904 | 1908 | try: |
|
1905 | 1909 | # Embedded instances require separate global/local namespaces |
|
1906 | 1910 | # so they can see both the surrounding (local) namespace and |
|
1907 | 1911 | # the module-level globals when called inside another function. |
|
1908 | 1912 | if self.embedded: |
|
1909 | 1913 | exec code_obj in self.user_global_ns, self.user_ns |
|
1910 | 1914 | # Normal (non-embedded) instances should only have a single |
|
1911 | 1915 | # namespace for user code execution, otherwise functions won't |
|
1912 | 1916 | # see interactive top-level globals. |
|
1913 | 1917 | else: |
|
1914 | 1918 | exec code_obj in self.user_ns |
|
1915 | 1919 | finally: |
|
1916 | 1920 | # Reset our crash handler in place |
|
1917 | 1921 | sys.excepthook = old_excepthook |
|
1918 | 1922 | except SystemExit: |
|
1919 | 1923 | self.resetbuffer() |
|
1920 | 1924 | self.showtraceback() |
|
1921 | 1925 | warn("Type %exit or %quit to exit IPython " |
|
1922 | 1926 | "(%Exit or %Quit do so unconditionally).",level=1) |
|
1923 | 1927 | except self.custom_exceptions: |
|
1924 | 1928 | etype,value,tb = sys.exc_info() |
|
1925 | 1929 | self.CustomTB(etype,value,tb) |
|
1926 | 1930 | except: |
|
1927 | 1931 | self.showtraceback() |
|
1928 | 1932 | else: |
|
1929 | 1933 | outflag = 0 |
|
1930 | 1934 | if softspace(sys.stdout, 0): |
|
1931 | 1935 | |
|
1932 | 1936 | # Flush out code object which has been run (and source) |
|
1933 | 1937 | self.code_to_run = None |
|
1934 | 1938 | return outflag |
|
1935 | 1939 | |
|
1936 | 1940 | def push(self, line): |
|
1937 | 1941 | """Push a line to the interpreter. |
|
1938 | 1942 | |
|
1939 | 1943 | The line should not have a trailing newline; it may have |
|
1940 | 1944 | internal newlines. The line is appended to a buffer and the |
|
1941 | 1945 | interpreter's runsource() method is called with the |
|
1942 | 1946 | concatenated contents of the buffer as source. If this |
|
1943 | 1947 | indicates that the command was executed or invalid, the buffer |
|
1944 | 1948 | is reset; otherwise, the command is incomplete, and the buffer |
|
1945 | 1949 | is left as it was after the line was appended. The return |
|
1946 | 1950 | value is 1 if more input is required, 0 if the line was dealt |
|
1947 | 1951 | with in some way (this is the same as runsource()). |
|
1948 | 1952 | """ |
|
1949 | 1953 | |
|
1950 | 1954 | # autoindent management should be done here, and not in the |
|
1951 | 1955 | # interactive loop, since that one is only seen by keyboard input. We |
|
1952 | 1956 | # need this done correctly even for code run via runlines (which uses |
|
1953 | 1957 | # push). |
|
1954 | 1958 | |
|
1955 | 1959 | #print 'push line: <%s>' % line # dbg |
|
1956 | 1960 | for subline in line.splitlines(): |
|
1957 | 1961 | self.autoindent_update(subline) |
|
1958 | 1962 | self.buffer.append(line) |
|
1959 | 1963 | more = self.runsource('\n'.join(self.buffer), self.filename) |
|
1960 | 1964 | if not more: |
|
1961 | 1965 | self.resetbuffer() |
|
1962 | 1966 | return more |
|
1963 | 1967 | |
|
1964 | 1968 | def split_user_input(self, line): |
|
1965 | 1969 | # This is really a hold-over to support ipapi and some extensions |
|
1966 | 1970 | return prefilter.splitUserInput(line) |
|
1967 | 1971 | |
|
1968 | 1972 | def resetbuffer(self): |
|
1969 | 1973 | """Reset the input buffer.""" |
|
1970 | 1974 | self.buffer[:] = [] |
|
1971 | 1975 | |
|
1972 | 1976 | def raw_input(self,prompt='',continue_prompt=False): |
|
1973 | 1977 | """Write a prompt and read a line. |
|
1974 | 1978 | |
|
1975 | 1979 | The returned line does not include the trailing newline. |
|
1976 | 1980 | When the user enters the EOF key sequence, EOFError is raised. |
|
1977 | 1981 | |
|
1978 | 1982 | Optional inputs: |
|
1979 | 1983 | |
|
1980 | 1984 | - prompt(''): a string to be printed to prompt the user. |
|
1981 | 1985 | |
|
1982 | 1986 | - continue_prompt(False): whether this line is the first one or a |
|
1983 | 1987 | continuation in a sequence of inputs. |
|
1984 | 1988 | """ |
|
1985 | 1989 | |
|
1986 | 1990 | # Code run by the user may have modified the readline completer state. |
|
1987 | 1991 | # We must ensure that our completer is back in place. |
|
1988 | 1992 | if self.has_readline: |
|
1989 | 1993 | self.set_completer() |
|
1990 | 1994 | |
|
1991 | 1995 | try: |
|
1992 | 1996 | line = raw_input_original(prompt).decode(self.stdin_encoding) |
|
1993 | 1997 | except ValueError: |
|
1994 | 1998 | warn("\n********\nYou or a %run:ed script called sys.stdin.close()" |
|
1995 | 1999 | " or sys.stdout.close()!\nExiting IPython!") |
|
1996 | 2000 | self.exit_now = True |
|
1997 | 2001 | return "" |
|
1998 | 2002 | |
|
1999 | 2003 | # Try to be reasonably smart about not re-indenting pasted input more |
|
2000 | 2004 | # than necessary. We do this by trimming out the auto-indent initial |
|
2001 | 2005 | # spaces, if the user's actual input started itself with whitespace. |
|
2002 | 2006 | #debugx('self.buffer[-1]') |
|
2003 | 2007 | |
|
2004 | 2008 | if self.autoindent: |
|
2005 | 2009 | if num_ini_spaces(line) > self.indent_current_nsp: |
|
2006 | 2010 | line = line[self.indent_current_nsp:] |
|
2007 | 2011 | self.indent_current_nsp = 0 |
|
2008 | 2012 | |
|
2009 | 2013 | # store the unfiltered input before the user has any chance to modify |
|
2010 | 2014 | # it. |
|
2011 | 2015 | if line.strip(): |
|
2012 | 2016 | if continue_prompt: |
|
2013 | 2017 | self.input_hist_raw[-1] += '%s\n' % line |
|
2014 | 2018 | if self.has_readline: # and some config option is set? |
|
2015 | 2019 | try: |
|
2016 | 2020 | histlen = self.readline.get_current_history_length() |
|
2017 | 2021 | newhist = self.input_hist_raw[-1].rstrip() |
|
2018 | 2022 | self.readline.remove_history_item(histlen-1) |
|
2019 | 2023 | self.readline.replace_history_item(histlen-2,newhist) |
|
2020 | 2024 | except AttributeError: |
|
2021 | 2025 | pass # re{move,place}_history_item are new in 2.4. |
|
2022 | 2026 | else: |
|
2023 | 2027 | self.input_hist_raw.append('%s\n' % line) |
|
2024 | 2028 | |
|
2025 | 2029 | if line.lstrip() == line: |
|
2026 | 2030 | self.shadowhist.add(line.strip()) |
|
2027 | 2031 | |
|
2028 | 2032 | try: |
|
2029 | 2033 | lineout = self.prefilter(line,continue_prompt) |
|
2030 | 2034 | except: |
|
2031 | 2035 | # blanket except, in case a user-defined prefilter crashes, so it |
|
2032 | 2036 | # can't take all of ipython with it. |
|
2033 | 2037 | self.showtraceback() |
|
2034 | 2038 | return '' |
|
2035 | 2039 | else: |
|
2036 | 2040 | return lineout |
|
2037 | 2041 | |
|
2038 | 2042 | def _prefilter(self, line, continue_prompt): |
|
2039 | 2043 | """Calls different preprocessors, depending on the form of line.""" |
|
2040 | 2044 | |
|
2041 | 2045 | # All handlers *must* return a value, even if it's blank (''). |
|
2042 | 2046 | |
|
2043 | 2047 | # Lines are NOT logged here. Handlers should process the line as |
|
2044 | 2048 | # needed, update the cache AND log it (so that the input cache array |
|
2045 | 2049 | # stays synced). |
|
2046 | 2050 | |
|
2047 | 2051 | #..................................................................... |
|
2048 | 2052 | # Code begins |
|
2049 | 2053 | |
|
2050 | 2054 | #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg |
|
2051 | 2055 | |
|
2052 | 2056 | # save the line away in case we crash, so the post-mortem handler can |
|
2053 | 2057 | # record it |
|
2054 | 2058 | self._last_input_line = line |
|
2055 | 2059 | |
|
2056 | 2060 | #print '***line: <%s>' % line # dbg |
|
2057 | 2061 | |
|
2058 | 2062 | line_info = prefilter.LineInfo(line, continue_prompt) |
|
2059 | 2063 | |
|
2060 | 2064 | # the input history needs to track even empty lines |
|
2061 | 2065 | stripped = line.strip() |
|
2062 | 2066 | |
|
2063 | 2067 | if not stripped: |
|
2064 | 2068 | if not continue_prompt: |
|
2065 | 2069 | self.outputcache.prompt_count -= 1 |
|
2066 | 2070 | return self.handle_normal(line_info) |
|
2067 | 2071 | |
|
2068 | 2072 | # print '***cont',continue_prompt # dbg |
|
2069 | 2073 | # special handlers are only allowed for single line statements |
|
2070 | 2074 | if continue_prompt and not self.rc.multi_line_specials: |
|
2071 | 2075 | return self.handle_normal(line_info) |
|
2072 | 2076 | |
|
2073 | 2077 | |
|
2074 | 2078 | # See whether any pre-existing handler can take care of it |
|
2075 | 2079 | rewritten = self.hooks.input_prefilter(stripped) |
|
2076 | 2080 | if rewritten != stripped: # ok, some prefilter did something |
|
2077 | 2081 | rewritten = line_info.pre + rewritten # add indentation |
|
2078 | 2082 | return self.handle_normal(prefilter.LineInfo(rewritten, |
|
2079 | 2083 | continue_prompt)) |
|
2080 | 2084 | |
|
2081 | 2085 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
2082 | 2086 | |
|
2083 | 2087 | return prefilter.prefilter(line_info, self) |
|
2084 | 2088 | |
|
2085 | 2089 | |
|
2086 | 2090 | def _prefilter_dumb(self, line, continue_prompt): |
|
2087 | 2091 | """simple prefilter function, for debugging""" |
|
2088 | 2092 | return self.handle_normal(line,continue_prompt) |
|
2089 | 2093 | |
|
2090 | 2094 | |
|
2091 | 2095 | def multiline_prefilter(self, line, continue_prompt): |
|
2092 | 2096 | """ Run _prefilter for each line of input |
|
2093 | 2097 | |
|
2094 | 2098 | Covers cases where there are multiple lines in the user entry, |
|
2095 | 2099 | which is the case when the user goes back to a multiline history |
|
2096 | 2100 | entry and presses enter. |
|
2097 | 2101 | |
|
2098 | 2102 | """ |
|
2099 | 2103 | out = [] |
|
2100 | 2104 | for l in line.rstrip('\n').split('\n'): |
|
2101 | 2105 | out.append(self._prefilter(l, continue_prompt)) |
|
2102 | 2106 | return '\n'.join(out) |
|
2103 | 2107 | |
|
2104 | 2108 | # Set the default prefilter() function (this can be user-overridden) |
|
2105 | 2109 | prefilter = multiline_prefilter |
|
2106 | 2110 | |
|
2107 | 2111 | def handle_normal(self,line_info): |
|
2108 | 2112 | """Handle normal input lines. Use as a template for handlers.""" |
|
2109 | 2113 | |
|
2110 | 2114 | # With autoindent on, we need some way to exit the input loop, and I |
|
2111 | 2115 | # don't want to force the user to have to backspace all the way to |
|
2112 | 2116 | # clear the line. The rule will be in this case, that either two |
|
2113 | 2117 | # lines of pure whitespace in a row, or a line of pure whitespace but |
|
2114 | 2118 | # of a size different to the indent level, will exit the input loop. |
|
2115 | 2119 | line = line_info.line |
|
2116 | 2120 | continue_prompt = line_info.continue_prompt |
|
2117 | 2121 | |
|
2118 | 2122 | if (continue_prompt and self.autoindent and line.isspace() and |
|
2119 | 2123 | (0 < abs(len(line) - self.indent_current_nsp) <= 2 or |
|
2120 | 2124 | (self.buffer[-1]).isspace() )): |
|
2121 | 2125 | line = '' |
|
2122 | 2126 | |
|
2123 | 2127 | self.log(line,line,continue_prompt) |
|
2124 | 2128 | return line |
|
2125 | 2129 | |
|
2126 | 2130 | def handle_alias(self,line_info): |
|
2127 | 2131 | """Handle alias input lines. """ |
|
2128 | 2132 | tgt = self.alias_table[line_info.iFun] |
|
2129 | 2133 | # print "=>",tgt #dbg |
|
2130 | 2134 | if callable(tgt): |
|
2131 | 2135 | line_out = "_sh." + line_info.iFun + '(r"""' + line_info.theRest + '""")' |
|
2132 | 2136 | else: |
|
2133 | 2137 | transformed = self.expand_aliases(line_info.iFun,line_info.theRest) |
|
2134 | 2138 | |
|
2135 | 2139 | # pre is needed, because it carries the leading whitespace. Otherwise |
|
2136 | 2140 | # aliases won't work in indented sections. |
|
2137 | 2141 | line_out = '%s_ip.system(%s)' % (line_info.preWhitespace, |
|
2138 | 2142 | make_quoted_expr( transformed )) |
|
2139 | 2143 | |
|
2140 | 2144 | self.log(line_info.line,line_out,line_info.continue_prompt) |
|
2141 | 2145 | #print 'line out:',line_out # dbg |
|
2142 | 2146 | return line_out |
|
2143 | 2147 | |
|
2144 | 2148 | def handle_shell_escape(self, line_info): |
|
2145 | 2149 | """Execute the line in a shell, empty return value""" |
|
2146 | 2150 | #print 'line in :', `line` # dbg |
|
2147 | 2151 | line = line_info.line |
|
2148 | 2152 | if line.lstrip().startswith('!!'): |
|
2149 | 2153 | # rewrite LineInfo's line, iFun and theRest to properly hold the |
|
2150 | 2154 | # call to %sx and the actual command to be executed, so |
|
2151 | 2155 | # handle_magic can work correctly. Note that this works even if |
|
2152 | 2156 | # the line is indented, so it handles multi_line_specials |
|
2153 | 2157 | # properly. |
|
2154 | 2158 | new_rest = line.lstrip()[2:] |
|
2155 | 2159 | line_info.line = '%ssx %s' % (self.ESC_MAGIC,new_rest) |
|
2156 | 2160 | line_info.iFun = 'sx' |
|
2157 | 2161 | line_info.theRest = new_rest |
|
2158 | 2162 | return self.handle_magic(line_info) |
|
2159 | 2163 | else: |
|
2160 | 2164 | cmd = line.lstrip().lstrip('!') |
|
2161 | 2165 | line_out = '%s_ip.system(%s)' % (line_info.preWhitespace, |
|
2162 | 2166 | make_quoted_expr(cmd)) |
|
2163 | 2167 | # update cache/log and return |
|
2164 | 2168 | self.log(line,line_out,line_info.continue_prompt) |
|
2165 | 2169 | return line_out |
|
2166 | 2170 | |
|
2167 | 2171 | def handle_magic(self, line_info): |
|
2168 | 2172 | """Execute magic functions.""" |
|
2169 | 2173 | iFun = line_info.iFun |
|
2170 | 2174 | theRest = line_info.theRest |
|
2171 | 2175 | cmd = '%s_ip.magic(%s)' % (line_info.preWhitespace, |
|
2172 | 2176 | make_quoted_expr(iFun + " " + theRest)) |
|
2173 | 2177 | self.log(line_info.line,cmd,line_info.continue_prompt) |
|
2174 | 2178 | #print 'in handle_magic, cmd=<%s>' % cmd # dbg |
|
2175 | 2179 | return cmd |
|
2176 | 2180 | |
|
2177 | 2181 | def handle_auto(self, line_info): |
|
2178 | 2182 | """Hande lines which can be auto-executed, quoting if requested.""" |
|
2179 | 2183 | |
|
2180 | 2184 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
2181 | 2185 | line = line_info.line |
|
2182 | 2186 | iFun = line_info.iFun |
|
2183 | 2187 | theRest = line_info.theRest |
|
2184 | 2188 | pre = line_info.pre |
|
2185 | 2189 | continue_prompt = line_info.continue_prompt |
|
2186 | 2190 | obj = line_info.ofind(self)['obj'] |
|
2187 | 2191 | |
|
2188 | 2192 | # This should only be active for single-line input! |
|
2189 | 2193 | if continue_prompt: |
|
2190 | 2194 | self.log(line,line,continue_prompt) |
|
2191 | 2195 | return line |
|
2192 | 2196 | |
|
2193 | 2197 | force_auto = isinstance(obj, IPython.ipapi.IPyAutocall) |
|
2194 | 2198 | auto_rewrite = True |
|
2195 | 2199 | |
|
2196 | 2200 | if pre == self.ESC_QUOTE: |
|
2197 | 2201 | # Auto-quote splitting on whitespace |
|
2198 | 2202 | newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) ) |
|
2199 | 2203 | elif pre == self.ESC_QUOTE2: |
|
2200 | 2204 | # Auto-quote whole string |
|
2201 | 2205 | newcmd = '%s("%s")' % (iFun,theRest) |
|
2202 | 2206 | elif pre == self.ESC_PAREN: |
|
2203 | 2207 | newcmd = '%s(%s)' % (iFun,",".join(theRest.split())) |
|
2204 | 2208 | else: |
|
2205 | 2209 | # Auto-paren. |
|
2206 | 2210 | # We only apply it to argument-less calls if the autocall |
|
2207 | 2211 | # parameter is set to 2. We only need to check that autocall is < |
|
2208 | 2212 | # 2, since this function isn't called unless it's at least 1. |
|
2209 | 2213 | if not theRest and (self.rc.autocall < 2) and not force_auto: |
|
2210 | 2214 | newcmd = '%s %s' % (iFun,theRest) |
|
2211 | 2215 | auto_rewrite = False |
|
2212 | 2216 | else: |
|
2213 | 2217 | if not force_auto and theRest.startswith('['): |
|
2214 | 2218 | if hasattr(obj,'__getitem__'): |
|
2215 | 2219 | # Don't autocall in this case: item access for an object |
|
2216 | 2220 | # which is BOTH callable and implements __getitem__. |
|
2217 | 2221 | newcmd = '%s %s' % (iFun,theRest) |
|
2218 | 2222 | auto_rewrite = False |
|
2219 | 2223 | else: |
|
2220 | 2224 | # if the object doesn't support [] access, go ahead and |
|
2221 | 2225 | # autocall |
|
2222 | 2226 | newcmd = '%s(%s)' % (iFun.rstrip(),theRest) |
|
2223 | 2227 | elif theRest.endswith(';'): |
|
2224 | 2228 | newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1]) |
|
2225 | 2229 | else: |
|
2226 | 2230 | newcmd = '%s(%s)' % (iFun.rstrip(), theRest) |
|
2227 | 2231 | |
|
2228 | 2232 | if auto_rewrite: |
|
2229 | 2233 | rw = self.outputcache.prompt1.auto_rewrite() + newcmd |
|
2230 | 2234 | |
|
2231 | 2235 | try: |
|
2232 | 2236 | # plain ascii works better w/ pyreadline, on some machines, so |
|
2233 | 2237 | # we use it and only print uncolored rewrite if we have unicode |
|
2234 | 2238 | rw = str(rw) |
|
2235 | 2239 | print >>Term.cout, rw |
|
2236 | 2240 | except UnicodeEncodeError: |
|
2237 | 2241 | print "-------------->" + newcmd |
|
2238 | 2242 | |
|
2239 | 2243 | # log what is now valid Python, not the actual user input (without the |
|
2240 | 2244 | # final newline) |
|
2241 | 2245 | self.log(line,newcmd,continue_prompt) |
|
2242 | 2246 | return newcmd |
|
2243 | 2247 | |
|
2244 | 2248 | def handle_help(self, line_info): |
|
2245 | 2249 | """Try to get some help for the object. |
|
2246 | 2250 | |
|
2247 | 2251 | obj? or ?obj -> basic information. |
|
2248 | 2252 | obj?? or ??obj -> more details. |
|
2249 | 2253 | """ |
|
2250 | 2254 | |
|
2251 | 2255 | line = line_info.line |
|
2252 | 2256 | # We need to make sure that we don't process lines which would be |
|
2253 | 2257 | # otherwise valid python, such as "x=1 # what?" |
|
2254 | 2258 | try: |
|
2255 | 2259 | codeop.compile_command(line) |
|
2256 | 2260 | except SyntaxError: |
|
2257 | 2261 | # We should only handle as help stuff which is NOT valid syntax |
|
2258 | 2262 | if line[0]==self.ESC_HELP: |
|
2259 | 2263 | line = line[1:] |
|
2260 | 2264 | elif line[-1]==self.ESC_HELP: |
|
2261 | 2265 | line = line[:-1] |
|
2262 | 2266 | self.log(line,'#?'+line,line_info.continue_prompt) |
|
2263 | 2267 | if line: |
|
2264 | 2268 | #print 'line:<%r>' % line # dbg |
|
2265 | 2269 | self.magic_pinfo(line) |
|
2266 | 2270 | else: |
|
2267 | 2271 | page(self.usage,screen_lines=self.rc.screen_length) |
|
2268 | 2272 | return '' # Empty string is needed here! |
|
2269 | 2273 | except: |
|
2270 | 2274 | # Pass any other exceptions through to the normal handler |
|
2271 | 2275 | return self.handle_normal(line_info) |
|
2272 | 2276 | else: |
|
2273 | 2277 | # If the code compiles ok, we should handle it normally |
|
2274 | 2278 | return self.handle_normal(line_info) |
|
2275 | 2279 | |
|
2276 | 2280 | def getapi(self): |
|
2277 | 2281 | """ Get an IPApi object for this shell instance |
|
2278 | 2282 | |
|
2279 | 2283 | Getting an IPApi object is always preferable to accessing the shell |
|
2280 | 2284 | directly, but this holds true especially for extensions. |
|
2281 | 2285 | |
|
2282 | 2286 | It should always be possible to implement an extension with IPApi |
|
2283 | 2287 | alone. If not, contact maintainer to request an addition. |
|
2284 | 2288 | |
|
2285 | 2289 | """ |
|
2286 | 2290 | return self.api |
|
2287 | 2291 | |
|
2288 | 2292 | def handle_emacs(self, line_info): |
|
2289 | 2293 | """Handle input lines marked by python-mode.""" |
|
2290 | 2294 | |
|
2291 | 2295 | # Currently, nothing is done. Later more functionality can be added |
|
2292 | 2296 | # here if needed. |
|
2293 | 2297 | |
|
2294 | 2298 | # The input cache shouldn't be updated |
|
2295 | 2299 | return line_info.line |
|
2296 | 2300 | |
|
2297 | 2301 | |
|
2298 | 2302 | def mktempfile(self,data=None): |
|
2299 | 2303 | """Make a new tempfile and return its filename. |
|
2300 | 2304 | |
|
2301 | 2305 | This makes a call to tempfile.mktemp, but it registers the created |
|
2302 | 2306 | filename internally so ipython cleans it up at exit time. |
|
2303 | 2307 | |
|
2304 | 2308 | Optional inputs: |
|
2305 | 2309 | |
|
2306 | 2310 | - data(None): if data is given, it gets written out to the temp file |
|
2307 | 2311 | immediately, and the file is closed again.""" |
|
2308 | 2312 | |
|
2309 | 2313 | filename = tempfile.mktemp('.py','ipython_edit_') |
|
2310 | 2314 | self.tempfiles.append(filename) |
|
2311 | 2315 | |
|
2312 | 2316 | if data: |
|
2313 | 2317 | tmp_file = open(filename,'w') |
|
2314 | 2318 | tmp_file.write(data) |
|
2315 | 2319 | tmp_file.close() |
|
2316 | 2320 | return filename |
|
2317 | 2321 | |
|
2318 | 2322 | def write(self,data): |
|
2319 | 2323 | """Write a string to the default output""" |
|
2320 | 2324 | Term.cout.write(data) |
|
2321 | 2325 | |
|
2322 | 2326 | def write_err(self,data): |
|
2323 | 2327 | """Write a string to the default error output""" |
|
2324 | 2328 | Term.cerr.write(data) |
|
2325 | 2329 | |
|
2326 | 2330 | def exit(self): |
|
2327 | 2331 | """Handle interactive exit. |
|
2328 | 2332 | |
|
2329 | 2333 | This method sets the exit_now attribute.""" |
|
2330 | 2334 | |
|
2331 | 2335 | if self.rc.confirm_exit: |
|
2332 | 2336 | if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'): |
|
2333 | 2337 | self.exit_now = True |
|
2334 | 2338 | else: |
|
2335 | 2339 | self.exit_now = True |
|
2336 | 2340 | |
|
2337 | 2341 | def safe_execfile(self,fname,*where,**kw): |
|
2338 | 2342 | """A safe version of the builtin execfile(). |
|
2339 | 2343 | |
|
2340 | 2344 | This version will never throw an exception, and knows how to handle |
|
2341 | 2345 | ipython logs as well.""" |
|
2342 | 2346 | |
|
2343 | 2347 | def syspath_cleanup(): |
|
2344 | 2348 | """Internal cleanup routine for sys.path.""" |
|
2345 | 2349 | if add_dname: |
|
2346 | 2350 | try: |
|
2347 | 2351 | sys.path.remove(dname) |
|
2348 | 2352 | except ValueError: |
|
2349 | 2353 | # For some reason the user has already removed it, ignore. |
|
2350 | 2354 | pass |
|
2351 | 2355 | |
|
2352 | 2356 | fname = os.path.expanduser(fname) |
|
2353 | 2357 | |
|
2354 | 2358 | # Find things also in current directory. This is needed to mimic the |
|
2355 | 2359 | # behavior of running a script from the system command line, where |
|
2356 | 2360 | # Python inserts the script's directory into sys.path |
|
2357 | 2361 | dname = os.path.dirname(os.path.abspath(fname)) |
|
2358 | 2362 | add_dname = False |
|
2359 | 2363 | if dname not in sys.path: |
|
2360 | 2364 | sys.path.insert(0,dname) |
|
2361 | 2365 | add_dname = True |
|
2362 | 2366 | |
|
2363 | 2367 | try: |
|
2364 | 2368 | xfile = open(fname) |
|
2365 | 2369 | except: |
|
2366 | 2370 | print >> Term.cerr, \ |
|
2367 | 2371 | 'Could not open file <%s> for safe execution.' % fname |
|
2368 | 2372 | syspath_cleanup() |
|
2369 | 2373 | return None |
|
2370 | 2374 | |
|
2371 | 2375 | kw.setdefault('islog',0) |
|
2372 | 2376 | kw.setdefault('quiet',1) |
|
2373 | 2377 | kw.setdefault('exit_ignore',0) |
|
2374 | 2378 | first = xfile.readline() |
|
2375 | 2379 | loghead = str(self.loghead_tpl).split('\n',1)[0].strip() |
|
2376 | 2380 | xfile.close() |
|
2377 | 2381 | # line by line execution |
|
2378 | 2382 | if first.startswith(loghead) or kw['islog']: |
|
2379 | 2383 | print 'Loading log file <%s> one line at a time...' % fname |
|
2380 | 2384 | if kw['quiet']: |
|
2381 | 2385 | stdout_save = sys.stdout |
|
2382 | 2386 | sys.stdout = StringIO.StringIO() |
|
2383 | 2387 | try: |
|
2384 | 2388 | globs,locs = where[0:2] |
|
2385 | 2389 | except: |
|
2386 | 2390 | try: |
|
2387 | 2391 | globs = locs = where[0] |
|
2388 | 2392 | except: |
|
2389 | 2393 | globs = locs = globals() |
|
2390 | 2394 | badblocks = [] |
|
2391 | 2395 | |
|
2392 | 2396 | # we also need to identify indented blocks of code when replaying |
|
2393 | 2397 | # logs and put them together before passing them to an exec |
|
2394 | 2398 | # statement. This takes a bit of regexp and look-ahead work in the |
|
2395 | 2399 | # file. It's easiest if we swallow the whole thing in memory |
|
2396 | 2400 | # first, and manually walk through the lines list moving the |
|
2397 | 2401 | # counter ourselves. |
|
2398 | 2402 | indent_re = re.compile('\s+\S') |
|
2399 | 2403 | xfile = open(fname) |
|
2400 | 2404 | filelines = xfile.readlines() |
|
2401 | 2405 | xfile.close() |
|
2402 | 2406 | nlines = len(filelines) |
|
2403 | 2407 | lnum = 0 |
|
2404 | 2408 | while lnum < nlines: |
|
2405 | 2409 | line = filelines[lnum] |
|
2406 | 2410 | lnum += 1 |
|
2407 | 2411 | # don't re-insert logger status info into cache |
|
2408 | 2412 | if line.startswith('#log#'): |
|
2409 | 2413 | continue |
|
2410 | 2414 | else: |
|
2411 | 2415 | # build a block of code (maybe a single line) for execution |
|
2412 | 2416 | block = line |
|
2413 | 2417 | try: |
|
2414 | 2418 | next = filelines[lnum] # lnum has already incremented |
|
2415 | 2419 | except: |
|
2416 | 2420 | next = None |
|
2417 | 2421 | while next and indent_re.match(next): |
|
2418 | 2422 | block += next |
|
2419 | 2423 | lnum += 1 |
|
2420 | 2424 | try: |
|
2421 | 2425 | next = filelines[lnum] |
|
2422 | 2426 | except: |
|
2423 | 2427 | next = None |
|
2424 | 2428 | # now execute the block of one or more lines |
|
2425 | 2429 | try: |
|
2426 | 2430 | exec block in globs,locs |
|
2427 | 2431 | except SystemExit: |
|
2428 | 2432 | pass |
|
2429 | 2433 | except: |
|
2430 | 2434 | badblocks.append(block.rstrip()) |
|
2431 | 2435 | if kw['quiet']: # restore stdout |
|
2432 | 2436 | sys.stdout.close() |
|
2433 | 2437 | sys.stdout = stdout_save |
|
2434 | 2438 | print 'Finished replaying log file <%s>' % fname |
|
2435 | 2439 | if badblocks: |
|
2436 | 2440 | print >> sys.stderr, ('\nThe following lines/blocks in file ' |
|
2437 | 2441 | '<%s> reported errors:' % fname) |
|
2438 | 2442 | |
|
2439 | 2443 | for badline in badblocks: |
|
2440 | 2444 | print >> sys.stderr, badline |
|
2441 | 2445 | else: # regular file execution |
|
2442 | 2446 | try: |
|
2443 | 2447 | if sys.platform == 'win32' and sys.version_info < (2,5,1): |
|
2444 | 2448 | # Work around a bug in Python for Windows. The bug was |
|
2445 | 2449 | # fixed in in Python 2.5 r54159 and 54158, but that's still |
|
2446 | 2450 | # SVN Python as of March/07. For details, see: |
|
2447 | 2451 | # http://projects.scipy.org/ipython/ipython/ticket/123 |
|
2448 | 2452 | try: |
|
2449 | 2453 | globs,locs = where[0:2] |
|
2450 | 2454 | except: |
|
2451 | 2455 | try: |
|
2452 | 2456 | globs = locs = where[0] |
|
2453 | 2457 | except: |
|
2454 | 2458 | globs = locs = globals() |
|
2455 | 2459 | exec file(fname) in globs,locs |
|
2456 | 2460 | else: |
|
2457 | 2461 | execfile(fname,*where) |
|
2458 | 2462 | except SyntaxError: |
|
2459 | 2463 | self.showsyntaxerror() |
|
2460 | 2464 | warn('Failure executing file: <%s>' % fname) |
|
2461 | 2465 | except SystemExit,status: |
|
2462 | 2466 | if not kw['exit_ignore']: |
|
2463 | 2467 | self.showtraceback() |
|
2464 | 2468 | warn('Failure executing file: <%s>' % fname) |
|
2465 | 2469 | except: |
|
2466 | 2470 | self.showtraceback() |
|
2467 | 2471 | warn('Failure executing file: <%s>' % fname) |
|
2468 | 2472 | |
|
2469 | 2473 | syspath_cleanup() |
|
2470 | 2474 | |
|
2471 | 2475 | #************************* end of file <iplib.py> ***************************** |
@@ -1,6897 +1,6911 b'' | |||
|
1 | 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu> | |
|
2 | ||
|
3 | * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in | |
|
4 | r1357, which had killed multiple invocations of an embedded | |
|
5 | ipython (this means that example-embed has been broken for over 1 | |
|
6 | year!!!). Rather than possibly breaking the batch stuff for which | |
|
7 | the code in iplib.py/interact was introduced, I worked around the | |
|
8 | problem in the embedding class in Shell.py. We really need a | |
|
9 | bloody test suite for this code, I'm sick of finding stuff that | |
|
10 | used to work breaking left and right every time I use an old | |
|
11 | feature I hadn't touched in a few months. | |
|
12 | (kill_embedded): Add a new magic that only shows up in embedded | |
|
13 | mode, to allow users to permanently deactivate an embedded instance. | |
|
14 | ||
|
1 | 15 | 2007-08-01 Ville Vainio <vivainio@gmail.com> |
|
2 | 16 | |
|
3 | 17 | * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw |
|
4 | 18 | history gets out of sync on runlines (e.g. when running macros). |
|
5 | 19 | |
|
6 | 20 | 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
7 | 21 | |
|
8 | 22 | * IPython/Magic.py (magic_colors): fix win32-related error message |
|
9 | 23 | that could appear under *nix when readline was missing. Patch by |
|
10 | 24 | Scott Jackson, closes #175. |
|
11 | 25 | |
|
12 | 26 | 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
13 | 27 | |
|
14 | 28 | * IPython/Extensions/ipy_traits_completer.py: Add a new custom |
|
15 | 29 | completer that it traits-aware, so that traits objects don't show |
|
16 | 30 | all of their internal attributes all the time. |
|
17 | 31 | |
|
18 | 32 | * IPython/genutils.py (dir2): moved this code from inside |
|
19 | 33 | completer.py to expose it publicly, so I could use it in the |
|
20 | 34 | wildcards bugfix. |
|
21 | 35 | |
|
22 | 36 | * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by |
|
23 | 37 | Stefan with Traits. |
|
24 | 38 | |
|
25 | 39 | * IPython/completer.py (Completer.attr_matches): change internal |
|
26 | 40 | var name from 'object' to 'obj', since 'object' is now a builtin |
|
27 | 41 | and this can lead to weird bugs if reusing this code elsewhere. |
|
28 | 42 | |
|
29 | 43 | 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
30 | 44 | |
|
31 | 45 | * IPython/OInspect.py (Inspector.pinfo): fix small glitches in |
|
32 | 46 | 'foo?' and update the code to prevent printing of default |
|
33 | 47 | docstrings that started appearing after I added support for |
|
34 | 48 | new-style classes. The approach I'm using isn't ideal (I just |
|
35 | 49 | special-case those strings) but I'm not sure how to more robustly |
|
36 | 50 | differentiate between truly user-written strings and Python's |
|
37 | 51 | automatic ones. |
|
38 | 52 | |
|
39 | 53 | 2007-07-09 Ville Vainio <vivainio@gmail.com> |
|
40 | 54 | |
|
41 | 55 | * completer.py: Applied Matthew Neeley's patch: |
|
42 | 56 | Dynamic attributes from trait_names and _getAttributeNames are added |
|
43 | 57 | to the list of tab completions, but when this happens, the attribute |
|
44 | 58 | list is turned into a set, so the attributes are unordered when |
|
45 | 59 | printed, which makes it hard to find the right completion. This patch |
|
46 | 60 | turns this set back into a list and sort it. |
|
47 | 61 | |
|
48 | 62 | 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
49 | 63 | |
|
50 | 64 | * IPython/OInspect.py (Inspector.pinfo): Add support for new-style |
|
51 | 65 | classes in various inspector functions. |
|
52 | 66 | |
|
53 | 67 | 2007-06-28 Ville Vainio <vivainio@gmail.com> |
|
54 | 68 | |
|
55 | 69 | * shadowns.py, iplib.py, ipapi.py, OInspect.py: |
|
56 | 70 | Implement "shadow" namespace, and callable aliases that reside there. |
|
57 | 71 | Use them by: |
|
58 | 72 | |
|
59 | 73 | _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc |
|
60 | 74 | |
|
61 | 75 | foo hello world |
|
62 | 76 | (gets translated to:) |
|
63 | 77 | _sh.foo(r"""hello world""") |
|
64 | 78 | |
|
65 | 79 | In practice, this kind of alias can take the role of a magic function |
|
66 | 80 | |
|
67 | 81 | * New generic inspect_object, called on obj? and obj?? |
|
68 | 82 | |
|
69 | 83 | 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
70 | 84 | |
|
71 | 85 | * IPython/ultraTB.py (findsource): fix a problem with |
|
72 | 86 | inspect.getfile that can cause crashes during traceback construction. |
|
73 | 87 | |
|
74 | 88 | 2007-06-14 Ville Vainio <vivainio@gmail.com> |
|
75 | 89 | |
|
76 | 90 | * iplib.py (handle_auto): Try to use ascii for printing "--->" |
|
77 | 91 | autocall rewrite indication, becausesometimes unicode fails to print |
|
78 | 92 | properly (and you get ' - - - '). Use plain uncoloured ---> for |
|
79 | 93 | unicode. |
|
80 | 94 | |
|
81 | 95 | * shadow history. Usable through "%hist -g <pat>" and "%rep 0123". |
|
82 | 96 | |
|
83 | 97 | . pickleshare 'hash' commands (hget, hset, hcompress, |
|
84 | 98 | hdict) for efficient shadow history storage. |
|
85 | 99 | |
|
86 | 100 | 2007-06-13 Ville Vainio <vivainio@gmail.com> |
|
87 | 101 | |
|
88 | 102 | * ipapi.py: _ip.to_user_ns(vars, interactive = True). |
|
89 | 103 | Added kw arg 'interactive', tell whether vars should be visible |
|
90 | 104 | with %whos. |
|
91 | 105 | |
|
92 | 106 | 2007-06-11 Ville Vainio <vivainio@gmail.com> |
|
93 | 107 | |
|
94 | 108 | * pspersistence.py, Magic.py, iplib.py: directory history now saved |
|
95 | 109 | to db |
|
96 | 110 | |
|
97 | 111 | * iplib.py: "ipython -c <cmd>" now passes the command through prefilter. |
|
98 | 112 | Also, it exits IPython immediately after evaluating the command (just like |
|
99 | 113 | std python) |
|
100 | 114 | |
|
101 | 115 | 2007-06-05 Walter Doerwald <walter@livinglogic.de> |
|
102 | 116 | |
|
103 | 117 | * IPython/Extensions/ipipe.py: Added a new table icap, which executes a |
|
104 | 118 | Python string and captures the output. (Idea and original patch by |
|
105 | 119 | StοΏ½fan van der Walt) |
|
106 | 120 | |
|
107 | 121 | 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu> |
|
108 | 122 | |
|
109 | 123 | * IPython/ultraTB.py (VerboseTB.text): update printing of |
|
110 | 124 | exception types for Python 2.5 (now all exceptions in the stdlib |
|
111 | 125 | are new-style classes). |
|
112 | 126 | |
|
113 | 127 | 2007-05-31 Walter Doerwald <walter@livinglogic.de> |
|
114 | 128 | |
|
115 | 129 | * IPython/Extensions/igrid.py: Add new commands refresh and |
|
116 | 130 | refresh_timer (mapped to "R"/"F5" and to the menu) which restarts |
|
117 | 131 | the iterator once (refresh) or after every x seconds (refresh_timer). |
|
118 | 132 | Add a working implementation of "searchexpression", where the text |
|
119 | 133 | entered is not the text to search for, but an expression that must |
|
120 | 134 | be true. Added display of shortcuts to the menu. Added commands "pickinput" |
|
121 | 135 | and "pickinputattr" that put the object or attribute under the cursor |
|
122 | 136 | in the input line. Split the statusbar to be able to display the currently |
|
123 | 137 | active refresh interval. (Patch by Nik Tautenhahn) |
|
124 | 138 | |
|
125 | 139 | 2007-05-29 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu> |
|
126 | 140 | |
|
127 | 141 | * fixing set_term_title to use ctypes as default |
|
128 | 142 | |
|
129 | 143 | * fixing set_term_title fallback to work when curent dir |
|
130 | 144 | is on a windows network share |
|
131 | 145 | |
|
132 | 146 | 2007-05-28 Ville Vainio <vivainio@gmail.com> |
|
133 | 147 | |
|
134 | 148 | * %cpaste: strip + with > from left (diffs). |
|
135 | 149 | |
|
136 | 150 | * iplib.py: Fix crash when readline not installed |
|
137 | 151 | |
|
138 | 152 | 2007-05-26 Ville Vainio <vivainio@gmail.com> |
|
139 | 153 | |
|
140 | 154 | * generics.py: intruduce easy to extend result_display generic |
|
141 | 155 | function (using simplegeneric.py). |
|
142 | 156 | |
|
143 | 157 | * Fixed the append functionality of %set. |
|
144 | 158 | |
|
145 | 159 | 2007-05-25 Ville Vainio <vivainio@gmail.com> |
|
146 | 160 | |
|
147 | 161 | * New magic: %rep (fetch / run old commands from history) |
|
148 | 162 | |
|
149 | 163 | * New extension: mglob (%mglob magic), for powerful glob / find /filter |
|
150 | 164 | like functionality |
|
151 | 165 | |
|
152 | 166 | % maghistory.py: %hist -g PATTERM greps the history for pattern |
|
153 | 167 | |
|
154 | 168 | 2007-05-24 Walter Doerwald <walter@livinglogic.de> |
|
155 | 169 | |
|
156 | 170 | * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to |
|
157 | 171 | browse the IPython input history |
|
158 | 172 | |
|
159 | 173 | * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput |
|
160 | 174 | (mapped to "i") can be used to put the object under the curser in the input |
|
161 | 175 | line. pickinputattr (mapped to "I") does the same for the attribute under |
|
162 | 176 | the cursor. |
|
163 | 177 | |
|
164 | 178 | 2007-05-24 Ville Vainio <vivainio@gmail.com> |
|
165 | 179 | |
|
166 | 180 | * Grand magic cleansing (changeset [2380]): |
|
167 | 181 | |
|
168 | 182 | * Introduce ipy_legacy.py where the following magics were |
|
169 | 183 | moved: |
|
170 | 184 | |
|
171 | 185 | pdef pdoc psource pfile rehash dhist Quit p r automagic autocall |
|
172 | 186 | |
|
173 | 187 | If you need them, either use default profile or "import ipy_legacy" |
|
174 | 188 | in your ipy_user_conf.py |
|
175 | 189 | |
|
176 | 190 | * Move sh and scipy profile to Extensions from UserConfig. this implies |
|
177 | 191 | you should not edit them, but you don't need to run %upgrade when |
|
178 | 192 | upgrading IPython anymore. |
|
179 | 193 | |
|
180 | 194 | * %hist/%history now operates in "raw" mode by default. To get the old |
|
181 | 195 | behaviour, run '%hist -n' (native mode). |
|
182 | 196 | |
|
183 | 197 | * split ipy_stock_completers.py to ipy_stock_completers.py and |
|
184 | 198 | ipy_app_completers.py. Stock completers (%cd, import, %run) are now |
|
185 | 199 | installed as default. |
|
186 | 200 | |
|
187 | 201 | * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c |
|
188 | 202 | handling. |
|
189 | 203 | |
|
190 | 204 | * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default") |
|
191 | 205 | input if readline is available. |
|
192 | 206 | |
|
193 | 207 | 2007-05-23 Ville Vainio <vivainio@gmail.com> |
|
194 | 208 | |
|
195 | 209 | * macro.py: %store uses __getstate__ properly |
|
196 | 210 | |
|
197 | 211 | * exesetup.py: added new setup script for creating |
|
198 | 212 | standalone IPython executables with py2exe (i.e. |
|
199 | 213 | no python installation required). |
|
200 | 214 | |
|
201 | 215 | * Removed ipythonrc-scipy, ipy_profile_scipy.py takes |
|
202 | 216 | its place. |
|
203 | 217 | |
|
204 | 218 | * rlineimpl.py, genutils.py (get_home_dir): py2exe support |
|
205 | 219 | |
|
206 | 220 | 2007-05-21 Ville Vainio <vivainio@gmail.com> |
|
207 | 221 | |
|
208 | 222 | * platutil_win32.py (set_term_title): handle |
|
209 | 223 | failure of 'title' system call properly. |
|
210 | 224 | |
|
211 | 225 | 2007-05-17 Walter Doerwald <walter@livinglogic.de> |
|
212 | 226 | |
|
213 | 227 | * IPython/Extensions/ipipe.py: Fix xrepr for ifiles. |
|
214 | 228 | (Bug detected by Paul Mueller). |
|
215 | 229 | |
|
216 | 230 | 2007-05-16 Ville Vainio <vivainio@gmail.com> |
|
217 | 231 | |
|
218 | 232 | * ipy_profile_sci.py, ipython_win_post_install.py: Create |
|
219 | 233 | new "sci" profile, effectively a modern version of the old |
|
220 | 234 | "scipy" profile (which is now slated for deprecation). |
|
221 | 235 | |
|
222 | 236 | 2007-05-15 Ville Vainio <vivainio@gmail.com> |
|
223 | 237 | |
|
224 | 238 | * pycolorize.py, pycolor.1: Paul Mueller's patches that |
|
225 | 239 | make pycolorize read input from stdin when run without arguments. |
|
226 | 240 | |
|
227 | 241 | * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155 |
|
228 | 242 | |
|
229 | 243 | * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import |
|
230 | 244 | it in sh profile (instead of ipy_system_conf.py). |
|
231 | 245 | |
|
232 | 246 | * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command |
|
233 | 247 | aliases are now lower case on windows (MyCommand.exe => mycommand). |
|
234 | 248 | |
|
235 | 249 | * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul. |
|
236 | 250 | Macros are now callable objects that inherit from ipapi.IPyAutocall, |
|
237 | 251 | i.e. get autocalled regardless of system autocall setting. |
|
238 | 252 | |
|
239 | 253 | 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
240 | 254 | |
|
241 | 255 | * IPython/rlineimpl.py: check for clear_history in readline and |
|
242 | 256 | make it a dummy no-op if not available. This function isn't |
|
243 | 257 | guaranteed to be in the API and appeared in Python 2.4, so we need |
|
244 | 258 | to check it ourselves. Also, clean up this file quite a bit. |
|
245 | 259 | |
|
246 | 260 | * ipython.1: update man page and full manual with information |
|
247 | 261 | about threads (remove outdated warning). Closes #151. |
|
248 | 262 | |
|
249 | 263 | 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
250 | 264 | |
|
251 | 265 | * IPython/Extensions/ipy_constants.py: Add Gael's constants module |
|
252 | 266 | in trunk (note that this made it into the 0.8.1 release already, |
|
253 | 267 | but the changelogs didn't get coordinated). Many thanks to Gael |
|
254 | 268 | Varoquaux <gael.varoquaux-AT-normalesup.org> |
|
255 | 269 | |
|
256 | 270 | 2007-05-09 *** Released version 0.8.1 |
|
257 | 271 | |
|
258 | 272 | 2007-05-10 Walter Doerwald <walter@livinglogic.de> |
|
259 | 273 | |
|
260 | 274 | * IPython/Extensions/igrid.py: Incorporate html help into |
|
261 | 275 | the module, so we don't have to search for the file. |
|
262 | 276 | |
|
263 | 277 | 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
264 | 278 | |
|
265 | 279 | * test/test_irunner.py (RunnerTestCase._test_runner): Close #147. |
|
266 | 280 | |
|
267 | 281 | 2007-04-30 Ville Vainio <vivainio@gmail.com> |
|
268 | 282 | |
|
269 | 283 | * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the |
|
270 | 284 | user has illegal (non-ascii) home directory name |
|
271 | 285 | |
|
272 | 286 | 2007-04-27 Ville Vainio <vivainio@gmail.com> |
|
273 | 287 | |
|
274 | 288 | * platutils_win32.py: implement set_term_title for windows |
|
275 | 289 | |
|
276 | 290 | * Update version number |
|
277 | 291 | |
|
278 | 292 | * ipy_profile_sh.py: more informative prompt (2 dir levels) |
|
279 | 293 | |
|
280 | 294 | 2007-04-26 Walter Doerwald <walter@livinglogic.de> |
|
281 | 295 | |
|
282 | 296 | * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced |
|
283 | 297 | when the igrid input raised an exception. (Patch by Nik Tautenhahn, |
|
284 | 298 | bug discovered by Ville). |
|
285 | 299 | |
|
286 | 300 | 2007-04-26 Ville Vainio <vivainio@gmail.com> |
|
287 | 301 | |
|
288 | 302 | * Extensions/ipy_completers.py: Olivier's module completer now |
|
289 | 303 | saves the list of root modules if it takes > 4 secs on the first run. |
|
290 | 304 | |
|
291 | 305 | * Magic.py (%rehashx): %rehashx now clears the completer cache |
|
292 | 306 | |
|
293 | 307 | |
|
294 | 308 | 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
295 | 309 | |
|
296 | 310 | * ipython.el: fix incorrect color scheme, reported by Stefan. |
|
297 | 311 | Closes #149. |
|
298 | 312 | |
|
299 | 313 | * IPython/PyColorize.py (Parser.format2): fix state-handling |
|
300 | 314 | logic. I still don't like how that code handles state, but at |
|
301 | 315 | least now it should be correct, if inelegant. Closes #146. |
|
302 | 316 | |
|
303 | 317 | 2007-04-25 Ville Vainio <vivainio@gmail.com> |
|
304 | 318 | |
|
305 | 319 | * Extensions/ipy_which.py: added extension for %which magic, works |
|
306 | 320 | a lot like unix 'which' but also finds and expands aliases, and |
|
307 | 321 | allows wildcards. |
|
308 | 322 | |
|
309 | 323 | * ipapi.py (expand_alias): Now actually *return* the expanded alias, |
|
310 | 324 | as opposed to returning nothing. |
|
311 | 325 | |
|
312 | 326 | * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import |
|
313 | 327 | ipy_stock_completers on default profile, do import on sh profile. |
|
314 | 328 | |
|
315 | 329 | 2007-04-22 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu> |
|
316 | 330 | |
|
317 | 331 | * Fix bug in iplib.py/safe_execfile when launching ipython with a script |
|
318 | 332 | like ipython.py foo.py which raised a IndexError. |
|
319 | 333 | |
|
320 | 334 | 2007-04-21 Ville Vainio <vivainio@gmail.com> |
|
321 | 335 | |
|
322 | 336 | * Extensions/ipy_extutil.py: added extension to manage other ipython |
|
323 | 337 | extensions. Now only supports 'ls' == list extensions. |
|
324 | 338 | |
|
325 | 339 | 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
326 | 340 | |
|
327 | 341 | * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that |
|
328 | 342 | would prevent use of the exception system outside of a running |
|
329 | 343 | IPython instance. |
|
330 | 344 | |
|
331 | 345 | 2007-04-20 Ville Vainio <vivainio@gmail.com> |
|
332 | 346 | |
|
333 | 347 | * Extensions/ipy_render.py: added extension for easy |
|
334 | 348 | interactive text template rendering (to clipboard). Uses Ka-Ping Yee's |
|
335 | 349 | 'Iptl' template notation, |
|
336 | 350 | |
|
337 | 351 | * Extensions/ipy_completers.py: introduced Olivier Lauzanne's |
|
338 | 352 | safer & faster 'import' completer. |
|
339 | 353 | |
|
340 | 354 | * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value) |
|
341 | 355 | and _ip.defalias(name, command). |
|
342 | 356 | |
|
343 | 357 | * Extensions/ipy_exportdb.py: New extension for exporting all the |
|
344 | 358 | %store'd data in a portable format (normal ipapi calls like |
|
345 | 359 | defmacro() etc.) |
|
346 | 360 | |
|
347 | 361 | 2007-04-19 Ville Vainio <vivainio@gmail.com> |
|
348 | 362 | |
|
349 | 363 | * upgrade_dir.py: skip junk files like *.pyc |
|
350 | 364 | |
|
351 | 365 | * Release.py: version number to 0.8.1 |
|
352 | 366 | |
|
353 | 367 | 2007-04-18 Ville Vainio <vivainio@gmail.com> |
|
354 | 368 | |
|
355 | 369 | * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1 |
|
356 | 370 | and later on win32. |
|
357 | 371 | |
|
358 | 372 | 2007-04-16 Ville Vainio <vivainio@gmail.com> |
|
359 | 373 | |
|
360 | 374 | * iplib.py (showtraceback): Do not crash when running w/o readline. |
|
361 | 375 | |
|
362 | 376 | 2007-04-12 Walter Doerwald <walter@livinglogic.de> |
|
363 | 377 | |
|
364 | 378 | * IPython/Extensions/ipipe.py: (ils) Directoy listings are now |
|
365 | 379 | sorted (case sensitive with files and dirs mixed). |
|
366 | 380 | |
|
367 | 381 | 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
368 | 382 | |
|
369 | 383 | * IPython/Release.py (version): Open trunk for 0.8.1 development. |
|
370 | 384 | |
|
371 | 385 | 2007-04-10 *** Released version 0.8.0 |
|
372 | 386 | |
|
373 | 387 | 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
374 | 388 | |
|
375 | 389 | * Tag 0.8.0 for release. |
|
376 | 390 | |
|
377 | 391 | * IPython/iplib.py (reloadhist): add API function to cleanly |
|
378 | 392 | reload the readline history, which was growing inappropriately on |
|
379 | 393 | every %run call. |
|
380 | 394 | |
|
381 | 395 | * win32_manual_post_install.py (run): apply last part of Nicolas |
|
382 | 396 | Pernetty's patch (I'd accidentally applied it in a different |
|
383 | 397 | directory and this particular file didn't get patched). |
|
384 | 398 | |
|
385 | 399 | 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
386 | 400 | |
|
387 | 401 | * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to |
|
388 | 402 | find the main thread id and use the proper API call. Thanks to |
|
389 | 403 | Stefan for the fix. |
|
390 | 404 | |
|
391 | 405 | * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's |
|
392 | 406 | unit tests to reflect fixed ticket #52, and add more tests sent by |
|
393 | 407 | him. |
|
394 | 408 | |
|
395 | 409 | * IPython/iplib.py (raw_input): restore the readline completer |
|
396 | 410 | state on every input, in case third-party code messed it up. |
|
397 | 411 | (_prefilter): revert recent addition of early-escape checks which |
|
398 | 412 | prevent many valid alias calls from working. |
|
399 | 413 | |
|
400 | 414 | * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking |
|
401 | 415 | flag for sigint handler so we don't run a full signal() call on |
|
402 | 416 | each runcode access. |
|
403 | 417 | |
|
404 | 418 | * IPython/Magic.py (magic_whos): small improvement to diagnostic |
|
405 | 419 | message. |
|
406 | 420 | |
|
407 | 421 | 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu> |
|
408 | 422 | |
|
409 | 423 | * IPython/Shell.py (sigint_handler): I *THINK* I finally got |
|
410 | 424 | asynchronous exceptions working, i.e., Ctrl-C can actually |
|
411 | 425 | interrupt long-running code in the multithreaded shells. |
|
412 | 426 | |
|
413 | 427 | This is using Tomer Filiba's great ctypes-based trick: |
|
414 | 428 | http://sebulba.wikispaces.com/recipe+thread2. I'd already tried |
|
415 | 429 | this in the past, but hadn't been able to make it work before. So |
|
416 | 430 | far it looks like it's actually running, but this needs more |
|
417 | 431 | testing. If it really works, I'll be *very* happy, and we'll owe |
|
418 | 432 | a huge thank you to Tomer. My current implementation is ugly, |
|
419 | 433 | hackish and uses nasty globals, but I don't want to try and clean |
|
420 | 434 | anything up until we know if it actually works. |
|
421 | 435 | |
|
422 | 436 | NOTE: this feature needs ctypes to work. ctypes is included in |
|
423 | 437 | Python2.5, but 2.4 users will need to manually install it. This |
|
424 | 438 | feature makes multi-threaded shells so much more usable that it's |
|
425 | 439 | a minor price to pay (ctypes is very easy to install, already a |
|
426 | 440 | requirement for win32 and available in major linux distros). |
|
427 | 441 | |
|
428 | 442 | 2007-04-04 Ville Vainio <vivainio@gmail.com> |
|
429 | 443 | |
|
430 | 444 | * Extensions/ipy_completers.py, ipy_stock_completers.py: |
|
431 | 445 | Moved implementations of 'bundled' completers to ipy_completers.py, |
|
432 | 446 | they are only enabled in ipy_stock_completers.py. |
|
433 | 447 | |
|
434 | 448 | 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu> |
|
435 | 449 | |
|
436 | 450 | * IPython/PyColorize.py (Parser.format2): Fix identation of |
|
437 | 451 | colorzied output and return early if color scheme is NoColor, to |
|
438 | 452 | avoid unnecessary and expensive tokenization. Closes #131. |
|
439 | 453 | |
|
440 | 454 | 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
441 | 455 | |
|
442 | 456 | * IPython/Debugger.py: disable the use of pydb version 1.17. It |
|
443 | 457 | has a critical bug (a missing import that makes post-mortem not |
|
444 | 458 | work at all). Unfortunately as of this time, this is the version |
|
445 | 459 | shipped with Ubuntu Edgy, so quite a few people have this one. I |
|
446 | 460 | hope Edgy will update to a more recent package. |
|
447 | 461 | |
|
448 | 462 | 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
449 | 463 | |
|
450 | 464 | * IPython/iplib.py (_prefilter): close #52, second part of a patch |
|
451 | 465 | set by Stefan (only the first part had been applied before). |
|
452 | 466 | |
|
453 | 467 | * IPython/Extensions/ipy_stock_completers.py (module_completer): |
|
454 | 468 | remove usage of the dangerous pkgutil.walk_packages(). See |
|
455 | 469 | details in comments left in the code. |
|
456 | 470 | |
|
457 | 471 | * IPython/Magic.py (magic_whos): add support for numpy arrays |
|
458 | 472 | similar to what we had for Numeric. |
|
459 | 473 | |
|
460 | 474 | * IPython/completer.py (IPCompleter.complete): extend the |
|
461 | 475 | complete() call API to support completions by other mechanisms |
|
462 | 476 | than readline. Closes #109. |
|
463 | 477 | |
|
464 | 478 | * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to |
|
465 | 479 | protect against a bug in Python's execfile(). Closes #123. |
|
466 | 480 | |
|
467 | 481 | 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu> |
|
468 | 482 | |
|
469 | 483 | * IPython/iplib.py (split_user_input): ensure that when splitting |
|
470 | 484 | user input, the part that can be treated as a python name is pure |
|
471 | 485 | ascii (Python identifiers MUST be pure ascii). Part of the |
|
472 | 486 | ongoing Unicode support work. |
|
473 | 487 | |
|
474 | 488 | * IPython/Prompts.py (prompt_specials_color): Add \N for the |
|
475 | 489 | actual prompt number, without any coloring. This allows users to |
|
476 | 490 | produce numbered prompts with their own colors. Added after a |
|
477 | 491 | report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
478 | 492 | |
|
479 | 493 | 2007-03-31 Walter Doerwald <walter@livinglogic.de> |
|
480 | 494 | |
|
481 | 495 | * IPython/Extensions/igrid.py: Map the return key |
|
482 | 496 | to enter() and shift-return to enterattr(). |
|
483 | 497 | |
|
484 | 498 | 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
485 | 499 | |
|
486 | 500 | * IPython/Magic.py (magic_psearch): add unicode support by |
|
487 | 501 | encoding to ascii the input, since this routine also only deals |
|
488 | 502 | with valid Python names. Fixes a bug reported by Stefan. |
|
489 | 503 | |
|
490 | 504 | 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
491 | 505 | |
|
492 | 506 | * IPython/Magic.py (_inspect): convert unicode input into ascii |
|
493 | 507 | before trying to evaluate it as a Python identifier. This fixes a |
|
494 | 508 | problem that the new unicode support had introduced when analyzing |
|
495 | 509 | long definition lines for functions. |
|
496 | 510 | |
|
497 | 511 | 2007-03-24 Walter Doerwald <walter@livinglogic.de> |
|
498 | 512 | |
|
499 | 513 | * IPython/Extensions/igrid.py: Fix picking. Using |
|
500 | 514 | igrid with wxPython 2.6 and -wthread should work now. |
|
501 | 515 | igrid.display() simply tries to create a frame without |
|
502 | 516 | an application. Only if this fails an application is created. |
|
503 | 517 | |
|
504 | 518 | 2007-03-23 Walter Doerwald <walter@livinglogic.de> |
|
505 | 519 | |
|
506 | 520 | * IPython/Extensions/path.py: Updated to version 2.2. |
|
507 | 521 | |
|
508 | 522 | 2007-03-23 Ville Vainio <vivainio@gmail.com> |
|
509 | 523 | |
|
510 | 524 | * iplib.py: recursive alias expansion now works better, so that |
|
511 | 525 | cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top' |
|
512 | 526 | doesn't trip up the process, if 'd' has been aliased to 'ls'. |
|
513 | 527 | |
|
514 | 528 | * Extensions/ipy_gnuglobal.py added, provides %global magic |
|
515 | 529 | for users of http://www.gnu.org/software/global |
|
516 | 530 | |
|
517 | 531 | * iplib.py: '!command /?' now doesn't invoke IPython's help system. |
|
518 | 532 | Closes #52. Patch by Stefan van der Walt. |
|
519 | 533 | |
|
520 | 534 | 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
521 | 535 | |
|
522 | 536 | * IPython/FakeModule.py (FakeModule.__init__): Small fix to |
|
523 | 537 | respect the __file__ attribute when using %run. Thanks to a bug |
|
524 | 538 | report by Sebastian Rooks <sebastian.rooks-AT-free.fr>. |
|
525 | 539 | |
|
526 | 540 | 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
527 | 541 | |
|
528 | 542 | * IPython/iplib.py (raw_input): Fix mishandling of unicode at |
|
529 | 543 | input. Patch sent by Stefan. |
|
530 | 544 | |
|
531 | 545 | 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu> |
|
532 | 546 | * IPython/Extensions/ipy_stock_completer.py |
|
533 | 547 | shlex_split, fix bug in shlex_split. len function |
|
534 | 548 | call was missing an if statement. Caused shlex_split to |
|
535 | 549 | sometimes return "" as last element. |
|
536 | 550 | |
|
537 | 551 | 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
538 | 552 | |
|
539 | 553 | * IPython/completer.py |
|
540 | 554 | (IPCompleter.file_matches.single_dir_expand): fix a problem |
|
541 | 555 | reported by Stefan, where directories containign a single subdir |
|
542 | 556 | would be completed too early. |
|
543 | 557 | |
|
544 | 558 | * IPython/Shell.py (_load_pylab): Make the execution of 'from |
|
545 | 559 | pylab import *' when -pylab is given be optional. A new flag, |
|
546 | 560 | pylab_import_all controls this behavior, the default is True for |
|
547 | 561 | backwards compatibility. |
|
548 | 562 | |
|
549 | 563 | * IPython/ultraTB.py (_formatTracebackLines): Added (slightly |
|
550 | 564 | modified) R. Bernstein's patch for fully syntax highlighted |
|
551 | 565 | tracebacks. The functionality is also available under ultraTB for |
|
552 | 566 | non-ipython users (someone using ultraTB but outside an ipython |
|
553 | 567 | session). They can select the color scheme by setting the |
|
554 | 568 | module-level global DEFAULT_SCHEME. The highlight functionality |
|
555 | 569 | also works when debugging. |
|
556 | 570 | |
|
557 | 571 | * IPython/genutils.py (IOStream.close): small patch by |
|
558 | 572 | R. Bernstein for improved pydb support. |
|
559 | 573 | |
|
560 | 574 | * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by |
|
561 | 575 | DaveS <davls@telus.net> to improve support of debugging under |
|
562 | 576 | NTEmacs, including improved pydb behavior. |
|
563 | 577 | |
|
564 | 578 | * IPython/Magic.py (magic_prun): Fix saving of profile info for |
|
565 | 579 | Python 2.5, where the stats object API changed a little. Thanks |
|
566 | 580 | to a bug report by Paul Smith <paul.smith-AT-catugmt.com>. |
|
567 | 581 | |
|
568 | 582 | * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas |
|
569 | 583 | Pernetty's patch to improve support for (X)Emacs under Win32. |
|
570 | 584 | |
|
571 | 585 | 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
572 | 586 | |
|
573 | 587 | * IPython/Shell.py (hijack_wx): ipmort WX with current semantics |
|
574 | 588 | to quiet a deprecation warning that fires with Wx 2.8. Thanks to |
|
575 | 589 | a report by Nik Tautenhahn. |
|
576 | 590 | |
|
577 | 591 | 2007-03-16 Walter Doerwald <walter@livinglogic.de> |
|
578 | 592 | |
|
579 | 593 | * setup.py: Add the igrid help files to the list of data files |
|
580 | 594 | to be installed alongside igrid. |
|
581 | 595 | * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn) |
|
582 | 596 | Show the input object of the igrid browser as the window tile. |
|
583 | 597 | Show the object the cursor is on in the statusbar. |
|
584 | 598 | |
|
585 | 599 | 2007-03-15 Ville Vainio <vivainio@gmail.com> |
|
586 | 600 | |
|
587 | 601 | * Extensions/ipy_stock_completers.py: Fixed exception |
|
588 | 602 | on mismatching quotes in %run completer. Patch by |
|
589 | 603 | JοΏ½rgen Stenarson. Closes #127. |
|
590 | 604 | |
|
591 | 605 | 2007-03-14 Ville Vainio <vivainio@gmail.com> |
|
592 | 606 | |
|
593 | 607 | * Extensions/ext_rehashdir.py: Do not do auto_alias |
|
594 | 608 | in %rehashdir, it clobbers %store'd aliases. |
|
595 | 609 | |
|
596 | 610 | * UserConfig/ipy_profile_sh.py: envpersist.py extension |
|
597 | 611 | (beefed up %env) imported for sh profile. |
|
598 | 612 | |
|
599 | 613 | 2007-03-10 Walter Doerwald <walter@livinglogic.de> |
|
600 | 614 | |
|
601 | 615 | * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid |
|
602 | 616 | as the default browser. |
|
603 | 617 | * IPython/Extensions/igrid.py: Make a few igrid attributes private. |
|
604 | 618 | As igrid displays all attributes it ever encounters, fetch() (which has |
|
605 | 619 | been renamed to _fetch()) doesn't have to recalculate the display attributes |
|
606 | 620 | every time a new item is fetched. This should speed up scrolling. |
|
607 | 621 | |
|
608 | 622 | 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
609 | 623 | |
|
610 | 624 | * IPython/iplib.py (InteractiveShell.__init__): fix for Alex |
|
611 | 625 | Schmolck's recently reported tab-completion bug (my previous one |
|
612 | 626 | had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>. |
|
613 | 627 | |
|
614 | 628 | 2007-03-09 Walter Doerwald <walter@livinglogic.de> |
|
615 | 629 | |
|
616 | 630 | * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn: |
|
617 | 631 | Close help window if exiting igrid. |
|
618 | 632 | |
|
619 | 633 | 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu> |
|
620 | 634 | |
|
621 | 635 | * IPython/Extensions/ipy_defaults.py: Check if readline is available |
|
622 | 636 | before calling functions from readline. |
|
623 | 637 | |
|
624 | 638 | 2007-03-02 Walter Doerwald <walter@livinglogic.de> |
|
625 | 639 | |
|
626 | 640 | * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension. |
|
627 | 641 | igrid is a wxPython-based display object for ipipe. If your system has |
|
628 | 642 | wx installed igrid will be the default display. Without wx ipipe falls |
|
629 | 643 | back to ibrowse (which needs curses). If no curses is installed ipipe |
|
630 | 644 | falls back to idump. |
|
631 | 645 | |
|
632 | 646 | 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu> |
|
633 | 647 | |
|
634 | 648 | * IPython/iplib.py (split_user_inputBROKEN): temporarily disable |
|
635 | 649 | my changes from yesterday, they introduced bugs. Will reactivate |
|
636 | 650 | once I get a correct solution, which will be much easier thanks to |
|
637 | 651 | Dan Milstein's new prefilter test suite. |
|
638 | 652 | |
|
639 | 653 | 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
640 | 654 | |
|
641 | 655 | * IPython/iplib.py (split_user_input): fix input splitting so we |
|
642 | 656 | don't attempt attribute accesses on things that can't possibly be |
|
643 | 657 | valid Python attributes. After a bug report by Alex Schmolck. |
|
644 | 658 | (InteractiveShell.__init__): brown-paper bag fix; regexp broke |
|
645 | 659 | %magic with explicit % prefix. |
|
646 | 660 | |
|
647 | 661 | 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
648 | 662 | |
|
649 | 663 | * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to |
|
650 | 664 | avoid a DeprecationWarning from GTK. |
|
651 | 665 | |
|
652 | 666 | 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
653 | 667 | |
|
654 | 668 | * IPython/genutils.py (clock): I modified clock() to return total |
|
655 | 669 | time, user+system. This is a more commonly needed metric. I also |
|
656 | 670 | introduced the new clocku/clocks to get only user/system time if |
|
657 | 671 | one wants those instead. |
|
658 | 672 | |
|
659 | 673 | ***WARNING: API CHANGE*** clock() used to return only user time, |
|
660 | 674 | so if you want exactly the same results as before, use clocku |
|
661 | 675 | instead. |
|
662 | 676 | |
|
663 | 677 | 2007-02-22 Ville Vainio <vivainio@gmail.com> |
|
664 | 678 | |
|
665 | 679 | * IPython/Extensions/ipy_p4.py: Extension for improved |
|
666 | 680 | p4 (perforce version control system) experience. |
|
667 | 681 | Adds %p4 magic with p4 command completion and |
|
668 | 682 | automatic -G argument (marshall output as python dict) |
|
669 | 683 | |
|
670 | 684 | 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
671 | 685 | |
|
672 | 686 | * IPython/demo.py (Demo.re_stop): make dashes optional in demo |
|
673 | 687 | stop marks. |
|
674 | 688 | (ClearingMixin): a simple mixin to easily make a Demo class clear |
|
675 | 689 | the screen in between blocks and have empty marquees. The |
|
676 | 690 | ClearDemo and ClearIPDemo classes that use it are included. |
|
677 | 691 | |
|
678 | 692 | 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
679 | 693 | |
|
680 | 694 | * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to |
|
681 | 695 | protect against exceptions at Python shutdown time. Patch |
|
682 | 696 | sumbmitted to upstream. |
|
683 | 697 | |
|
684 | 698 | 2007-02-14 Walter Doerwald <walter@livinglogic.de> |
|
685 | 699 | |
|
686 | 700 | * IPython/Extensions/ibrowse.py: If entering the first object level |
|
687 | 701 | (i.e. the object for which the browser has been started) fails, |
|
688 | 702 | now the error is raised directly (aborting the browser) instead of |
|
689 | 703 | running into an empty levels list later. |
|
690 | 704 | |
|
691 | 705 | 2007-02-03 Walter Doerwald <walter@livinglogic.de> |
|
692 | 706 | |
|
693 | 707 | * IPython/Extensions/ipipe.py: Add an xrepr implementation |
|
694 | 708 | for the noitem object. |
|
695 | 709 | |
|
696 | 710 | 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
697 | 711 | |
|
698 | 712 | * IPython/completer.py (Completer.attr_matches): Fix small |
|
699 | 713 | tab-completion bug with Enthought Traits objects with units. |
|
700 | 714 | Thanks to a bug report by Tom Denniston |
|
701 | 715 | <tom.denniston-AT-alum.dartmouth.org>. |
|
702 | 716 | |
|
703 | 717 | 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
704 | 718 | |
|
705 | 719 | * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a |
|
706 | 720 | bug where only .ipy or .py would be completed. Once the first |
|
707 | 721 | argument to %run has been given, all completions are valid because |
|
708 | 722 | they are the arguments to the script, which may well be non-python |
|
709 | 723 | filenames. |
|
710 | 724 | |
|
711 | 725 | * IPython/irunner.py (InteractiveRunner.run_source): major updates |
|
712 | 726 | to irunner to allow it to correctly support real doctesting of |
|
713 | 727 | out-of-process ipython code. |
|
714 | 728 | |
|
715 | 729 | * IPython/Magic.py (magic_cd): Make the setting of the terminal |
|
716 | 730 | title an option (-noterm_title) because it completely breaks |
|
717 | 731 | doctesting. |
|
718 | 732 | |
|
719 | 733 | * IPython/demo.py: fix IPythonDemo class that was not actually working. |
|
720 | 734 | |
|
721 | 735 | 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
722 | 736 | |
|
723 | 737 | * IPython/irunner.py (main): fix small bug where extensions were |
|
724 | 738 | not being correctly recognized. |
|
725 | 739 | |
|
726 | 740 | 2007-01-23 Walter Doerwald <walter@livinglogic.de> |
|
727 | 741 | |
|
728 | 742 | * IPython/Extensions/ipipe.py (xiter): Make sure that iterating |
|
729 | 743 | a string containing a single line yields the string itself as the |
|
730 | 744 | only item. |
|
731 | 745 | |
|
732 | 746 | * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an |
|
733 | 747 | object if it's the same as the one on the last level (This avoids |
|
734 | 748 | infinite recursion for one line strings). |
|
735 | 749 | |
|
736 | 750 | 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
737 | 751 | |
|
738 | 752 | * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush |
|
739 | 753 | all output streams before printing tracebacks. This ensures that |
|
740 | 754 | user output doesn't end up interleaved with traceback output. |
|
741 | 755 | |
|
742 | 756 | 2007-01-10 Ville Vainio <vivainio@gmail.com> |
|
743 | 757 | |
|
744 | 758 | * Extensions/envpersist.py: Turbocharged %env that remembers |
|
745 | 759 | env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or |
|
746 | 760 | "%env VISUAL=jed". |
|
747 | 761 | |
|
748 | 762 | 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
749 | 763 | |
|
750 | 764 | * IPython/iplib.py (showtraceback): ensure that we correctly call |
|
751 | 765 | custom handlers in all cases (some with pdb were slipping through, |
|
752 | 766 | but I'm not exactly sure why). |
|
753 | 767 | |
|
754 | 768 | * IPython/Debugger.py (Tracer.__init__): added new class to |
|
755 | 769 | support set_trace-like usage of IPython's enhanced debugger. |
|
756 | 770 | |
|
757 | 771 | 2006-12-24 Ville Vainio <vivainio@gmail.com> |
|
758 | 772 | |
|
759 | 773 | * ipmaker.py: more informative message when ipy_user_conf |
|
760 | 774 | import fails (suggest running %upgrade). |
|
761 | 775 | |
|
762 | 776 | * tools/run_ipy_in_profiler.py: Utility to see where |
|
763 | 777 | the time during IPython startup is spent. |
|
764 | 778 | |
|
765 | 779 | 2006-12-20 Ville Vainio <vivainio@gmail.com> |
|
766 | 780 | |
|
767 | 781 | * 0.7.3 is out - merge all from 0.7.3 branch to trunk |
|
768 | 782 | |
|
769 | 783 | * ipapi.py: Add new ipapi method, expand_alias. |
|
770 | 784 | |
|
771 | 785 | * Release.py: Bump up version to 0.7.4.svn |
|
772 | 786 | |
|
773 | 787 | 2006-12-17 Ville Vainio <vivainio@gmail.com> |
|
774 | 788 | |
|
775 | 789 | * Extensions/jobctrl.py: Fixed &cmd arg arg... |
|
776 | 790 | to work properly on posix too |
|
777 | 791 | |
|
778 | 792 | * Release.py: Update revnum (version is still just 0.7.3). |
|
779 | 793 | |
|
780 | 794 | 2006-12-15 Ville Vainio <vivainio@gmail.com> |
|
781 | 795 | |
|
782 | 796 | * scripts/ipython_win_post_install: create ipython.py in |
|
783 | 797 | prefix + "/scripts". |
|
784 | 798 | |
|
785 | 799 | * Release.py: Update version to 0.7.3. |
|
786 | 800 | |
|
787 | 801 | 2006-12-14 Ville Vainio <vivainio@gmail.com> |
|
788 | 802 | |
|
789 | 803 | * scripts/ipython_win_post_install: Overwrite old shortcuts |
|
790 | 804 | if they already exist |
|
791 | 805 | |
|
792 | 806 | * Release.py: release 0.7.3rc2 |
|
793 | 807 | |
|
794 | 808 | 2006-12-13 Ville Vainio <vivainio@gmail.com> |
|
795 | 809 | |
|
796 | 810 | * Branch and update Release.py for 0.7.3rc1 |
|
797 | 811 | |
|
798 | 812 | 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
799 | 813 | |
|
800 | 814 | * IPython/Shell.py (IPShellWX): update for current WX naming |
|
801 | 815 | conventions, to avoid a deprecation warning with current WX |
|
802 | 816 | versions. Thanks to a report by Danny Shevitz. |
|
803 | 817 | |
|
804 | 818 | 2006-12-12 Ville Vainio <vivainio@gmail.com> |
|
805 | 819 | |
|
806 | 820 | * ipmaker.py: apply david cournapeau's patch to make |
|
807 | 821 | import_some work properly even when ipythonrc does |
|
808 | 822 | import_some on empty list (it was an old bug!). |
|
809 | 823 | |
|
810 | 824 | * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc: |
|
811 | 825 | Add deprecation note to ipythonrc and a url to wiki |
|
812 | 826 | in ipy_user_conf.py |
|
813 | 827 | |
|
814 | 828 | |
|
815 | 829 | * Magic.py (%run): %run myscript.ipy now runs myscript.ipy |
|
816 | 830 | as if it was typed on IPython command prompt, i.e. |
|
817 | 831 | as IPython script. |
|
818 | 832 | |
|
819 | 833 | * example-magic.py, magic_grepl.py: remove outdated examples |
|
820 | 834 | |
|
821 | 835 | 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
822 | 836 | |
|
823 | 837 | * IPython/iplib.py (debugger): prevent a nasty traceback if %debug |
|
824 | 838 | is called before any exception has occurred. |
|
825 | 839 | |
|
826 | 840 | 2006-12-08 Ville Vainio <vivainio@gmail.com> |
|
827 | 841 | |
|
828 | 842 | * Extensions/ipy_stock_completers.py: fix cd completer |
|
829 | 843 | to translate /'s to \'s again. |
|
830 | 844 | |
|
831 | 845 | * completer.py: prevent traceback on file completions w/ |
|
832 | 846 | backslash. |
|
833 | 847 | |
|
834 | 848 | * Release.py: Update release number to 0.7.3b3 for release |
|
835 | 849 | |
|
836 | 850 | 2006-12-07 Ville Vainio <vivainio@gmail.com> |
|
837 | 851 | |
|
838 | 852 | * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process |
|
839 | 853 | while executing external code. Provides more shell-like behaviour |
|
840 | 854 | and overall better response to ctrl + C / ctrl + break. |
|
841 | 855 | |
|
842 | 856 | * tools/make_tarball.py: new script to create tarball straight from svn |
|
843 | 857 | (setup.py sdist doesn't work on win32). |
|
844 | 858 | |
|
845 | 859 | * Extensions/ipy_stock_completers.py: fix cd completer to give up |
|
846 | 860 | on dirnames with spaces and use the default completer instead. |
|
847 | 861 | |
|
848 | 862 | * Revision.py: Change version to 0.7.3b2 for release. |
|
849 | 863 | |
|
850 | 864 | 2006-12-05 Ville Vainio <vivainio@gmail.com> |
|
851 | 865 | |
|
852 | 866 | * Magic.py, iplib.py, completer.py: Apply R. Bernstein's |
|
853 | 867 | pydb patch 4 (rm debug printing, py 2.5 checking) |
|
854 | 868 | |
|
855 | 869 | 2006-11-30 Walter Doerwald <walter@livinglogic.de> |
|
856 | 870 | * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse: |
|
857 | 871 | "refresh" (mapped to "r") refreshes the screen by restarting the iterator. |
|
858 | 872 | "refreshfind" (mapped to "R") does the same but tries to go back to the same |
|
859 | 873 | object the cursor was on before the refresh. The command "markrange" is |
|
860 | 874 | mapped to "%" now. |
|
861 | 875 | * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable. |
|
862 | 876 | |
|
863 | 877 | 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
864 | 878 | |
|
865 | 879 | * IPython/Magic.py (magic_debug): new %debug magic to activate the |
|
866 | 880 | interactive debugger on the last traceback, without having to call |
|
867 | 881 | %pdb and rerun your code. Made minor changes in various modules, |
|
868 | 882 | should automatically recognize pydb if available. |
|
869 | 883 | |
|
870 | 884 | 2006-11-28 Ville Vainio <vivainio@gmail.com> |
|
871 | 885 | |
|
872 | 886 | * completer.py: If the text start with !, show file completions |
|
873 | 887 | properly. This helps when trying to complete command name |
|
874 | 888 | for shell escapes. |
|
875 | 889 | |
|
876 | 890 | 2006-11-27 Ville Vainio <vivainio@gmail.com> |
|
877 | 891 | |
|
878 | 892 | * ipy_stock_completers.py: bzr completer submitted by Stefan van |
|
879 | 893 | der Walt. Clean up svn and hg completers by using a common |
|
880 | 894 | vcs_completer. |
|
881 | 895 | |
|
882 | 896 | 2006-11-26 Ville Vainio <vivainio@gmail.com> |
|
883 | 897 | |
|
884 | 898 | * Remove ipconfig and %config; you should use _ip.options structure |
|
885 | 899 | directly instead! |
|
886 | 900 | |
|
887 | 901 | * genutils.py: add wrap_deprecated function for deprecating callables |
|
888 | 902 | |
|
889 | 903 | * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and |
|
890 | 904 | _ip.system instead. ipalias is redundant. |
|
891 | 905 | |
|
892 | 906 | * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on |
|
893 | 907 | win32, but just 'cmdname'. Other extensions (non-'exe') are still made |
|
894 | 908 | explicit. |
|
895 | 909 | |
|
896 | 910 | * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom |
|
897 | 911 | completer. Try it by entering 'hg ' and pressing tab. |
|
898 | 912 | |
|
899 | 913 | * macro.py: Give Macro a useful __repr__ method |
|
900 | 914 | |
|
901 | 915 | * Magic.py: %whos abbreviates the typename of Macro for brevity. |
|
902 | 916 | |
|
903 | 917 | 2006-11-24 Walter Doerwald <walter@livinglogic.de> |
|
904 | 918 | * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that |
|
905 | 919 | we don't get a duplicate ipipe module, where registration of the xrepr |
|
906 | 920 | implementation for Text is useless. |
|
907 | 921 | |
|
908 | 922 | * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils. |
|
909 | 923 | |
|
910 | 924 | * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command. |
|
911 | 925 | |
|
912 | 926 | 2006-11-24 Ville Vainio <vivainio@gmail.com> |
|
913 | 927 | |
|
914 | 928 | * Magic.py, manual_base.lyx: Kirill Smelkov patch: |
|
915 | 929 | try to use "cProfile" instead of the slower pure python |
|
916 | 930 | "profile" |
|
917 | 931 | |
|
918 | 932 | 2006-11-23 Ville Vainio <vivainio@gmail.com> |
|
919 | 933 | |
|
920 | 934 | * manual_base.lyx: Kirill Smelkov patch: Fix wrong |
|
921 | 935 | Qt+IPython+Designer link in documentation. |
|
922 | 936 | |
|
923 | 937 | * Extensions/ipy_pydb.py: R. Bernstein's patch for passing |
|
924 | 938 | correct Pdb object to %pydb. |
|
925 | 939 | |
|
926 | 940 | |
|
927 | 941 | 2006-11-22 Walter Doerwald <walter@livinglogic.de> |
|
928 | 942 | * IPython/Extensions/astyle.py: Text needs it's own implemenation of the |
|
929 | 943 | generic xrepr(), otherwise the list implementation would kick in. |
|
930 | 944 | |
|
931 | 945 | 2006-11-21 Ville Vainio <vivainio@gmail.com> |
|
932 | 946 | |
|
933 | 947 | * upgrade_dir.py: Now actually overwrites a nonmodified user file |
|
934 | 948 | with one from UserConfig. |
|
935 | 949 | |
|
936 | 950 | * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda, |
|
937 | 951 | it was missing which broke the sh profile. |
|
938 | 952 | |
|
939 | 953 | * completer.py: file completer now uses explicit '/' instead |
|
940 | 954 | of os.path.join, expansion of 'foo' was broken on win32 |
|
941 | 955 | if there was one directory with name 'foobar'. |
|
942 | 956 | |
|
943 | 957 | * A bunch of patches from Kirill Smelkov: |
|
944 | 958 | |
|
945 | 959 | * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets. |
|
946 | 960 | |
|
947 | 961 | * [patch 7/9] Implement %page -r (page in raw mode) - |
|
948 | 962 | |
|
949 | 963 | * [patch 5/9] ScientificPython webpage has moved |
|
950 | 964 | |
|
951 | 965 | * [patch 4/9] The manual mentions %ds, should be %dhist |
|
952 | 966 | |
|
953 | 967 | * [patch 3/9] Kill old bits from %prun doc. |
|
954 | 968 | |
|
955 | 969 | * [patch 1/9] Fix typos here and there. |
|
956 | 970 | |
|
957 | 971 | 2006-11-08 Ville Vainio <vivainio@gmail.com> |
|
958 | 972 | |
|
959 | 973 | * completer.py (attr_matches): catch all exceptions raised |
|
960 | 974 | by eval of expr with dots. |
|
961 | 975 | |
|
962 | 976 | 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
963 | 977 | |
|
964 | 978 | * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user |
|
965 | 979 | input if it starts with whitespace. This allows you to paste |
|
966 | 980 | indented input from any editor without manually having to type in |
|
967 | 981 | the 'if 1:', which is convenient when working interactively. |
|
968 | 982 | Slightly modifed version of a patch by Bo Peng |
|
969 | 983 | <bpeng-AT-rice.edu>. |
|
970 | 984 | |
|
971 | 985 | 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
972 | 986 | |
|
973 | 987 | * IPython/irunner.py (main): modified irunner so it automatically |
|
974 | 988 | recognizes the right runner to use based on the extension (.py for |
|
975 | 989 | python, .ipy for ipython and .sage for sage). |
|
976 | 990 | |
|
977 | 991 | * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also |
|
978 | 992 | visible in ipapi as ip.config(), to programatically control the |
|
979 | 993 | internal rc object. There's an accompanying %config magic for |
|
980 | 994 | interactive use, which has been enhanced to match the |
|
981 | 995 | funtionality in ipconfig. |
|
982 | 996 | |
|
983 | 997 | * IPython/Magic.py (magic_system_verbose): Change %system_verbose |
|
984 | 998 | so it's not just a toggle, it now takes an argument. Add support |
|
985 | 999 | for a customizable header when making system calls, as the new |
|
986 | 1000 | system_header variable in the ipythonrc file. |
|
987 | 1001 | |
|
988 | 1002 | 2006-11-03 Walter Doerwald <walter@livinglogic.de> |
|
989 | 1003 | |
|
990 | 1004 | * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now |
|
991 | 1005 | generic functions (using Philip J. Eby's simplegeneric package). |
|
992 | 1006 | This makes it possible to customize the display of third-party classes |
|
993 | 1007 | without having to monkeypatch them. xiter() no longer supports a mode |
|
994 | 1008 | argument and the XMode class has been removed. The same functionality can |
|
995 | 1009 | be implemented via IterAttributeDescriptor and IterMethodDescriptor. |
|
996 | 1010 | One consequence of the switch to generic functions is that xrepr() and |
|
997 | 1011 | xattrs() implementation must define the default value for the mode |
|
998 | 1012 | argument themselves and xattrs() implementations must return real |
|
999 | 1013 | descriptors. |
|
1000 | 1014 | |
|
1001 | 1015 | * IPython/external: This new subpackage will contain all third-party |
|
1002 | 1016 | packages that are bundled with IPython. (The first one is simplegeneric). |
|
1003 | 1017 | |
|
1004 | 1018 | * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent |
|
1005 | 1019 | directory which as been dropped in r1703. |
|
1006 | 1020 | |
|
1007 | 1021 | * IPython/Extensions/ipipe.py (iless): Fixed. |
|
1008 | 1022 | |
|
1009 | 1023 | * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3. |
|
1010 | 1024 | |
|
1011 | 1025 | 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1012 | 1026 | |
|
1013 | 1027 | * IPython/iplib.py (InteractiveShell.var_expand): fix stack |
|
1014 | 1028 | handling in variable expansion so that shells and magics recognize |
|
1015 | 1029 | function local scopes correctly. Bug reported by Brian. |
|
1016 | 1030 | |
|
1017 | 1031 | * scripts/ipython: remove the very first entry in sys.path which |
|
1018 | 1032 | Python auto-inserts for scripts, so that sys.path under IPython is |
|
1019 | 1033 | as similar as possible to that under plain Python. |
|
1020 | 1034 | |
|
1021 | 1035 | * IPython/completer.py (IPCompleter.file_matches): Fix |
|
1022 | 1036 | tab-completion so that quotes are not closed unless the completion |
|
1023 | 1037 | is unambiguous. After a request by Stefan. Minor cleanups in |
|
1024 | 1038 | ipy_stock_completers. |
|
1025 | 1039 | |
|
1026 | 1040 | 2006-11-02 Ville Vainio <vivainio@gmail.com> |
|
1027 | 1041 | |
|
1028 | 1042 | * ipy_stock_completers.py: Add %run and %cd completers. |
|
1029 | 1043 | |
|
1030 | 1044 | * completer.py: Try running custom completer for both |
|
1031 | 1045 | "foo" and "%foo" if the command is just "foo". Ignore case |
|
1032 | 1046 | when filtering possible completions. |
|
1033 | 1047 | |
|
1034 | 1048 | * UserConfig/ipy_user_conf.py: install stock completers as default |
|
1035 | 1049 | |
|
1036 | 1050 | * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py: |
|
1037 | 1051 | simplified readline history save / restore through a wrapper |
|
1038 | 1052 | function |
|
1039 | 1053 | |
|
1040 | 1054 | |
|
1041 | 1055 | 2006-10-31 Ville Vainio <vivainio@gmail.com> |
|
1042 | 1056 | |
|
1043 | 1057 | * strdispatch.py, completer.py, ipy_stock_completers.py: |
|
1044 | 1058 | Allow str_key ("command") in completer hooks. Implement |
|
1045 | 1059 | trivial completer for 'import' (stdlib modules only). Rename |
|
1046 | 1060 | ipy_linux_package_managers.py to ipy_stock_completers.py. |
|
1047 | 1061 | SVN completer. |
|
1048 | 1062 | |
|
1049 | 1063 | * Extensions/ledit.py: %magic line editor for easily and |
|
1050 | 1064 | incrementally manipulating lists of strings. The magic command |
|
1051 | 1065 | name is %led. |
|
1052 | 1066 | |
|
1053 | 1067 | 2006-10-30 Ville Vainio <vivainio@gmail.com> |
|
1054 | 1068 | |
|
1055 | 1069 | * Debugger.py, iplib.py (debugger()): Add last set of Rocky |
|
1056 | 1070 | Bernsteins's patches for pydb integration. |
|
1057 | 1071 | http://bashdb.sourceforge.net/pydb/ |
|
1058 | 1072 | |
|
1059 | 1073 | * strdispatch.py, iplib.py, completer.py, IPython/__init__.py, |
|
1060 | 1074 | Extensions/ipy_linux_package_managers.py, hooks.py: Implement |
|
1061 | 1075 | custom completer hook to allow the users to implement their own |
|
1062 | 1076 | completers. See ipy_linux_package_managers.py for example. The |
|
1063 | 1077 | hook name is 'complete_command'. |
|
1064 | 1078 | |
|
1065 | 1079 | 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1066 | 1080 | |
|
1067 | 1081 | * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old |
|
1068 | 1082 | Numeric leftovers. |
|
1069 | 1083 | |
|
1070 | 1084 | * ipython.el (py-execute-region): apply Stefan's patch to fix |
|
1071 | 1085 | garbled results if the python shell hasn't been previously started. |
|
1072 | 1086 | |
|
1073 | 1087 | * IPython/genutils.py (arg_split): moved to genutils, since it's a |
|
1074 | 1088 | pretty generic function and useful for other things. |
|
1075 | 1089 | |
|
1076 | 1090 | * IPython/OInspect.py (getsource): Add customizable source |
|
1077 | 1091 | extractor. After a request/patch form W. Stein (SAGE). |
|
1078 | 1092 | |
|
1079 | 1093 | * IPython/irunner.py (InteractiveRunner.run_source): reset tty |
|
1080 | 1094 | window size to a more reasonable value from what pexpect does, |
|
1081 | 1095 | since their choice causes wrapping bugs with long input lines. |
|
1082 | 1096 | |
|
1083 | 1097 | 2006-10-28 Ville Vainio <vivainio@gmail.com> |
|
1084 | 1098 | |
|
1085 | 1099 | * Magic.py (%run): Save and restore the readline history from |
|
1086 | 1100 | file around %run commands to prevent side effects from |
|
1087 | 1101 | %runned programs that might use readline (e.g. pydb). |
|
1088 | 1102 | |
|
1089 | 1103 | * extensions/ipy_pydb.py: Adds %pydb magic when imported, for |
|
1090 | 1104 | invoking the pydb enhanced debugger. |
|
1091 | 1105 | |
|
1092 | 1106 | 2006-10-23 Walter Doerwald <walter@livinglogic.de> |
|
1093 | 1107 | |
|
1094 | 1108 | * IPython/Extensions/ipipe.py (ifile): Remove all methods that |
|
1095 | 1109 | call the base class method and propagate the return value to |
|
1096 | 1110 | ifile. This is now done by path itself. |
|
1097 | 1111 | |
|
1098 | 1112 | 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1099 | 1113 | |
|
1100 | 1114 | * IPython/ipapi.py (IPApi.__init__): Added new entry to public |
|
1101 | 1115 | api: set_crash_handler(), to expose the ability to change the |
|
1102 | 1116 | internal crash handler. |
|
1103 | 1117 | |
|
1104 | 1118 | * IPython/CrashHandler.py (CrashHandler.__init__): abstract out |
|
1105 | 1119 | the various parameters of the crash handler so that apps using |
|
1106 | 1120 | IPython as their engine can customize crash handling. Ipmlemented |
|
1107 | 1121 | at the request of SAGE. |
|
1108 | 1122 | |
|
1109 | 1123 | 2006-10-14 Ville Vainio <vivainio@gmail.com> |
|
1110 | 1124 | |
|
1111 | 1125 | * Magic.py, ipython.el: applied first "safe" part of Rocky |
|
1112 | 1126 | Bernstein's patch set for pydb integration. |
|
1113 | 1127 | |
|
1114 | 1128 | * Magic.py (%unalias, %alias): %store'd aliases can now be |
|
1115 | 1129 | removed with '%unalias'. %alias w/o args now shows most |
|
1116 | 1130 | interesting (stored / manually defined) aliases last |
|
1117 | 1131 | where they catch the eye w/o scrolling. |
|
1118 | 1132 | |
|
1119 | 1133 | * Magic.py (%rehashx), ext_rehashdir.py: files with |
|
1120 | 1134 | 'py' extension are always considered executable, even |
|
1121 | 1135 | when not in PATHEXT environment variable. |
|
1122 | 1136 | |
|
1123 | 1137 | 2006-10-12 Ville Vainio <vivainio@gmail.com> |
|
1124 | 1138 | |
|
1125 | 1139 | * jobctrl.py: Add new "jobctrl" extension for spawning background |
|
1126 | 1140 | processes with "&find /". 'import jobctrl' to try it out. Requires |
|
1127 | 1141 | 'subprocess' module, standard in python 2.4+. |
|
1128 | 1142 | |
|
1129 | 1143 | * iplib.py (expand_aliases, handle_alias): Aliases expand transitively, |
|
1130 | 1144 | so if foo -> bar and bar -> baz, then foo -> baz. |
|
1131 | 1145 | |
|
1132 | 1146 | 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1133 | 1147 | |
|
1134 | 1148 | * IPython/Magic.py (Magic.parse_options): add a new posix option |
|
1135 | 1149 | to allow parsing of input args in magics that doesn't strip quotes |
|
1136 | 1150 | (if posix=False). This also closes %timeit bug reported by |
|
1137 | 1151 | Stefan. |
|
1138 | 1152 | |
|
1139 | 1153 | 2006-10-03 Ville Vainio <vivainio@gmail.com> |
|
1140 | 1154 | |
|
1141 | 1155 | * iplib.py (raw_input, interact): Return ValueError catching for |
|
1142 | 1156 | raw_input. Fixes infinite loop for sys.stdin.close() or |
|
1143 | 1157 | sys.stdout.close(). |
|
1144 | 1158 | |
|
1145 | 1159 | 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1146 | 1160 | |
|
1147 | 1161 | * IPython/irunner.py (InteractiveRunner.run_source): small fixes |
|
1148 | 1162 | to help in handling doctests. irunner is now pretty useful for |
|
1149 | 1163 | running standalone scripts and simulate a full interactive session |
|
1150 | 1164 | in a format that can be then pasted as a doctest. |
|
1151 | 1165 | |
|
1152 | 1166 | * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit |
|
1153 | 1167 | on top of the default (useless) ones. This also fixes the nasty |
|
1154 | 1168 | way in which 2.5's Quitter() exits (reverted [1785]). |
|
1155 | 1169 | |
|
1156 | 1170 | * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python |
|
1157 | 1171 | 2.5. |
|
1158 | 1172 | |
|
1159 | 1173 | * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb |
|
1160 | 1174 | color scheme is updated as well when color scheme is changed |
|
1161 | 1175 | interactively. |
|
1162 | 1176 | |
|
1163 | 1177 | 2006-09-27 Ville Vainio <vivainio@gmail.com> |
|
1164 | 1178 | |
|
1165 | 1179 | * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid |
|
1166 | 1180 | infinite loop and just exit. It's a hack, but will do for a while. |
|
1167 | 1181 | |
|
1168 | 1182 | 2006-08-25 Walter Doerwald <walter@livinglogic.de> |
|
1169 | 1183 | |
|
1170 | 1184 | * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to |
|
1171 | 1185 | the constructor, this makes it possible to get a list of only directories |
|
1172 | 1186 | or only files. |
|
1173 | 1187 | |
|
1174 | 1188 | 2006-08-12 Ville Vainio <vivainio@gmail.com> |
|
1175 | 1189 | |
|
1176 | 1190 | * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods, |
|
1177 | 1191 | they broke unittest |
|
1178 | 1192 | |
|
1179 | 1193 | 2006-08-11 Ville Vainio <vivainio@gmail.com> |
|
1180 | 1194 | |
|
1181 | 1195 | * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch |
|
1182 | 1196 | by resolving issue properly, i.e. by inheriting FakeModule |
|
1183 | 1197 | from types.ModuleType. Pickling ipython interactive data |
|
1184 | 1198 | should still work as usual (testing appreciated). |
|
1185 | 1199 | |
|
1186 | 1200 | 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1187 | 1201 | |
|
1188 | 1202 | * IPython/OInspect.py: monkeypatch inspect from the stdlib if |
|
1189 | 1203 | running under python 2.3 with code from 2.4 to fix a bug with |
|
1190 | 1204 | help(). Reported by the Debian maintainers, Norbert Tretkowski |
|
1191 | 1205 | <norbert-AT-tretkowski.de> and Alexandre Fayolle |
|
1192 | 1206 | <afayolle-AT-debian.org>. |
|
1193 | 1207 | |
|
1194 | 1208 | 2006-08-04 Walter Doerwald <walter@livinglogic.de> |
|
1195 | 1209 | |
|
1196 | 1210 | * IPython/Extensions/ibrowse.py: Fixed the help message in the footer |
|
1197 | 1211 | (which was displaying "quit" twice). |
|
1198 | 1212 | |
|
1199 | 1213 | 2006-07-28 Walter Doerwald <walter@livinglogic.de> |
|
1200 | 1214 | |
|
1201 | 1215 | * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using |
|
1202 | 1216 | the mode argument). |
|
1203 | 1217 | |
|
1204 | 1218 | 2006-07-27 Walter Doerwald <walter@livinglogic.de> |
|
1205 | 1219 | |
|
1206 | 1220 | * IPython/Extensions/ipipe.py: Fix getglobals() if we're |
|
1207 | 1221 | not running under IPython. |
|
1208 | 1222 | |
|
1209 | 1223 | * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail |
|
1210 | 1224 | and make it iterable (iterating over the attribute itself). Add two new |
|
1211 | 1225 | magic strings for __xattrs__(): If the string starts with "-", the attribute |
|
1212 | 1226 | will not be displayed in ibrowse's detail view (but it can still be |
|
1213 | 1227 | iterated over). This makes it possible to add attributes that are large |
|
1214 | 1228 | lists or generator methods to the detail view. Replace magic attribute names |
|
1215 | 1229 | and _attrname() and _getattr() with "descriptors": For each type of magic |
|
1216 | 1230 | attribute name there's a subclass of Descriptor: None -> SelfDescriptor(); |
|
1217 | 1231 | "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo"); |
|
1218 | 1232 | "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo"); |
|
1219 | 1233 | foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__() |
|
1220 | 1234 | are still supported. |
|
1221 | 1235 | |
|
1222 | 1236 | * IPython/Extensions/ibrowse.py: If fetching the next row from the input |
|
1223 | 1237 | fails in ibrowse.fetch(), the exception object is added as the last item |
|
1224 | 1238 | and item fetching is canceled. This prevents ibrowse from aborting if e.g. |
|
1225 | 1239 | a generator throws an exception midway through execution. |
|
1226 | 1240 | |
|
1227 | 1241 | * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and |
|
1228 | 1242 | encoding into methods. |
|
1229 | 1243 | |
|
1230 | 1244 | 2006-07-26 Ville Vainio <vivainio@gmail.com> |
|
1231 | 1245 | |
|
1232 | 1246 | * iplib.py: history now stores multiline input as single |
|
1233 | 1247 | history entries. Patch by Jorgen Cederlof. |
|
1234 | 1248 | |
|
1235 | 1249 | 2006-07-18 Walter Doerwald <walter@livinglogic.de> |
|
1236 | 1250 | |
|
1237 | 1251 | * IPython/Extensions/ibrowse.py: Make cursor visible over |
|
1238 | 1252 | non existing attributes. |
|
1239 | 1253 | |
|
1240 | 1254 | 2006-07-14 Walter Doerwald <walter@livinglogic.de> |
|
1241 | 1255 | |
|
1242 | 1256 | * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the |
|
1243 | 1257 | error output of the running command doesn't mess up the screen. |
|
1244 | 1258 | |
|
1245 | 1259 | 2006-07-13 Walter Doerwald <walter@livinglogic.de> |
|
1246 | 1260 | |
|
1247 | 1261 | * IPython/Extensions/ipipe.py (isort): Make isort usable without |
|
1248 | 1262 | argument. This sorts the items themselves. |
|
1249 | 1263 | |
|
1250 | 1264 | 2006-07-12 Walter Doerwald <walter@livinglogic.de> |
|
1251 | 1265 | |
|
1252 | 1266 | * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval): |
|
1253 | 1267 | Compile expression strings into code objects. This should speed |
|
1254 | 1268 | up ifilter and friends somewhat. |
|
1255 | 1269 | |
|
1256 | 1270 | 2006-07-08 Ville Vainio <vivainio@gmail.com> |
|
1257 | 1271 | |
|
1258 | 1272 | * Magic.py: %cpaste now strips > from the beginning of lines |
|
1259 | 1273 | to ease pasting quoted code from emails. Contributed by |
|
1260 | 1274 | Stefan van der Walt. |
|
1261 | 1275 | |
|
1262 | 1276 | 2006-06-29 Ville Vainio <vivainio@gmail.com> |
|
1263 | 1277 | |
|
1264 | 1278 | * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab |
|
1265 | 1279 | mode, patch contributed by Darren Dale. NEEDS TESTING! |
|
1266 | 1280 | |
|
1267 | 1281 | 2006-06-28 Walter Doerwald <walter@livinglogic.de> |
|
1268 | 1282 | |
|
1269 | 1283 | * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row |
|
1270 | 1284 | a blue background. Fix fetching new display rows when the browser |
|
1271 | 1285 | scrolls more than a screenful (e.g. by using the goto command). |
|
1272 | 1286 | |
|
1273 | 1287 | 2006-06-27 Ville Vainio <vivainio@gmail.com> |
|
1274 | 1288 | |
|
1275 | 1289 | * Magic.py (_inspect, _ofind) Apply David Huard's |
|
1276 | 1290 | patch for displaying the correct docstring for 'property' |
|
1277 | 1291 | attributes. |
|
1278 | 1292 | |
|
1279 | 1293 | 2006-06-23 Walter Doerwald <walter@livinglogic.de> |
|
1280 | 1294 | |
|
1281 | 1295 | * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard |
|
1282 | 1296 | commands into the methods implementing them. |
|
1283 | 1297 | |
|
1284 | 1298 | 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1285 | 1299 | |
|
1286 | 1300 | * ipython.el (ipython-indentation-hook): cleanup patch, submitted |
|
1287 | 1301 | by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original |
|
1288 | 1302 | autoindent support was authored by Jin Liu. |
|
1289 | 1303 | |
|
1290 | 1304 | 2006-06-22 Walter Doerwald <walter@livinglogic.de> |
|
1291 | 1305 | |
|
1292 | 1306 | * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used |
|
1293 | 1307 | for keymaps with a custom class that simplifies handling. |
|
1294 | 1308 | |
|
1295 | 1309 | 2006-06-19 Walter Doerwald <walter@livinglogic.de> |
|
1296 | 1310 | |
|
1297 | 1311 | * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal |
|
1298 | 1312 | resizing. This requires Python 2.5 to work. |
|
1299 | 1313 | |
|
1300 | 1314 | 2006-06-16 Walter Doerwald <walter@livinglogic.de> |
|
1301 | 1315 | |
|
1302 | 1316 | * IPython/Extensions/ibrowse.py: Add two new commands to |
|
1303 | 1317 | ibrowse: "hideattr" (mapped to "h") hides the attribute under |
|
1304 | 1318 | the cursor. "unhiderattrs" (mapped to "H") reveals all hidden |
|
1305 | 1319 | attributes again. Remapped the help command to "?". Display |
|
1306 | 1320 | keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e |
|
1307 | 1321 | as keys for the "home" and "end" commands. Add three new commands |
|
1308 | 1322 | to the input mode for "find" and friends: "delend" (CTRL-K) |
|
1309 | 1323 | deletes to the end of line. "incsearchup" searches upwards in the |
|
1310 | 1324 | command history for an input that starts with the text before the cursor. |
|
1311 | 1325 | "incsearchdown" does the same downwards. Removed a bogus mapping of |
|
1312 | 1326 | the x key to "delete". |
|
1313 | 1327 | |
|
1314 | 1328 | 2006-06-15 Ville Vainio <vivainio@gmail.com> |
|
1315 | 1329 | |
|
1316 | 1330 | * iplib.py, hooks.py: Added new generate_prompt hook that can be |
|
1317 | 1331 | used to create prompts dynamically, instead of the "old" way of |
|
1318 | 1332 | assigning "magic" strings to prompt_in1 and prompt_in2. The old |
|
1319 | 1333 | way still works (it's invoked by the default hook), of course. |
|
1320 | 1334 | |
|
1321 | 1335 | * Prompts.py: added generate_output_prompt hook for altering output |
|
1322 | 1336 | prompt |
|
1323 | 1337 | |
|
1324 | 1338 | * Release.py: Changed version string to 0.7.3.svn. |
|
1325 | 1339 | |
|
1326 | 1340 | 2006-06-15 Walter Doerwald <walter@livinglogic.de> |
|
1327 | 1341 | |
|
1328 | 1342 | * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that |
|
1329 | 1343 | the call to fetch() always tries to fetch enough data for at least one |
|
1330 | 1344 | full screen. This makes it possible to simply call moveto(0,0,True) in |
|
1331 | 1345 | the constructor. Fix typos and removed the obsolete goto attribute. |
|
1332 | 1346 | |
|
1333 | 1347 | 2006-06-12 Ville Vainio <vivainio@gmail.com> |
|
1334 | 1348 | |
|
1335 | 1349 | * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for |
|
1336 | 1350 | allowing $variable interpolation within multiline statements, |
|
1337 | 1351 | though so far only with "sh" profile for a testing period. |
|
1338 | 1352 | The patch also enables splitting long commands with \ but it |
|
1339 | 1353 | doesn't work properly yet. |
|
1340 | 1354 | |
|
1341 | 1355 | 2006-06-12 Walter Doerwald <walter@livinglogic.de> |
|
1342 | 1356 | |
|
1343 | 1357 | * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the |
|
1344 | 1358 | input history and the position of the cursor in the input history for |
|
1345 | 1359 | the find, findbackwards and goto command. |
|
1346 | 1360 | |
|
1347 | 1361 | 2006-06-10 Walter Doerwald <walter@livinglogic.de> |
|
1348 | 1362 | |
|
1349 | 1363 | * IPython/Extensions/ibrowse.py: Add a class _CommandInput that |
|
1350 | 1364 | implements the basic functionality of browser commands that require |
|
1351 | 1365 | input. Reimplement the goto, find and findbackwards commands as |
|
1352 | 1366 | subclasses of _CommandInput. Add an input history and keymaps to those |
|
1353 | 1367 | commands. Add "\r" as a keyboard shortcut for the enterdefault and |
|
1354 | 1368 | execute commands. |
|
1355 | 1369 | |
|
1356 | 1370 | 2006-06-07 Ville Vainio <vivainio@gmail.com> |
|
1357 | 1371 | |
|
1358 | 1372 | * iplib.py: ipython mybatch.ipy exits ipython immediately after |
|
1359 | 1373 | running the batch files instead of leaving the session open. |
|
1360 | 1374 | |
|
1361 | 1375 | 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1362 | 1376 | |
|
1363 | 1377 | * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as |
|
1364 | 1378 | the original fix was incomplete. Patch submitted by W. Maier. |
|
1365 | 1379 | |
|
1366 | 1380 | 2006-06-07 Ville Vainio <vivainio@gmail.com> |
|
1367 | 1381 | |
|
1368 | 1382 | * iplib.py,Magic.py, ipmaker.py (magic_rehashx): |
|
1369 | 1383 | Confirmation prompts can be supressed by 'quiet' option. |
|
1370 | 1384 | _ip.options.quiet = 1 means "assume yes for all yes/no queries". |
|
1371 | 1385 | |
|
1372 | 1386 | 2006-06-06 *** Released version 0.7.2 |
|
1373 | 1387 | |
|
1374 | 1388 | 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1375 | 1389 | |
|
1376 | 1390 | * IPython/Release.py (version): Made 0.7.2 final for release. |
|
1377 | 1391 | Repo tagged and release cut. |
|
1378 | 1392 | |
|
1379 | 1393 | 2006-06-05 Ville Vainio <vivainio@gmail.com> |
|
1380 | 1394 | |
|
1381 | 1395 | * Magic.py (magic_rehashx): Honor no_alias list earlier in |
|
1382 | 1396 | %rehashx, to avoid clobbering builtins in ipy_profile_sh.py |
|
1383 | 1397 | |
|
1384 | 1398 | * upgrade_dir.py: try import 'path' module a bit harder |
|
1385 | 1399 | (for %upgrade) |
|
1386 | 1400 | |
|
1387 | 1401 | 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1388 | 1402 | |
|
1389 | 1403 | * IPython/genutils.py (ask_yes_no): treat EOF as a default answer |
|
1390 | 1404 | instead of looping 20 times. |
|
1391 | 1405 | |
|
1392 | 1406 | * IPython/ipmaker.py (make_IPython): honor -ipythondir flag |
|
1393 | 1407 | correctly at initialization time. Bug reported by Krishna Mohan |
|
1394 | 1408 | Gundu <gkmohan-AT-gmail.com> on the user list. |
|
1395 | 1409 | |
|
1396 | 1410 | * IPython/Release.py (version): Mark 0.7.2 version to start |
|
1397 | 1411 | testing for release on 06/06. |
|
1398 | 1412 | |
|
1399 | 1413 | 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1400 | 1414 | |
|
1401 | 1415 | * scripts/irunner: thin script interface so users don't have to |
|
1402 | 1416 | find the module and call it as an executable, since modules rarely |
|
1403 | 1417 | live in people's PATH. |
|
1404 | 1418 | |
|
1405 | 1419 | * IPython/irunner.py (InteractiveRunner.__init__): added |
|
1406 | 1420 | delaybeforesend attribute to control delays with newer versions of |
|
1407 | 1421 | pexpect. Thanks to detailed help from pexpect's author, Noah |
|
1408 | 1422 | Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner |
|
1409 | 1423 | correctly (it works in NoColor mode). |
|
1410 | 1424 | |
|
1411 | 1425 | * IPython/iplib.py (handle_normal): fix nasty crash reported on |
|
1412 | 1426 | SAGE list, from improper log() calls. |
|
1413 | 1427 | |
|
1414 | 1428 | 2006-05-31 Ville Vainio <vivainio@gmail.com> |
|
1415 | 1429 | |
|
1416 | 1430 | * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir |
|
1417 | 1431 | with args in parens to work correctly with dirs that have spaces. |
|
1418 | 1432 | |
|
1419 | 1433 | 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1420 | 1434 | |
|
1421 | 1435 | * IPython/Logger.py (Logger.logstart): add option to log raw input |
|
1422 | 1436 | instead of the processed one. A -r flag was added to the |
|
1423 | 1437 | %logstart magic used for controlling logging. |
|
1424 | 1438 | |
|
1425 | 1439 | 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1426 | 1440 | |
|
1427 | 1441 | * IPython/iplib.py (InteractiveShell.__init__): add check for the |
|
1428 | 1442 | *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't |
|
1429 | 1443 | recognize the option. After a bug report by Will Maier. This |
|
1430 | 1444 | closes #64 (will do it after confirmation from W. Maier). |
|
1431 | 1445 | |
|
1432 | 1446 | * IPython/irunner.py: New module to run scripts as if manually |
|
1433 | 1447 | typed into an interactive environment, based on pexpect. After a |
|
1434 | 1448 | submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the |
|
1435 | 1449 | ipython-user list. Simple unittests in the tests/ directory. |
|
1436 | 1450 | |
|
1437 | 1451 | * tools/release: add Will Maier, OpenBSD port maintainer, to |
|
1438 | 1452 | recepients list. We are now officially part of the OpenBSD ports: |
|
1439 | 1453 | http://www.openbsd.org/ports.html ! Many thanks to Will for the |
|
1440 | 1454 | work. |
|
1441 | 1455 | |
|
1442 | 1456 | 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1443 | 1457 | |
|
1444 | 1458 | * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below) |
|
1445 | 1459 | so that it doesn't break tkinter apps. |
|
1446 | 1460 | |
|
1447 | 1461 | * IPython/iplib.py (_prefilter): fix bug where aliases would |
|
1448 | 1462 | shadow variables when autocall was fully off. Reported by SAGE |
|
1449 | 1463 | author William Stein. |
|
1450 | 1464 | |
|
1451 | 1465 | * IPython/OInspect.py (Inspector.__init__): add a flag to control |
|
1452 | 1466 | at what detail level strings are computed when foo? is requested. |
|
1453 | 1467 | This allows users to ask for example that the string form of an |
|
1454 | 1468 | object is only computed when foo?? is called, or even never, by |
|
1455 | 1469 | setting the object_info_string_level >= 2 in the configuration |
|
1456 | 1470 | file. This new option has been added and documented. After a |
|
1457 | 1471 | request by SAGE to be able to control the printing of very large |
|
1458 | 1472 | objects more easily. |
|
1459 | 1473 | |
|
1460 | 1474 | 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1461 | 1475 | |
|
1462 | 1476 | * IPython/ipmaker.py (make_IPython): remove the ipython call path |
|
1463 | 1477 | from sys.argv, to be 100% consistent with how Python itself works |
|
1464 | 1478 | (as seen for example with python -i file.py). After a bug report |
|
1465 | 1479 | by Jeffrey Collins. |
|
1466 | 1480 | |
|
1467 | 1481 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix |
|
1468 | 1482 | nasty bug which was preventing custom namespaces with -pylab, |
|
1469 | 1483 | reported by M. Foord. Minor cleanup, remove old matplotlib.matlab |
|
1470 | 1484 | compatibility (long gone from mpl). |
|
1471 | 1485 | |
|
1472 | 1486 | * IPython/ipapi.py (make_session): name change: create->make. We |
|
1473 | 1487 | use make in other places (ipmaker,...), it's shorter and easier to |
|
1474 | 1488 | type and say, etc. I'm trying to clean things before 0.7.2 so |
|
1475 | 1489 | that I can keep things stable wrt to ipapi in the chainsaw branch. |
|
1476 | 1490 | |
|
1477 | 1491 | * ipython.el: fix the py-pdbtrack-input-prompt variable so that |
|
1478 | 1492 | python-mode recognizes our debugger mode. Add support for |
|
1479 | 1493 | autoindent inside (X)emacs. After a patch sent in by Jin Liu |
|
1480 | 1494 | <m.liu.jin-AT-gmail.com> originally written by |
|
1481 | 1495 | doxgen-AT-newsmth.net (with minor modifications for xemacs |
|
1482 | 1496 | compatibility) |
|
1483 | 1497 | |
|
1484 | 1498 | * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of |
|
1485 | 1499 | tracebacks when walking the stack so that the stack tracking system |
|
1486 | 1500 | in emacs' python-mode can identify the frames correctly. |
|
1487 | 1501 | |
|
1488 | 1502 | * IPython/ipmaker.py (make_IPython): make the internal (and |
|
1489 | 1503 | default config) autoedit_syntax value false by default. Too many |
|
1490 | 1504 | users have complained to me (both on and off-list) about problems |
|
1491 | 1505 | with this option being on by default, so I'm making it default to |
|
1492 | 1506 | off. It can still be enabled by anyone via the usual mechanisms. |
|
1493 | 1507 | |
|
1494 | 1508 | * IPython/completer.py (Completer.attr_matches): add support for |
|
1495 | 1509 | PyCrust-style _getAttributeNames magic method. Patch contributed |
|
1496 | 1510 | by <mscott-AT-goldenspud.com>. Closes #50. |
|
1497 | 1511 | |
|
1498 | 1512 | * IPython/iplib.py (InteractiveShell.__init__): remove the |
|
1499 | 1513 | deletion of exit/quit from __builtin__, which can break |
|
1500 | 1514 | third-party tools like the Zope debugging console. The |
|
1501 | 1515 | %exit/%quit magics remain. In general, it's probably a good idea |
|
1502 | 1516 | not to delete anything from __builtin__, since we never know what |
|
1503 | 1517 | that will break. In any case, python now (for 2.5) will support |
|
1504 | 1518 | 'real' exit/quit, so this issue is moot. Closes #55. |
|
1505 | 1519 | |
|
1506 | 1520 | * IPython/genutils.py (with_obj): rename the 'with' function to |
|
1507 | 1521 | 'withobj' to avoid incompatibilities with Python 2.5, where 'with' |
|
1508 | 1522 | becomes a language keyword. Closes #53. |
|
1509 | 1523 | |
|
1510 | 1524 | * IPython/FakeModule.py (FakeModule.__init__): add a proper |
|
1511 | 1525 | __file__ attribute to this so it fools more things into thinking |
|
1512 | 1526 | it is a real module. Closes #59. |
|
1513 | 1527 | |
|
1514 | 1528 | * IPython/Magic.py (magic_edit): add -n option to open the editor |
|
1515 | 1529 | at a specific line number. After a patch by Stefan van der Walt. |
|
1516 | 1530 | |
|
1517 | 1531 | 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1518 | 1532 | |
|
1519 | 1533 | * IPython/iplib.py (edit_syntax_error): fix crash when for some |
|
1520 | 1534 | reason the file could not be opened. After automatic crash |
|
1521 | 1535 | reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and |
|
1522 | 1536 | Charles Dolan <charlespatrickdolan-AT-yahoo.com>. |
|
1523 | 1537 | (_should_recompile): Don't fire editor if using %bg, since there |
|
1524 | 1538 | is no file in the first place. From the same report as above. |
|
1525 | 1539 | (raw_input): protect against faulty third-party prefilters. After |
|
1526 | 1540 | an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za> |
|
1527 | 1541 | while running under SAGE. |
|
1528 | 1542 | |
|
1529 | 1543 | 2006-05-23 Ville Vainio <vivainio@gmail.com> |
|
1530 | 1544 | |
|
1531 | 1545 | * ipapi.py: Stripped down ip.to_user_ns() to work only as |
|
1532 | 1546 | ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get() |
|
1533 | 1547 | now returns None (again), unless dummy is specifically allowed by |
|
1534 | 1548 | ipapi.get(allow_dummy=True). |
|
1535 | 1549 | |
|
1536 | 1550 | 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1537 | 1551 | |
|
1538 | 1552 | * IPython: remove all 2.2-compatibility objects and hacks from |
|
1539 | 1553 | everywhere, since we only support 2.3 at this point. Docs |
|
1540 | 1554 | updated. |
|
1541 | 1555 | |
|
1542 | 1556 | * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters. |
|
1543 | 1557 | Anything requiring extra validation can be turned into a Python |
|
1544 | 1558 | property in the future. I used a property for the db one b/c |
|
1545 | 1559 | there was a nasty circularity problem with the initialization |
|
1546 | 1560 | order, which right now I don't have time to clean up. |
|
1547 | 1561 | |
|
1548 | 1562 | * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think, |
|
1549 | 1563 | another locking bug reported by Jorgen. I'm not 100% sure though, |
|
1550 | 1564 | so more testing is needed... |
|
1551 | 1565 | |
|
1552 | 1566 | 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1553 | 1567 | |
|
1554 | 1568 | * IPython/ipapi.py (IPApi.to_user_ns): New function to inject |
|
1555 | 1569 | local variables from any routine in user code (typically executed |
|
1556 | 1570 | with %run) directly into the interactive namespace. Very useful |
|
1557 | 1571 | when doing complex debugging. |
|
1558 | 1572 | (IPythonNotRunning): Changed the default None object to a dummy |
|
1559 | 1573 | whose attributes can be queried as well as called without |
|
1560 | 1574 | exploding, to ease writing code which works transparently both in |
|
1561 | 1575 | and out of ipython and uses some of this API. |
|
1562 | 1576 | |
|
1563 | 1577 | 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1564 | 1578 | |
|
1565 | 1579 | * IPython/hooks.py (result_display): Fix the fact that our display |
|
1566 | 1580 | hook was using str() instead of repr(), as the default python |
|
1567 | 1581 | console does. This had gone unnoticed b/c it only happened if |
|
1568 | 1582 | %Pprint was off, but the inconsistency was there. |
|
1569 | 1583 | |
|
1570 | 1584 | 2006-05-15 Ville Vainio <vivainio@gmail.com> |
|
1571 | 1585 | |
|
1572 | 1586 | * Oinspect.py: Only show docstring for nonexisting/binary files |
|
1573 | 1587 | when doing object??, closing ticket #62 |
|
1574 | 1588 | |
|
1575 | 1589 | 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1576 | 1590 | |
|
1577 | 1591 | * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading |
|
1578 | 1592 | bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock |
|
1579 | 1593 | was being released in a routine which hadn't checked if it had |
|
1580 | 1594 | been the one to acquire it. |
|
1581 | 1595 | |
|
1582 | 1596 | 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1583 | 1597 | |
|
1584 | 1598 | * IPython/Release.py (version): put out 0.7.2.rc1 for testing. |
|
1585 | 1599 | |
|
1586 | 1600 | 2006-04-11 Ville Vainio <vivainio@gmail.com> |
|
1587 | 1601 | |
|
1588 | 1602 | * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file" |
|
1589 | 1603 | in command line. E.g. "ipython test.ipy" runs test.ipy with ipython |
|
1590 | 1604 | prefilters, allowing stuff like magics and aliases in the file. |
|
1591 | 1605 | |
|
1592 | 1606 | * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic |
|
1593 | 1607 | added. Supported now are "%clear in" and "%clear out" (clear input and |
|
1594 | 1608 | output history, respectively). Also fixed CachedOutput.flush to |
|
1595 | 1609 | properly flush the output cache. |
|
1596 | 1610 | |
|
1597 | 1611 | * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr" |
|
1598 | 1612 | half-success (and fail explicitly). |
|
1599 | 1613 | |
|
1600 | 1614 | 2006-03-28 Ville Vainio <vivainio@gmail.com> |
|
1601 | 1615 | |
|
1602 | 1616 | * iplib.py: Fix quoting of aliases so that only argless ones |
|
1603 | 1617 | are quoted |
|
1604 | 1618 | |
|
1605 | 1619 | 2006-03-28 Ville Vainio <vivainio@gmail.com> |
|
1606 | 1620 | |
|
1607 | 1621 | * iplib.py: Quote aliases with spaces in the name. |
|
1608 | 1622 | "c:\program files\blah\bin" is now legal alias target. |
|
1609 | 1623 | |
|
1610 | 1624 | * ext_rehashdir.py: Space no longer allowed as arg |
|
1611 | 1625 | separator, since space is legal in path names. |
|
1612 | 1626 | |
|
1613 | 1627 | 2006-03-16 Ville Vainio <vivainio@gmail.com> |
|
1614 | 1628 | |
|
1615 | 1629 | * upgrade_dir.py: Take path.py from Extensions, correcting |
|
1616 | 1630 | %upgrade magic |
|
1617 | 1631 | |
|
1618 | 1632 | * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found. |
|
1619 | 1633 | |
|
1620 | 1634 | * hooks.py: Only enclose editor binary in quotes if legal and |
|
1621 | 1635 | necessary (space in the name, and is an existing file). Fixes a bug |
|
1622 | 1636 | reported by Zachary Pincus. |
|
1623 | 1637 | |
|
1624 | 1638 | 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1625 | 1639 | |
|
1626 | 1640 | * Manual: thanks to a tip on proper color handling for Emacs, by |
|
1627 | 1641 | Eric J Haywiser <ejh1-AT-MIT.EDU>. |
|
1628 | 1642 | |
|
1629 | 1643 | * ipython.el: close http://www.scipy.net/roundup/ipython/issue57 |
|
1630 | 1644 | by applying the provided patch. Thanks to Liu Jin |
|
1631 | 1645 | <m.liu.jin-AT-gmail.com> for the contribution. No problems under |
|
1632 | 1646 | XEmacs/Linux, I'm trusting the submitter that it actually helps |
|
1633 | 1647 | under win32/GNU Emacs. Will revisit if any problems are reported. |
|
1634 | 1648 | |
|
1635 | 1649 | 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1636 | 1650 | |
|
1637 | 1651 | * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py |
|
1638 | 1652 | from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>. |
|
1639 | 1653 | |
|
1640 | 1654 | 2006-03-12 Ville Vainio <vivainio@gmail.com> |
|
1641 | 1655 | |
|
1642 | 1656 | * Magic.py (magic_timeit): Added %timeit magic, contributed by |
|
1643 | 1657 | Torsten Marek. |
|
1644 | 1658 | |
|
1645 | 1659 | 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1646 | 1660 | |
|
1647 | 1661 | * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for |
|
1648 | 1662 | line ranges works again. |
|
1649 | 1663 | |
|
1650 | 1664 | 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1651 | 1665 | |
|
1652 | 1666 | * IPython/iplib.py (showtraceback): add back sys.last_traceback |
|
1653 | 1667 | and friends, after a discussion with Zach Pincus on ipython-user. |
|
1654 | 1668 | I'm not 100% sure, but after thinking about it quite a bit, it may |
|
1655 | 1669 | be OK. Testing with the multithreaded shells didn't reveal any |
|
1656 | 1670 | problems, but let's keep an eye out. |
|
1657 | 1671 | |
|
1658 | 1672 | In the process, I fixed a few things which were calling |
|
1659 | 1673 | self.InteractiveTB() directly (like safe_execfile), which is a |
|
1660 | 1674 | mistake: ALL exception reporting should be done by calling |
|
1661 | 1675 | self.showtraceback(), which handles state and tab-completion and |
|
1662 | 1676 | more. |
|
1663 | 1677 | |
|
1664 | 1678 | 2006-03-01 Ville Vainio <vivainio@gmail.com> |
|
1665 | 1679 | |
|
1666 | 1680 | * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module. |
|
1667 | 1681 | To use, do "from ipipe import *". |
|
1668 | 1682 | |
|
1669 | 1683 | 2006-02-24 Ville Vainio <vivainio@gmail.com> |
|
1670 | 1684 | |
|
1671 | 1685 | * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more |
|
1672 | 1686 | "cleanly" and safely than the older upgrade mechanism. |
|
1673 | 1687 | |
|
1674 | 1688 | 2006-02-21 Ville Vainio <vivainio@gmail.com> |
|
1675 | 1689 | |
|
1676 | 1690 | * Magic.py: %save works again. |
|
1677 | 1691 | |
|
1678 | 1692 | 2006-02-15 Ville Vainio <vivainio@gmail.com> |
|
1679 | 1693 | |
|
1680 | 1694 | * Magic.py: %Pprint works again |
|
1681 | 1695 | |
|
1682 | 1696 | * Extensions/ipy_sane_defaults.py: Provide everything provided |
|
1683 | 1697 | in default ipythonrc, to make it possible to have a completely empty |
|
1684 | 1698 | ipythonrc (and thus completely rc-file free configuration) |
|
1685 | 1699 | |
|
1686 | 1700 | 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1687 | 1701 | |
|
1688 | 1702 | * IPython/hooks.py (editor): quote the call to the editor command, |
|
1689 | 1703 | to allow commands with spaces in them. Problem noted by watching |
|
1690 | 1704 | Ian Oswald's video about textpad under win32 at |
|
1691 | 1705 | http://showmedo.com/videoListPage?listKey=PythonIPythonSeries |
|
1692 | 1706 | |
|
1693 | 1707 | * IPython/UserConfig/ipythonrc: Replace @ signs with % when |
|
1694 | 1708 | describing magics (we haven't used @ for a loong time). |
|
1695 | 1709 | |
|
1696 | 1710 | * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch |
|
1697 | 1711 | contributed by marienz to close |
|
1698 | 1712 | http://www.scipy.net/roundup/ipython/issue53. |
|
1699 | 1713 | |
|
1700 | 1714 | 2006-02-10 Ville Vainio <vivainio@gmail.com> |
|
1701 | 1715 | |
|
1702 | 1716 | * genutils.py: getoutput now works in win32 too |
|
1703 | 1717 | |
|
1704 | 1718 | * completer.py: alias and magic completion only invoked |
|
1705 | 1719 | at the first "item" in the line, to avoid "cd %store" |
|
1706 | 1720 | nonsense. |
|
1707 | 1721 | |
|
1708 | 1722 | 2006-02-09 Ville Vainio <vivainio@gmail.com> |
|
1709 | 1723 | |
|
1710 | 1724 | * test/*: Added a unit testing framework (finally). |
|
1711 | 1725 | '%run runtests.py' to run test_*. |
|
1712 | 1726 | |
|
1713 | 1727 | * ipapi.py: Exposed runlines and set_custom_exc |
|
1714 | 1728 | |
|
1715 | 1729 | 2006-02-07 Ville Vainio <vivainio@gmail.com> |
|
1716 | 1730 | |
|
1717 | 1731 | * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall, |
|
1718 | 1732 | instead use "f(1 2)" as before. |
|
1719 | 1733 | |
|
1720 | 1734 | 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1721 | 1735 | |
|
1722 | 1736 | * IPython/demo.py (IPythonDemo): Add new classes to the demo |
|
1723 | 1737 | facilities, for demos processed by the IPython input filter |
|
1724 | 1738 | (IPythonDemo), and for running a script one-line-at-a-time as a |
|
1725 | 1739 | demo, both for pure Python (LineDemo) and for IPython-processed |
|
1726 | 1740 | input (IPythonLineDemo). After a request by Dave Kohel, from the |
|
1727 | 1741 | SAGE team. |
|
1728 | 1742 | (Demo.edit): added an edit() method to the demo objects, to edit |
|
1729 | 1743 | the in-memory copy of the last executed block. |
|
1730 | 1744 | |
|
1731 | 1745 | * IPython/Magic.py (magic_edit): add '-r' option for 'raw' |
|
1732 | 1746 | processing to %edit, %macro and %save. These commands can now be |
|
1733 | 1747 | invoked on the unprocessed input as it was typed by the user |
|
1734 | 1748 | (without any prefilters applied). After requests by the SAGE team |
|
1735 | 1749 | at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html. |
|
1736 | 1750 | |
|
1737 | 1751 | 2006-02-01 Ville Vainio <vivainio@gmail.com> |
|
1738 | 1752 | |
|
1739 | 1753 | * setup.py, eggsetup.py: easy_install ipython==dev works |
|
1740 | 1754 | correctly now (on Linux) |
|
1741 | 1755 | |
|
1742 | 1756 | * ipy_user_conf,ipmaker: user config changes, removed spurious |
|
1743 | 1757 | warnings |
|
1744 | 1758 | |
|
1745 | 1759 | * iplib: if rc.banner is string, use it as is. |
|
1746 | 1760 | |
|
1747 | 1761 | * Magic: %pycat accepts a string argument and pages it's contents. |
|
1748 | 1762 | |
|
1749 | 1763 | |
|
1750 | 1764 | 2006-01-30 Ville Vainio <vivainio@gmail.com> |
|
1751 | 1765 | |
|
1752 | 1766 | * pickleshare,pspersistence,ipapi,Magic: persistence overhaul. |
|
1753 | 1767 | Now %store and bookmarks work through PickleShare, meaning that |
|
1754 | 1768 | concurrent access is possible and all ipython sessions see the |
|
1755 | 1769 | same database situation all the time, instead of snapshot of |
|
1756 | 1770 | the situation when the session was started. Hence, %bookmark |
|
1757 | 1771 | results are immediately accessible from othes sessions. The database |
|
1758 | 1772 | is also available for use by user extensions. See: |
|
1759 | 1773 | http://www.python.org/pypi/pickleshare |
|
1760 | 1774 | |
|
1761 | 1775 | * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'. |
|
1762 | 1776 | |
|
1763 | 1777 | * aliases can now be %store'd |
|
1764 | 1778 | |
|
1765 | 1779 | * path.py moved to Extensions so that pickleshare does not need |
|
1766 | 1780 | IPython-specific import. Extensions added to pythonpath right |
|
1767 | 1781 | at __init__. |
|
1768 | 1782 | |
|
1769 | 1783 | * iplib.py: ipalias deprecated/redundant; aliases are converted and |
|
1770 | 1784 | called with _ip.system and the pre-transformed command string. |
|
1771 | 1785 | |
|
1772 | 1786 | 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1773 | 1787 | |
|
1774 | 1788 | * IPython/iplib.py (interact): Fix that we were not catching |
|
1775 | 1789 | KeyboardInterrupt exceptions properly. I'm not quite sure why the |
|
1776 | 1790 | logic here had to change, but it's fixed now. |
|
1777 | 1791 | |
|
1778 | 1792 | 2006-01-29 Ville Vainio <vivainio@gmail.com> |
|
1779 | 1793 | |
|
1780 | 1794 | * iplib.py: Try to import pyreadline on Windows. |
|
1781 | 1795 | |
|
1782 | 1796 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
1783 | 1797 | |
|
1784 | 1798 | * iplib.py: Expose ipapi as _ip in builtin namespace. |
|
1785 | 1799 | Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system) |
|
1786 | 1800 | and ip_set_hook (-> _ip.set_hook) redundant. % and ! |
|
1787 | 1801 | syntax now produce _ip.* variant of the commands. |
|
1788 | 1802 | |
|
1789 | 1803 | * "_ip.options().autoedit_syntax = 2" automatically throws |
|
1790 | 1804 | user to editor for syntax error correction without prompting. |
|
1791 | 1805 | |
|
1792 | 1806 | 2006-01-27 Ville Vainio <vivainio@gmail.com> |
|
1793 | 1807 | |
|
1794 | 1808 | * ipmaker.py: Give "realistic" sys.argv for scripts (without |
|
1795 | 1809 | 'ipython' at argv[0]) executed through command line. |
|
1796 | 1810 | NOTE: this DEPRECATES calling ipython with multiple scripts |
|
1797 | 1811 | ("ipython a.py b.py c.py") |
|
1798 | 1812 | |
|
1799 | 1813 | * iplib.py, hooks.py: Added configurable input prefilter, |
|
1800 | 1814 | named 'input_prefilter'. See ext_rescapture.py for example |
|
1801 | 1815 | usage. |
|
1802 | 1816 | |
|
1803 | 1817 | * ext_rescapture.py, Magic.py: Better system command output capture |
|
1804 | 1818 | through 'var = !ls' (deprecates user-visible %sc). Same notation |
|
1805 | 1819 | applies for magics, 'var = %alias' assigns alias list to var. |
|
1806 | 1820 | |
|
1807 | 1821 | * ipapi.py: added meta() for accessing extension-usable data store. |
|
1808 | 1822 | |
|
1809 | 1823 | * iplib.py: added InteractiveShell.getapi(). New magics should be |
|
1810 | 1824 | written doing self.getapi() instead of using the shell directly. |
|
1811 | 1825 | |
|
1812 | 1826 | * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and |
|
1813 | 1827 | %store foo >> ~/myfoo.txt to store variables to files (in clean |
|
1814 | 1828 | textual form, not a restorable pickle). |
|
1815 | 1829 | |
|
1816 | 1830 | * ipmaker.py: now import ipy_profile_PROFILENAME automatically |
|
1817 | 1831 | |
|
1818 | 1832 | * usage.py, Magic.py: added %quickref |
|
1819 | 1833 | |
|
1820 | 1834 | * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2). |
|
1821 | 1835 | |
|
1822 | 1836 | * GetoptErrors when invoking magics etc. with wrong args |
|
1823 | 1837 | are now more helpful: |
|
1824 | 1838 | GetoptError: option -l not recognized (allowed: "qb" ) |
|
1825 | 1839 | |
|
1826 | 1840 | 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1827 | 1841 | |
|
1828 | 1842 | * IPython/demo.py (Demo.show): Flush stdout after each block, so |
|
1829 | 1843 | computationally intensive blocks don't appear to stall the demo. |
|
1830 | 1844 | |
|
1831 | 1845 | 2006-01-24 Ville Vainio <vivainio@gmail.com> |
|
1832 | 1846 | |
|
1833 | 1847 | * iplib.py, hooks.py: 'result_display' hook can return a non-None |
|
1834 | 1848 | value to manipulate resulting history entry. |
|
1835 | 1849 | |
|
1836 | 1850 | * ipapi.py: Moved TryNext here from hooks.py. Moved functions |
|
1837 | 1851 | to instance methods of IPApi class, to make extending an embedded |
|
1838 | 1852 | IPython feasible. See ext_rehashdir.py for example usage. |
|
1839 | 1853 | |
|
1840 | 1854 | * Merged 1071-1076 from branches/0.7.1 |
|
1841 | 1855 | |
|
1842 | 1856 | |
|
1843 | 1857 | 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1844 | 1858 | |
|
1845 | 1859 | * tools/release (daystamp): Fix build tools to use the new |
|
1846 | 1860 | eggsetup.py script to build lightweight eggs. |
|
1847 | 1861 | |
|
1848 | 1862 | * Applied changesets 1062 and 1064 before 0.7.1 release. |
|
1849 | 1863 | |
|
1850 | 1864 | * IPython/Magic.py (magic_history): Add '-r' option to %hist, to |
|
1851 | 1865 | see the raw input history (without conversions like %ls -> |
|
1852 | 1866 | ipmagic("ls")). After a request from W. Stein, SAGE |
|
1853 | 1867 | (http://modular.ucsd.edu/sage) developer. This information is |
|
1854 | 1868 | stored in the input_hist_raw attribute of the IPython instance, so |
|
1855 | 1869 | developers can access it if needed (it's an InputList instance). |
|
1856 | 1870 | |
|
1857 | 1871 | * Versionstring = 0.7.2.svn |
|
1858 | 1872 | |
|
1859 | 1873 | * eggsetup.py: A separate script for constructing eggs, creates |
|
1860 | 1874 | proper launch scripts even on Windows (an .exe file in |
|
1861 | 1875 | \python24\scripts). |
|
1862 | 1876 | |
|
1863 | 1877 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
1864 | 1878 | egg. |
|
1865 | 1879 | |
|
1866 | 1880 | 2006-01-23 Ville Vainio <vivainio@gmail.com> |
|
1867 | 1881 | |
|
1868 | 1882 | * Added %cpaste magic for pasting python code |
|
1869 | 1883 | |
|
1870 | 1884 | 2006-01-22 Ville Vainio <vivainio@gmail.com> |
|
1871 | 1885 | |
|
1872 | 1886 | * Merge from branches/0.7.1 into trunk, revs 1052-1057 |
|
1873 | 1887 | |
|
1874 | 1888 | * Versionstring = 0.7.2.svn |
|
1875 | 1889 | |
|
1876 | 1890 | * eggsetup.py: A separate script for constructing eggs, creates |
|
1877 | 1891 | proper launch scripts even on Windows (an .exe file in |
|
1878 | 1892 | \python24\scripts). |
|
1879 | 1893 | |
|
1880 | 1894 | * ipapi.py: launch_new_instance, launch entry point needed for the |
|
1881 | 1895 | egg. |
|
1882 | 1896 | |
|
1883 | 1897 | 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1884 | 1898 | |
|
1885 | 1899 | * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or |
|
1886 | 1900 | %pfile foo would print the file for foo even if it was a binary. |
|
1887 | 1901 | Now, extensions '.so' and '.dll' are skipped. |
|
1888 | 1902 | |
|
1889 | 1903 | * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading |
|
1890 | 1904 | bug, where macros would fail in all threaded modes. I'm not 100% |
|
1891 | 1905 | sure, so I'm going to put out an rc instead of making a release |
|
1892 | 1906 | today, and wait for feedback for at least a few days. |
|
1893 | 1907 | |
|
1894 | 1908 | * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt |
|
1895 | 1909 | it...) the handling of pasting external code with autoindent on. |
|
1896 | 1910 | To get out of a multiline input, the rule will appear for most |
|
1897 | 1911 | users unchanged: two blank lines or change the indent level |
|
1898 | 1912 | proposed by IPython. But there is a twist now: you can |
|
1899 | 1913 | add/subtract only *one or two spaces*. If you add/subtract three |
|
1900 | 1914 | or more (unless you completely delete the line), IPython will |
|
1901 | 1915 | accept that line, and you'll need to enter a second one of pure |
|
1902 | 1916 | whitespace. I know it sounds complicated, but I can't find a |
|
1903 | 1917 | different solution that covers all the cases, with the right |
|
1904 | 1918 | heuristics. Hopefully in actual use, nobody will really notice |
|
1905 | 1919 | all these strange rules and things will 'just work'. |
|
1906 | 1920 | |
|
1907 | 1921 | 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1908 | 1922 | |
|
1909 | 1923 | * IPython/iplib.py (interact): catch exceptions which can be |
|
1910 | 1924 | triggered asynchronously by signal handlers. Thanks to an |
|
1911 | 1925 | automatic crash report, submitted by Colin Kingsley |
|
1912 | 1926 | <tercel-AT-gentoo.org>. |
|
1913 | 1927 | |
|
1914 | 1928 | 2006-01-20 Ville Vainio <vivainio@gmail.com> |
|
1915 | 1929 | |
|
1916 | 1930 | * Ipython/Extensions/ext_rehashdir.py: Created a usable example |
|
1917 | 1931 | (%rehashdir, very useful, try it out) of how to extend ipython |
|
1918 | 1932 | with new magics. Also added Extensions dir to pythonpath to make |
|
1919 | 1933 | importing extensions easy. |
|
1920 | 1934 | |
|
1921 | 1935 | * %store now complains when trying to store interactively declared |
|
1922 | 1936 | classes / instances of those classes. |
|
1923 | 1937 | |
|
1924 | 1938 | * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py, |
|
1925 | 1939 | ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported |
|
1926 | 1940 | if they exist, and ipy_user_conf.py with some defaults is created for |
|
1927 | 1941 | the user. |
|
1928 | 1942 | |
|
1929 | 1943 | * Startup rehashing done by the config file, not InterpreterExec. |
|
1930 | 1944 | This means system commands are available even without selecting the |
|
1931 | 1945 | pysh profile. It's the sensible default after all. |
|
1932 | 1946 | |
|
1933 | 1947 | 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1934 | 1948 | |
|
1935 | 1949 | * IPython/iplib.py (raw_input): I _think_ I got the pasting of |
|
1936 | 1950 | multiline code with autoindent on working. But I am really not |
|
1937 | 1951 | sure, so this needs more testing. Will commit a debug-enabled |
|
1938 | 1952 | version for now, while I test it some more, so that Ville and |
|
1939 | 1953 | others may also catch any problems. Also made |
|
1940 | 1954 | self.indent_current_str() a method, to ensure that there's no |
|
1941 | 1955 | chance of the indent space count and the corresponding string |
|
1942 | 1956 | falling out of sync. All code needing the string should just call |
|
1943 | 1957 | the method. |
|
1944 | 1958 | |
|
1945 | 1959 | 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1946 | 1960 | |
|
1947 | 1961 | * IPython/Magic.py (magic_edit): fix check for when users don't |
|
1948 | 1962 | save their output files, the try/except was in the wrong section. |
|
1949 | 1963 | |
|
1950 | 1964 | 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu> |
|
1951 | 1965 | |
|
1952 | 1966 | * IPython/Magic.py (magic_run): fix __file__ global missing from |
|
1953 | 1967 | script's namespace when executed via %run. After a report by |
|
1954 | 1968 | Vivian. |
|
1955 | 1969 | |
|
1956 | 1970 | * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d' |
|
1957 | 1971 | when using python 2.4. The parent constructor changed in 2.4, and |
|
1958 | 1972 | we need to track it directly (we can't call it, as it messes up |
|
1959 | 1973 | readline and tab-completion inside our pdb would stop working). |
|
1960 | 1974 | After a bug report by R. Bernstein <rocky-AT-panix.com>. |
|
1961 | 1975 | |
|
1962 | 1976 | 2006-01-16 Ville Vainio <vivainio@gmail.com> |
|
1963 | 1977 | |
|
1964 | 1978 | * Ipython/magic.py: Reverted back to old %edit functionality |
|
1965 | 1979 | that returns file contents on exit. |
|
1966 | 1980 | |
|
1967 | 1981 | * IPython/path.py: Added Jason Orendorff's "path" module to |
|
1968 | 1982 | IPython tree, http://www.jorendorff.com/articles/python/path/. |
|
1969 | 1983 | You can get path objects conveniently through %sc, and !!, e.g.: |
|
1970 | 1984 | sc files=ls |
|
1971 | 1985 | for p in files.paths: # or files.p |
|
1972 | 1986 | print p,p.mtime |
|
1973 | 1987 | |
|
1974 | 1988 | * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall |
|
1975 | 1989 | now work again without considering the exclusion regexp - |
|
1976 | 1990 | hence, things like ',foo my/path' turn to 'foo("my/path")' |
|
1977 | 1991 | instead of syntax error. |
|
1978 | 1992 | |
|
1979 | 1993 | |
|
1980 | 1994 | 2006-01-14 Ville Vainio <vivainio@gmail.com> |
|
1981 | 1995 | |
|
1982 | 1996 | * IPython/ipapi.py (ashook, asmagic, options): Added convenience |
|
1983 | 1997 | ipapi decorators for python 2.4 users, options() provides access to rc |
|
1984 | 1998 | data. |
|
1985 | 1999 | |
|
1986 | 2000 | * IPython/Magic.py (magic_cd): %cd now accepts backslashes |
|
1987 | 2001 | as path separators (even on Linux ;-). Space character after |
|
1988 | 2002 | backslash (as yielded by tab completer) is still space; |
|
1989 | 2003 | "%cd long\ name" works as expected. |
|
1990 | 2004 | |
|
1991 | 2005 | * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented |
|
1992 | 2006 | as "chain of command", with priority. API stays the same, |
|
1993 | 2007 | TryNext exception raised by a hook function signals that |
|
1994 | 2008 | current hook failed and next hook should try handling it, as |
|
1995 | 2009 | suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also |
|
1996 | 2010 | requested configurable display hook, which is now implemented. |
|
1997 | 2011 | |
|
1998 | 2012 | 2006-01-13 Ville Vainio <vivainio@gmail.com> |
|
1999 | 2013 | |
|
2000 | 2014 | * IPython/platutils*.py: platform specific utility functions, |
|
2001 | 2015 | so far only set_term_title is implemented (change terminal |
|
2002 | 2016 | label in windowing systems). %cd now changes the title to |
|
2003 | 2017 | current dir. |
|
2004 | 2018 | |
|
2005 | 2019 | * IPython/Release.py: Added myself to "authors" list, |
|
2006 | 2020 | had to create new files. |
|
2007 | 2021 | |
|
2008 | 2022 | * IPython/iplib.py (handle_shell_escape): fixed logical flaw in |
|
2009 | 2023 | shell escape; not a known bug but had potential to be one in the |
|
2010 | 2024 | future. |
|
2011 | 2025 | |
|
2012 | 2026 | * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public" |
|
2013 | 2027 | extension API for IPython! See the module for usage example. Fix |
|
2014 | 2028 | OInspect for docstring-less magic functions. |
|
2015 | 2029 | |
|
2016 | 2030 | |
|
2017 | 2031 | 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2018 | 2032 | |
|
2019 | 2033 | * IPython/iplib.py (raw_input): temporarily deactivate all |
|
2020 | 2034 | attempts at allowing pasting of code with autoindent on. It |
|
2021 | 2035 | introduced bugs (reported by Prabhu) and I can't seem to find a |
|
2022 | 2036 | robust combination which works in all cases. Will have to revisit |
|
2023 | 2037 | later. |
|
2024 | 2038 | |
|
2025 | 2039 | * IPython/genutils.py: remove isspace() function. We've dropped |
|
2026 | 2040 | 2.2 compatibility, so it's OK to use the string method. |
|
2027 | 2041 | |
|
2028 | 2042 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2029 | 2043 | |
|
2030 | 2044 | * IPython/iplib.py (InteractiveShell.__init__): fix regexp |
|
2031 | 2045 | matching what NOT to autocall on, to include all python binary |
|
2032 | 2046 | operators (including things like 'and', 'or', 'is' and 'in'). |
|
2033 | 2047 | Prompted by a bug report on 'foo & bar', but I realized we had |
|
2034 | 2048 | many more potential bug cases with other operators. The regexp is |
|
2035 | 2049 | self.re_exclude_auto, it's fairly commented. |
|
2036 | 2050 | |
|
2037 | 2051 | 2006-01-12 Ville Vainio <vivainio@gmail.com> |
|
2038 | 2052 | |
|
2039 | 2053 | * IPython/iplib.py (make_quoted_expr,handle_shell_escape): |
|
2040 | 2054 | Prettified and hardened string/backslash quoting with ipsystem(), |
|
2041 | 2055 | ipalias() and ipmagic(). Now even \ characters are passed to |
|
2042 | 2056 | %magics, !shell escapes and aliases exactly as they are in the |
|
2043 | 2057 | ipython command line. Should improve backslash experience, |
|
2044 | 2058 | particularly in Windows (path delimiter for some commands that |
|
2045 | 2059 | won't understand '/'), but Unix benefits as well (regexps). %cd |
|
2046 | 2060 | magic still doesn't support backslash path delimiters, though. Also |
|
2047 | 2061 | deleted all pretense of supporting multiline command strings in |
|
2048 | 2062 | !system or %magic commands. Thanks to Jerry McRae for suggestions. |
|
2049 | 2063 | |
|
2050 | 2064 | * doc/build_doc_instructions.txt added. Documentation on how to |
|
2051 | 2065 | use doc/update_manual.py, added yesterday. Both files contributed |
|
2052 | 2066 | by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates |
|
2053 | 2067 | doc/*.sh for deprecation at a later date. |
|
2054 | 2068 | |
|
2055 | 2069 | * /ipython.py Added ipython.py to root directory for |
|
2056 | 2070 | zero-installation (tar xzvf ipython.tgz; cd ipython; python |
|
2057 | 2071 | ipython.py) and development convenience (no need to keep doing |
|
2058 | 2072 | "setup.py install" between changes). |
|
2059 | 2073 | |
|
2060 | 2074 | * Made ! and !! shell escapes work (again) in multiline expressions: |
|
2061 | 2075 | if 1: |
|
2062 | 2076 | !ls |
|
2063 | 2077 | !!ls |
|
2064 | 2078 | |
|
2065 | 2079 | 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2066 | 2080 | |
|
2067 | 2081 | * IPython/ipstruct.py (Struct): Rename IPython.Struct to |
|
2068 | 2082 | IPython.ipstruct, to avoid local shadowing of the stdlib 'struct' |
|
2069 | 2083 | module in case-insensitive installation. Was causing crashes |
|
2070 | 2084 | under win32. Closes http://www.scipy.net/roundup/ipython/issue49. |
|
2071 | 2085 | |
|
2072 | 2086 | * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart |
|
2073 | 2087 | <marienz-AT-gentoo.org>, closes |
|
2074 | 2088 | http://www.scipy.net/roundup/ipython/issue51. |
|
2075 | 2089 | |
|
2076 | 2090 | 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2077 | 2091 | |
|
2078 | 2092 | * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the |
|
2079 | 2093 | problem of excessive CPU usage under *nix and keyboard lag under |
|
2080 | 2094 | win32. |
|
2081 | 2095 | |
|
2082 | 2096 | 2006-01-10 *** Released version 0.7.0 |
|
2083 | 2097 | |
|
2084 | 2098 | 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2085 | 2099 | |
|
2086 | 2100 | * IPython/Release.py (revision): tag version number to 0.7.0, |
|
2087 | 2101 | ready for release. |
|
2088 | 2102 | |
|
2089 | 2103 | * IPython/Magic.py (magic_edit): Add print statement to %edit so |
|
2090 | 2104 | it informs the user of the name of the temp. file used. This can |
|
2091 | 2105 | help if you decide later to reuse that same file, so you know |
|
2092 | 2106 | where to copy the info from. |
|
2093 | 2107 | |
|
2094 | 2108 | 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2095 | 2109 | |
|
2096 | 2110 | * setup_bdist_egg.py: little script to build an egg. Added |
|
2097 | 2111 | support in the release tools as well. |
|
2098 | 2112 | |
|
2099 | 2113 | 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2100 | 2114 | |
|
2101 | 2115 | * IPython/Shell.py (IPShellWX.__init__): add support for WXPython |
|
2102 | 2116 | version selection (new -wxversion command line and ipythonrc |
|
2103 | 2117 | parameter). Patch contributed by Arnd Baecker |
|
2104 | 2118 | <arnd.baecker-AT-web.de>. |
|
2105 | 2119 | |
|
2106 | 2120 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
2107 | 2121 | embedded instances, for variables defined at the interactive |
|
2108 | 2122 | prompt of the embedded ipython. Reported by Arnd. |
|
2109 | 2123 | |
|
2110 | 2124 | * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now |
|
2111 | 2125 | it can be used as a (stateful) toggle, or with a direct parameter. |
|
2112 | 2126 | |
|
2113 | 2127 | * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which |
|
2114 | 2128 | could be triggered in certain cases and cause the traceback |
|
2115 | 2129 | printer not to work. |
|
2116 | 2130 | |
|
2117 | 2131 | 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2118 | 2132 | |
|
2119 | 2133 | * IPython/iplib.py (_should_recompile): Small fix, closes |
|
2120 | 2134 | http://www.scipy.net/roundup/ipython/issue48. Patch by Scott. |
|
2121 | 2135 | |
|
2122 | 2136 | 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2123 | 2137 | |
|
2124 | 2138 | * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK |
|
2125 | 2139 | backend for matplotlib (100% cpu utiliziation). Thanks to Charlie |
|
2126 | 2140 | Moad for help with tracking it down. |
|
2127 | 2141 | |
|
2128 | 2142 | * IPython/iplib.py (handle_auto): fix autocall handling for |
|
2129 | 2143 | objects which support BOTH __getitem__ and __call__ (so that f [x] |
|
2130 | 2144 | is left alone, instead of becoming f([x]) automatically). |
|
2131 | 2145 | |
|
2132 | 2146 | * IPython/Magic.py (magic_cd): fix crash when cd -b was used. |
|
2133 | 2147 | Ville's patch. |
|
2134 | 2148 | |
|
2135 | 2149 | 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2136 | 2150 | |
|
2137 | 2151 | * IPython/iplib.py (handle_auto): changed autocall semantics to |
|
2138 | 2152 | include 'smart' mode, where the autocall transformation is NOT |
|
2139 | 2153 | applied if there are no arguments on the line. This allows you to |
|
2140 | 2154 | just type 'foo' if foo is a callable to see its internal form, |
|
2141 | 2155 | instead of having it called with no arguments (typically a |
|
2142 | 2156 | mistake). The old 'full' autocall still exists: for that, you |
|
2143 | 2157 | need to set the 'autocall' parameter to 2 in your ipythonrc file. |
|
2144 | 2158 | |
|
2145 | 2159 | * IPython/completer.py (Completer.attr_matches): add |
|
2146 | 2160 | tab-completion support for Enthoughts' traits. After a report by |
|
2147 | 2161 | Arnd and a patch by Prabhu. |
|
2148 | 2162 | |
|
2149 | 2163 | 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2150 | 2164 | |
|
2151 | 2165 | * IPython/ultraTB.py (_fixed_getinnerframes): added Alex |
|
2152 | 2166 | Schmolck's patch to fix inspect.getinnerframes(). |
|
2153 | 2167 | |
|
2154 | 2168 | * IPython/iplib.py (InteractiveShell.__init__): significant fixes |
|
2155 | 2169 | for embedded instances, regarding handling of namespaces and items |
|
2156 | 2170 | added to the __builtin__ one. Multiple embedded instances and |
|
2157 | 2171 | recursive embeddings should work better now (though I'm not sure |
|
2158 | 2172 | I've got all the corner cases fixed, that code is a bit of a brain |
|
2159 | 2173 | twister). |
|
2160 | 2174 | |
|
2161 | 2175 | * IPython/Magic.py (magic_edit): added support to edit in-memory |
|
2162 | 2176 | macros (automatically creates the necessary temp files). %edit |
|
2163 | 2177 | also doesn't return the file contents anymore, it's just noise. |
|
2164 | 2178 | |
|
2165 | 2179 | * IPython/completer.py (Completer.attr_matches): revert change to |
|
2166 | 2180 | complete only on attributes listed in __all__. I realized it |
|
2167 | 2181 | cripples the tab-completion system as a tool for exploring the |
|
2168 | 2182 | internals of unknown libraries (it renders any non-__all__ |
|
2169 | 2183 | attribute off-limits). I got bit by this when trying to see |
|
2170 | 2184 | something inside the dis module. |
|
2171 | 2185 | |
|
2172 | 2186 | 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2173 | 2187 | |
|
2174 | 2188 | * IPython/iplib.py (InteractiveShell.__init__): add .meta |
|
2175 | 2189 | namespace for users and extension writers to hold data in. This |
|
2176 | 2190 | follows the discussion in |
|
2177 | 2191 | http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython. |
|
2178 | 2192 | |
|
2179 | 2193 | * IPython/completer.py (IPCompleter.complete): small patch to help |
|
2180 | 2194 | tab-completion under Emacs, after a suggestion by John Barnard |
|
2181 | 2195 | <barnarj-AT-ccf.org>. |
|
2182 | 2196 | |
|
2183 | 2197 | * IPython/Magic.py (Magic.extract_input_slices): added support for |
|
2184 | 2198 | the slice notation in magics to use N-M to represent numbers N...M |
|
2185 | 2199 | (closed endpoints). This is used by %macro and %save. |
|
2186 | 2200 | |
|
2187 | 2201 | * IPython/completer.py (Completer.attr_matches): for modules which |
|
2188 | 2202 | define __all__, complete only on those. After a patch by Jeffrey |
|
2189 | 2203 | Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and |
|
2190 | 2204 | speed up this routine. |
|
2191 | 2205 | |
|
2192 | 2206 | * IPython/Logger.py (Logger.log): fix a history handling bug. I |
|
2193 | 2207 | don't know if this is the end of it, but the behavior now is |
|
2194 | 2208 | certainly much more correct. Note that coupled with macros, |
|
2195 | 2209 | slightly surprising (at first) behavior may occur: a macro will in |
|
2196 | 2210 | general expand to multiple lines of input, so upon exiting, the |
|
2197 | 2211 | in/out counters will both be bumped by the corresponding amount |
|
2198 | 2212 | (as if the macro's contents had been typed interactively). Typing |
|
2199 | 2213 | %hist will reveal the intermediate (silently processed) lines. |
|
2200 | 2214 | |
|
2201 | 2215 | * IPython/Magic.py (magic_run): fix a subtle bug which could cause |
|
2202 | 2216 | pickle to fail (%run was overwriting __main__ and not restoring |
|
2203 | 2217 | it, but pickle relies on __main__ to operate). |
|
2204 | 2218 | |
|
2205 | 2219 | * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now |
|
2206 | 2220 | using properties, but forgot to make the main InteractiveShell |
|
2207 | 2221 | class a new-style class. Properties fail silently, and |
|
2208 | 2222 | mysteriously, with old-style class (getters work, but |
|
2209 | 2223 | setters don't do anything). |
|
2210 | 2224 | |
|
2211 | 2225 | 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2212 | 2226 | |
|
2213 | 2227 | * IPython/Magic.py (magic_history): fix history reporting bug (I |
|
2214 | 2228 | know some nasties are still there, I just can't seem to find a |
|
2215 | 2229 | reproducible test case to track them down; the input history is |
|
2216 | 2230 | falling out of sync...) |
|
2217 | 2231 | |
|
2218 | 2232 | * IPython/iplib.py (handle_shell_escape): fix bug where both |
|
2219 | 2233 | aliases and system accesses where broken for indented code (such |
|
2220 | 2234 | as loops). |
|
2221 | 2235 | |
|
2222 | 2236 | * IPython/genutils.py (shell): fix small but critical bug for |
|
2223 | 2237 | win32 system access. |
|
2224 | 2238 | |
|
2225 | 2239 | 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2226 | 2240 | |
|
2227 | 2241 | * IPython/iplib.py (showtraceback): remove use of the |
|
2228 | 2242 | sys.last_{type/value/traceback} structures, which are non |
|
2229 | 2243 | thread-safe. |
|
2230 | 2244 | (_prefilter): change control flow to ensure that we NEVER |
|
2231 | 2245 | introspect objects when autocall is off. This will guarantee that |
|
2232 | 2246 | having an input line of the form 'x.y', where access to attribute |
|
2233 | 2247 | 'y' has side effects, doesn't trigger the side effect TWICE. It |
|
2234 | 2248 | is important to note that, with autocall on, these side effects |
|
2235 | 2249 | can still happen. |
|
2236 | 2250 | (ipsystem): new builtin, to complete the ip{magic/alias/system} |
|
2237 | 2251 | trio. IPython offers these three kinds of special calls which are |
|
2238 | 2252 | not python code, and it's a good thing to have their call method |
|
2239 | 2253 | be accessible as pure python functions (not just special syntax at |
|
2240 | 2254 | the command line). It gives us a better internal implementation |
|
2241 | 2255 | structure, as well as exposing these for user scripting more |
|
2242 | 2256 | cleanly. |
|
2243 | 2257 | |
|
2244 | 2258 | * IPython/macro.py (Macro.__init__): moved macros to a standalone |
|
2245 | 2259 | file. Now that they'll be more likely to be used with the |
|
2246 | 2260 | persistance system (%store), I want to make sure their module path |
|
2247 | 2261 | doesn't change in the future, so that we don't break things for |
|
2248 | 2262 | users' persisted data. |
|
2249 | 2263 | |
|
2250 | 2264 | * IPython/iplib.py (autoindent_update): move indentation |
|
2251 | 2265 | management into the _text_ processing loop, not the keyboard |
|
2252 | 2266 | interactive one. This is necessary to correctly process non-typed |
|
2253 | 2267 | multiline input (such as macros). |
|
2254 | 2268 | |
|
2255 | 2269 | * IPython/Magic.py (Magic.format_latex): patch by Stefan van der |
|
2256 | 2270 | Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings, |
|
2257 | 2271 | which was producing problems in the resulting manual. |
|
2258 | 2272 | (magic_whos): improve reporting of instances (show their class, |
|
2259 | 2273 | instead of simply printing 'instance' which isn't terribly |
|
2260 | 2274 | informative). |
|
2261 | 2275 | |
|
2262 | 2276 | * IPython/genutils.py (shell): commit Jorgen Stenarson's patch |
|
2263 | 2277 | (minor mods) to support network shares under win32. |
|
2264 | 2278 | |
|
2265 | 2279 | * IPython/winconsole.py (get_console_size): add new winconsole |
|
2266 | 2280 | module and fixes to page_dumb() to improve its behavior under |
|
2267 | 2281 | win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>. |
|
2268 | 2282 | |
|
2269 | 2283 | * IPython/Magic.py (Macro): simplified Macro class to just |
|
2270 | 2284 | subclass list. We've had only 2.2 compatibility for a very long |
|
2271 | 2285 | time, yet I was still avoiding subclassing the builtin types. No |
|
2272 | 2286 | more (I'm also starting to use properties, though I won't shift to |
|
2273 | 2287 | 2.3-specific features quite yet). |
|
2274 | 2288 | (magic_store): added Ville's patch for lightweight variable |
|
2275 | 2289 | persistence, after a request on the user list by Matt Wilkie |
|
2276 | 2290 | <maphew-AT-gmail.com>. The new %store magic's docstring has full |
|
2277 | 2291 | details. |
|
2278 | 2292 | |
|
2279 | 2293 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
2280 | 2294 | changed the default logfile name from 'ipython.log' to |
|
2281 | 2295 | 'ipython_log.py'. These logs are real python files, and now that |
|
2282 | 2296 | we have much better multiline support, people are more likely to |
|
2283 | 2297 | want to use them as such. Might as well name them correctly. |
|
2284 | 2298 | |
|
2285 | 2299 | * IPython/Magic.py: substantial cleanup. While we can't stop |
|
2286 | 2300 | using magics as mixins, due to the existing customizations 'out |
|
2287 | 2301 | there' which rely on the mixin naming conventions, at least I |
|
2288 | 2302 | cleaned out all cross-class name usage. So once we are OK with |
|
2289 | 2303 | breaking compatibility, the two systems can be separated. |
|
2290 | 2304 | |
|
2291 | 2305 | * IPython/Logger.py: major cleanup. This one is NOT a mixin |
|
2292 | 2306 | anymore, and the class is a fair bit less hideous as well. New |
|
2293 | 2307 | features were also introduced: timestamping of input, and logging |
|
2294 | 2308 | of output results. These are user-visible with the -t and -o |
|
2295 | 2309 | options to %logstart. Closes |
|
2296 | 2310 | http://www.scipy.net/roundup/ipython/issue11 and a request by |
|
2297 | 2311 | William Stein (SAGE developer - http://modular.ucsd.edu/sage). |
|
2298 | 2312 | |
|
2299 | 2313 | 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2300 | 2314 | |
|
2301 | 2315 | * IPython/iplib.py (handle_shell_escape): add Ville's patch to |
|
2302 | 2316 | better handle backslashes in paths. See the thread 'More Windows |
|
2303 | 2317 | questions part 2 - \/ characters revisited' on the iypthon user |
|
2304 | 2318 | list: |
|
2305 | 2319 | http://scipy.net/pipermail/ipython-user/2005-June/000907.html |
|
2306 | 2320 | |
|
2307 | 2321 | (InteractiveShell.__init__): fix tab-completion bug in threaded shells. |
|
2308 | 2322 | |
|
2309 | 2323 | (InteractiveShell.__init__): change threaded shells to not use the |
|
2310 | 2324 | ipython crash handler. This was causing more problems than not, |
|
2311 | 2325 | as exceptions in the main thread (GUI code, typically) would |
|
2312 | 2326 | always show up as a 'crash', when they really weren't. |
|
2313 | 2327 | |
|
2314 | 2328 | The colors and exception mode commands (%colors/%xmode) have been |
|
2315 | 2329 | synchronized to also take this into account, so users can get |
|
2316 | 2330 | verbose exceptions for their threaded code as well. I also added |
|
2317 | 2331 | support for activating pdb inside this exception handler as well, |
|
2318 | 2332 | so now GUI authors can use IPython's enhanced pdb at runtime. |
|
2319 | 2333 | |
|
2320 | 2334 | * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag |
|
2321 | 2335 | true by default, and add it to the shipped ipythonrc file. Since |
|
2322 | 2336 | this asks the user before proceeding, I think it's OK to make it |
|
2323 | 2337 | true by default. |
|
2324 | 2338 | |
|
2325 | 2339 | * IPython/Magic.py (magic_exit): make new exit/quit magics instead |
|
2326 | 2340 | of the previous special-casing of input in the eval loop. I think |
|
2327 | 2341 | this is cleaner, as they really are commands and shouldn't have |
|
2328 | 2342 | a special role in the middle of the core code. |
|
2329 | 2343 | |
|
2330 | 2344 | 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2331 | 2345 | |
|
2332 | 2346 | * IPython/iplib.py (edit_syntax_error): added support for |
|
2333 | 2347 | automatically reopening the editor if the file had a syntax error |
|
2334 | 2348 | in it. Thanks to scottt who provided the patch at: |
|
2335 | 2349 | http://www.scipy.net/roundup/ipython/issue36 (slightly modified |
|
2336 | 2350 | version committed). |
|
2337 | 2351 | |
|
2338 | 2352 | * IPython/iplib.py (handle_normal): add suport for multi-line |
|
2339 | 2353 | input with emtpy lines. This fixes |
|
2340 | 2354 | http://www.scipy.net/roundup/ipython/issue43 and a similar |
|
2341 | 2355 | discussion on the user list. |
|
2342 | 2356 | |
|
2343 | 2357 | WARNING: a behavior change is necessarily introduced to support |
|
2344 | 2358 | blank lines: now a single blank line with whitespace does NOT |
|
2345 | 2359 | break the input loop, which means that when autoindent is on, by |
|
2346 | 2360 | default hitting return on the next (indented) line does NOT exit. |
|
2347 | 2361 | |
|
2348 | 2362 | Instead, to exit a multiline input you can either have: |
|
2349 | 2363 | |
|
2350 | 2364 | - TWO whitespace lines (just hit return again), or |
|
2351 | 2365 | - a single whitespace line of a different length than provided |
|
2352 | 2366 | by the autoindent (add or remove a space). |
|
2353 | 2367 | |
|
2354 | 2368 | * IPython/completer.py (MagicCompleter.__init__): new 'completer' |
|
2355 | 2369 | module to better organize all readline-related functionality. |
|
2356 | 2370 | I've deleted FlexCompleter and put all completion clases here. |
|
2357 | 2371 | |
|
2358 | 2372 | * IPython/iplib.py (raw_input): improve indentation management. |
|
2359 | 2373 | It is now possible to paste indented code with autoindent on, and |
|
2360 | 2374 | the code is interpreted correctly (though it still looks bad on |
|
2361 | 2375 | screen, due to the line-oriented nature of ipython). |
|
2362 | 2376 | (MagicCompleter.complete): change behavior so that a TAB key on an |
|
2363 | 2377 | otherwise empty line actually inserts a tab, instead of completing |
|
2364 | 2378 | on the entire global namespace. This makes it easier to use the |
|
2365 | 2379 | TAB key for indentation. After a request by Hans Meine |
|
2366 | 2380 | <hans_meine-AT-gmx.net> |
|
2367 | 2381 | (_prefilter): add support so that typing plain 'exit' or 'quit' |
|
2368 | 2382 | does a sensible thing. Originally I tried to deviate as little as |
|
2369 | 2383 | possible from the default python behavior, but even that one may |
|
2370 | 2384 | change in this direction (thread on python-dev to that effect). |
|
2371 | 2385 | Regardless, ipython should do the right thing even if CPython's |
|
2372 | 2386 | '>>>' prompt doesn't. |
|
2373 | 2387 | (InteractiveShell): removed subclassing code.InteractiveConsole |
|
2374 | 2388 | class. By now we'd overridden just about all of its methods: I've |
|
2375 | 2389 | copied the remaining two over, and now ipython is a standalone |
|
2376 | 2390 | class. This will provide a clearer picture for the chainsaw |
|
2377 | 2391 | branch refactoring. |
|
2378 | 2392 | |
|
2379 | 2393 | 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2380 | 2394 | |
|
2381 | 2395 | * IPython/ultraTB.py (VerboseTB.text): harden reporting against |
|
2382 | 2396 | failures for objects which break when dir() is called on them. |
|
2383 | 2397 | |
|
2384 | 2398 | * IPython/FlexCompleter.py (Completer.__init__): Added support for |
|
2385 | 2399 | distinct local and global namespaces in the completer API. This |
|
2386 | 2400 | change allows us to properly handle completion with distinct |
|
2387 | 2401 | scopes, including in embedded instances (this had never really |
|
2388 | 2402 | worked correctly). |
|
2389 | 2403 | |
|
2390 | 2404 | Note: this introduces a change in the constructor for |
|
2391 | 2405 | MagicCompleter, as a new global_namespace parameter is now the |
|
2392 | 2406 | second argument (the others were bumped one position). |
|
2393 | 2407 | |
|
2394 | 2408 | 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2395 | 2409 | |
|
2396 | 2410 | * IPython/iplib.py (embed_mainloop): fix tab-completion in |
|
2397 | 2411 | embedded instances (which can be done now thanks to Vivian's |
|
2398 | 2412 | frame-handling fixes for pdb). |
|
2399 | 2413 | (InteractiveShell.__init__): Fix namespace handling problem in |
|
2400 | 2414 | embedded instances. We were overwriting __main__ unconditionally, |
|
2401 | 2415 | and this should only be done for 'full' (non-embedded) IPython; |
|
2402 | 2416 | embedded instances must respect the caller's __main__. Thanks to |
|
2403 | 2417 | a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com> |
|
2404 | 2418 | |
|
2405 | 2419 | 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2406 | 2420 | |
|
2407 | 2421 | * setup.py: added download_url to setup(). This registers the |
|
2408 | 2422 | download address at PyPI, which is not only useful to humans |
|
2409 | 2423 | browsing the site, but is also picked up by setuptools (the Eggs |
|
2410 | 2424 | machinery). Thanks to Ville and R. Kern for the info/discussion |
|
2411 | 2425 | on this. |
|
2412 | 2426 | |
|
2413 | 2427 | 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2414 | 2428 | |
|
2415 | 2429 | * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements. |
|
2416 | 2430 | This brings a lot of nice functionality to the pdb mode, which now |
|
2417 | 2431 | has tab-completion, syntax highlighting, and better stack handling |
|
2418 | 2432 | than before. Many thanks to Vivian De Smedt |
|
2419 | 2433 | <vivian-AT-vdesmedt.com> for the original patches. |
|
2420 | 2434 | |
|
2421 | 2435 | 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2422 | 2436 | |
|
2423 | 2437 | * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling |
|
2424 | 2438 | sequence to consistently accept the banner argument. The |
|
2425 | 2439 | inconsistency was tripping SAGE, thanks to Gary Zablackis |
|
2426 | 2440 | <gzabl-AT-yahoo.com> for the report. |
|
2427 | 2441 | |
|
2428 | 2442 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2429 | 2443 | |
|
2430 | 2444 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
2431 | 2445 | Fix bug where a naked 'alias' call in the ipythonrc file would |
|
2432 | 2446 | cause a crash. Bug reported by Jorgen Stenarson. |
|
2433 | 2447 | |
|
2434 | 2448 | 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2435 | 2449 | |
|
2436 | 2450 | * IPython/ipmaker.py (make_IPython): cleanups which should improve |
|
2437 | 2451 | startup time. |
|
2438 | 2452 | |
|
2439 | 2453 | * IPython/iplib.py (runcode): my globals 'fix' for embedded |
|
2440 | 2454 | instances had introduced a bug with globals in normal code. Now |
|
2441 | 2455 | it's working in all cases. |
|
2442 | 2456 | |
|
2443 | 2457 | * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and |
|
2444 | 2458 | API changes. A new ipytonrc option, 'wildcards_case_sensitive' |
|
2445 | 2459 | has been introduced to set the default case sensitivity of the |
|
2446 | 2460 | searches. Users can still select either mode at runtime on a |
|
2447 | 2461 | per-search basis. |
|
2448 | 2462 | |
|
2449 | 2463 | 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2450 | 2464 | |
|
2451 | 2465 | * IPython/wildcard.py (NameSpace.__init__): fix resolution of |
|
2452 | 2466 | attributes in wildcard searches for subclasses. Modified version |
|
2453 | 2467 | of a patch by Jorgen. |
|
2454 | 2468 | |
|
2455 | 2469 | 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2456 | 2470 | |
|
2457 | 2471 | * IPython/iplib.py (embed_mainloop): Fix handling of globals for |
|
2458 | 2472 | embedded instances. I added a user_global_ns attribute to the |
|
2459 | 2473 | InteractiveShell class to handle this. |
|
2460 | 2474 | |
|
2461 | 2475 | 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2462 | 2476 | |
|
2463 | 2477 | * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to |
|
2464 | 2478 | idle_add, which fixes horrible keyboard lag problems under gtk 2.6 |
|
2465 | 2479 | (reported under win32, but may happen also in other platforms). |
|
2466 | 2480 | Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm> |
|
2467 | 2481 | |
|
2468 | 2482 | 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2469 | 2483 | |
|
2470 | 2484 | * IPython/Magic.py (magic_psearch): new support for wildcard |
|
2471 | 2485 | patterns. Now, typing ?a*b will list all names which begin with a |
|
2472 | 2486 | and end in b, for example. The %psearch magic has full |
|
2473 | 2487 | docstrings. Many thanks to JΓΆrgen Stenarson |
|
2474 | 2488 | <jorgen.stenarson-AT-bostream.nu>, author of the patches |
|
2475 | 2489 | implementing this functionality. |
|
2476 | 2490 | |
|
2477 | 2491 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2478 | 2492 | |
|
2479 | 2493 | * Manual: fixed long-standing annoyance of double-dashes (as in |
|
2480 | 2494 | --prefix=~, for example) being stripped in the HTML version. This |
|
2481 | 2495 | is a latex2html bug, but a workaround was provided. Many thanks |
|
2482 | 2496 | to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed |
|
2483 | 2497 | help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball |
|
2484 | 2498 | rolling. This seemingly small issue had tripped a number of users |
|
2485 | 2499 | when first installing, so I'm glad to see it gone. |
|
2486 | 2500 | |
|
2487 | 2501 | 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2488 | 2502 | |
|
2489 | 2503 | * IPython/Extensions/numeric_formats.py: fix missing import, |
|
2490 | 2504 | reported by Stephen Walton. |
|
2491 | 2505 | |
|
2492 | 2506 | 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2493 | 2507 | |
|
2494 | 2508 | * IPython/demo.py: finish demo module, fully documented now. |
|
2495 | 2509 | |
|
2496 | 2510 | * IPython/genutils.py (file_read): simple little utility to read a |
|
2497 | 2511 | file and ensure it's closed afterwards. |
|
2498 | 2512 | |
|
2499 | 2513 | 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2500 | 2514 | |
|
2501 | 2515 | * IPython/demo.py (Demo.__init__): added support for individually |
|
2502 | 2516 | tagging blocks for automatic execution. |
|
2503 | 2517 | |
|
2504 | 2518 | * IPython/Magic.py (magic_pycat): new %pycat magic for showing |
|
2505 | 2519 | syntax-highlighted python sources, requested by John. |
|
2506 | 2520 | |
|
2507 | 2521 | 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2508 | 2522 | |
|
2509 | 2523 | * IPython/demo.py (Demo.again): fix bug where again() blocks after |
|
2510 | 2524 | finishing. |
|
2511 | 2525 | |
|
2512 | 2526 | * IPython/genutils.py (shlex_split): moved from Magic to here, |
|
2513 | 2527 | where all 2.2 compatibility stuff lives. I needed it for demo.py. |
|
2514 | 2528 | |
|
2515 | 2529 | * IPython/demo.py (Demo.__init__): added support for silent |
|
2516 | 2530 | blocks, improved marks as regexps, docstrings written. |
|
2517 | 2531 | (Demo.__init__): better docstring, added support for sys.argv. |
|
2518 | 2532 | |
|
2519 | 2533 | * IPython/genutils.py (marquee): little utility used by the demo |
|
2520 | 2534 | code, handy in general. |
|
2521 | 2535 | |
|
2522 | 2536 | * IPython/demo.py (Demo.__init__): new class for interactive |
|
2523 | 2537 | demos. Not documented yet, I just wrote it in a hurry for |
|
2524 | 2538 | scipy'05. Will docstring later. |
|
2525 | 2539 | |
|
2526 | 2540 | 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2527 | 2541 | |
|
2528 | 2542 | * IPython/Shell.py (sigint_handler): Drastic simplification which |
|
2529 | 2543 | also seems to make Ctrl-C work correctly across threads! This is |
|
2530 | 2544 | so simple, that I can't beleive I'd missed it before. Needs more |
|
2531 | 2545 | testing, though. |
|
2532 | 2546 | (KBINT): Never mind, revert changes. I'm sure I'd tried something |
|
2533 | 2547 | like this before... |
|
2534 | 2548 | |
|
2535 | 2549 | * IPython/genutils.py (get_home_dir): add protection against |
|
2536 | 2550 | non-dirs in win32 registry. |
|
2537 | 2551 | |
|
2538 | 2552 | * IPython/iplib.py (InteractiveShell.alias_table_validate): fix |
|
2539 | 2553 | bug where dict was mutated while iterating (pysh crash). |
|
2540 | 2554 | |
|
2541 | 2555 | 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2542 | 2556 | |
|
2543 | 2557 | * IPython/iplib.py (handle_auto): Fix inconsistency arising from |
|
2544 | 2558 | spurious newlines added by this routine. After a report by |
|
2545 | 2559 | F. Mantegazza. |
|
2546 | 2560 | |
|
2547 | 2561 | 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2548 | 2562 | |
|
2549 | 2563 | * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0") |
|
2550 | 2564 | calls. These were a leftover from the GTK 1.x days, and can cause |
|
2551 | 2565 | problems in certain cases (after a report by John Hunter). |
|
2552 | 2566 | |
|
2553 | 2567 | * IPython/iplib.py (InteractiveShell.__init__): Trap exception if |
|
2554 | 2568 | os.getcwd() fails at init time. Thanks to patch from David Remahl |
|
2555 | 2569 | <chmod007-AT-mac.com>. |
|
2556 | 2570 | (InteractiveShell.__init__): prevent certain special magics from |
|
2557 | 2571 | being shadowed by aliases. Closes |
|
2558 | 2572 | http://www.scipy.net/roundup/ipython/issue41. |
|
2559 | 2573 | |
|
2560 | 2574 | 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2561 | 2575 | |
|
2562 | 2576 | * IPython/iplib.py (InteractiveShell.complete): Added new |
|
2563 | 2577 | top-level completion method to expose the completion mechanism |
|
2564 | 2578 | beyond readline-based environments. |
|
2565 | 2579 | |
|
2566 | 2580 | 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2567 | 2581 | |
|
2568 | 2582 | * tools/ipsvnc (svnversion): fix svnversion capture. |
|
2569 | 2583 | |
|
2570 | 2584 | * IPython/iplib.py (InteractiveShell.__init__): Add has_readline |
|
2571 | 2585 | attribute to self, which was missing. Before, it was set by a |
|
2572 | 2586 | routine which in certain cases wasn't being called, so the |
|
2573 | 2587 | instance could end up missing the attribute. This caused a crash. |
|
2574 | 2588 | Closes http://www.scipy.net/roundup/ipython/issue40. |
|
2575 | 2589 | |
|
2576 | 2590 | 2005-08-16 Fernando Perez <fperez@colorado.edu> |
|
2577 | 2591 | |
|
2578 | 2592 | * IPython/ultraTB.py (VerboseTB.text): don't crash if object |
|
2579 | 2593 | contains non-string attribute. Closes |
|
2580 | 2594 | http://www.scipy.net/roundup/ipython/issue38. |
|
2581 | 2595 | |
|
2582 | 2596 | 2005-08-14 Fernando Perez <fperez@colorado.edu> |
|
2583 | 2597 | |
|
2584 | 2598 | * tools/ipsvnc: Minor improvements, to add changeset info. |
|
2585 | 2599 | |
|
2586 | 2600 | 2005-08-12 Fernando Perez <fperez@colorado.edu> |
|
2587 | 2601 | |
|
2588 | 2602 | * IPython/iplib.py (runsource): remove self.code_to_run_src |
|
2589 | 2603 | attribute. I realized this is nothing more than |
|
2590 | 2604 | '\n'.join(self.buffer), and having the same data in two different |
|
2591 | 2605 | places is just asking for synchronization bugs. This may impact |
|
2592 | 2606 | people who have custom exception handlers, so I need to warn |
|
2593 | 2607 | ipython-dev about it (F. Mantegazza may use them). |
|
2594 | 2608 | |
|
2595 | 2609 | 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2596 | 2610 | |
|
2597 | 2611 | * IPython/genutils.py: fix 2.2 compatibility (generators) |
|
2598 | 2612 | |
|
2599 | 2613 | 2005-07-18 Fernando Perez <fperez@colorado.edu> |
|
2600 | 2614 | |
|
2601 | 2615 | * IPython/genutils.py (get_home_dir): fix to help users with |
|
2602 | 2616 | invalid $HOME under win32. |
|
2603 | 2617 | |
|
2604 | 2618 | 2005-07-17 Fernando Perez <fperez@colorado.edu> |
|
2605 | 2619 | |
|
2606 | 2620 | * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove |
|
2607 | 2621 | some old hacks and clean up a bit other routines; code should be |
|
2608 | 2622 | simpler and a bit faster. |
|
2609 | 2623 | |
|
2610 | 2624 | * IPython/iplib.py (interact): removed some last-resort attempts |
|
2611 | 2625 | to survive broken stdout/stderr. That code was only making it |
|
2612 | 2626 | harder to abstract out the i/o (necessary for gui integration), |
|
2613 | 2627 | and the crashes it could prevent were extremely rare in practice |
|
2614 | 2628 | (besides being fully user-induced in a pretty violent manner). |
|
2615 | 2629 | |
|
2616 | 2630 | * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff. |
|
2617 | 2631 | Nothing major yet, but the code is simpler to read; this should |
|
2618 | 2632 | make it easier to do more serious modifications in the future. |
|
2619 | 2633 | |
|
2620 | 2634 | * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh, |
|
2621 | 2635 | which broke in .15 (thanks to a report by Ville). |
|
2622 | 2636 | |
|
2623 | 2637 | * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not |
|
2624 | 2638 | be quite correct, I know next to nothing about unicode). This |
|
2625 | 2639 | will allow unicode strings to be used in prompts, amongst other |
|
2626 | 2640 | cases. It also will prevent ipython from crashing when unicode |
|
2627 | 2641 | shows up unexpectedly in many places. If ascii encoding fails, we |
|
2628 | 2642 | assume utf_8. Currently the encoding is not a user-visible |
|
2629 | 2643 | setting, though it could be made so if there is demand for it. |
|
2630 | 2644 | |
|
2631 | 2645 | * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack. |
|
2632 | 2646 | |
|
2633 | 2647 | * IPython/Struct.py (Struct.merge): switch keys() to iterator. |
|
2634 | 2648 | |
|
2635 | 2649 | * IPython/background_jobs.py: moved 2.2 compatibility to genutils. |
|
2636 | 2650 | |
|
2637 | 2651 | * IPython/genutils.py: Add 2.2 compatibility here, so all other |
|
2638 | 2652 | code can work transparently for 2.2/2.3. |
|
2639 | 2653 | |
|
2640 | 2654 | 2005-07-16 Fernando Perez <fperez@colorado.edu> |
|
2641 | 2655 | |
|
2642 | 2656 | * IPython/ultraTB.py (ExceptionColors): Make a global variable |
|
2643 | 2657 | out of the color scheme table used for coloring exception |
|
2644 | 2658 | tracebacks. This allows user code to add new schemes at runtime. |
|
2645 | 2659 | This is a minimally modified version of the patch at |
|
2646 | 2660 | http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw |
|
2647 | 2661 | for the contribution. |
|
2648 | 2662 | |
|
2649 | 2663 | * IPython/FlexCompleter.py (Completer.attr_matches): Add a |
|
2650 | 2664 | slightly modified version of the patch in |
|
2651 | 2665 | http://www.scipy.net/roundup/ipython/issue34, which also allows me |
|
2652 | 2666 | to remove the previous try/except solution (which was costlier). |
|
2653 | 2667 | Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix. |
|
2654 | 2668 | |
|
2655 | 2669 | 2005-06-08 Fernando Perez <fperez@colorado.edu> |
|
2656 | 2670 | |
|
2657 | 2671 | * IPython/iplib.py (write/write_err): Add methods to abstract all |
|
2658 | 2672 | I/O a bit more. |
|
2659 | 2673 | |
|
2660 | 2674 | * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation |
|
2661 | 2675 | warning, reported by Aric Hagberg, fix by JD Hunter. |
|
2662 | 2676 | |
|
2663 | 2677 | 2005-06-02 *** Released version 0.6.15 |
|
2664 | 2678 | |
|
2665 | 2679 | 2005-06-01 Fernando Perez <fperez@colorado.edu> |
|
2666 | 2680 | |
|
2667 | 2681 | * IPython/iplib.py (MagicCompleter.file_matches): Fix |
|
2668 | 2682 | tab-completion of filenames within open-quoted strings. Note that |
|
2669 | 2683 | this requires that in ~/.ipython/ipythonrc, users change the |
|
2670 | 2684 | readline delimiters configuration to read: |
|
2671 | 2685 | |
|
2672 | 2686 | readline_remove_delims -/~ |
|
2673 | 2687 | |
|
2674 | 2688 | |
|
2675 | 2689 | 2005-05-31 *** Released version 0.6.14 |
|
2676 | 2690 | |
|
2677 | 2691 | 2005-05-29 Fernando Perez <fperez@colorado.edu> |
|
2678 | 2692 | |
|
2679 | 2693 | * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks |
|
2680 | 2694 | with files not on the filesystem. Reported by Eliyahu Sandler |
|
2681 | 2695 | <eli@gondolin.net> |
|
2682 | 2696 | |
|
2683 | 2697 | 2005-05-22 Fernando Perez <fperez@colorado.edu> |
|
2684 | 2698 | |
|
2685 | 2699 | * IPython/iplib.py: Fix a few crashes in the --upgrade option. |
|
2686 | 2700 | After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>. |
|
2687 | 2701 | |
|
2688 | 2702 | 2005-05-19 Fernando Perez <fperez@colorado.edu> |
|
2689 | 2703 | |
|
2690 | 2704 | * IPython/iplib.py (safe_execfile): close a file which could be |
|
2691 | 2705 | left open (causing problems in win32, which locks open files). |
|
2692 | 2706 | Thanks to a bug report by D Brown <dbrown2@yahoo.com>. |
|
2693 | 2707 | |
|
2694 | 2708 | 2005-05-18 Fernando Perez <fperez@colorado.edu> |
|
2695 | 2709 | |
|
2696 | 2710 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all |
|
2697 | 2711 | keyword arguments correctly to safe_execfile(). |
|
2698 | 2712 | |
|
2699 | 2713 | 2005-05-13 Fernando Perez <fperez@colorado.edu> |
|
2700 | 2714 | |
|
2701 | 2715 | * ipython.1: Added info about Qt to manpage, and threads warning |
|
2702 | 2716 | to usage page (invoked with --help). |
|
2703 | 2717 | |
|
2704 | 2718 | * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added |
|
2705 | 2719 | new matcher (it goes at the end of the priority list) to do |
|
2706 | 2720 | tab-completion on named function arguments. Submitted by George |
|
2707 | 2721 | Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at |
|
2708 | 2722 | http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html |
|
2709 | 2723 | for more details. |
|
2710 | 2724 | |
|
2711 | 2725 | * IPython/Magic.py (magic_run): Added new -e flag to ignore |
|
2712 | 2726 | SystemExit exceptions in the script being run. Thanks to a report |
|
2713 | 2727 | by danny shevitz <danny_shevitz-AT-yahoo.com>, about this |
|
2714 | 2728 | producing very annoying behavior when running unit tests. |
|
2715 | 2729 | |
|
2716 | 2730 | 2005-05-12 Fernando Perez <fperez@colorado.edu> |
|
2717 | 2731 | |
|
2718 | 2732 | * IPython/iplib.py (handle_auto): fixed auto-quoting and parens, |
|
2719 | 2733 | which I'd broken (again) due to a changed regexp. In the process, |
|
2720 | 2734 | added ';' as an escape to auto-quote the whole line without |
|
2721 | 2735 | splitting its arguments. Thanks to a report by Jerry McRae |
|
2722 | 2736 | <qrs0xyc02-AT-sneakemail.com>. |
|
2723 | 2737 | |
|
2724 | 2738 | * IPython/ultraTB.py (VerboseTB.text): protect against rare but |
|
2725 | 2739 | possible crashes caused by a TokenError. Reported by Ed Schofield |
|
2726 | 2740 | <schofield-AT-ftw.at>. |
|
2727 | 2741 | |
|
2728 | 2742 | 2005-05-06 Fernando Perez <fperez@colorado.edu> |
|
2729 | 2743 | |
|
2730 | 2744 | * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6. |
|
2731 | 2745 | |
|
2732 | 2746 | 2005-04-29 Fernando Perez <fperez@colorado.edu> |
|
2733 | 2747 | |
|
2734 | 2748 | * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière |
|
2735 | 2749 | <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin |
|
2736 | 2750 | Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option |
|
2737 | 2751 | which provides support for Qt interactive usage (similar to the |
|
2738 | 2752 | existing one for WX and GTK). This had been often requested. |
|
2739 | 2753 | |
|
2740 | 2754 | 2005-04-14 *** Released version 0.6.13 |
|
2741 | 2755 | |
|
2742 | 2756 | 2005-04-08 Fernando Perez <fperez@colorado.edu> |
|
2743 | 2757 | |
|
2744 | 2758 | * IPython/Magic.py (Magic._ofind): remove docstring evaluation |
|
2745 | 2759 | from _ofind, which gets called on almost every input line. Now, |
|
2746 | 2760 | we only try to get docstrings if they are actually going to be |
|
2747 | 2761 | used (the overhead of fetching unnecessary docstrings can be |
|
2748 | 2762 | noticeable for certain objects, such as Pyro proxies). |
|
2749 | 2763 | |
|
2750 | 2764 | * IPython/iplib.py (MagicCompleter.python_matches): Change the API |
|
2751 | 2765 | for completers. For some reason I had been passing them the state |
|
2752 | 2766 | variable, which completers never actually need, and was in |
|
2753 | 2767 | conflict with the rlcompleter API. Custom completers ONLY need to |
|
2754 | 2768 | take the text parameter. |
|
2755 | 2769 | |
|
2756 | 2770 | * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics |
|
2757 | 2771 | work correctly in pysh. I've also moved all the logic which used |
|
2758 | 2772 | to be in pysh.py here, which will prevent problems with future |
|
2759 | 2773 | upgrades. However, this time I must warn users to update their |
|
2760 | 2774 | pysh profile to include the line |
|
2761 | 2775 | |
|
2762 | 2776 | import_all IPython.Extensions.InterpreterExec |
|
2763 | 2777 | |
|
2764 | 2778 | because otherwise things won't work for them. They MUST also |
|
2765 | 2779 | delete pysh.py and the line |
|
2766 | 2780 | |
|
2767 | 2781 | execfile pysh.py |
|
2768 | 2782 | |
|
2769 | 2783 | from their ipythonrc-pysh. |
|
2770 | 2784 | |
|
2771 | 2785 | * IPython/FlexCompleter.py (Completer.attr_matches): Make more |
|
2772 | 2786 | robust in the face of objects whose dir() returns non-strings |
|
2773 | 2787 | (which it shouldn't, but some broken libs like ITK do). Thanks to |
|
2774 | 2788 | a patch by John Hunter (implemented differently, though). Also |
|
2775 | 2789 | minor improvements by using .extend instead of + on lists. |
|
2776 | 2790 | |
|
2777 | 2791 | * pysh.py: |
|
2778 | 2792 | |
|
2779 | 2793 | 2005-04-06 Fernando Perez <fperez@colorado.edu> |
|
2780 | 2794 | |
|
2781 | 2795 | * IPython/ipmaker.py (make_IPython): Make multi_line_specials on |
|
2782 | 2796 | by default, so that all users benefit from it. Those who don't |
|
2783 | 2797 | want it can still turn it off. |
|
2784 | 2798 | |
|
2785 | 2799 | * IPython/UserConfig/ipythonrc: Add multi_line_specials to the |
|
2786 | 2800 | config file, I'd forgotten about this, so users were getting it |
|
2787 | 2801 | off by default. |
|
2788 | 2802 | |
|
2789 | 2803 | * IPython/iplib.py (ipmagic): big overhaul of the magic system for |
|
2790 | 2804 | consistency. Now magics can be called in multiline statements, |
|
2791 | 2805 | and python variables can be expanded in magic calls via $var. |
|
2792 | 2806 | This makes the magic system behave just like aliases or !system |
|
2793 | 2807 | calls. |
|
2794 | 2808 | |
|
2795 | 2809 | 2005-03-28 Fernando Perez <fperez@colorado.edu> |
|
2796 | 2810 | |
|
2797 | 2811 | * IPython/iplib.py (handle_auto): cleanup to use %s instead of |
|
2798 | 2812 | expensive string additions for building command. Add support for |
|
2799 | 2813 | trailing ';' when autocall is used. |
|
2800 | 2814 | |
|
2801 | 2815 | 2005-03-26 Fernando Perez <fperez@colorado.edu> |
|
2802 | 2816 | |
|
2803 | 2817 | * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31. |
|
2804 | 2818 | Bugfix by A. Schmolck, the ipython.el maintainer. Also make |
|
2805 | 2819 | ipython.el robust against prompts with any number of spaces |
|
2806 | 2820 | (including 0) after the ':' character. |
|
2807 | 2821 | |
|
2808 | 2822 | * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in |
|
2809 | 2823 | continuation prompt, which misled users to think the line was |
|
2810 | 2824 | already indented. Closes debian Bug#300847, reported to me by |
|
2811 | 2825 | Norbert Tretkowski <tretkowski-AT-inittab.de>. |
|
2812 | 2826 | |
|
2813 | 2827 | 2005-03-23 Fernando Perez <fperez@colorado.edu> |
|
2814 | 2828 | |
|
2815 | 2829 | * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are |
|
2816 | 2830 | properly aligned if they have embedded newlines. |
|
2817 | 2831 | |
|
2818 | 2832 | * IPython/iplib.py (runlines): Add a public method to expose |
|
2819 | 2833 | IPython's code execution machinery, so that users can run strings |
|
2820 | 2834 | as if they had been typed at the prompt interactively. |
|
2821 | 2835 | (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__ |
|
2822 | 2836 | methods which can call the system shell, but with python variable |
|
2823 | 2837 | expansion. The three such methods are: __IPYTHON__.system, |
|
2824 | 2838 | .getoutput and .getoutputerror. These need to be documented in a |
|
2825 | 2839 | 'public API' section (to be written) of the manual. |
|
2826 | 2840 | |
|
2827 | 2841 | 2005-03-20 Fernando Perez <fperez@colorado.edu> |
|
2828 | 2842 | |
|
2829 | 2843 | * IPython/iplib.py (InteractiveShell.set_custom_exc): new system |
|
2830 | 2844 | for custom exception handling. This is quite powerful, and it |
|
2831 | 2845 | allows for user-installable exception handlers which can trap |
|
2832 | 2846 | custom exceptions at runtime and treat them separately from |
|
2833 | 2847 | IPython's default mechanisms. At the request of FrΓ©dΓ©ric |
|
2834 | 2848 | Mantegazza <mantegazza-AT-ill.fr>. |
|
2835 | 2849 | (InteractiveShell.set_custom_completer): public API function to |
|
2836 | 2850 | add new completers at runtime. |
|
2837 | 2851 | |
|
2838 | 2852 | 2005-03-19 Fernando Perez <fperez@colorado.edu> |
|
2839 | 2853 | |
|
2840 | 2854 | * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to |
|
2841 | 2855 | allow objects which provide their docstrings via non-standard |
|
2842 | 2856 | mechanisms (like Pyro proxies) to still be inspected by ipython's |
|
2843 | 2857 | ? system. |
|
2844 | 2858 | |
|
2845 | 2859 | * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e |
|
2846 | 2860 | automatic capture system. I tried quite hard to make it work |
|
2847 | 2861 | reliably, and simply failed. I tried many combinations with the |
|
2848 | 2862 | subprocess module, but eventually nothing worked in all needed |
|
2849 | 2863 | cases (not blocking stdin for the child, duplicating stdout |
|
2850 | 2864 | without blocking, etc). The new %sc/%sx still do capture to these |
|
2851 | 2865 | magical list/string objects which make shell use much more |
|
2852 | 2866 | conveninent, so not all is lost. |
|
2853 | 2867 | |
|
2854 | 2868 | XXX - FIX MANUAL for the change above! |
|
2855 | 2869 | |
|
2856 | 2870 | (runsource): I copied code.py's runsource() into ipython to modify |
|
2857 | 2871 | it a bit. Now the code object and source to be executed are |
|
2858 | 2872 | stored in ipython. This makes this info accessible to third-party |
|
2859 | 2873 | tools, like custom exception handlers. After a request by FrΓ©dΓ©ric |
|
2860 | 2874 | Mantegazza <mantegazza-AT-ill.fr>. |
|
2861 | 2875 | |
|
2862 | 2876 | * IPython/UserConfig/ipythonrc: Add up/down arrow keys to |
|
2863 | 2877 | history-search via readline (like C-p/C-n). I'd wanted this for a |
|
2864 | 2878 | long time, but only recently found out how to do it. For users |
|
2865 | 2879 | who already have their ipythonrc files made and want this, just |
|
2866 | 2880 | add: |
|
2867 | 2881 | |
|
2868 | 2882 | readline_parse_and_bind "\e[A": history-search-backward |
|
2869 | 2883 | readline_parse_and_bind "\e[B": history-search-forward |
|
2870 | 2884 | |
|
2871 | 2885 | 2005-03-18 Fernando Perez <fperez@colorado.edu> |
|
2872 | 2886 | |
|
2873 | 2887 | * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy |
|
2874 | 2888 | LSString and SList classes which allow transparent conversions |
|
2875 | 2889 | between list mode and whitespace-separated string. |
|
2876 | 2890 | (magic_r): Fix recursion problem in %r. |
|
2877 | 2891 | |
|
2878 | 2892 | * IPython/genutils.py (LSString): New class to be used for |
|
2879 | 2893 | automatic storage of the results of all alias/system calls in _o |
|
2880 | 2894 | and _e (stdout/err). These provide a .l/.list attribute which |
|
2881 | 2895 | does automatic splitting on newlines. This means that for most |
|
2882 | 2896 | uses, you'll never need to do capturing of output with %sc/%sx |
|
2883 | 2897 | anymore, since ipython keeps this always done for you. Note that |
|
2884 | 2898 | only the LAST results are stored, the _o/e variables are |
|
2885 | 2899 | overwritten on each call. If you need to save their contents |
|
2886 | 2900 | further, simply bind them to any other name. |
|
2887 | 2901 | |
|
2888 | 2902 | 2005-03-17 Fernando Perez <fperez@colorado.edu> |
|
2889 | 2903 | |
|
2890 | 2904 | * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for |
|
2891 | 2905 | prompt namespace handling. |
|
2892 | 2906 | |
|
2893 | 2907 | 2005-03-16 Fernando Perez <fperez@colorado.edu> |
|
2894 | 2908 | |
|
2895 | 2909 | * IPython/Prompts.py (CachedOutput.__init__): Fix default and |
|
2896 | 2910 | classic prompts to be '>>> ' (final space was missing, and it |
|
2897 | 2911 | trips the emacs python mode). |
|
2898 | 2912 | (BasePrompt.__str__): Added safe support for dynamic prompt |
|
2899 | 2913 | strings. Now you can set your prompt string to be '$x', and the |
|
2900 | 2914 | value of x will be printed from your interactive namespace. The |
|
2901 | 2915 | interpolation syntax includes the full Itpl support, so |
|
2902 | 2916 | ${foo()+x+bar()} is a valid prompt string now, and the function |
|
2903 | 2917 | calls will be made at runtime. |
|
2904 | 2918 | |
|
2905 | 2919 | 2005-03-15 Fernando Perez <fperez@colorado.edu> |
|
2906 | 2920 | |
|
2907 | 2921 | * IPython/Magic.py (magic_history): renamed %hist to %history, to |
|
2908 | 2922 | avoid name clashes in pylab. %hist still works, it just forwards |
|
2909 | 2923 | the call to %history. |
|
2910 | 2924 | |
|
2911 | 2925 | 2005-03-02 *** Released version 0.6.12 |
|
2912 | 2926 | |
|
2913 | 2927 | 2005-03-02 Fernando Perez <fperez@colorado.edu> |
|
2914 | 2928 | |
|
2915 | 2929 | * IPython/iplib.py (handle_magic): log magic calls properly as |
|
2916 | 2930 | ipmagic() function calls. |
|
2917 | 2931 | |
|
2918 | 2932 | * IPython/Magic.py (magic_time): Improved %time to support |
|
2919 | 2933 | statements and provide wall-clock as well as CPU time. |
|
2920 | 2934 | |
|
2921 | 2935 | 2005-02-27 Fernando Perez <fperez@colorado.edu> |
|
2922 | 2936 | |
|
2923 | 2937 | * IPython/hooks.py: New hooks module, to expose user-modifiable |
|
2924 | 2938 | IPython functionality in a clean manner. For now only the editor |
|
2925 | 2939 | hook is actually written, and other thigns which I intend to turn |
|
2926 | 2940 | into proper hooks aren't yet there. The display and prefilter |
|
2927 | 2941 | stuff, for example, should be hooks. But at least now the |
|
2928 | 2942 | framework is in place, and the rest can be moved here with more |
|
2929 | 2943 | time later. IPython had had a .hooks variable for a long time for |
|
2930 | 2944 | this purpose, but I'd never actually used it for anything. |
|
2931 | 2945 | |
|
2932 | 2946 | 2005-02-26 Fernando Perez <fperez@colorado.edu> |
|
2933 | 2947 | |
|
2934 | 2948 | * IPython/ipmaker.py (make_IPython): make the default ipython |
|
2935 | 2949 | directory be called _ipython under win32, to follow more the |
|
2936 | 2950 | naming peculiarities of that platform (where buggy software like |
|
2937 | 2951 | Visual Sourcesafe breaks with .named directories). Reported by |
|
2938 | 2952 | Ville Vainio. |
|
2939 | 2953 | |
|
2940 | 2954 | 2005-02-23 Fernando Perez <fperez@colorado.edu> |
|
2941 | 2955 | |
|
2942 | 2956 | * IPython/iplib.py (InteractiveShell.__init__): removed a few |
|
2943 | 2957 | auto_aliases for win32 which were causing problems. Users can |
|
2944 | 2958 | define the ones they personally like. |
|
2945 | 2959 | |
|
2946 | 2960 | 2005-02-21 Fernando Perez <fperez@colorado.edu> |
|
2947 | 2961 | |
|
2948 | 2962 | * IPython/Magic.py (magic_time): new magic to time execution of |
|
2949 | 2963 | expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>. |
|
2950 | 2964 | |
|
2951 | 2965 | 2005-02-19 Fernando Perez <fperez@colorado.edu> |
|
2952 | 2966 | |
|
2953 | 2967 | * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings |
|
2954 | 2968 | into keys (for prompts, for example). |
|
2955 | 2969 | |
|
2956 | 2970 | * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty |
|
2957 | 2971 | prompts in case users want them. This introduces a small behavior |
|
2958 | 2972 | change: ipython does not automatically add a space to all prompts |
|
2959 | 2973 | anymore. To get the old prompts with a space, users should add it |
|
2960 | 2974 | manually to their ipythonrc file, so for example prompt_in1 should |
|
2961 | 2975 | now read 'In [\#]: ' instead of 'In [\#]:'. |
|
2962 | 2976 | (BasePrompt.__init__): New option prompts_pad_left (only in rc |
|
2963 | 2977 | file) to control left-padding of secondary prompts. |
|
2964 | 2978 | |
|
2965 | 2979 | * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if |
|
2966 | 2980 | the profiler can't be imported. Fix for Debian, which removed |
|
2967 | 2981 | profile.py because of License issues. I applied a slightly |
|
2968 | 2982 | modified version of the original Debian patch at |
|
2969 | 2983 | http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500. |
|
2970 | 2984 | |
|
2971 | 2985 | 2005-02-17 Fernando Perez <fperez@colorado.edu> |
|
2972 | 2986 | |
|
2973 | 2987 | * IPython/genutils.py (native_line_ends): Fix bug which would |
|
2974 | 2988 | cause improper line-ends under win32 b/c I was not opening files |
|
2975 | 2989 | in binary mode. Bug report and fix thanks to Ville. |
|
2976 | 2990 | |
|
2977 | 2991 | * IPython/iplib.py (handle_auto): Fix bug which I introduced when |
|
2978 | 2992 | trying to catch spurious foo[1] autocalls. My fix actually broke |
|
2979 | 2993 | ',/' autoquote/call with explicit escape (bad regexp). |
|
2980 | 2994 | |
|
2981 | 2995 | 2005-02-15 *** Released version 0.6.11 |
|
2982 | 2996 | |
|
2983 | 2997 | 2005-02-14 Fernando Perez <fperez@colorado.edu> |
|
2984 | 2998 | |
|
2985 | 2999 | * IPython/background_jobs.py: New background job management |
|
2986 | 3000 | subsystem. This is implemented via a new set of classes, and |
|
2987 | 3001 | IPython now provides a builtin 'jobs' object for background job |
|
2988 | 3002 | execution. A convenience %bg magic serves as a lightweight |
|
2989 | 3003 | frontend for starting the more common type of calls. This was |
|
2990 | 3004 | inspired by discussions with B. Granger and the BackgroundCommand |
|
2991 | 3005 | class described in the book Python Scripting for Computational |
|
2992 | 3006 | Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting |
|
2993 | 3007 | (although ultimately no code from this text was used, as IPython's |
|
2994 | 3008 | system is a separate implementation). |
|
2995 | 3009 | |
|
2996 | 3010 | * IPython/iplib.py (MagicCompleter.python_matches): add new option |
|
2997 | 3011 | to control the completion of single/double underscore names |
|
2998 | 3012 | separately. As documented in the example ipytonrc file, the |
|
2999 | 3013 | readline_omit__names variable can now be set to 2, to omit even |
|
3000 | 3014 | single underscore names. Thanks to a patch by Brian Wong |
|
3001 | 3015 | <BrianWong-AT-AirgoNetworks.Com>. |
|
3002 | 3016 | (InteractiveShell.__init__): Fix bug which would cause foo[1] to |
|
3003 | 3017 | be autocalled as foo([1]) if foo were callable. A problem for |
|
3004 | 3018 | things which are both callable and implement __getitem__. |
|
3005 | 3019 | (init_readline): Fix autoindentation for win32. Thanks to a patch |
|
3006 | 3020 | by Vivian De Smedt <vivian-AT-vdesmedt.com>. |
|
3007 | 3021 | |
|
3008 | 3022 | 2005-02-12 Fernando Perez <fperez@colorado.edu> |
|
3009 | 3023 | |
|
3010 | 3024 | * IPython/ipmaker.py (make_IPython): Disabled the stout traps |
|
3011 | 3025 | which I had written long ago to sort out user error messages which |
|
3012 | 3026 | may occur during startup. This seemed like a good idea initially, |
|
3013 | 3027 | but it has proven a disaster in retrospect. I don't want to |
|
3014 | 3028 | change much code for now, so my fix is to set the internal 'debug' |
|
3015 | 3029 | flag to true everywhere, whose only job was precisely to control |
|
3016 | 3030 | this subsystem. This closes issue 28 (as well as avoiding all |
|
3017 | 3031 | sorts of strange hangups which occur from time to time). |
|
3018 | 3032 | |
|
3019 | 3033 | 2005-02-07 Fernando Perez <fperez@colorado.edu> |
|
3020 | 3034 | |
|
3021 | 3035 | * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the |
|
3022 | 3036 | previous call produced a syntax error. |
|
3023 | 3037 | |
|
3024 | 3038 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
3025 | 3039 | classes without constructor. |
|
3026 | 3040 | |
|
3027 | 3041 | 2005-02-06 Fernando Perez <fperez@colorado.edu> |
|
3028 | 3042 | |
|
3029 | 3043 | * IPython/iplib.py (MagicCompleter.complete): Extend the list of |
|
3030 | 3044 | completions with the results of each matcher, so we return results |
|
3031 | 3045 | to the user from all namespaces. This breaks with ipython |
|
3032 | 3046 | tradition, but I think it's a nicer behavior. Now you get all |
|
3033 | 3047 | possible completions listed, from all possible namespaces (python, |
|
3034 | 3048 | filesystem, magics...) After a request by John Hunter |
|
3035 | 3049 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
3036 | 3050 | |
|
3037 | 3051 | 2005-02-05 Fernando Perez <fperez@colorado.edu> |
|
3038 | 3052 | |
|
3039 | 3053 | * IPython/Magic.py (magic_prun): Fix bug where prun would fail if |
|
3040 | 3054 | the call had quote characters in it (the quotes were stripped). |
|
3041 | 3055 | |
|
3042 | 3056 | 2005-01-31 Fernando Perez <fperez@colorado.edu> |
|
3043 | 3057 | |
|
3044 | 3058 | * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on |
|
3045 | 3059 | Itpl.itpl() to make the code more robust against psyco |
|
3046 | 3060 | optimizations. |
|
3047 | 3061 | |
|
3048 | 3062 | * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead |
|
3049 | 3063 | of causing an exception. Quicker, cleaner. |
|
3050 | 3064 | |
|
3051 | 3065 | 2005-01-28 Fernando Perez <fperez@colorado.edu> |
|
3052 | 3066 | |
|
3053 | 3067 | * scripts/ipython_win_post_install.py (install): hardcode |
|
3054 | 3068 | sys.prefix+'python.exe' as the executable path. It turns out that |
|
3055 | 3069 | during the post-installation run, sys.executable resolves to the |
|
3056 | 3070 | name of the binary installer! I should report this as a distutils |
|
3057 | 3071 | bug, I think. I updated the .10 release with this tiny fix, to |
|
3058 | 3072 | avoid annoying the lists further. |
|
3059 | 3073 | |
|
3060 | 3074 | 2005-01-27 *** Released version 0.6.10 |
|
3061 | 3075 | |
|
3062 | 3076 | 2005-01-27 Fernando Perez <fperez@colorado.edu> |
|
3063 | 3077 | |
|
3064 | 3078 | * IPython/numutils.py (norm): Added 'inf' as optional name for |
|
3065 | 3079 | L-infinity norm, included references to mathworld.com for vector |
|
3066 | 3080 | norm definitions. |
|
3067 | 3081 | (amin/amax): added amin/amax for array min/max. Similar to what |
|
3068 | 3082 | pylab ships with after the recent reorganization of names. |
|
3069 | 3083 | (spike/spike_odd): removed deprecated spike/spike_odd functions. |
|
3070 | 3084 | |
|
3071 | 3085 | * ipython.el: committed Alex's recent fixes and improvements. |
|
3072 | 3086 | Tested with python-mode from CVS, and it looks excellent. Since |
|
3073 | 3087 | python-mode hasn't released anything in a while, I'm temporarily |
|
3074 | 3088 | putting a copy of today's CVS (v 4.70) of python-mode in: |
|
3075 | 3089 | http://ipython.scipy.org/tmp/python-mode.el |
|
3076 | 3090 | |
|
3077 | 3091 | * scripts/ipython_win_post_install.py (install): Win32 fix to use |
|
3078 | 3092 | sys.executable for the executable name, instead of assuming it's |
|
3079 | 3093 | called 'python.exe' (the post-installer would have produced broken |
|
3080 | 3094 | setups on systems with a differently named python binary). |
|
3081 | 3095 | |
|
3082 | 3096 | * IPython/PyColorize.py (Parser.__call__): change explicit '\n' |
|
3083 | 3097 | references to os.linesep, to make the code more |
|
3084 | 3098 | platform-independent. This is also part of the win32 coloring |
|
3085 | 3099 | fixes. |
|
3086 | 3100 | |
|
3087 | 3101 | * IPython/genutils.py (page_dumb): Remove attempts to chop long |
|
3088 | 3102 | lines, which actually cause coloring bugs because the length of |
|
3089 | 3103 | the line is very difficult to correctly compute with embedded |
|
3090 | 3104 | escapes. This was the source of all the coloring problems under |
|
3091 | 3105 | Win32. I think that _finally_, Win32 users have a properly |
|
3092 | 3106 | working ipython in all respects. This would never have happened |
|
3093 | 3107 | if not for Gary Bishop and Viktor Ransmayr's great help and work. |
|
3094 | 3108 | |
|
3095 | 3109 | 2005-01-26 *** Released version 0.6.9 |
|
3096 | 3110 | |
|
3097 | 3111 | 2005-01-25 Fernando Perez <fperez@colorado.edu> |
|
3098 | 3112 | |
|
3099 | 3113 | * setup.py: finally, we have a true Windows installer, thanks to |
|
3100 | 3114 | the excellent work of Viktor Ransmayr |
|
3101 | 3115 | <viktor.ransmayr-AT-t-online.de>. The docs have been updated for |
|
3102 | 3116 | Windows users. The setup routine is quite a bit cleaner thanks to |
|
3103 | 3117 | this, and the post-install script uses the proper functions to |
|
3104 | 3118 | allow a clean de-installation using the standard Windows Control |
|
3105 | 3119 | Panel. |
|
3106 | 3120 | |
|
3107 | 3121 | * IPython/genutils.py (get_home_dir): changed to use the $HOME |
|
3108 | 3122 | environment variable under all OSes (including win32) if |
|
3109 | 3123 | available. This will give consistency to win32 users who have set |
|
3110 | 3124 | this variable for any reason. If os.environ['HOME'] fails, the |
|
3111 | 3125 | previous policy of using HOMEDRIVE\HOMEPATH kicks in. |
|
3112 | 3126 | |
|
3113 | 3127 | 2005-01-24 Fernando Perez <fperez@colorado.edu> |
|
3114 | 3128 | |
|
3115 | 3129 | * IPython/numutils.py (empty_like): add empty_like(), similar to |
|
3116 | 3130 | zeros_like() but taking advantage of the new empty() Numeric routine. |
|
3117 | 3131 | |
|
3118 | 3132 | 2005-01-23 *** Released version 0.6.8 |
|
3119 | 3133 | |
|
3120 | 3134 | 2005-01-22 Fernando Perez <fperez@colorado.edu> |
|
3121 | 3135 | |
|
3122 | 3136 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the |
|
3123 | 3137 | automatic show() calls. After discussing things with JDH, it |
|
3124 | 3138 | turns out there are too many corner cases where this can go wrong. |
|
3125 | 3139 | It's best not to try to be 'too smart', and simply have ipython |
|
3126 | 3140 | reproduce as much as possible the default behavior of a normal |
|
3127 | 3141 | python shell. |
|
3128 | 3142 | |
|
3129 | 3143 | * IPython/iplib.py (InteractiveShell.__init__): Modified the |
|
3130 | 3144 | line-splitting regexp and _prefilter() to avoid calling getattr() |
|
3131 | 3145 | on assignments. This closes |
|
3132 | 3146 | http://www.scipy.net/roundup/ipython/issue24. Note that Python's |
|
3133 | 3147 | readline uses getattr(), so a simple <TAB> keypress is still |
|
3134 | 3148 | enough to trigger getattr() calls on an object. |
|
3135 | 3149 | |
|
3136 | 3150 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
3137 | 3151 | |
|
3138 | 3152 | * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run |
|
3139 | 3153 | docstring under pylab so it doesn't mask the original. |
|
3140 | 3154 | |
|
3141 | 3155 | 2005-01-21 *** Released version 0.6.7 |
|
3142 | 3156 | |
|
3143 | 3157 | 2005-01-21 Fernando Perez <fperez@colorado.edu> |
|
3144 | 3158 | |
|
3145 | 3159 | * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with |
|
3146 | 3160 | signal handling for win32 users in multithreaded mode. |
|
3147 | 3161 | |
|
3148 | 3162 | 2005-01-17 Fernando Perez <fperez@colorado.edu> |
|
3149 | 3163 | |
|
3150 | 3164 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting |
|
3151 | 3165 | instances with no __init__. After a crash report by Norbert Nemec |
|
3152 | 3166 | <Norbert-AT-nemec-online.de>. |
|
3153 | 3167 | |
|
3154 | 3168 | 2005-01-14 Fernando Perez <fperez@colorado.edu> |
|
3155 | 3169 | |
|
3156 | 3170 | * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of |
|
3157 | 3171 | names for verbose exceptions, when multiple dotted names and the |
|
3158 | 3172 | 'parent' object were present on the same line. |
|
3159 | 3173 | |
|
3160 | 3174 | 2005-01-11 Fernando Perez <fperez@colorado.edu> |
|
3161 | 3175 | |
|
3162 | 3176 | * IPython/genutils.py (flag_calls): new utility to trap and flag |
|
3163 | 3177 | calls in functions. I need it to clean up matplotlib support. |
|
3164 | 3178 | Also removed some deprecated code in genutils. |
|
3165 | 3179 | |
|
3166 | 3180 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so |
|
3167 | 3181 | that matplotlib scripts called with %run, which don't call show() |
|
3168 | 3182 | themselves, still have their plotting windows open. |
|
3169 | 3183 | |
|
3170 | 3184 | 2005-01-05 Fernando Perez <fperez@colorado.edu> |
|
3171 | 3185 | |
|
3172 | 3186 | * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw |
|
3173 | 3187 | <astraw-AT-caltech.edu>, to fix gtk deprecation warnings. |
|
3174 | 3188 | |
|
3175 | 3189 | 2004-12-19 Fernando Perez <fperez@colorado.edu> |
|
3176 | 3190 | |
|
3177 | 3191 | * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of |
|
3178 | 3192 | parent_runcode, which was an eyesore. The same result can be |
|
3179 | 3193 | obtained with Python's regular superclass mechanisms. |
|
3180 | 3194 | |
|
3181 | 3195 | 2004-12-17 Fernando Perez <fperez@colorado.edu> |
|
3182 | 3196 | |
|
3183 | 3197 | * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem |
|
3184 | 3198 | reported by Prabhu. |
|
3185 | 3199 | (Magic.magic_sx): direct all errors to Term.cerr (defaults to |
|
3186 | 3200 | sys.stderr) instead of explicitly calling sys.stderr. This helps |
|
3187 | 3201 | maintain our I/O abstractions clean, for future GUI embeddings. |
|
3188 | 3202 | |
|
3189 | 3203 | * IPython/genutils.py (info): added new utility for sys.stderr |
|
3190 | 3204 | unified info message handling (thin wrapper around warn()). |
|
3191 | 3205 | |
|
3192 | 3206 | * IPython/ultraTB.py (VerboseTB.text): Fix misreported global |
|
3193 | 3207 | composite (dotted) names on verbose exceptions. |
|
3194 | 3208 | (VerboseTB.nullrepr): harden against another kind of errors which |
|
3195 | 3209 | Python's inspect module can trigger, and which were crashing |
|
3196 | 3210 | IPython. Thanks to a report by Marco Lombardi |
|
3197 | 3211 | <mlombard-AT-ma010192.hq.eso.org>. |
|
3198 | 3212 | |
|
3199 | 3213 | 2004-12-13 *** Released version 0.6.6 |
|
3200 | 3214 | |
|
3201 | 3215 | 2004-12-12 Fernando Perez <fperez@colorado.edu> |
|
3202 | 3216 | |
|
3203 | 3217 | * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors |
|
3204 | 3218 | generated by pygtk upon initialization if it was built without |
|
3205 | 3219 | threads (for matplotlib users). After a crash reported by |
|
3206 | 3220 | Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>. |
|
3207 | 3221 | |
|
3208 | 3222 | * IPython/ipmaker.py (make_IPython): fix small bug in the |
|
3209 | 3223 | import_some parameter for multiple imports. |
|
3210 | 3224 | |
|
3211 | 3225 | * IPython/iplib.py (ipmagic): simplified the interface of |
|
3212 | 3226 | ipmagic() to take a single string argument, just as it would be |
|
3213 | 3227 | typed at the IPython cmd line. |
|
3214 | 3228 | (ipalias): Added new ipalias() with an interface identical to |
|
3215 | 3229 | ipmagic(). This completes exposing a pure python interface to the |
|
3216 | 3230 | alias and magic system, which can be used in loops or more complex |
|
3217 | 3231 | code where IPython's automatic line mangling is not active. |
|
3218 | 3232 | |
|
3219 | 3233 | * IPython/genutils.py (timing): changed interface of timing to |
|
3220 | 3234 | simply run code once, which is the most common case. timings() |
|
3221 | 3235 | remains unchanged, for the cases where you want multiple runs. |
|
3222 | 3236 | |
|
3223 | 3237 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a |
|
3224 | 3238 | bug where Python2.2 crashes with exec'ing code which does not end |
|
3225 | 3239 | in a single newline. Python 2.3 is OK, so I hadn't noticed this |
|
3226 | 3240 | before. |
|
3227 | 3241 | |
|
3228 | 3242 | 2004-12-10 Fernando Perez <fperez@colorado.edu> |
|
3229 | 3243 | |
|
3230 | 3244 | * IPython/Magic.py (Magic.magic_prun): changed name of option from |
|
3231 | 3245 | -t to -T, to accomodate the new -t flag in %run (the %run and |
|
3232 | 3246 | %prun options are kind of intermixed, and it's not easy to change |
|
3233 | 3247 | this with the limitations of python's getopt). |
|
3234 | 3248 | |
|
3235 | 3249 | * IPython/Magic.py (Magic.magic_run): Added new -t option to time |
|
3236 | 3250 | the execution of scripts. It's not as fine-tuned as timeit.py, |
|
3237 | 3251 | but it works from inside ipython (and under 2.2, which lacks |
|
3238 | 3252 | timeit.py). Optionally a number of runs > 1 can be given for |
|
3239 | 3253 | timing very short-running code. |
|
3240 | 3254 | |
|
3241 | 3255 | * IPython/genutils.py (uniq_stable): new routine which returns a |
|
3242 | 3256 | list of unique elements in any iterable, but in stable order of |
|
3243 | 3257 | appearance. I needed this for the ultraTB fixes, and it's a handy |
|
3244 | 3258 | utility. |
|
3245 | 3259 | |
|
3246 | 3260 | * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of |
|
3247 | 3261 | dotted names in Verbose exceptions. This had been broken since |
|
3248 | 3262 | the very start, now x.y will properly be printed in a Verbose |
|
3249 | 3263 | traceback, instead of x being shown and y appearing always as an |
|
3250 | 3264 | 'undefined global'. Getting this to work was a bit tricky, |
|
3251 | 3265 | because by default python tokenizers are stateless. Saved by |
|
3252 | 3266 | python's ability to easily add a bit of state to an arbitrary |
|
3253 | 3267 | function (without needing to build a full-blown callable object). |
|
3254 | 3268 | |
|
3255 | 3269 | Also big cleanup of this code, which had horrendous runtime |
|
3256 | 3270 | lookups of zillions of attributes for colorization. Moved all |
|
3257 | 3271 | this code into a few templates, which make it cleaner and quicker. |
|
3258 | 3272 | |
|
3259 | 3273 | Printout quality was also improved for Verbose exceptions: one |
|
3260 | 3274 | variable per line, and memory addresses are printed (this can be |
|
3261 | 3275 | quite handy in nasty debugging situations, which is what Verbose |
|
3262 | 3276 | is for). |
|
3263 | 3277 | |
|
3264 | 3278 | * IPython/ipmaker.py (make_IPython): Do NOT execute files named in |
|
3265 | 3279 | the command line as scripts to be loaded by embedded instances. |
|
3266 | 3280 | Doing so has the potential for an infinite recursion if there are |
|
3267 | 3281 | exceptions thrown in the process. This fixes a strange crash |
|
3268 | 3282 | reported by Philippe MULLER <muller-AT-irit.fr>. |
|
3269 | 3283 | |
|
3270 | 3284 | 2004-12-09 Fernando Perez <fperez@colorado.edu> |
|
3271 | 3285 | |
|
3272 | 3286 | * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support |
|
3273 | 3287 | to reflect new names in matplotlib, which now expose the |
|
3274 | 3288 | matlab-compatible interface via a pylab module instead of the |
|
3275 | 3289 | 'matlab' name. The new code is backwards compatible, so users of |
|
3276 | 3290 | all matplotlib versions are OK. Patch by J. Hunter. |
|
3277 | 3291 | |
|
3278 | 3292 | * IPython/OInspect.py (Inspector.pinfo): Add to object? printing |
|
3279 | 3293 | of __init__ docstrings for instances (class docstrings are already |
|
3280 | 3294 | automatically printed). Instances with customized docstrings |
|
3281 | 3295 | (indep. of the class) are also recognized and all 3 separate |
|
3282 | 3296 | docstrings are printed (instance, class, constructor). After some |
|
3283 | 3297 | comments/suggestions by J. Hunter. |
|
3284 | 3298 | |
|
3285 | 3299 | 2004-12-05 Fernando Perez <fperez@colorado.edu> |
|
3286 | 3300 | |
|
3287 | 3301 | * IPython/iplib.py (MagicCompleter.complete): Remove annoying |
|
3288 | 3302 | warnings when tab-completion fails and triggers an exception. |
|
3289 | 3303 | |
|
3290 | 3304 | 2004-12-03 Fernando Perez <fperez@colorado.edu> |
|
3291 | 3305 | |
|
3292 | 3306 | * IPython/Magic.py (magic_prun): Fix bug where an exception would |
|
3293 | 3307 | be triggered when using 'run -p'. An incorrect option flag was |
|
3294 | 3308 | being set ('d' instead of 'D'). |
|
3295 | 3309 | (manpage): fix missing escaped \- sign. |
|
3296 | 3310 | |
|
3297 | 3311 | 2004-11-30 *** Released version 0.6.5 |
|
3298 | 3312 | |
|
3299 | 3313 | 2004-11-30 Fernando Perez <fperez@colorado.edu> |
|
3300 | 3314 | |
|
3301 | 3315 | * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint |
|
3302 | 3316 | setting with -d option. |
|
3303 | 3317 | |
|
3304 | 3318 | * setup.py (docfiles): Fix problem where the doc glob I was using |
|
3305 | 3319 | was COMPLETELY BROKEN. It was giving the right files by pure |
|
3306 | 3320 | accident, but failed once I tried to include ipython.el. Note: |
|
3307 | 3321 | glob() does NOT allow you to do exclusion on multiple endings! |
|
3308 | 3322 | |
|
3309 | 3323 | 2004-11-29 Fernando Perez <fperez@colorado.edu> |
|
3310 | 3324 | |
|
3311 | 3325 | * IPython/usage.py (__doc__): cleaned up usage docstring, by using |
|
3312 | 3326 | the manpage as the source. Better formatting & consistency. |
|
3313 | 3327 | |
|
3314 | 3328 | * IPython/Magic.py (magic_run): Added new -d option, to run |
|
3315 | 3329 | scripts under the control of the python pdb debugger. Note that |
|
3316 | 3330 | this required changing the %prun option -d to -D, to avoid a clash |
|
3317 | 3331 | (since %run must pass options to %prun, and getopt is too dumb to |
|
3318 | 3332 | handle options with string values with embedded spaces). Thanks |
|
3319 | 3333 | to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>. |
|
3320 | 3334 | (magic_who_ls): added type matching to %who and %whos, so that one |
|
3321 | 3335 | can filter their output to only include variables of certain |
|
3322 | 3336 | types. Another suggestion by Matthew. |
|
3323 | 3337 | (magic_whos): Added memory summaries in kb and Mb for arrays. |
|
3324 | 3338 | (magic_who): Improve formatting (break lines every 9 vars). |
|
3325 | 3339 | |
|
3326 | 3340 | 2004-11-28 Fernando Perez <fperez@colorado.edu> |
|
3327 | 3341 | |
|
3328 | 3342 | * IPython/Logger.py (Logger.log): Fix bug in syncing the input |
|
3329 | 3343 | cache when empty lines were present. |
|
3330 | 3344 | |
|
3331 | 3345 | 2004-11-24 Fernando Perez <fperez@colorado.edu> |
|
3332 | 3346 | |
|
3333 | 3347 | * IPython/usage.py (__doc__): document the re-activated threading |
|
3334 | 3348 | options for WX and GTK. |
|
3335 | 3349 | |
|
3336 | 3350 | 2004-11-23 Fernando Perez <fperez@colorado.edu> |
|
3337 | 3351 | |
|
3338 | 3352 | * IPython/Shell.py (start): Added Prabhu's big patch to reactivate |
|
3339 | 3353 | the -wthread and -gthread options, along with a new -tk one to try |
|
3340 | 3354 | and coordinate Tk threading with wx/gtk. The tk support is very |
|
3341 | 3355 | platform dependent, since it seems to require Tcl and Tk to be |
|
3342 | 3356 | built with threads (Fedora1/2 appears NOT to have it, but in |
|
3343 | 3357 | Prabhu's Debian boxes it works OK). But even with some Tk |
|
3344 | 3358 | limitations, this is a great improvement. |
|
3345 | 3359 | |
|
3346 | 3360 | * IPython/Prompts.py (prompt_specials_color): Added \t for time |
|
3347 | 3361 | info in user prompts. Patch by Prabhu. |
|
3348 | 3362 | |
|
3349 | 3363 | 2004-11-18 Fernando Perez <fperez@colorado.edu> |
|
3350 | 3364 | |
|
3351 | 3365 | * IPython/genutils.py (ask_yes_no): Add check for a max of 20 |
|
3352 | 3366 | EOFErrors and bail, to avoid infinite loops if a non-terminating |
|
3353 | 3367 | file is fed into ipython. Patch submitted in issue 19 by user, |
|
3354 | 3368 | many thanks. |
|
3355 | 3369 | |
|
3356 | 3370 | * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger |
|
3357 | 3371 | autoquote/parens in continuation prompts, which can cause lots of |
|
3358 | 3372 | problems. Closes roundup issue 20. |
|
3359 | 3373 | |
|
3360 | 3374 | 2004-11-17 Fernando Perez <fperez@colorado.edu> |
|
3361 | 3375 | |
|
3362 | 3376 | * debian/control (Build-Depends-Indep): Fix dpatch dependency, |
|
3363 | 3377 | reported as debian bug #280505. I'm not sure my local changelog |
|
3364 | 3378 | entry has the proper debian format (Jack?). |
|
3365 | 3379 | |
|
3366 | 3380 | 2004-11-08 *** Released version 0.6.4 |
|
3367 | 3381 | |
|
3368 | 3382 | 2004-11-08 Fernando Perez <fperez@colorado.edu> |
|
3369 | 3383 | |
|
3370 | 3384 | * IPython/iplib.py (init_readline): Fix exit message for Windows |
|
3371 | 3385 | when readline is active. Thanks to a report by Eric Jones |
|
3372 | 3386 | <eric-AT-enthought.com>. |
|
3373 | 3387 | |
|
3374 | 3388 | 2004-11-07 Fernando Perez <fperez@colorado.edu> |
|
3375 | 3389 | |
|
3376 | 3390 | * IPython/genutils.py (page): Add a trap for OSError exceptions, |
|
3377 | 3391 | sometimes seen by win2k/cygwin users. |
|
3378 | 3392 | |
|
3379 | 3393 | 2004-11-06 Fernando Perez <fperez@colorado.edu> |
|
3380 | 3394 | |
|
3381 | 3395 | * IPython/iplib.py (interact): Change the handling of %Exit from |
|
3382 | 3396 | trying to propagate a SystemExit to an internal ipython flag. |
|
3383 | 3397 | This is less elegant than using Python's exception mechanism, but |
|
3384 | 3398 | I can't get that to work reliably with threads, so under -pylab |
|
3385 | 3399 | %Exit was hanging IPython. Cross-thread exception handling is |
|
3386 | 3400 | really a bitch. Thaks to a bug report by Stephen Walton |
|
3387 | 3401 | <stephen.walton-AT-csun.edu>. |
|
3388 | 3402 | |
|
3389 | 3403 | 2004-11-04 Fernando Perez <fperez@colorado.edu> |
|
3390 | 3404 | |
|
3391 | 3405 | * IPython/iplib.py (raw_input_original): store a pointer to the |
|
3392 | 3406 | true raw_input to harden against code which can modify it |
|
3393 | 3407 | (wx.py.PyShell does this and would otherwise crash ipython). |
|
3394 | 3408 | Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>. |
|
3395 | 3409 | |
|
3396 | 3410 | * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for |
|
3397 | 3411 | Ctrl-C problem, which does not mess up the input line. |
|
3398 | 3412 | |
|
3399 | 3413 | 2004-11-03 Fernando Perez <fperez@colorado.edu> |
|
3400 | 3414 | |
|
3401 | 3415 | * IPython/Release.py: Changed licensing to BSD, in all files. |
|
3402 | 3416 | (name): lowercase name for tarball/RPM release. |
|
3403 | 3417 | |
|
3404 | 3418 | * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for |
|
3405 | 3419 | use throughout ipython. |
|
3406 | 3420 | |
|
3407 | 3421 | * IPython/Magic.py (Magic._ofind): Switch to using the new |
|
3408 | 3422 | OInspect.getdoc() function. |
|
3409 | 3423 | |
|
3410 | 3424 | * IPython/Shell.py (sigint_handler): Hack to ignore the execution |
|
3411 | 3425 | of the line currently being canceled via Ctrl-C. It's extremely |
|
3412 | 3426 | ugly, but I don't know how to do it better (the problem is one of |
|
3413 | 3427 | handling cross-thread exceptions). |
|
3414 | 3428 | |
|
3415 | 3429 | 2004-10-28 Fernando Perez <fperez@colorado.edu> |
|
3416 | 3430 | |
|
3417 | 3431 | * IPython/Shell.py (signal_handler): add signal handlers to trap |
|
3418 | 3432 | SIGINT and SIGSEGV in threaded code properly. Thanks to a bug |
|
3419 | 3433 | report by Francesc Alted. |
|
3420 | 3434 | |
|
3421 | 3435 | 2004-10-21 Fernando Perez <fperez@colorado.edu> |
|
3422 | 3436 | |
|
3423 | 3437 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @ |
|
3424 | 3438 | to % for pysh syntax extensions. |
|
3425 | 3439 | |
|
3426 | 3440 | 2004-10-09 Fernando Perez <fperez@colorado.edu> |
|
3427 | 3441 | |
|
3428 | 3442 | * IPython/Magic.py (Magic.magic_whos): modify output of Numeric |
|
3429 | 3443 | arrays to print a more useful summary, without calling str(arr). |
|
3430 | 3444 | This avoids the problem of extremely lengthy computations which |
|
3431 | 3445 | occur if arr is large, and appear to the user as a system lockup |
|
3432 | 3446 | with 100% cpu activity. After a suggestion by Kristian Sandberg |
|
3433 | 3447 | <Kristian.Sandberg@colorado.edu>. |
|
3434 | 3448 | (Magic.__init__): fix bug in global magic escapes not being |
|
3435 | 3449 | correctly set. |
|
3436 | 3450 | |
|
3437 | 3451 | 2004-10-08 Fernando Perez <fperez@colorado.edu> |
|
3438 | 3452 | |
|
3439 | 3453 | * IPython/Magic.py (__license__): change to absolute imports of |
|
3440 | 3454 | ipython's own internal packages, to start adapting to the absolute |
|
3441 | 3455 | import requirement of PEP-328. |
|
3442 | 3456 | |
|
3443 | 3457 | * IPython/genutils.py (__author__): Fix coding to utf-8 on all |
|
3444 | 3458 | files, and standardize author/license marks through the Release |
|
3445 | 3459 | module instead of having per/file stuff (except for files with |
|
3446 | 3460 | particular licenses, like the MIT/PSF-licensed codes). |
|
3447 | 3461 | |
|
3448 | 3462 | * IPython/Debugger.py: remove dead code for python 2.1 |
|
3449 | 3463 | |
|
3450 | 3464 | 2004-10-04 Fernando Perez <fperez@colorado.edu> |
|
3451 | 3465 | |
|
3452 | 3466 | * IPython/iplib.py (ipmagic): New function for accessing magics |
|
3453 | 3467 | via a normal python function call. |
|
3454 | 3468 | |
|
3455 | 3469 | * IPython/Magic.py (Magic.magic_magic): Change the magic escape |
|
3456 | 3470 | from '@' to '%', to accomodate the new @decorator syntax of python |
|
3457 | 3471 | 2.4. |
|
3458 | 3472 | |
|
3459 | 3473 | 2004-09-29 Fernando Perez <fperez@colorado.edu> |
|
3460 | 3474 | |
|
3461 | 3475 | * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to |
|
3462 | 3476 | matplotlib.use to prevent running scripts which try to switch |
|
3463 | 3477 | interactive backends from within ipython. This will just crash |
|
3464 | 3478 | the python interpreter, so we can't allow it (but a detailed error |
|
3465 | 3479 | is given to the user). |
|
3466 | 3480 | |
|
3467 | 3481 | 2004-09-28 Fernando Perez <fperez@colorado.edu> |
|
3468 | 3482 | |
|
3469 | 3483 | * IPython/Shell.py (MatplotlibShellBase.mplot_exec): |
|
3470 | 3484 | matplotlib-related fixes so that using @run with non-matplotlib |
|
3471 | 3485 | scripts doesn't pop up spurious plot windows. This requires |
|
3472 | 3486 | matplotlib >= 0.63, where I had to make some changes as well. |
|
3473 | 3487 | |
|
3474 | 3488 | * IPython/ipmaker.py (make_IPython): update version requirement to |
|
3475 | 3489 | python 2.2. |
|
3476 | 3490 | |
|
3477 | 3491 | * IPython/iplib.py (InteractiveShell.mainloop): Add an optional |
|
3478 | 3492 | banner arg for embedded customization. |
|
3479 | 3493 | |
|
3480 | 3494 | * IPython/Magic.py (Magic.__init__): big cleanup to remove all |
|
3481 | 3495 | explicit uses of __IP as the IPython's instance name. Now things |
|
3482 | 3496 | are properly handled via the shell.name value. The actual code |
|
3483 | 3497 | is a bit ugly b/c I'm doing it via a global in Magic.py, but this |
|
3484 | 3498 | is much better than before. I'll clean things completely when the |
|
3485 | 3499 | magic stuff gets a real overhaul. |
|
3486 | 3500 | |
|
3487 | 3501 | * ipython.1: small fixes, sent in by Jack Moffit. He also sent in |
|
3488 | 3502 | minor changes to debian dir. |
|
3489 | 3503 | |
|
3490 | 3504 | * IPython/iplib.py (InteractiveShell.__init__): Fix adding a |
|
3491 | 3505 | pointer to the shell itself in the interactive namespace even when |
|
3492 | 3506 | a user-supplied dict is provided. This is needed for embedding |
|
3493 | 3507 | purposes (found by tests with Michel Sanner). |
|
3494 | 3508 | |
|
3495 | 3509 | 2004-09-27 Fernando Perez <fperez@colorado.edu> |
|
3496 | 3510 | |
|
3497 | 3511 | * IPython/UserConfig/ipythonrc: remove []{} from |
|
3498 | 3512 | readline_remove_delims, so that things like [modname.<TAB> do |
|
3499 | 3513 | proper completion. This disables [].TAB, but that's a less common |
|
3500 | 3514 | case than module names in list comprehensions, for example. |
|
3501 | 3515 | Thanks to a report by Andrea Riciputi. |
|
3502 | 3516 | |
|
3503 | 3517 | 2004-09-09 Fernando Perez <fperez@colorado.edu> |
|
3504 | 3518 | |
|
3505 | 3519 | * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid |
|
3506 | 3520 | blocking problems in win32 and osx. Fix by John. |
|
3507 | 3521 | |
|
3508 | 3522 | 2004-09-08 Fernando Perez <fperez@colorado.edu> |
|
3509 | 3523 | |
|
3510 | 3524 | * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug |
|
3511 | 3525 | for Win32 and OSX. Fix by John Hunter. |
|
3512 | 3526 | |
|
3513 | 3527 | 2004-08-30 *** Released version 0.6.3 |
|
3514 | 3528 | |
|
3515 | 3529 | 2004-08-30 Fernando Perez <fperez@colorado.edu> |
|
3516 | 3530 | |
|
3517 | 3531 | * setup.py (isfile): Add manpages to list of dependent files to be |
|
3518 | 3532 | updated. |
|
3519 | 3533 | |
|
3520 | 3534 | 2004-08-27 Fernando Perez <fperez@colorado.edu> |
|
3521 | 3535 | |
|
3522 | 3536 | * IPython/Shell.py (start): I've disabled -wthread and -gthread |
|
3523 | 3537 | for now. They don't really work with standalone WX/GTK code |
|
3524 | 3538 | (though matplotlib IS working fine with both of those backends). |
|
3525 | 3539 | This will neeed much more testing. I disabled most things with |
|
3526 | 3540 | comments, so turning it back on later should be pretty easy. |
|
3527 | 3541 | |
|
3528 | 3542 | * IPython/iplib.py (InteractiveShell.__init__): Fix accidental |
|
3529 | 3543 | autocalling of expressions like r'foo', by modifying the line |
|
3530 | 3544 | split regexp. Closes |
|
3531 | 3545 | http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas |
|
3532 | 3546 | Riley <ipythonbugs-AT-sabi.net>. |
|
3533 | 3547 | (InteractiveShell.mainloop): honor --nobanner with banner |
|
3534 | 3548 | extensions. |
|
3535 | 3549 | |
|
3536 | 3550 | * IPython/Shell.py: Significant refactoring of all classes, so |
|
3537 | 3551 | that we can really support ALL matplotlib backends and threading |
|
3538 | 3552 | models (John spotted a bug with Tk which required this). Now we |
|
3539 | 3553 | should support single-threaded, WX-threads and GTK-threads, both |
|
3540 | 3554 | for generic code and for matplotlib. |
|
3541 | 3555 | |
|
3542 | 3556 | * IPython/ipmaker.py (__call__): Changed -mpthread option to |
|
3543 | 3557 | -pylab, to simplify things for users. Will also remove the pylab |
|
3544 | 3558 | profile, since now all of matplotlib configuration is directly |
|
3545 | 3559 | handled here. This also reduces startup time. |
|
3546 | 3560 | |
|
3547 | 3561 | * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of |
|
3548 | 3562 | shell wasn't being correctly called. Also in IPShellWX. |
|
3549 | 3563 | |
|
3550 | 3564 | * IPython/iplib.py (InteractiveShell.__init__): Added option to |
|
3551 | 3565 | fine-tune banner. |
|
3552 | 3566 | |
|
3553 | 3567 | * IPython/numutils.py (spike): Deprecate these spike functions, |
|
3554 | 3568 | delete (long deprecated) gnuplot_exec handler. |
|
3555 | 3569 | |
|
3556 | 3570 | 2004-08-26 Fernando Perez <fperez@colorado.edu> |
|
3557 | 3571 | |
|
3558 | 3572 | * ipython.1: Update for threading options, plus some others which |
|
3559 | 3573 | were missing. |
|
3560 | 3574 | |
|
3561 | 3575 | * IPython/ipmaker.py (__call__): Added -wthread option for |
|
3562 | 3576 | wxpython thread handling. Make sure threading options are only |
|
3563 | 3577 | valid at the command line. |
|
3564 | 3578 | |
|
3565 | 3579 | * scripts/ipython: moved shell selection into a factory function |
|
3566 | 3580 | in Shell.py, to keep the starter script to a minimum. |
|
3567 | 3581 | |
|
3568 | 3582 | 2004-08-25 Fernando Perez <fperez@colorado.edu> |
|
3569 | 3583 | |
|
3570 | 3584 | * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by |
|
3571 | 3585 | John. Along with some recent changes he made to matplotlib, the |
|
3572 | 3586 | next versions of both systems should work very well together. |
|
3573 | 3587 | |
|
3574 | 3588 | 2004-08-24 Fernando Perez <fperez@colorado.edu> |
|
3575 | 3589 | |
|
3576 | 3590 | * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I |
|
3577 | 3591 | tried to switch the profiling to using hotshot, but I'm getting |
|
3578 | 3592 | strange errors from prof.runctx() there. I may be misreading the |
|
3579 | 3593 | docs, but it looks weird. For now the profiling code will |
|
3580 | 3594 | continue to use the standard profiler. |
|
3581 | 3595 | |
|
3582 | 3596 | 2004-08-23 Fernando Perez <fperez@colorado.edu> |
|
3583 | 3597 | |
|
3584 | 3598 | * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX |
|
3585 | 3599 | threaded shell, by John Hunter. It's not quite ready yet, but |
|
3586 | 3600 | close. |
|
3587 | 3601 | |
|
3588 | 3602 | 2004-08-22 Fernando Perez <fperez@colorado.edu> |
|
3589 | 3603 | |
|
3590 | 3604 | * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also |
|
3591 | 3605 | in Magic and ultraTB. |
|
3592 | 3606 | |
|
3593 | 3607 | * ipython.1: document threading options in manpage. |
|
3594 | 3608 | |
|
3595 | 3609 | * scripts/ipython: Changed name of -thread option to -gthread, |
|
3596 | 3610 | since this is GTK specific. I want to leave the door open for a |
|
3597 | 3611 | -wthread option for WX, which will most likely be necessary. This |
|
3598 | 3612 | change affects usage and ipmaker as well. |
|
3599 | 3613 | |
|
3600 | 3614 | * IPython/Shell.py (matplotlib_shell): Add a factory function to |
|
3601 | 3615 | handle the matplotlib shell issues. Code by John Hunter |
|
3602 | 3616 | <jdhunter-AT-nitace.bsd.uchicago.edu>. |
|
3603 | 3617 | (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's |
|
3604 | 3618 | broken (and disabled for end users) for now, but it puts the |
|
3605 | 3619 | infrastructure in place. |
|
3606 | 3620 | |
|
3607 | 3621 | 2004-08-21 Fernando Perez <fperez@colorado.edu> |
|
3608 | 3622 | |
|
3609 | 3623 | * ipythonrc-pylab: Add matplotlib support. |
|
3610 | 3624 | |
|
3611 | 3625 | * matplotlib_config.py: new files for matplotlib support, part of |
|
3612 | 3626 | the pylab profile. |
|
3613 | 3627 | |
|
3614 | 3628 | * IPython/usage.py (__doc__): documented the threading options. |
|
3615 | 3629 | |
|
3616 | 3630 | 2004-08-20 Fernando Perez <fperez@colorado.edu> |
|
3617 | 3631 | |
|
3618 | 3632 | * ipython: Modified the main calling routine to handle the -thread |
|
3619 | 3633 | and -mpthread options. This needs to be done as a top-level hack, |
|
3620 | 3634 | because it determines which class to instantiate for IPython |
|
3621 | 3635 | itself. |
|
3622 | 3636 | |
|
3623 | 3637 | * IPython/Shell.py (MTInteractiveShell.__init__): New set of |
|
3624 | 3638 | classes to support multithreaded GTK operation without blocking, |
|
3625 | 3639 | and matplotlib with all backends. This is a lot of still very |
|
3626 | 3640 | experimental code, and threads are tricky. So it may still have a |
|
3627 | 3641 | few rough edges... This code owes a lot to |
|
3628 | 3642 | http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by |
|
3629 | 3643 | Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and |
|
3630 | 3644 | to John Hunter for all the matplotlib work. |
|
3631 | 3645 | |
|
3632 | 3646 | * IPython/ipmaker.py (__call__): Added -thread and -mpthread |
|
3633 | 3647 | options for gtk thread and matplotlib support. |
|
3634 | 3648 | |
|
3635 | 3649 | 2004-08-16 Fernando Perez <fperez@colorado.edu> |
|
3636 | 3650 | |
|
3637 | 3651 | * IPython/iplib.py (InteractiveShell.__init__): don't trigger |
|
3638 | 3652 | autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug |
|
3639 | 3653 | reported by Stephen Walton <stephen.walton-AT-csun.edu>. |
|
3640 | 3654 | |
|
3641 | 3655 | 2004-08-11 Fernando Perez <fperez@colorado.edu> |
|
3642 | 3656 | |
|
3643 | 3657 | * setup.py (isfile): Fix build so documentation gets updated for |
|
3644 | 3658 | rpms (it was only done for .tgz builds). |
|
3645 | 3659 | |
|
3646 | 3660 | 2004-08-10 Fernando Perez <fperez@colorado.edu> |
|
3647 | 3661 | |
|
3648 | 3662 | * genutils.py (Term): Fix misspell of stdin stream (sin->cin). |
|
3649 | 3663 | |
|
3650 | 3664 | * iplib.py : Silence syntax error exceptions in tab-completion. |
|
3651 | 3665 | |
|
3652 | 3666 | 2004-08-05 Fernando Perez <fperez@colorado.edu> |
|
3653 | 3667 | |
|
3654 | 3668 | * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set |
|
3655 | 3669 | 'color off' mark for continuation prompts. This was causing long |
|
3656 | 3670 | continuation lines to mis-wrap. |
|
3657 | 3671 | |
|
3658 | 3672 | 2004-08-01 Fernando Perez <fperez@colorado.edu> |
|
3659 | 3673 | |
|
3660 | 3674 | * IPython/ipmaker.py (make_IPython): Allow the shell class used |
|
3661 | 3675 | for building ipython to be a parameter. All this is necessary |
|
3662 | 3676 | right now to have a multithreaded version, but this insane |
|
3663 | 3677 | non-design will be cleaned up soon. For now, it's a hack that |
|
3664 | 3678 | works. |
|
3665 | 3679 | |
|
3666 | 3680 | * IPython/Shell.py (IPShell.__init__): Stop using mutable default |
|
3667 | 3681 | args in various places. No bugs so far, but it's a dangerous |
|
3668 | 3682 | practice. |
|
3669 | 3683 | |
|
3670 | 3684 | 2004-07-31 Fernando Perez <fperez@colorado.edu> |
|
3671 | 3685 | |
|
3672 | 3686 | * IPython/iplib.py (complete): ignore SyntaxError exceptions to |
|
3673 | 3687 | fix completion of files with dots in their names under most |
|
3674 | 3688 | profiles (pysh was OK because the completion order is different). |
|
3675 | 3689 | |
|
3676 | 3690 | 2004-07-27 Fernando Perez <fperez@colorado.edu> |
|
3677 | 3691 | |
|
3678 | 3692 | * IPython/iplib.py (InteractiveShell.__init__): build dict of |
|
3679 | 3693 | keywords manually, b/c the one in keyword.py was removed in python |
|
3680 | 3694 | 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>. |
|
3681 | 3695 | This is NOT a bug under python 2.3 and earlier. |
|
3682 | 3696 | |
|
3683 | 3697 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
3684 | 3698 | |
|
3685 | 3699 | * IPython/ultraTB.py (VerboseTB.text): Add another |
|
3686 | 3700 | linecache.checkcache() call to try to prevent inspect.py from |
|
3687 | 3701 | crashing under python 2.3. I think this fixes |
|
3688 | 3702 | http://www.scipy.net/roundup/ipython/issue17. |
|
3689 | 3703 | |
|
3690 | 3704 | 2004-07-26 *** Released version 0.6.2 |
|
3691 | 3705 | |
|
3692 | 3706 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
3693 | 3707 | |
|
3694 | 3708 | * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would |
|
3695 | 3709 | fail for any number. |
|
3696 | 3710 | (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for |
|
3697 | 3711 | empty bookmarks. |
|
3698 | 3712 | |
|
3699 | 3713 | 2004-07-26 *** Released version 0.6.1 |
|
3700 | 3714 | |
|
3701 | 3715 | 2004-07-26 Fernando Perez <fperez@colorado.edu> |
|
3702 | 3716 | |
|
3703 | 3717 | * ipython_win_post_install.py (run): Added pysh shortcut for Windows. |
|
3704 | 3718 | |
|
3705 | 3719 | * IPython/iplib.py (protect_filename): Applied Ville's patch for |
|
3706 | 3720 | escaping '()[]{}' in filenames. |
|
3707 | 3721 | |
|
3708 | 3722 | * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for |
|
3709 | 3723 | Python 2.2 users who lack a proper shlex.split. |
|
3710 | 3724 | |
|
3711 | 3725 | 2004-07-19 Fernando Perez <fperez@colorado.edu> |
|
3712 | 3726 | |
|
3713 | 3727 | * IPython/iplib.py (InteractiveShell.init_readline): Add support |
|
3714 | 3728 | for reading readline's init file. I follow the normal chain: |
|
3715 | 3729 | $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a |
|
3716 | 3730 | report by Mike Heeter. This closes |
|
3717 | 3731 | http://www.scipy.net/roundup/ipython/issue16. |
|
3718 | 3732 | |
|
3719 | 3733 | 2004-07-18 Fernando Perez <fperez@colorado.edu> |
|
3720 | 3734 | |
|
3721 | 3735 | * IPython/iplib.py (__init__): Add better handling of '\' under |
|
3722 | 3736 | Win32 for filenames. After a patch by Ville. |
|
3723 | 3737 | |
|
3724 | 3738 | 2004-07-17 Fernando Perez <fperez@colorado.edu> |
|
3725 | 3739 | |
|
3726 | 3740 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
3727 | 3741 | autocalling would be triggered for 'foo is bar' if foo is |
|
3728 | 3742 | callable. I also cleaned up the autocall detection code to use a |
|
3729 | 3743 | regexp, which is faster. Bug reported by Alexander Schmolck. |
|
3730 | 3744 | |
|
3731 | 3745 | * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with |
|
3732 | 3746 | '?' in them would confuse the help system. Reported by Alex |
|
3733 | 3747 | Schmolck. |
|
3734 | 3748 | |
|
3735 | 3749 | 2004-07-16 Fernando Perez <fperez@colorado.edu> |
|
3736 | 3750 | |
|
3737 | 3751 | * IPython/GnuplotInteractive.py (__all__): added plot2. |
|
3738 | 3752 | |
|
3739 | 3753 | * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for |
|
3740 | 3754 | plotting dictionaries, lists or tuples of 1d arrays. |
|
3741 | 3755 | |
|
3742 | 3756 | * IPython/Magic.py (Magic.magic_hist): small clenaups and |
|
3743 | 3757 | optimizations. |
|
3744 | 3758 | |
|
3745 | 3759 | * IPython/iplib.py:Remove old Changelog info for cleanup. This is |
|
3746 | 3760 | the information which was there from Janko's original IPP code: |
|
3747 | 3761 | |
|
3748 | 3762 | 03.05.99 20:53 porto.ifm.uni-kiel.de |
|
3749 | 3763 | --Started changelog. |
|
3750 | 3764 | --make clear do what it say it does |
|
3751 | 3765 | --added pretty output of lines from inputcache |
|
3752 | 3766 | --Made Logger a mixin class, simplifies handling of switches |
|
3753 | 3767 | --Added own completer class. .string<TAB> expands to last history |
|
3754 | 3768 | line which starts with string. The new expansion is also present |
|
3755 | 3769 | with Ctrl-r from the readline library. But this shows, who this |
|
3756 | 3770 | can be done for other cases. |
|
3757 | 3771 | --Added convention that all shell functions should accept a |
|
3758 | 3772 | parameter_string This opens the door for different behaviour for |
|
3759 | 3773 | each function. @cd is a good example of this. |
|
3760 | 3774 | |
|
3761 | 3775 | 04.05.99 12:12 porto.ifm.uni-kiel.de |
|
3762 | 3776 | --added logfile rotation |
|
3763 | 3777 | --added new mainloop method which freezes first the namespace |
|
3764 | 3778 | |
|
3765 | 3779 | 07.05.99 21:24 porto.ifm.uni-kiel.de |
|
3766 | 3780 | --added the docreader classes. Now there is a help system. |
|
3767 | 3781 | -This is only a first try. Currently it's not easy to put new |
|
3768 | 3782 | stuff in the indices. But this is the way to go. Info would be |
|
3769 | 3783 | better, but HTML is every where and not everybody has an info |
|
3770 | 3784 | system installed and it's not so easy to change html-docs to info. |
|
3771 | 3785 | --added global logfile option |
|
3772 | 3786 | --there is now a hook for object inspection method pinfo needs to |
|
3773 | 3787 | be provided for this. Can be reached by two '??'. |
|
3774 | 3788 | |
|
3775 | 3789 | 08.05.99 20:51 porto.ifm.uni-kiel.de |
|
3776 | 3790 | --added a README |
|
3777 | 3791 | --bug in rc file. Something has changed so functions in the rc |
|
3778 | 3792 | file need to reference the shell and not self. Not clear if it's a |
|
3779 | 3793 | bug or feature. |
|
3780 | 3794 | --changed rc file for new behavior |
|
3781 | 3795 | |
|
3782 | 3796 | 2004-07-15 Fernando Perez <fperez@colorado.edu> |
|
3783 | 3797 | |
|
3784 | 3798 | * IPython/Logger.py (Logger.log): fixed recent bug where the input |
|
3785 | 3799 | cache was falling out of sync in bizarre manners when multi-line |
|
3786 | 3800 | input was present. Minor optimizations and cleanup. |
|
3787 | 3801 | |
|
3788 | 3802 | (Logger): Remove old Changelog info for cleanup. This is the |
|
3789 | 3803 | information which was there from Janko's original code: |
|
3790 | 3804 | |
|
3791 | 3805 | Changes to Logger: - made the default log filename a parameter |
|
3792 | 3806 | |
|
3793 | 3807 | - put a check for lines beginning with !@? in log(). Needed |
|
3794 | 3808 | (even if the handlers properly log their lines) for mid-session |
|
3795 | 3809 | logging activation to work properly. Without this, lines logged |
|
3796 | 3810 | in mid session, which get read from the cache, would end up |
|
3797 | 3811 | 'bare' (with !@? in the open) in the log. Now they are caught |
|
3798 | 3812 | and prepended with a #. |
|
3799 | 3813 | |
|
3800 | 3814 | * IPython/iplib.py (InteractiveShell.init_readline): added check |
|
3801 | 3815 | in case MagicCompleter fails to be defined, so we don't crash. |
|
3802 | 3816 | |
|
3803 | 3817 | 2004-07-13 Fernando Perez <fperez@colorado.edu> |
|
3804 | 3818 | |
|
3805 | 3819 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation |
|
3806 | 3820 | of EPS if the requested filename ends in '.eps'. |
|
3807 | 3821 | |
|
3808 | 3822 | 2004-07-04 Fernando Perez <fperez@colorado.edu> |
|
3809 | 3823 | |
|
3810 | 3824 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix |
|
3811 | 3825 | escaping of quotes when calling the shell. |
|
3812 | 3826 | |
|
3813 | 3827 | 2004-07-02 Fernando Perez <fperez@colorado.edu> |
|
3814 | 3828 | |
|
3815 | 3829 | * IPython/Prompts.py (CachedOutput.update): Fix problem with |
|
3816 | 3830 | gettext not working because we were clobbering '_'. Fixes |
|
3817 | 3831 | http://www.scipy.net/roundup/ipython/issue6. |
|
3818 | 3832 | |
|
3819 | 3833 | 2004-07-01 Fernando Perez <fperez@colorado.edu> |
|
3820 | 3834 | |
|
3821 | 3835 | * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling |
|
3822 | 3836 | into @cd. Patch by Ville. |
|
3823 | 3837 | |
|
3824 | 3838 | * IPython/iplib.py (InteractiveShell.post_config_initialization): |
|
3825 | 3839 | new function to store things after ipmaker runs. Patch by Ville. |
|
3826 | 3840 | Eventually this will go away once ipmaker is removed and the class |
|
3827 | 3841 | gets cleaned up, but for now it's ok. Key functionality here is |
|
3828 | 3842 | the addition of the persistent storage mechanism, a dict for |
|
3829 | 3843 | keeping data across sessions (for now just bookmarks, but more can |
|
3830 | 3844 | be implemented later). |
|
3831 | 3845 | |
|
3832 | 3846 | * IPython/Magic.py (Magic.magic_bookmark): New bookmark system, |
|
3833 | 3847 | persistent across sections. Patch by Ville, I modified it |
|
3834 | 3848 | soemwhat to allow bookmarking arbitrary dirs other than CWD. Also |
|
3835 | 3849 | added a '-l' option to list all bookmarks. |
|
3836 | 3850 | |
|
3837 | 3851 | * IPython/iplib.py (InteractiveShell.atexit_operations): new |
|
3838 | 3852 | center for cleanup. Registered with atexit.register(). I moved |
|
3839 | 3853 | here the old exit_cleanup(). After a patch by Ville. |
|
3840 | 3854 | |
|
3841 | 3855 | * IPython/Magic.py (get_py_filename): added '~' to the accepted |
|
3842 | 3856 | characters in the hacked shlex_split for python 2.2. |
|
3843 | 3857 | |
|
3844 | 3858 | * IPython/iplib.py (file_matches): more fixes to filenames with |
|
3845 | 3859 | whitespace in them. It's not perfect, but limitations in python's |
|
3846 | 3860 | readline make it impossible to go further. |
|
3847 | 3861 | |
|
3848 | 3862 | 2004-06-29 Fernando Perez <fperez@colorado.edu> |
|
3849 | 3863 | |
|
3850 | 3864 | * IPython/iplib.py (file_matches): escape whitespace correctly in |
|
3851 | 3865 | filename completions. Bug reported by Ville. |
|
3852 | 3866 | |
|
3853 | 3867 | 2004-06-28 Fernando Perez <fperez@colorado.edu> |
|
3854 | 3868 | |
|
3855 | 3869 | * IPython/ipmaker.py (__call__): Added per-profile histories. Now |
|
3856 | 3870 | the history file will be called 'history-PROFNAME' (or just |
|
3857 | 3871 | 'history' if no profile is loaded). I was getting annoyed at |
|
3858 | 3872 | getting my Numerical work history clobbered by pysh sessions. |
|
3859 | 3873 | |
|
3860 | 3874 | * IPython/iplib.py (InteractiveShell.__init__): Internal |
|
3861 | 3875 | getoutputerror() function so that we can honor the system_verbose |
|
3862 | 3876 | flag for _all_ system calls. I also added escaping of # |
|
3863 | 3877 | characters here to avoid confusing Itpl. |
|
3864 | 3878 | |
|
3865 | 3879 | * IPython/Magic.py (shlex_split): removed call to shell in |
|
3866 | 3880 | parse_options and replaced it with shlex.split(). The annoying |
|
3867 | 3881 | part was that in Python 2.2, shlex.split() doesn't exist, so I had |
|
3868 | 3882 | to backport it from 2.3, with several frail hacks (the shlex |
|
3869 | 3883 | module is rather limited in 2.2). Thanks to a suggestion by Ville |
|
3870 | 3884 | Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no |
|
3871 | 3885 | problem. |
|
3872 | 3886 | |
|
3873 | 3887 | (Magic.magic_system_verbose): new toggle to print the actual |
|
3874 | 3888 | system calls made by ipython. Mainly for debugging purposes. |
|
3875 | 3889 | |
|
3876 | 3890 | * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which |
|
3877 | 3891 | doesn't support persistence. Reported (and fix suggested) by |
|
3878 | 3892 | Travis Caldwell <travis_caldwell2000@yahoo.com>. |
|
3879 | 3893 | |
|
3880 | 3894 | 2004-06-26 Fernando Perez <fperez@colorado.edu> |
|
3881 | 3895 | |
|
3882 | 3896 | * IPython/Logger.py (Logger.log): fix to handle correctly empty |
|
3883 | 3897 | continue prompts. |
|
3884 | 3898 | |
|
3885 | 3899 | * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh() |
|
3886 | 3900 | function (basically a big docstring) and a few more things here to |
|
3887 | 3901 | speedup startup. pysh.py is now very lightweight. We want because |
|
3888 | 3902 | it gets execfile'd, while InterpreterExec gets imported, so |
|
3889 | 3903 | byte-compilation saves time. |
|
3890 | 3904 | |
|
3891 | 3905 | 2004-06-25 Fernando Perez <fperez@colorado.edu> |
|
3892 | 3906 | |
|
3893 | 3907 | * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd |
|
3894 | 3908 | -NUM', which was recently broken. |
|
3895 | 3909 | |
|
3896 | 3910 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow ! |
|
3897 | 3911 | in multi-line input (but not !!, which doesn't make sense there). |
|
3898 | 3912 | |
|
3899 | 3913 | * IPython/UserConfig/ipythonrc: made autoindent on by default. |
|
3900 | 3914 | It's just too useful, and people can turn it off in the less |
|
3901 | 3915 | common cases where it's a problem. |
|
3902 | 3916 | |
|
3903 | 3917 | 2004-06-24 Fernando Perez <fperez@colorado.edu> |
|
3904 | 3918 | |
|
3905 | 3919 | * IPython/iplib.py (InteractiveShell._prefilter): big change - |
|
3906 | 3920 | special syntaxes (like alias calling) is now allied in multi-line |
|
3907 | 3921 | input. This is still _very_ experimental, but it's necessary for |
|
3908 | 3922 | efficient shell usage combining python looping syntax with system |
|
3909 | 3923 | calls. For now it's restricted to aliases, I don't think it |
|
3910 | 3924 | really even makes sense to have this for magics. |
|
3911 | 3925 | |
|
3912 | 3926 | 2004-06-23 Fernando Perez <fperez@colorado.edu> |
|
3913 | 3927 | |
|
3914 | 3928 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added |
|
3915 | 3929 | $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd. |
|
3916 | 3930 | |
|
3917 | 3931 | * IPython/Magic.py (Magic.magic_rehashx): modified to handle |
|
3918 | 3932 | extensions under Windows (after code sent by Gary Bishop). The |
|
3919 | 3933 | extensions considered 'executable' are stored in IPython's rc |
|
3920 | 3934 | structure as win_exec_ext. |
|
3921 | 3935 | |
|
3922 | 3936 | * IPython/genutils.py (shell): new function, like system() but |
|
3923 | 3937 | without return value. Very useful for interactive shell work. |
|
3924 | 3938 | |
|
3925 | 3939 | * IPython/Magic.py (Magic.magic_unalias): New @unalias function to |
|
3926 | 3940 | delete aliases. |
|
3927 | 3941 | |
|
3928 | 3942 | * IPython/iplib.py (InteractiveShell.alias_table_update): make |
|
3929 | 3943 | sure that the alias table doesn't contain python keywords. |
|
3930 | 3944 | |
|
3931 | 3945 | 2004-06-21 Fernando Perez <fperez@colorado.edu> |
|
3932 | 3946 | |
|
3933 | 3947 | * IPython/Magic.py (Magic.magic_rehash): Fix crash when |
|
3934 | 3948 | non-existent items are found in $PATH. Reported by Thorsten. |
|
3935 | 3949 | |
|
3936 | 3950 | 2004-06-20 Fernando Perez <fperez@colorado.edu> |
|
3937 | 3951 | |
|
3938 | 3952 | * IPython/iplib.py (complete): modified the completer so that the |
|
3939 | 3953 | order of priorities can be easily changed at runtime. |
|
3940 | 3954 | |
|
3941 | 3955 | * IPython/Extensions/InterpreterExec.py (prefilter_shell): |
|
3942 | 3956 | Modified to auto-execute all lines beginning with '~', '/' or '.'. |
|
3943 | 3957 | |
|
3944 | 3958 | * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to |
|
3945 | 3959 | expand Python variables prepended with $ in all system calls. The |
|
3946 | 3960 | same was done to InteractiveShell.handle_shell_escape. Now all |
|
3947 | 3961 | system access mechanisms (!, !!, @sc, @sx and aliases) allow the |
|
3948 | 3962 | expansion of python variables and expressions according to the |
|
3949 | 3963 | syntax of PEP-215 - http://www.python.org/peps/pep-0215.html. |
|
3950 | 3964 | |
|
3951 | 3965 | Though PEP-215 has been rejected, a similar (but simpler) one |
|
3952 | 3966 | seems like it will go into Python 2.4, PEP-292 - |
|
3953 | 3967 | http://www.python.org/peps/pep-0292.html. |
|
3954 | 3968 | |
|
3955 | 3969 | I'll keep the full syntax of PEP-215, since IPython has since the |
|
3956 | 3970 | start used Ka-Ping Yee's reference implementation discussed there |
|
3957 | 3971 | (Itpl), and I actually like the powerful semantics it offers. |
|
3958 | 3972 | |
|
3959 | 3973 | In order to access normal shell variables, the $ has to be escaped |
|
3960 | 3974 | via an extra $. For example: |
|
3961 | 3975 | |
|
3962 | 3976 | In [7]: PATH='a python variable' |
|
3963 | 3977 | |
|
3964 | 3978 | In [8]: !echo $PATH |
|
3965 | 3979 | a python variable |
|
3966 | 3980 | |
|
3967 | 3981 | In [9]: !echo $$PATH |
|
3968 | 3982 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
3969 | 3983 | |
|
3970 | 3984 | (Magic.parse_options): escape $ so the shell doesn't evaluate |
|
3971 | 3985 | things prematurely. |
|
3972 | 3986 | |
|
3973 | 3987 | * IPython/iplib.py (InteractiveShell.call_alias): added the |
|
3974 | 3988 | ability for aliases to expand python variables via $. |
|
3975 | 3989 | |
|
3976 | 3990 | * IPython/Magic.py (Magic.magic_rehash): based on the new alias |
|
3977 | 3991 | system, now there's a @rehash/@rehashx pair of magics. These work |
|
3978 | 3992 | like the csh rehash command, and can be invoked at any time. They |
|
3979 | 3993 | build a table of aliases to everything in the user's $PATH |
|
3980 | 3994 | (@rehash uses everything, @rehashx is slower but only adds |
|
3981 | 3995 | executable files). With this, the pysh.py-based shell profile can |
|
3982 | 3996 | now simply call rehash upon startup, and full access to all |
|
3983 | 3997 | programs in the user's path is obtained. |
|
3984 | 3998 | |
|
3985 | 3999 | * IPython/iplib.py (InteractiveShell.call_alias): The new alias |
|
3986 | 4000 | functionality is now fully in place. I removed the old dynamic |
|
3987 | 4001 | code generation based approach, in favor of a much lighter one |
|
3988 | 4002 | based on a simple dict. The advantage is that this allows me to |
|
3989 | 4003 | now have thousands of aliases with negligible cost (unthinkable |
|
3990 | 4004 | with the old system). |
|
3991 | 4005 | |
|
3992 | 4006 | 2004-06-19 Fernando Perez <fperez@colorado.edu> |
|
3993 | 4007 | |
|
3994 | 4008 | * IPython/iplib.py (__init__): extended MagicCompleter class to |
|
3995 | 4009 | also complete (last in priority) on user aliases. |
|
3996 | 4010 | |
|
3997 | 4011 | * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in |
|
3998 | 4012 | call to eval. |
|
3999 | 4013 | (ItplNS.__init__): Added a new class which functions like Itpl, |
|
4000 | 4014 | but allows configuring the namespace for the evaluation to occur |
|
4001 | 4015 | in. |
|
4002 | 4016 | |
|
4003 | 4017 | 2004-06-18 Fernando Perez <fperez@colorado.edu> |
|
4004 | 4018 | |
|
4005 | 4019 | * IPython/iplib.py (InteractiveShell.runcode): modify to print a |
|
4006 | 4020 | better message when 'exit' or 'quit' are typed (a common newbie |
|
4007 | 4021 | confusion). |
|
4008 | 4022 | |
|
4009 | 4023 | * IPython/Magic.py (Magic.magic_colors): Added the runtime color |
|
4010 | 4024 | check for Windows users. |
|
4011 | 4025 | |
|
4012 | 4026 | * IPython/iplib.py (InteractiveShell.user_setup): removed |
|
4013 | 4027 | disabling of colors for Windows. I'll test at runtime and issue a |
|
4014 | 4028 | warning if Gary's readline isn't found, as to nudge users to |
|
4015 | 4029 | download it. |
|
4016 | 4030 | |
|
4017 | 4031 | 2004-06-16 Fernando Perez <fperez@colorado.edu> |
|
4018 | 4032 | |
|
4019 | 4033 | * IPython/genutils.py (Stream.__init__): changed to print errors |
|
4020 | 4034 | to sys.stderr. I had a circular dependency here. Now it's |
|
4021 | 4035 | possible to run ipython as IDLE's shell (consider this pre-alpha, |
|
4022 | 4036 | since true stdout things end up in the starting terminal instead |
|
4023 | 4037 | of IDLE's out). |
|
4024 | 4038 | |
|
4025 | 4039 | * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for |
|
4026 | 4040 | users who haven't # updated their prompt_in2 definitions. Remove |
|
4027 | 4041 | eventually. |
|
4028 | 4042 | (multiple_replace): added credit to original ASPN recipe. |
|
4029 | 4043 | |
|
4030 | 4044 | 2004-06-15 Fernando Perez <fperez@colorado.edu> |
|
4031 | 4045 | |
|
4032 | 4046 | * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the |
|
4033 | 4047 | list of auto-defined aliases. |
|
4034 | 4048 | |
|
4035 | 4049 | 2004-06-13 Fernando Perez <fperez@colorado.edu> |
|
4036 | 4050 | |
|
4037 | 4051 | * setup.py (scriptfiles): Don't trigger win_post_install unless an |
|
4038 | 4052 | install was really requested (so setup.py can be used for other |
|
4039 | 4053 | things under Windows). |
|
4040 | 4054 | |
|
4041 | 4055 | 2004-06-10 Fernando Perez <fperez@colorado.edu> |
|
4042 | 4056 | |
|
4043 | 4057 | * IPython/Logger.py (Logger.create_log): Manually remove any old |
|
4044 | 4058 | backup, since os.remove may fail under Windows. Fixes bug |
|
4045 | 4059 | reported by Thorsten. |
|
4046 | 4060 | |
|
4047 | 4061 | 2004-06-09 Fernando Perez <fperez@colorado.edu> |
|
4048 | 4062 | |
|
4049 | 4063 | * examples/example-embed.py: fixed all references to %n (replaced |
|
4050 | 4064 | with \\# for ps1/out prompts and with \\D for ps2 prompts). Done |
|
4051 | 4065 | for all examples and the manual as well. |
|
4052 | 4066 | |
|
4053 | 4067 | 2004-06-08 Fernando Perez <fperez@colorado.edu> |
|
4054 | 4068 | |
|
4055 | 4069 | * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt |
|
4056 | 4070 | alignment and color management. All 3 prompt subsystems now |
|
4057 | 4071 | inherit from BasePrompt. |
|
4058 | 4072 | |
|
4059 | 4073 | * tools/release: updates for windows installer build and tag rpms |
|
4060 | 4074 | with python version (since paths are fixed). |
|
4061 | 4075 | |
|
4062 | 4076 | * IPython/UserConfig/ipythonrc: modified to use \# instead of %n, |
|
4063 | 4077 | which will become eventually obsolete. Also fixed the default |
|
4064 | 4078 | prompt_in2 to use \D, so at least new users start with the correct |
|
4065 | 4079 | defaults. |
|
4066 | 4080 | WARNING: Users with existing ipythonrc files will need to apply |
|
4067 | 4081 | this fix manually! |
|
4068 | 4082 | |
|
4069 | 4083 | * setup.py: make windows installer (.exe). This is finally the |
|
4070 | 4084 | integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>, |
|
4071 | 4085 | which I hadn't included because it required Python 2.3 (or recent |
|
4072 | 4086 | distutils). |
|
4073 | 4087 | |
|
4074 | 4088 | * IPython/usage.py (__doc__): update docs (and manpage) to reflect |
|
4075 | 4089 | usage of new '\D' escape. |
|
4076 | 4090 | |
|
4077 | 4091 | * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which |
|
4078 | 4092 | lacks os.getuid()) |
|
4079 | 4093 | (CachedOutput.set_colors): Added the ability to turn coloring |
|
4080 | 4094 | on/off with @colors even for manually defined prompt colors. It |
|
4081 | 4095 | uses a nasty global, but it works safely and via the generic color |
|
4082 | 4096 | handling mechanism. |
|
4083 | 4097 | (Prompt2.__init__): Introduced new escape '\D' for continuation |
|
4084 | 4098 | prompts. It represents the counter ('\#') as dots. |
|
4085 | 4099 | *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will |
|
4086 | 4100 | need to update their ipythonrc files and replace '%n' with '\D' in |
|
4087 | 4101 | their prompt_in2 settings everywhere. Sorry, but there's |
|
4088 | 4102 | otherwise no clean way to get all prompts to properly align. The |
|
4089 | 4103 | ipythonrc shipped with IPython has been updated. |
|
4090 | 4104 | |
|
4091 | 4105 | 2004-06-07 Fernando Perez <fperez@colorado.edu> |
|
4092 | 4106 | |
|
4093 | 4107 | * setup.py (isfile): Pass local_icons option to latex2html, so the |
|
4094 | 4108 | resulting HTML file is self-contained. Thanks to |
|
4095 | 4109 | dryice-AT-liu.com.cn for the tip. |
|
4096 | 4110 | |
|
4097 | 4111 | * pysh.py: I created a new profile 'shell', which implements a |
|
4098 | 4112 | _rudimentary_ IPython-based shell. This is in NO WAY a realy |
|
4099 | 4113 | system shell, nor will it become one anytime soon. It's mainly |
|
4100 | 4114 | meant to illustrate the use of the new flexible bash-like prompts. |
|
4101 | 4115 | I guess it could be used by hardy souls for true shell management, |
|
4102 | 4116 | but it's no tcsh/bash... pysh.py is loaded by the 'shell' |
|
4103 | 4117 | profile. This uses the InterpreterExec extension provided by |
|
4104 | 4118 | W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl> |
|
4105 | 4119 | |
|
4106 | 4120 | * IPython/Prompts.py (PromptOut.__str__): now it will correctly |
|
4107 | 4121 | auto-align itself with the length of the previous input prompt |
|
4108 | 4122 | (taking into account the invisible color escapes). |
|
4109 | 4123 | (CachedOutput.__init__): Large restructuring of this class. Now |
|
4110 | 4124 | all three prompts (primary1, primary2, output) are proper objects, |
|
4111 | 4125 | managed by the 'parent' CachedOutput class. The code is still a |
|
4112 | 4126 | bit hackish (all prompts share state via a pointer to the cache), |
|
4113 | 4127 | but it's overall far cleaner than before. |
|
4114 | 4128 | |
|
4115 | 4129 | * IPython/genutils.py (getoutputerror): modified to add verbose, |
|
4116 | 4130 | debug and header options. This makes the interface of all getout* |
|
4117 | 4131 | functions uniform. |
|
4118 | 4132 | (SystemExec.getoutputerror): added getoutputerror to SystemExec. |
|
4119 | 4133 | |
|
4120 | 4134 | * IPython/Magic.py (Magic.default_option): added a function to |
|
4121 | 4135 | allow registering default options for any magic command. This |
|
4122 | 4136 | makes it easy to have profiles which customize the magics globally |
|
4123 | 4137 | for a certain use. The values set through this function are |
|
4124 | 4138 | picked up by the parse_options() method, which all magics should |
|
4125 | 4139 | use to parse their options. |
|
4126 | 4140 | |
|
4127 | 4141 | * IPython/genutils.py (warn): modified the warnings framework to |
|
4128 | 4142 | use the Term I/O class. I'm trying to slowly unify all of |
|
4129 | 4143 | IPython's I/O operations to pass through Term. |
|
4130 | 4144 | |
|
4131 | 4145 | * IPython/Prompts.py (Prompt2._str_other): Added functionality in |
|
4132 | 4146 | the secondary prompt to correctly match the length of the primary |
|
4133 | 4147 | one for any prompt. Now multi-line code will properly line up |
|
4134 | 4148 | even for path dependent prompts, such as the new ones available |
|
4135 | 4149 | via the prompt_specials. |
|
4136 | 4150 | |
|
4137 | 4151 | 2004-06-06 Fernando Perez <fperez@colorado.edu> |
|
4138 | 4152 | |
|
4139 | 4153 | * IPython/Prompts.py (prompt_specials): Added the ability to have |
|
4140 | 4154 | bash-like special sequences in the prompts, which get |
|
4141 | 4155 | automatically expanded. Things like hostname, current working |
|
4142 | 4156 | directory and username are implemented already, but it's easy to |
|
4143 | 4157 | add more in the future. Thanks to a patch by W.J. van der Laan |
|
4144 | 4158 | <gnufnork-AT-hetdigitalegat.nl> |
|
4145 | 4159 | (prompt_specials): Added color support for prompt strings, so |
|
4146 | 4160 | users can define arbitrary color setups for their prompts. |
|
4147 | 4161 | |
|
4148 | 4162 | 2004-06-05 Fernando Perez <fperez@colorado.edu> |
|
4149 | 4163 | |
|
4150 | 4164 | * IPython/genutils.py (Term.reopen_all): Added Windows-specific |
|
4151 | 4165 | code to load Gary Bishop's readline and configure it |
|
4152 | 4166 | automatically. Thanks to Gary for help on this. |
|
4153 | 4167 | |
|
4154 | 4168 | 2004-06-01 Fernando Perez <fperez@colorado.edu> |
|
4155 | 4169 | |
|
4156 | 4170 | * IPython/Logger.py (Logger.create_log): fix bug for logging |
|
4157 | 4171 | with no filename (previous fix was incomplete). |
|
4158 | 4172 | |
|
4159 | 4173 | 2004-05-25 Fernando Perez <fperez@colorado.edu> |
|
4160 | 4174 | |
|
4161 | 4175 | * IPython/Magic.py (Magic.parse_options): fix bug where naked |
|
4162 | 4176 | parens would get passed to the shell. |
|
4163 | 4177 | |
|
4164 | 4178 | 2004-05-20 Fernando Perez <fperez@colorado.edu> |
|
4165 | 4179 | |
|
4166 | 4180 | * IPython/Magic.py (Magic.magic_prun): changed default profile |
|
4167 | 4181 | sort order to 'time' (the more common profiling need). |
|
4168 | 4182 | |
|
4169 | 4183 | * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache |
|
4170 | 4184 | so that source code shown is guaranteed in sync with the file on |
|
4171 | 4185 | disk (also changed in psource). Similar fix to the one for |
|
4172 | 4186 | ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du |
|
4173 | 4187 | <yann.ledu-AT-noos.fr>. |
|
4174 | 4188 | |
|
4175 | 4189 | * IPython/Magic.py (Magic.parse_options): Fixed bug where commands |
|
4176 | 4190 | with a single option would not be correctly parsed. Closes |
|
4177 | 4191 | http://www.scipy.net/roundup/ipython/issue14. This bug had been |
|
4178 | 4192 | introduced in 0.6.0 (on 2004-05-06). |
|
4179 | 4193 | |
|
4180 | 4194 | 2004-05-13 *** Released version 0.6.0 |
|
4181 | 4195 | |
|
4182 | 4196 | 2004-05-13 Fernando Perez <fperez@colorado.edu> |
|
4183 | 4197 | |
|
4184 | 4198 | * debian/: Added debian/ directory to CVS, so that debian support |
|
4185 | 4199 | is publicly accessible. The debian package is maintained by Jack |
|
4186 | 4200 | Moffit <jack-AT-xiph.org>. |
|
4187 | 4201 | |
|
4188 | 4202 | * Documentation: included the notes about an ipython-based system |
|
4189 | 4203 | shell (the hypothetical 'pysh') into the new_design.pdf document, |
|
4190 | 4204 | so that these ideas get distributed to users along with the |
|
4191 | 4205 | official documentation. |
|
4192 | 4206 | |
|
4193 | 4207 | 2004-05-10 Fernando Perez <fperez@colorado.edu> |
|
4194 | 4208 | |
|
4195 | 4209 | * IPython/Logger.py (Logger.create_log): fix recently introduced |
|
4196 | 4210 | bug (misindented line) where logstart would fail when not given an |
|
4197 | 4211 | explicit filename. |
|
4198 | 4212 | |
|
4199 | 4213 | 2004-05-09 Fernando Perez <fperez@colorado.edu> |
|
4200 | 4214 | |
|
4201 | 4215 | * IPython/Magic.py (Magic.parse_options): skip system call when |
|
4202 | 4216 | there are no options to look for. Faster, cleaner for the common |
|
4203 | 4217 | case. |
|
4204 | 4218 | |
|
4205 | 4219 | * Documentation: many updates to the manual: describing Windows |
|
4206 | 4220 | support better, Gnuplot updates, credits, misc small stuff. Also |
|
4207 | 4221 | updated the new_design doc a bit. |
|
4208 | 4222 | |
|
4209 | 4223 | 2004-05-06 *** Released version 0.6.0.rc1 |
|
4210 | 4224 | |
|
4211 | 4225 | 2004-05-06 Fernando Perez <fperez@colorado.edu> |
|
4212 | 4226 | |
|
4213 | 4227 | * IPython/ultraTB.py (ListTB.text): modified a ton of string += |
|
4214 | 4228 | operations to use the vastly more efficient list/''.join() method. |
|
4215 | 4229 | (FormattedTB.text): Fix |
|
4216 | 4230 | http://www.scipy.net/roundup/ipython/issue12 - exception source |
|
4217 | 4231 | extract not updated after reload. Thanks to Mike Salib |
|
4218 | 4232 | <msalib-AT-mit.edu> for pinning the source of the problem. |
|
4219 | 4233 | Fortunately, the solution works inside ipython and doesn't require |
|
4220 | 4234 | any changes to python proper. |
|
4221 | 4235 | |
|
4222 | 4236 | * IPython/Magic.py (Magic.parse_options): Improved to process the |
|
4223 | 4237 | argument list as a true shell would (by actually using the |
|
4224 | 4238 | underlying system shell). This way, all @magics automatically get |
|
4225 | 4239 | shell expansion for variables. Thanks to a comment by Alex |
|
4226 | 4240 | Schmolck. |
|
4227 | 4241 | |
|
4228 | 4242 | 2004-04-04 Fernando Perez <fperez@colorado.edu> |
|
4229 | 4243 | |
|
4230 | 4244 | * IPython/iplib.py (InteractiveShell.interact): Added a special |
|
4231 | 4245 | trap for a debugger quit exception, which is basically impossible |
|
4232 | 4246 | to handle by normal mechanisms, given what pdb does to the stack. |
|
4233 | 4247 | This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>. |
|
4234 | 4248 | |
|
4235 | 4249 | 2004-04-03 Fernando Perez <fperez@colorado.edu> |
|
4236 | 4250 | |
|
4237 | 4251 | * IPython/genutils.py (Term): Standardized the names of the Term |
|
4238 | 4252 | class streams to cin/cout/cerr, following C++ naming conventions |
|
4239 | 4253 | (I can't use in/out/err because 'in' is not a valid attribute |
|
4240 | 4254 | name). |
|
4241 | 4255 | |
|
4242 | 4256 | * IPython/iplib.py (InteractiveShell.interact): don't increment |
|
4243 | 4257 | the prompt if there's no user input. By Daniel 'Dang' Griffith |
|
4244 | 4258 | <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from |
|
4245 | 4259 | Francois Pinard. |
|
4246 | 4260 | |
|
4247 | 4261 | 2004-04-02 Fernando Perez <fperez@colorado.edu> |
|
4248 | 4262 | |
|
4249 | 4263 | * IPython/genutils.py (Stream.__init__): Modified to survive at |
|
4250 | 4264 | least importing in contexts where stdin/out/err aren't true file |
|
4251 | 4265 | objects, such as PyCrust (they lack fileno() and mode). However, |
|
4252 | 4266 | the recovery facilities which rely on these things existing will |
|
4253 | 4267 | not work. |
|
4254 | 4268 | |
|
4255 | 4269 | 2004-04-01 Fernando Perez <fperez@colorado.edu> |
|
4256 | 4270 | |
|
4257 | 4271 | * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to |
|
4258 | 4272 | use the new getoutputerror() function, so it properly |
|
4259 | 4273 | distinguishes stdout/err. |
|
4260 | 4274 | |
|
4261 | 4275 | * IPython/genutils.py (getoutputerror): added a function to |
|
4262 | 4276 | capture separately the standard output and error of a command. |
|
4263 | 4277 | After a comment from dang on the mailing lists. This code is |
|
4264 | 4278 | basically a modified version of commands.getstatusoutput(), from |
|
4265 | 4279 | the standard library. |
|
4266 | 4280 | |
|
4267 | 4281 | * IPython/iplib.py (InteractiveShell.handle_shell_escape): added |
|
4268 | 4282 | '!!' as a special syntax (shorthand) to access @sx. |
|
4269 | 4283 | |
|
4270 | 4284 | * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell |
|
4271 | 4285 | command and return its output as a list split on '\n'. |
|
4272 | 4286 | |
|
4273 | 4287 | 2004-03-31 Fernando Perez <fperez@colorado.edu> |
|
4274 | 4288 | |
|
4275 | 4289 | * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__ |
|
4276 | 4290 | method to dictionaries used as FakeModule instances if they lack |
|
4277 | 4291 | it. At least pydoc in python2.3 breaks for runtime-defined |
|
4278 | 4292 | functions without this hack. At some point I need to _really_ |
|
4279 | 4293 | understand what FakeModule is doing, because it's a gross hack. |
|
4280 | 4294 | But it solves Arnd's problem for now... |
|
4281 | 4295 | |
|
4282 | 4296 | 2004-02-27 Fernando Perez <fperez@colorado.edu> |
|
4283 | 4297 | |
|
4284 | 4298 | * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate' |
|
4285 | 4299 | mode would behave erratically. Also increased the number of |
|
4286 | 4300 | possible logs in rotate mod to 999. Thanks to Rod Holland |
|
4287 | 4301 | <rhh@StructureLABS.com> for the report and fixes. |
|
4288 | 4302 | |
|
4289 | 4303 | 2004-02-26 Fernando Perez <fperez@colorado.edu> |
|
4290 | 4304 | |
|
4291 | 4305 | * IPython/genutils.py (page): Check that the curses module really |
|
4292 | 4306 | has the initscr attribute before trying to use it. For some |
|
4293 | 4307 | reason, the Solaris curses module is missing this. I think this |
|
4294 | 4308 | should be considered a Solaris python bug, but I'm not sure. |
|
4295 | 4309 | |
|
4296 | 4310 | 2004-01-17 Fernando Perez <fperez@colorado.edu> |
|
4297 | 4311 | |
|
4298 | 4312 | * IPython/genutils.py (Stream.__init__): Changes to try to make |
|
4299 | 4313 | ipython robust against stdin/out/err being closed by the user. |
|
4300 | 4314 | This is 'user error' (and blocks a normal python session, at least |
|
4301 | 4315 | the stdout case). However, Ipython should be able to survive such |
|
4302 | 4316 | instances of abuse as gracefully as possible. To simplify the |
|
4303 | 4317 | coding and maintain compatibility with Gary Bishop's Term |
|
4304 | 4318 | contributions, I've made use of classmethods for this. I think |
|
4305 | 4319 | this introduces a dependency on python 2.2. |
|
4306 | 4320 | |
|
4307 | 4321 | 2004-01-13 Fernando Perez <fperez@colorado.edu> |
|
4308 | 4322 | |
|
4309 | 4323 | * IPython/numutils.py (exp_safe): simplified the code a bit and |
|
4310 | 4324 | removed the need for importing the kinds module altogether. |
|
4311 | 4325 | |
|
4312 | 4326 | 2004-01-06 Fernando Perez <fperez@colorado.edu> |
|
4313 | 4327 | |
|
4314 | 4328 | * IPython/Magic.py (Magic.magic_sc): Made the shell capture system |
|
4315 | 4329 | a magic function instead, after some community feedback. No |
|
4316 | 4330 | special syntax will exist for it, but its name is deliberately |
|
4317 | 4331 | very short. |
|
4318 | 4332 | |
|
4319 | 4333 | 2003-12-20 Fernando Perez <fperez@colorado.edu> |
|
4320 | 4334 | |
|
4321 | 4335 | * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added |
|
4322 | 4336 | new functionality, to automagically assign the result of a shell |
|
4323 | 4337 | command to a variable. I'll solicit some community feedback on |
|
4324 | 4338 | this before making it permanent. |
|
4325 | 4339 | |
|
4326 | 4340 | * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was |
|
4327 | 4341 | requested about callables for which inspect couldn't obtain a |
|
4328 | 4342 | proper argspec. Thanks to a crash report sent by Etienne |
|
4329 | 4343 | Posthumus <etienne-AT-apple01.cs.vu.nl>. |
|
4330 | 4344 | |
|
4331 | 4345 | 2003-12-09 Fernando Perez <fperez@colorado.edu> |
|
4332 | 4346 | |
|
4333 | 4347 | * IPython/genutils.py (page): patch for the pager to work across |
|
4334 | 4348 | various versions of Windows. By Gary Bishop. |
|
4335 | 4349 | |
|
4336 | 4350 | 2003-12-04 Fernando Perez <fperez@colorado.edu> |
|
4337 | 4351 | |
|
4338 | 4352 | * IPython/Gnuplot2.py (PlotItems): Fixes for working with |
|
4339 | 4353 | Gnuplot.py version 1.7, whose internal names changed quite a bit. |
|
4340 | 4354 | While I tested this and it looks ok, there may still be corner |
|
4341 | 4355 | cases I've missed. |
|
4342 | 4356 | |
|
4343 | 4357 | 2003-12-01 Fernando Perez <fperez@colorado.edu> |
|
4344 | 4358 | |
|
4345 | 4359 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug |
|
4346 | 4360 | where a line like 'p,q=1,2' would fail because the automagic |
|
4347 | 4361 | system would be triggered for @p. |
|
4348 | 4362 | |
|
4349 | 4363 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related |
|
4350 | 4364 | cleanups, code unmodified. |
|
4351 | 4365 | |
|
4352 | 4366 | * IPython/genutils.py (Term): added a class for IPython to handle |
|
4353 | 4367 | output. In most cases it will just be a proxy for stdout/err, but |
|
4354 | 4368 | having this allows modifications to be made for some platforms, |
|
4355 | 4369 | such as handling color escapes under Windows. All of this code |
|
4356 | 4370 | was contributed by Gary Bishop, with minor modifications by me. |
|
4357 | 4371 | The actual changes affect many files. |
|
4358 | 4372 | |
|
4359 | 4373 | 2003-11-30 Fernando Perez <fperez@colorado.edu> |
|
4360 | 4374 | |
|
4361 | 4375 | * IPython/iplib.py (file_matches): new completion code, courtesy |
|
4362 | 4376 | of Jeff Collins. This enables filename completion again under |
|
4363 | 4377 | python 2.3, which disabled it at the C level. |
|
4364 | 4378 | |
|
4365 | 4379 | 2003-11-11 Fernando Perez <fperez@colorado.edu> |
|
4366 | 4380 | |
|
4367 | 4381 | * IPython/numutils.py (amap): Added amap() fn. Simple shorthand |
|
4368 | 4382 | for Numeric.array(map(...)), but often convenient. |
|
4369 | 4383 | |
|
4370 | 4384 | 2003-11-05 Fernando Perez <fperez@colorado.edu> |
|
4371 | 4385 | |
|
4372 | 4386 | * IPython/numutils.py (frange): Changed a call from int() to |
|
4373 | 4387 | int(round()) to prevent a problem reported with arange() in the |
|
4374 | 4388 | numpy list. |
|
4375 | 4389 | |
|
4376 | 4390 | 2003-10-06 Fernando Perez <fperez@colorado.edu> |
|
4377 | 4391 | |
|
4378 | 4392 | * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to |
|
4379 | 4393 | prevent crashes if sys lacks an argv attribute (it happens with |
|
4380 | 4394 | embedded interpreters which build a bare-bones sys module). |
|
4381 | 4395 | Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>. |
|
4382 | 4396 | |
|
4383 | 4397 | 2003-09-24 Fernando Perez <fperez@colorado.edu> |
|
4384 | 4398 | |
|
4385 | 4399 | * IPython/Magic.py (Magic._ofind): blanket except around getattr() |
|
4386 | 4400 | to protect against poorly written user objects where __getattr__ |
|
4387 | 4401 | raises exceptions other than AttributeError. Thanks to a bug |
|
4388 | 4402 | report by Oliver Sander <osander-AT-gmx.de>. |
|
4389 | 4403 | |
|
4390 | 4404 | * IPython/FakeModule.py (FakeModule.__repr__): this method was |
|
4391 | 4405 | missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>. |
|
4392 | 4406 | |
|
4393 | 4407 | 2003-09-09 Fernando Perez <fperez@colorado.edu> |
|
4394 | 4408 | |
|
4395 | 4409 | * IPython/iplib.py (InteractiveShell._prefilter): fix bug where |
|
4396 | 4410 | unpacking a list whith a callable as first element would |
|
4397 | 4411 | mistakenly trigger autocalling. Thanks to a bug report by Jeffery |
|
4398 | 4412 | Collins. |
|
4399 | 4413 | |
|
4400 | 4414 | 2003-08-25 *** Released version 0.5.0 |
|
4401 | 4415 | |
|
4402 | 4416 | 2003-08-22 Fernando Perez <fperez@colorado.edu> |
|
4403 | 4417 | |
|
4404 | 4418 | * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of |
|
4405 | 4419 | improperly defined user exceptions. Thanks to feedback from Mark |
|
4406 | 4420 | Russell <mrussell-AT-verio.net>. |
|
4407 | 4421 | |
|
4408 | 4422 | 2003-08-20 Fernando Perez <fperez@colorado.edu> |
|
4409 | 4423 | |
|
4410 | 4424 | * IPython/OInspect.py (Inspector.pinfo): changed String Form |
|
4411 | 4425 | printing so that it would print multi-line string forms starting |
|
4412 | 4426 | with a new line. This way the formatting is better respected for |
|
4413 | 4427 | objects which work hard to make nice string forms. |
|
4414 | 4428 | |
|
4415 | 4429 | * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where |
|
4416 | 4430 | autocall would overtake data access for objects with both |
|
4417 | 4431 | __getitem__ and __call__. |
|
4418 | 4432 | |
|
4419 | 4433 | 2003-08-19 *** Released version 0.5.0-rc1 |
|
4420 | 4434 | |
|
4421 | 4435 | 2003-08-19 Fernando Perez <fperez@colorado.edu> |
|
4422 | 4436 | |
|
4423 | 4437 | * IPython/deep_reload.py (load_tail): single tiny change here |
|
4424 | 4438 | seems to fix the long-standing bug of dreload() failing to work |
|
4425 | 4439 | for dotted names. But this module is pretty tricky, so I may have |
|
4426 | 4440 | missed some subtlety. Needs more testing!. |
|
4427 | 4441 | |
|
4428 | 4442 | * IPython/ultraTB.py (VerboseTB.linereader): harden against user |
|
4429 | 4443 | exceptions which have badly implemented __str__ methods. |
|
4430 | 4444 | (VerboseTB.text): harden against inspect.getinnerframes crashing, |
|
4431 | 4445 | which I've been getting reports about from Python 2.3 users. I |
|
4432 | 4446 | wish I had a simple test case to reproduce the problem, so I could |
|
4433 | 4447 | either write a cleaner workaround or file a bug report if |
|
4434 | 4448 | necessary. |
|
4435 | 4449 | |
|
4436 | 4450 | * IPython/Magic.py (Magic.magic_edit): fixed bug where after |
|
4437 | 4451 | making a class 'foo', file 'foo.py' couldn't be edited. Thanks to |
|
4438 | 4452 | a bug report by Tjabo Kloppenburg. |
|
4439 | 4453 | |
|
4440 | 4454 | * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb |
|
4441 | 4455 | crashes. Wrapped the pdb call in a blanket try/except, since pdb |
|
4442 | 4456 | seems rather unstable. Thanks to a bug report by Tjabo |
|
4443 | 4457 | Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>. |
|
4444 | 4458 | |
|
4445 | 4459 | * IPython/Release.py (version): release 0.5.0-rc1. I want to put |
|
4446 | 4460 | this out soon because of the critical fixes in the inner loop for |
|
4447 | 4461 | generators. |
|
4448 | 4462 | |
|
4449 | 4463 | * IPython/Magic.py (Magic.getargspec): removed. This (and |
|
4450 | 4464 | _get_def) have been obsoleted by OInspect for a long time, I |
|
4451 | 4465 | hadn't noticed that they were dead code. |
|
4452 | 4466 | (Magic._ofind): restored _ofind functionality for a few literals |
|
4453 | 4467 | (those in ["''",'""','[]','{}','()']). But it won't work anymore |
|
4454 | 4468 | for things like "hello".capitalize?, since that would require a |
|
4455 | 4469 | potentially dangerous eval() again. |
|
4456 | 4470 | |
|
4457 | 4471 | * IPython/iplib.py (InteractiveShell._prefilter): reorganized the |
|
4458 | 4472 | logic a bit more to clean up the escapes handling and minimize the |
|
4459 | 4473 | use of _ofind to only necessary cases. The interactive 'feel' of |
|
4460 | 4474 | IPython should have improved quite a bit with the changes in |
|
4461 | 4475 | _prefilter and _ofind (besides being far safer than before). |
|
4462 | 4476 | |
|
4463 | 4477 | * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather |
|
4464 | 4478 | obscure, never reported). Edit would fail to find the object to |
|
4465 | 4479 | edit under some circumstances. |
|
4466 | 4480 | (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls |
|
4467 | 4481 | which were causing double-calling of generators. Those eval calls |
|
4468 | 4482 | were _very_ dangerous, since code with side effects could be |
|
4469 | 4483 | triggered. As they say, 'eval is evil'... These were the |
|
4470 | 4484 | nastiest evals in IPython. Besides, _ofind is now far simpler, |
|
4471 | 4485 | and it should also be quite a bit faster. Its use of inspect is |
|
4472 | 4486 | also safer, so perhaps some of the inspect-related crashes I've |
|
4473 | 4487 | seen lately with Python 2.3 might be taken care of. That will |
|
4474 | 4488 | need more testing. |
|
4475 | 4489 | |
|
4476 | 4490 | 2003-08-17 Fernando Perez <fperez@colorado.edu> |
|
4477 | 4491 | |
|
4478 | 4492 | * IPython/iplib.py (InteractiveShell._prefilter): significant |
|
4479 | 4493 | simplifications to the logic for handling user escapes. Faster |
|
4480 | 4494 | and simpler code. |
|
4481 | 4495 | |
|
4482 | 4496 | 2003-08-14 Fernando Perez <fperez@colorado.edu> |
|
4483 | 4497 | |
|
4484 | 4498 | * IPython/numutils.py (sum_flat): rewrote to be non-recursive. |
|
4485 | 4499 | Now it requires O(N) storage (N=size(a)) for non-contiguous input, |
|
4486 | 4500 | but it should be quite a bit faster. And the recursive version |
|
4487 | 4501 | generated O(log N) intermediate storage for all rank>1 arrays, |
|
4488 | 4502 | even if they were contiguous. |
|
4489 | 4503 | (l1norm): Added this function. |
|
4490 | 4504 | (norm): Added this function for arbitrary norms (including |
|
4491 | 4505 | l-infinity). l1 and l2 are still special cases for convenience |
|
4492 | 4506 | and speed. |
|
4493 | 4507 | |
|
4494 | 4508 | 2003-08-03 Fernando Perez <fperez@colorado.edu> |
|
4495 | 4509 | |
|
4496 | 4510 | * IPython/Magic.py (Magic.magic_edit): Removed all remaining string |
|
4497 | 4511 | exceptions, which now raise PendingDeprecationWarnings in Python |
|
4498 | 4512 | 2.3. There were some in Magic and some in Gnuplot2. |
|
4499 | 4513 | |
|
4500 | 4514 | 2003-06-30 Fernando Perez <fperez@colorado.edu> |
|
4501 | 4515 | |
|
4502 | 4516 | * IPython/genutils.py (page): modified to call curses only for |
|
4503 | 4517 | terminals where TERM=='xterm'. After problems under many other |
|
4504 | 4518 | terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>. |
|
4505 | 4519 | |
|
4506 | 4520 | * IPython/iplib.py (complete): removed spurious 'print "IE"' which |
|
4507 | 4521 | would be triggered when readline was absent. This was just an old |
|
4508 | 4522 | debugging statement I'd forgotten to take out. |
|
4509 | 4523 | |
|
4510 | 4524 | 2003-06-20 Fernando Perez <fperez@colorado.edu> |
|
4511 | 4525 | |
|
4512 | 4526 | * IPython/genutils.py (clock): modified to return only user time |
|
4513 | 4527 | (not counting system time), after a discussion on scipy. While |
|
4514 | 4528 | system time may be a useful quantity occasionally, it may much |
|
4515 | 4529 | more easily be skewed by occasional swapping or other similar |
|
4516 | 4530 | activity. |
|
4517 | 4531 | |
|
4518 | 4532 | 2003-06-05 Fernando Perez <fperez@colorado.edu> |
|
4519 | 4533 | |
|
4520 | 4534 | * IPython/numutils.py (identity): new function, for building |
|
4521 | 4535 | arbitrary rank Kronecker deltas (mostly backwards compatible with |
|
4522 | 4536 | Numeric.identity) |
|
4523 | 4537 | |
|
4524 | 4538 | 2003-06-03 Fernando Perez <fperez@colorado.edu> |
|
4525 | 4539 | |
|
4526 | 4540 | * IPython/iplib.py (InteractiveShell.handle_magic): protect |
|
4527 | 4541 | arguments passed to magics with spaces, to allow trailing '\' to |
|
4528 | 4542 | work normally (mainly for Windows users). |
|
4529 | 4543 | |
|
4530 | 4544 | 2003-05-29 Fernando Perez <fperez@colorado.edu> |
|
4531 | 4545 | |
|
4532 | 4546 | * IPython/ipmaker.py (make_IPython): Load site._Helper() as help |
|
4533 | 4547 | instead of pydoc.help. This fixes a bizarre behavior where |
|
4534 | 4548 | printing '%s' % locals() would trigger the help system. Now |
|
4535 | 4549 | ipython behaves like normal python does. |
|
4536 | 4550 | |
|
4537 | 4551 | Note that if one does 'from pydoc import help', the bizarre |
|
4538 | 4552 | behavior returns, but this will also happen in normal python, so |
|
4539 | 4553 | it's not an ipython bug anymore (it has to do with how pydoc.help |
|
4540 | 4554 | is implemented). |
|
4541 | 4555 | |
|
4542 | 4556 | 2003-05-22 Fernando Perez <fperez@colorado.edu> |
|
4543 | 4557 | |
|
4544 | 4558 | * IPython/FlexCompleter.py (Completer.attr_matches): fixed to |
|
4545 | 4559 | return [] instead of None when nothing matches, also match to end |
|
4546 | 4560 | of line. Patch by Gary Bishop. |
|
4547 | 4561 | |
|
4548 | 4562 | * IPython/ipmaker.py (make_IPython): Added same sys.excepthook |
|
4549 | 4563 | protection as before, for files passed on the command line. This |
|
4550 | 4564 | prevents the CrashHandler from kicking in if user files call into |
|
4551 | 4565 | sys.excepthook (such as PyQt and WxWindows have a nasty habit of |
|
4552 | 4566 | doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr> |
|
4553 | 4567 | |
|
4554 | 4568 | 2003-05-20 *** Released version 0.4.0 |
|
4555 | 4569 | |
|
4556 | 4570 | 2003-05-20 Fernando Perez <fperez@colorado.edu> |
|
4557 | 4571 | |
|
4558 | 4572 | * setup.py: added support for manpages. It's a bit hackish b/c of |
|
4559 | 4573 | a bug in the way the bdist_rpm distutils target handles gzipped |
|
4560 | 4574 | manpages, but it works. After a patch by Jack. |
|
4561 | 4575 | |
|
4562 | 4576 | 2003-05-19 Fernando Perez <fperez@colorado.edu> |
|
4563 | 4577 | |
|
4564 | 4578 | * IPython/numutils.py: added a mockup of the kinds module, since |
|
4565 | 4579 | it was recently removed from Numeric. This way, numutils will |
|
4566 | 4580 | work for all users even if they are missing kinds. |
|
4567 | 4581 | |
|
4568 | 4582 | * IPython/Magic.py (Magic._ofind): Harden against an inspect |
|
4569 | 4583 | failure, which can occur with SWIG-wrapped extensions. After a |
|
4570 | 4584 | crash report from Prabhu. |
|
4571 | 4585 | |
|
4572 | 4586 | 2003-05-16 Fernando Perez <fperez@colorado.edu> |
|
4573 | 4587 | |
|
4574 | 4588 | * IPython/iplib.py (InteractiveShell.excepthook): New method to |
|
4575 | 4589 | protect ipython from user code which may call directly |
|
4576 | 4590 | sys.excepthook (this looks like an ipython crash to the user, even |
|
4577 | 4591 | when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
4578 | 4592 | This is especially important to help users of WxWindows, but may |
|
4579 | 4593 | also be useful in other cases. |
|
4580 | 4594 | |
|
4581 | 4595 | * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow |
|
4582 | 4596 | an optional tb_offset to be specified, and to preserve exception |
|
4583 | 4597 | info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>. |
|
4584 | 4598 | |
|
4585 | 4599 | * ipython.1 (Default): Thanks to Jack's work, we now have manpages! |
|
4586 | 4600 | |
|
4587 | 4601 | 2003-05-15 Fernando Perez <fperez@colorado.edu> |
|
4588 | 4602 | |
|
4589 | 4603 | * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when |
|
4590 | 4604 | installing for a new user under Windows. |
|
4591 | 4605 | |
|
4592 | 4606 | 2003-05-12 Fernando Perez <fperez@colorado.edu> |
|
4593 | 4607 | |
|
4594 | 4608 | * IPython/iplib.py (InteractiveShell.handle_emacs): New line |
|
4595 | 4609 | handler for Emacs comint-based lines. Currently it doesn't do |
|
4596 | 4610 | much (but importantly, it doesn't update the history cache). In |
|
4597 | 4611 | the future it may be expanded if Alex needs more functionality |
|
4598 | 4612 | there. |
|
4599 | 4613 | |
|
4600 | 4614 | * IPython/CrashHandler.py (CrashHandler.__call__): Added platform |
|
4601 | 4615 | info to crash reports. |
|
4602 | 4616 | |
|
4603 | 4617 | * IPython/iplib.py (InteractiveShell.mainloop): Added -c option, |
|
4604 | 4618 | just like Python's -c. Also fixed crash with invalid -color |
|
4605 | 4619 | option value at startup. Thanks to Will French |
|
4606 | 4620 | <wfrench-AT-bestweb.net> for the bug report. |
|
4607 | 4621 | |
|
4608 | 4622 | 2003-05-09 Fernando Perez <fperez@colorado.edu> |
|
4609 | 4623 | |
|
4610 | 4624 | * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString |
|
4611 | 4625 | to EvalDict (it's a mapping, after all) and simplified its code |
|
4612 | 4626 | quite a bit, after a nice discussion on c.l.py where Gustavo |
|
4613 | 4627 | CΓ³rdova <gcordova-AT-sismex.com> suggested the new version. |
|
4614 | 4628 | |
|
4615 | 4629 | 2003-04-30 Fernando Perez <fperez@colorado.edu> |
|
4616 | 4630 | |
|
4617 | 4631 | * IPython/genutils.py (timings_out): modified it to reduce its |
|
4618 | 4632 | overhead in the common reps==1 case. |
|
4619 | 4633 | |
|
4620 | 4634 | 2003-04-29 Fernando Perez <fperez@colorado.edu> |
|
4621 | 4635 | |
|
4622 | 4636 | * IPython/genutils.py (timings_out): Modified to use the resource |
|
4623 | 4637 | module, which avoids the wraparound problems of time.clock(). |
|
4624 | 4638 | |
|
4625 | 4639 | 2003-04-17 *** Released version 0.2.15pre4 |
|
4626 | 4640 | |
|
4627 | 4641 | 2003-04-17 Fernando Perez <fperez@colorado.edu> |
|
4628 | 4642 | |
|
4629 | 4643 | * setup.py (scriptfiles): Split windows-specific stuff over to a |
|
4630 | 4644 | separate file, in an attempt to have a Windows GUI installer. |
|
4631 | 4645 | That didn't work, but part of the groundwork is done. |
|
4632 | 4646 | |
|
4633 | 4647 | * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for |
|
4634 | 4648 | indent/unindent with 4 spaces. Particularly useful in combination |
|
4635 | 4649 | with the new auto-indent option. |
|
4636 | 4650 | |
|
4637 | 4651 | 2003-04-16 Fernando Perez <fperez@colorado.edu> |
|
4638 | 4652 | |
|
4639 | 4653 | * IPython/Magic.py: various replacements of self.rc for |
|
4640 | 4654 | self.shell.rc. A lot more remains to be done to fully disentangle |
|
4641 | 4655 | this class from the main Shell class. |
|
4642 | 4656 | |
|
4643 | 4657 | * IPython/GnuplotRuntime.py: added checks for mouse support so |
|
4644 | 4658 | that we don't try to enable it if the current gnuplot doesn't |
|
4645 | 4659 | really support it. Also added checks so that we don't try to |
|
4646 | 4660 | enable persist under Windows (where Gnuplot doesn't recognize the |
|
4647 | 4661 | option). |
|
4648 | 4662 | |
|
4649 | 4663 | * IPython/iplib.py (InteractiveShell.interact): Added optional |
|
4650 | 4664 | auto-indenting code, after a patch by King C. Shu |
|
4651 | 4665 | <kingshu-AT-myrealbox.com>. It's off by default because it doesn't |
|
4652 | 4666 | get along well with pasting indented code. If I ever figure out |
|
4653 | 4667 | how to make that part go well, it will become on by default. |
|
4654 | 4668 | |
|
4655 | 4669 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would |
|
4656 | 4670 | crash ipython if there was an unmatched '%' in the user's prompt |
|
4657 | 4671 | string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
4658 | 4672 | |
|
4659 | 4673 | * IPython/iplib.py (InteractiveShell.interact): removed the |
|
4660 | 4674 | ability to ask the user whether he wants to crash or not at the |
|
4661 | 4675 | 'last line' exception handler. Calling functions at that point |
|
4662 | 4676 | changes the stack, and the error reports would have incorrect |
|
4663 | 4677 | tracebacks. |
|
4664 | 4678 | |
|
4665 | 4679 | * IPython/Magic.py (Magic.magic_page): Added new @page magic, to |
|
4666 | 4680 | pass through a peger a pretty-printed form of any object. After a |
|
4667 | 4681 | contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr> |
|
4668 | 4682 | |
|
4669 | 4683 | 2003-04-14 Fernando Perez <fperez@colorado.edu> |
|
4670 | 4684 | |
|
4671 | 4685 | * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where |
|
4672 | 4686 | all files in ~ would be modified at first install (instead of |
|
4673 | 4687 | ~/.ipython). This could be potentially disastrous, as the |
|
4674 | 4688 | modification (make line-endings native) could damage binary files. |
|
4675 | 4689 | |
|
4676 | 4690 | 2003-04-10 Fernando Perez <fperez@colorado.edu> |
|
4677 | 4691 | |
|
4678 | 4692 | * IPython/iplib.py (InteractiveShell.handle_help): Modified to |
|
4679 | 4693 | handle only lines which are invalid python. This now means that |
|
4680 | 4694 | lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins |
|
4681 | 4695 | for the bug report. |
|
4682 | 4696 | |
|
4683 | 4697 | 2003-04-01 Fernando Perez <fperez@colorado.edu> |
|
4684 | 4698 | |
|
4685 | 4699 | * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug |
|
4686 | 4700 | where failing to set sys.last_traceback would crash pdb.pm(). |
|
4687 | 4701 | Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug |
|
4688 | 4702 | report. |
|
4689 | 4703 | |
|
4690 | 4704 | 2003-03-25 Fernando Perez <fperez@colorado.edu> |
|
4691 | 4705 | |
|
4692 | 4706 | * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler |
|
4693 | 4707 | before printing it (it had a lot of spurious blank lines at the |
|
4694 | 4708 | end). |
|
4695 | 4709 | |
|
4696 | 4710 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr |
|
4697 | 4711 | output would be sent 21 times! Obviously people don't use this |
|
4698 | 4712 | too often, or I would have heard about it. |
|
4699 | 4713 | |
|
4700 | 4714 | 2003-03-24 Fernando Perez <fperez@colorado.edu> |
|
4701 | 4715 | |
|
4702 | 4716 | * setup.py (scriptfiles): renamed the data_files parameter from |
|
4703 | 4717 | 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink |
|
4704 | 4718 | for the patch. |
|
4705 | 4719 | |
|
4706 | 4720 | 2003-03-20 Fernando Perez <fperez@colorado.edu> |
|
4707 | 4721 | |
|
4708 | 4722 | * IPython/genutils.py (error): added error() and fatal() |
|
4709 | 4723 | functions. |
|
4710 | 4724 | |
|
4711 | 4725 | 2003-03-18 *** Released version 0.2.15pre3 |
|
4712 | 4726 | |
|
4713 | 4727 | 2003-03-18 Fernando Perez <fperez@colorado.edu> |
|
4714 | 4728 | |
|
4715 | 4729 | * setupext/install_data_ext.py |
|
4716 | 4730 | (install_data_ext.initialize_options): Class contributed by Jack |
|
4717 | 4731 | Moffit for fixing the old distutils hack. He is sending this to |
|
4718 | 4732 | the distutils folks so in the future we may not need it as a |
|
4719 | 4733 | private fix. |
|
4720 | 4734 | |
|
4721 | 4735 | * MANIFEST.in: Extensive reorganization, based on Jack Moffit's |
|
4722 | 4736 | changes for Debian packaging. See his patch for full details. |
|
4723 | 4737 | The old distutils hack of making the ipythonrc* files carry a |
|
4724 | 4738 | bogus .py extension is gone, at last. Examples were moved to a |
|
4725 | 4739 | separate subdir under doc/, and the separate executable scripts |
|
4726 | 4740 | now live in their own directory. Overall a great cleanup. The |
|
4727 | 4741 | manual was updated to use the new files, and setup.py has been |
|
4728 | 4742 | fixed for this setup. |
|
4729 | 4743 | |
|
4730 | 4744 | * IPython/PyColorize.py (Parser.usage): made non-executable and |
|
4731 | 4745 | created a pycolor wrapper around it to be included as a script. |
|
4732 | 4746 | |
|
4733 | 4747 | 2003-03-12 *** Released version 0.2.15pre2 |
|
4734 | 4748 | |
|
4735 | 4749 | 2003-03-12 Fernando Perez <fperez@colorado.edu> |
|
4736 | 4750 | |
|
4737 | 4751 | * IPython/ColorANSI.py (make_color_table): Finally fixed the |
|
4738 | 4752 | long-standing problem with garbage characters in some terminals. |
|
4739 | 4753 | The issue was really that the \001 and \002 escapes must _only_ be |
|
4740 | 4754 | passed to input prompts (which call readline), but _never_ to |
|
4741 | 4755 | normal text to be printed on screen. I changed ColorANSI to have |
|
4742 | 4756 | two classes: TermColors and InputTermColors, each with the |
|
4743 | 4757 | appropriate escapes for input prompts or normal text. The code in |
|
4744 | 4758 | Prompts.py got slightly more complicated, but this very old and |
|
4745 | 4759 | annoying bug is finally fixed. |
|
4746 | 4760 | |
|
4747 | 4761 | All the credit for nailing down the real origin of this problem |
|
4748 | 4762 | and the correct solution goes to Jack Moffit <jack-AT-xiph.org>. |
|
4749 | 4763 | *Many* thanks to him for spending quite a bit of effort on this. |
|
4750 | 4764 | |
|
4751 | 4765 | 2003-03-05 *** Released version 0.2.15pre1 |
|
4752 | 4766 | |
|
4753 | 4767 | 2003-03-03 Fernando Perez <fperez@colorado.edu> |
|
4754 | 4768 | |
|
4755 | 4769 | * IPython/FakeModule.py: Moved the former _FakeModule to a |
|
4756 | 4770 | separate file, because it's also needed by Magic (to fix a similar |
|
4757 | 4771 | pickle-related issue in @run). |
|
4758 | 4772 | |
|
4759 | 4773 | 2003-03-02 Fernando Perez <fperez@colorado.edu> |
|
4760 | 4774 | |
|
4761 | 4775 | * IPython/Magic.py (Magic.magic_autocall): new magic to control |
|
4762 | 4776 | the autocall option at runtime. |
|
4763 | 4777 | (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns |
|
4764 | 4778 | across Magic.py to start separating Magic from InteractiveShell. |
|
4765 | 4779 | (Magic._ofind): Fixed to return proper namespace for dotted |
|
4766 | 4780 | names. Before, a dotted name would always return 'not currently |
|
4767 | 4781 | defined', because it would find the 'parent'. s.x would be found, |
|
4768 | 4782 | but since 'x' isn't defined by itself, it would get confused. |
|
4769 | 4783 | (Magic.magic_run): Fixed pickling problems reported by Ralf |
|
4770 | 4784 | Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to |
|
4771 | 4785 | that I'd used when Mike Heeter reported similar issues at the |
|
4772 | 4786 | top-level, but now for @run. It boils down to injecting the |
|
4773 | 4787 | namespace where code is being executed with something that looks |
|
4774 | 4788 | enough like a module to fool pickle.dump(). Since a pickle stores |
|
4775 | 4789 | a named reference to the importing module, we need this for |
|
4776 | 4790 | pickles to save something sensible. |
|
4777 | 4791 | |
|
4778 | 4792 | * IPython/ipmaker.py (make_IPython): added an autocall option. |
|
4779 | 4793 | |
|
4780 | 4794 | * IPython/iplib.py (InteractiveShell._prefilter): reordered all of |
|
4781 | 4795 | the auto-eval code. Now autocalling is an option, and the code is |
|
4782 | 4796 | also vastly safer. There is no more eval() involved at all. |
|
4783 | 4797 | |
|
4784 | 4798 | 2003-03-01 Fernando Perez <fperez@colorado.edu> |
|
4785 | 4799 | |
|
4786 | 4800 | * IPython/Magic.py (Magic._ofind): Changed interface to return a |
|
4787 | 4801 | dict with named keys instead of a tuple. |
|
4788 | 4802 | |
|
4789 | 4803 | * IPython: Started using CVS for IPython as of 0.2.15pre1. |
|
4790 | 4804 | |
|
4791 | 4805 | * setup.py (make_shortcut): Fixed message about directories |
|
4792 | 4806 | created during Windows installation (the directories were ok, just |
|
4793 | 4807 | the printed message was misleading). Thanks to Chris Liechti |
|
4794 | 4808 | <cliechti-AT-gmx.net> for the heads up. |
|
4795 | 4809 | |
|
4796 | 4810 | 2003-02-21 Fernando Perez <fperez@colorado.edu> |
|
4797 | 4811 | |
|
4798 | 4812 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching |
|
4799 | 4813 | of ValueError exception when checking for auto-execution. This |
|
4800 | 4814 | one is raised by things like Numeric arrays arr.flat when the |
|
4801 | 4815 | array is non-contiguous. |
|
4802 | 4816 | |
|
4803 | 4817 | 2003-01-31 Fernando Perez <fperez@colorado.edu> |
|
4804 | 4818 | |
|
4805 | 4819 | * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would |
|
4806 | 4820 | not return any value at all (even though the command would get |
|
4807 | 4821 | executed). |
|
4808 | 4822 | (xsys): Flush stdout right after printing the command to ensure |
|
4809 | 4823 | proper ordering of commands and command output in the total |
|
4810 | 4824 | output. |
|
4811 | 4825 | (SystemExec/xsys/bq): Switched the names of xsys/bq and |
|
4812 | 4826 | system/getoutput as defaults. The old ones are kept for |
|
4813 | 4827 | compatibility reasons, so no code which uses this library needs |
|
4814 | 4828 | changing. |
|
4815 | 4829 | |
|
4816 | 4830 | 2003-01-27 *** Released version 0.2.14 |
|
4817 | 4831 | |
|
4818 | 4832 | 2003-01-25 Fernando Perez <fperez@colorado.edu> |
|
4819 | 4833 | |
|
4820 | 4834 | * IPython/Magic.py (Magic.magic_edit): Fixed problem where |
|
4821 | 4835 | functions defined in previous edit sessions could not be re-edited |
|
4822 | 4836 | (because the temp files were immediately removed). Now temp files |
|
4823 | 4837 | are removed only at IPython's exit. |
|
4824 | 4838 | (Magic.magic_run): Improved @run to perform shell-like expansions |
|
4825 | 4839 | on its arguments (~users and $VARS). With this, @run becomes more |
|
4826 | 4840 | like a normal command-line. |
|
4827 | 4841 | |
|
4828 | 4842 | * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small |
|
4829 | 4843 | bugs related to embedding and cleaned up that code. A fairly |
|
4830 | 4844 | important one was the impossibility to access the global namespace |
|
4831 | 4845 | through the embedded IPython (only local variables were visible). |
|
4832 | 4846 | |
|
4833 | 4847 | 2003-01-14 Fernando Perez <fperez@colorado.edu> |
|
4834 | 4848 | |
|
4835 | 4849 | * IPython/iplib.py (InteractiveShell._prefilter): Fixed |
|
4836 | 4850 | auto-calling to be a bit more conservative. Now it doesn't get |
|
4837 | 4851 | triggered if any of '!=()<>' are in the rest of the input line, to |
|
4838 | 4852 | allow comparing callables. Thanks to Alex for the heads up. |
|
4839 | 4853 | |
|
4840 | 4854 | 2003-01-07 Fernando Perez <fperez@colorado.edu> |
|
4841 | 4855 | |
|
4842 | 4856 | * IPython/genutils.py (page): fixed estimation of the number of |
|
4843 | 4857 | lines in a string to be paged to simply count newlines. This |
|
4844 | 4858 | prevents over-guessing due to embedded escape sequences. A better |
|
4845 | 4859 | long-term solution would involve stripping out the control chars |
|
4846 | 4860 | for the count, but it's potentially so expensive I just don't |
|
4847 | 4861 | think it's worth doing. |
|
4848 | 4862 | |
|
4849 | 4863 | 2002-12-19 *** Released version 0.2.14pre50 |
|
4850 | 4864 | |
|
4851 | 4865 | 2002-12-19 Fernando Perez <fperez@colorado.edu> |
|
4852 | 4866 | |
|
4853 | 4867 | * tools/release (version): Changed release scripts to inform |
|
4854 | 4868 | Andrea and build a NEWS file with a list of recent changes. |
|
4855 | 4869 | |
|
4856 | 4870 | * IPython/ColorANSI.py (__all__): changed terminal detection |
|
4857 | 4871 | code. Seems to work better for xterms without breaking |
|
4858 | 4872 | konsole. Will need more testing to determine if WinXP and Mac OSX |
|
4859 | 4873 | also work ok. |
|
4860 | 4874 | |
|
4861 | 4875 | 2002-12-18 *** Released version 0.2.14pre49 |
|
4862 | 4876 | |
|
4863 | 4877 | 2002-12-18 Fernando Perez <fperez@colorado.edu> |
|
4864 | 4878 | |
|
4865 | 4879 | * Docs: added new info about Mac OSX, from Andrea. |
|
4866 | 4880 | |
|
4867 | 4881 | * IPython/Gnuplot2.py (String): Added a String PlotItem class to |
|
4868 | 4882 | allow direct plotting of python strings whose format is the same |
|
4869 | 4883 | of gnuplot data files. |
|
4870 | 4884 | |
|
4871 | 4885 | 2002-12-16 Fernando Perez <fperez@colorado.edu> |
|
4872 | 4886 | |
|
4873 | 4887 | * IPython/iplib.py (InteractiveShell.interact): fixed default (y) |
|
4874 | 4888 | value of exit question to be acknowledged. |
|
4875 | 4889 | |
|
4876 | 4890 | 2002-12-03 Fernando Perez <fperez@colorado.edu> |
|
4877 | 4891 | |
|
4878 | 4892 | * IPython/ipmaker.py: removed generators, which had been added |
|
4879 | 4893 | by mistake in an earlier debugging run. This was causing trouble |
|
4880 | 4894 | to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu> |
|
4881 | 4895 | for pointing this out. |
|
4882 | 4896 | |
|
4883 | 4897 | 2002-11-17 Fernando Perez <fperez@colorado.edu> |
|
4884 | 4898 | |
|
4885 | 4899 | * Manual: updated the Gnuplot section. |
|
4886 | 4900 | |
|
4887 | 4901 | * IPython/GnuplotRuntime.py: refactored a lot all this code, with |
|
4888 | 4902 | a much better split of what goes in Runtime and what goes in |
|
4889 | 4903 | Interactive. |
|
4890 | 4904 | |
|
4891 | 4905 | * IPython/ipmaker.py: fixed bug where import_fail_info wasn't |
|
4892 | 4906 | being imported from iplib. |
|
4893 | 4907 | |
|
4894 | 4908 | * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc |
|
4895 | 4909 | for command-passing. Now the global Gnuplot instance is called |
|
4896 | 4910 | 'gp' instead of 'g', which was really a far too fragile and |
|
4897 | 4911 | common name. |
|
4898 | 4912 | |
|
4899 | 4913 | * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken |
|
4900 | 4914 | bounding boxes generated by Gnuplot for square plots. |
|
4901 | 4915 | |
|
4902 | 4916 | * IPython/genutils.py (popkey): new function added. I should |
|
4903 | 4917 | suggest this on c.l.py as a dict method, it seems useful. |
|
4904 | 4918 | |
|
4905 | 4919 | * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot |
|
4906 | 4920 | to transparently handle PostScript generation. MUCH better than |
|
4907 | 4921 | the previous plot_eps/replot_eps (which I removed now). The code |
|
4908 | 4922 | is also fairly clean and well documented now (including |
|
4909 | 4923 | docstrings). |
|
4910 | 4924 | |
|
4911 | 4925 | 2002-11-13 Fernando Perez <fperez@colorado.edu> |
|
4912 | 4926 | |
|
4913 | 4927 | * IPython/Magic.py (Magic.magic_edit): fixed docstring |
|
4914 | 4928 | (inconsistent with options). |
|
4915 | 4929 | |
|
4916 | 4930 | * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been |
|
4917 | 4931 | manually disabled, I don't know why. Fixed it. |
|
4918 | 4932 | (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly |
|
4919 | 4933 | eps output. |
|
4920 | 4934 | |
|
4921 | 4935 | 2002-11-12 Fernando Perez <fperez@colorado.edu> |
|
4922 | 4936 | |
|
4923 | 4937 | * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they |
|
4924 | 4938 | don't propagate up to caller. Fixes crash reported by François |
|
4925 | 4939 | Pinard. |
|
4926 | 4940 | |
|
4927 | 4941 | 2002-11-09 Fernando Perez <fperez@colorado.edu> |
|
4928 | 4942 | |
|
4929 | 4943 | * IPython/ipmaker.py (make_IPython): fixed problem with writing |
|
4930 | 4944 | history file for new users. |
|
4931 | 4945 | (make_IPython): fixed bug where initial install would leave the |
|
4932 | 4946 | user running in the .ipython dir. |
|
4933 | 4947 | (make_IPython): fixed bug where config dir .ipython would be |
|
4934 | 4948 | created regardless of the given -ipythondir option. Thanks to Cory |
|
4935 | 4949 | Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report. |
|
4936 | 4950 | |
|
4937 | 4951 | * IPython/genutils.py (ask_yes_no): new function for asking yes/no |
|
4938 | 4952 | type confirmations. Will need to use it in all of IPython's code |
|
4939 | 4953 | consistently. |
|
4940 | 4954 | |
|
4941 | 4955 | * IPython/CrashHandler.py (CrashHandler.__call__): changed the |
|
4942 | 4956 | context to print 31 lines instead of the default 5. This will make |
|
4943 | 4957 | the crash reports extremely detailed in case the problem is in |
|
4944 | 4958 | libraries I don't have access to. |
|
4945 | 4959 | |
|
4946 | 4960 | * IPython/iplib.py (InteractiveShell.interact): changed the 'last |
|
4947 | 4961 | line of defense' code to still crash, but giving users fair |
|
4948 | 4962 | warning. I don't want internal errors to go unreported: if there's |
|
4949 | 4963 | an internal problem, IPython should crash and generate a full |
|
4950 | 4964 | report. |
|
4951 | 4965 | |
|
4952 | 4966 | 2002-11-08 Fernando Perez <fperez@colorado.edu> |
|
4953 | 4967 | |
|
4954 | 4968 | * IPython/iplib.py (InteractiveShell.interact): added code to trap |
|
4955 | 4969 | otherwise uncaught exceptions which can appear if people set |
|
4956 | 4970 | sys.stdout to something badly broken. Thanks to a crash report |
|
4957 | 4971 | from henni-AT-mail.brainbot.com. |
|
4958 | 4972 | |
|
4959 | 4973 | 2002-11-04 Fernando Perez <fperez@colorado.edu> |
|
4960 | 4974 | |
|
4961 | 4975 | * IPython/iplib.py (InteractiveShell.interact): added |
|
4962 | 4976 | __IPYTHON__active to the builtins. It's a flag which goes on when |
|
4963 | 4977 | the interaction starts and goes off again when it stops. This |
|
4964 | 4978 | allows embedding code to detect being inside IPython. Before this |
|
4965 | 4979 | was done via __IPYTHON__, but that only shows that an IPython |
|
4966 | 4980 | instance has been created. |
|
4967 | 4981 | |
|
4968 | 4982 | * IPython/Magic.py (Magic.magic_env): I realized that in a |
|
4969 | 4983 | UserDict, instance.data holds the data as a normal dict. So I |
|
4970 | 4984 | modified @env to return os.environ.data instead of rebuilding a |
|
4971 | 4985 | dict by hand. |
|
4972 | 4986 | |
|
4973 | 4987 | 2002-11-02 Fernando Perez <fperez@colorado.edu> |
|
4974 | 4988 | |
|
4975 | 4989 | * IPython/genutils.py (warn): changed so that level 1 prints no |
|
4976 | 4990 | header. Level 2 is now the default (with 'WARNING' header, as |
|
4977 | 4991 | before). I think I tracked all places where changes were needed in |
|
4978 | 4992 | IPython, but outside code using the old level numbering may have |
|
4979 | 4993 | broken. |
|
4980 | 4994 | |
|
4981 | 4995 | * IPython/iplib.py (InteractiveShell.runcode): added this to |
|
4982 | 4996 | handle the tracebacks in SystemExit traps correctly. The previous |
|
4983 | 4997 | code (through interact) was printing more of the stack than |
|
4984 | 4998 | necessary, showing IPython internal code to the user. |
|
4985 | 4999 | |
|
4986 | 5000 | * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by |
|
4987 | 5001 | default. Now that the default at the confirmation prompt is yes, |
|
4988 | 5002 | it's not so intrusive. François' argument that ipython sessions |
|
4989 | 5003 | tend to be complex enough not to lose them from an accidental C-d, |
|
4990 | 5004 | is a valid one. |
|
4991 | 5005 | |
|
4992 | 5006 | * IPython/iplib.py (InteractiveShell.interact): added a |
|
4993 | 5007 | showtraceback() call to the SystemExit trap, and modified the exit |
|
4994 | 5008 | confirmation to have yes as the default. |
|
4995 | 5009 | |
|
4996 | 5010 | * IPython/UserConfig/ipythonrc.py: removed 'session' option from |
|
4997 | 5011 | this file. It's been gone from the code for a long time, this was |
|
4998 | 5012 | simply leftover junk. |
|
4999 | 5013 | |
|
5000 | 5014 | 2002-11-01 Fernando Perez <fperez@colorado.edu> |
|
5001 | 5015 | |
|
5002 | 5016 | * IPython/UserConfig/ipythonrc.py: new confirm_exit option |
|
5003 | 5017 | added. If set, IPython now traps EOF and asks for |
|
5004 | 5018 | confirmation. After a request by François Pinard. |
|
5005 | 5019 | |
|
5006 | 5020 | * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead |
|
5007 | 5021 | of @abort, and with a new (better) mechanism for handling the |
|
5008 | 5022 | exceptions. |
|
5009 | 5023 | |
|
5010 | 5024 | 2002-10-27 Fernando Perez <fperez@colorado.edu> |
|
5011 | 5025 | |
|
5012 | 5026 | * IPython/usage.py (__doc__): updated the --help information and |
|
5013 | 5027 | the ipythonrc file to indicate that -log generates |
|
5014 | 5028 | ./ipython.log. Also fixed the corresponding info in @logstart. |
|
5015 | 5029 | This and several other fixes in the manuals thanks to reports by |
|
5016 | 5030 | François Pinard <pinard-AT-iro.umontreal.ca>. |
|
5017 | 5031 | |
|
5018 | 5032 | * IPython/Logger.py (Logger.switch_log): Fixed error message to |
|
5019 | 5033 | refer to @logstart (instead of @log, which doesn't exist). |
|
5020 | 5034 | |
|
5021 | 5035 | * IPython/iplib.py (InteractiveShell._prefilter): fixed |
|
5022 | 5036 | AttributeError crash. Thanks to Christopher Armstrong |
|
5023 | 5037 | <radix-AT-twistedmatrix.com> for the report/fix. This bug had been |
|
5024 | 5038 | introduced recently (in 0.2.14pre37) with the fix to the eval |
|
5025 | 5039 | problem mentioned below. |
|
5026 | 5040 | |
|
5027 | 5041 | 2002-10-17 Fernando Perez <fperez@colorado.edu> |
|
5028 | 5042 | |
|
5029 | 5043 | * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows |
|
5030 | 5044 | installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>. |
|
5031 | 5045 | |
|
5032 | 5046 | * IPython/iplib.py (InteractiveShell._prefilter): Many changes to |
|
5033 | 5047 | this function to fix a problem reported by Alex Schmolck. He saw |
|
5034 | 5048 | it with list comprehensions and generators, which were getting |
|
5035 | 5049 | called twice. The real problem was an 'eval' call in testing for |
|
5036 | 5050 | automagic which was evaluating the input line silently. |
|
5037 | 5051 | |
|
5038 | 5052 | This is a potentially very nasty bug, if the input has side |
|
5039 | 5053 | effects which must not be repeated. The code is much cleaner now, |
|
5040 | 5054 | without any blanket 'except' left and with a regexp test for |
|
5041 | 5055 | actual function names. |
|
5042 | 5056 | |
|
5043 | 5057 | But an eval remains, which I'm not fully comfortable with. I just |
|
5044 | 5058 | don't know how to find out if an expression could be a callable in |
|
5045 | 5059 | the user's namespace without doing an eval on the string. However |
|
5046 | 5060 | that string is now much more strictly checked so that no code |
|
5047 | 5061 | slips by, so the eval should only happen for things that can |
|
5048 | 5062 | really be only function/method names. |
|
5049 | 5063 | |
|
5050 | 5064 | 2002-10-15 Fernando Perez <fperez@colorado.edu> |
|
5051 | 5065 | |
|
5052 | 5066 | * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac |
|
5053 | 5067 | OSX information to main manual, removed README_Mac_OSX file from |
|
5054 | 5068 | distribution. Also updated credits for recent additions. |
|
5055 | 5069 | |
|
5056 | 5070 | 2002-10-10 Fernando Perez <fperez@colorado.edu> |
|
5057 | 5071 | |
|
5058 | 5072 | * README_Mac_OSX: Added a README for Mac OSX users for fixing |
|
5059 | 5073 | terminal-related issues. Many thanks to Andrea Riciputi |
|
5060 | 5074 | <andrea.riciputi-AT-libero.it> for writing it. |
|
5061 | 5075 | |
|
5062 | 5076 | * IPython/UserConfig/ipythonrc.py: Fixes to various small issues, |
|
5063 | 5077 | thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>. |
|
5064 | 5078 | |
|
5065 | 5079 | * setup.py (make_shortcut): Fixes for Windows installation. Thanks |
|
5066 | 5080 | to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad |
|
5067 | 5081 | <syver-en-AT-online.no> who both submitted patches for this problem. |
|
5068 | 5082 | |
|
5069 | 5083 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for |
|
5070 | 5084 | global embedding to make sure that things don't overwrite user |
|
5071 | 5085 | globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com> |
|
5072 | 5086 | |
|
5073 | 5087 | * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6 |
|
5074 | 5088 | compatibility. Thanks to Hayden Callow |
|
5075 | 5089 | <h.callow-AT-elec.canterbury.ac.nz> |
|
5076 | 5090 | |
|
5077 | 5091 | 2002-10-04 Fernando Perez <fperez@colorado.edu> |
|
5078 | 5092 | |
|
5079 | 5093 | * IPython/Gnuplot2.py (PlotItem): Added 'index' option for |
|
5080 | 5094 | Gnuplot.File objects. |
|
5081 | 5095 | |
|
5082 | 5096 | 2002-07-23 Fernando Perez <fperez@colorado.edu> |
|
5083 | 5097 | |
|
5084 | 5098 | * IPython/genutils.py (timing): Added timings() and timing() for |
|
5085 | 5099 | quick access to the most commonly needed data, the execution |
|
5086 | 5100 | times. Old timing() renamed to timings_out(). |
|
5087 | 5101 | |
|
5088 | 5102 | 2002-07-18 Fernando Perez <fperez@colorado.edu> |
|
5089 | 5103 | |
|
5090 | 5104 | * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed |
|
5091 | 5105 | bug with nested instances disrupting the parent's tab completion. |
|
5092 | 5106 | |
|
5093 | 5107 | * IPython/iplib.py (all_completions): Added Alex Schmolck's |
|
5094 | 5108 | all_completions code to begin the emacs integration. |
|
5095 | 5109 | |
|
5096 | 5110 | * IPython/Gnuplot2.py (zip_items): Added optional 'titles' |
|
5097 | 5111 | argument to allow titling individual arrays when plotting. |
|
5098 | 5112 | |
|
5099 | 5113 | 2002-07-15 Fernando Perez <fperez@colorado.edu> |
|
5100 | 5114 | |
|
5101 | 5115 | * setup.py (make_shortcut): changed to retrieve the value of |
|
5102 | 5116 | 'Program Files' directory from the registry (this value changes in |
|
5103 | 5117 | non-english versions of Windows). Thanks to Thomas Fanslau |
|
5104 | 5118 | <tfanslau-AT-gmx.de> for the report. |
|
5105 | 5119 | |
|
5106 | 5120 | 2002-07-10 Fernando Perez <fperez@colorado.edu> |
|
5107 | 5121 | |
|
5108 | 5122 | * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for |
|
5109 | 5123 | a bug in pdb, which crashes if a line with only whitespace is |
|
5110 | 5124 | entered. Bug report submitted to sourceforge. |
|
5111 | 5125 | |
|
5112 | 5126 | 2002-07-09 Fernando Perez <fperez@colorado.edu> |
|
5113 | 5127 | |
|
5114 | 5128 | * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when |
|
5115 | 5129 | reporting exceptions (it's a bug in inspect.py, I just set a |
|
5116 | 5130 | workaround). |
|
5117 | 5131 | |
|
5118 | 5132 | 2002-07-08 Fernando Perez <fperez@colorado.edu> |
|
5119 | 5133 | |
|
5120 | 5134 | * IPython/iplib.py (InteractiveShell.__init__): fixed reference to |
|
5121 | 5135 | __IPYTHON__ in __builtins__ to show up in user_ns. |
|
5122 | 5136 | |
|
5123 | 5137 | 2002-07-03 Fernando Perez <fperez@colorado.edu> |
|
5124 | 5138 | |
|
5125 | 5139 | * IPython/GnuplotInteractive.py (magic_gp_set_default): changed |
|
5126 | 5140 | name from @gp_set_instance to @gp_set_default. |
|
5127 | 5141 | |
|
5128 | 5142 | * IPython/ipmaker.py (make_IPython): default editor value set to |
|
5129 | 5143 | '0' (a string), to match the rc file. Otherwise will crash when |
|
5130 | 5144 | .strip() is called on it. |
|
5131 | 5145 | |
|
5132 | 5146 | |
|
5133 | 5147 | 2002-06-28 Fernando Perez <fperez@colorado.edu> |
|
5134 | 5148 | |
|
5135 | 5149 | * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing |
|
5136 | 5150 | of files in current directory when a file is executed via |
|
5137 | 5151 | @run. Patch also by RA <ralf_ahlbrink-AT-web.de>. |
|
5138 | 5152 | |
|
5139 | 5153 | * setup.py (manfiles): fix for rpm builds, submitted by RA |
|
5140 | 5154 | <ralf_ahlbrink-AT-web.de>. Now we have RPMs! |
|
5141 | 5155 | |
|
5142 | 5156 | * IPython/ipmaker.py (make_IPython): fixed lookup of default |
|
5143 | 5157 | editor when set to '0'. Problem was, '0' evaluates to True (it's a |
|
5144 | 5158 | string!). A. Schmolck caught this one. |
|
5145 | 5159 | |
|
5146 | 5160 | 2002-06-27 Fernando Perez <fperez@colorado.edu> |
|
5147 | 5161 | |
|
5148 | 5162 | * IPython/ipmaker.py (make_IPython): fixed bug when running user |
|
5149 | 5163 | defined files at the cmd line. __name__ wasn't being set to |
|
5150 | 5164 | __main__. |
|
5151 | 5165 | |
|
5152 | 5166 | * IPython/Gnuplot2.py (zip_items): improved it so it can plot also |
|
5153 | 5167 | regular lists and tuples besides Numeric arrays. |
|
5154 | 5168 | |
|
5155 | 5169 | * IPython/Prompts.py (CachedOutput.__call__): Added output |
|
5156 | 5170 | supression for input ending with ';'. Similar to Mathematica and |
|
5157 | 5171 | Matlab. The _* vars and Out[] list are still updated, just like |
|
5158 | 5172 | Mathematica behaves. |
|
5159 | 5173 | |
|
5160 | 5174 | 2002-06-25 Fernando Perez <fperez@colorado.edu> |
|
5161 | 5175 | |
|
5162 | 5176 | * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of |
|
5163 | 5177 | .ini extensions for profiels under Windows. |
|
5164 | 5178 | |
|
5165 | 5179 | * IPython/OInspect.py (Inspector.pinfo): improved alignment of |
|
5166 | 5180 | string form. Fix contributed by Alexander Schmolck |
|
5167 | 5181 | <a.schmolck-AT-gmx.net> |
|
5168 | 5182 | |
|
5169 | 5183 | * IPython/GnuplotRuntime.py (gp_new): new function. Returns a |
|
5170 | 5184 | pre-configured Gnuplot instance. |
|
5171 | 5185 | |
|
5172 | 5186 | 2002-06-21 Fernando Perez <fperez@colorado.edu> |
|
5173 | 5187 | |
|
5174 | 5188 | * IPython/numutils.py (exp_safe): new function, works around the |
|
5175 | 5189 | underflow problems in Numeric. |
|
5176 | 5190 | (log2): New fn. Safe log in base 2: returns exact integer answer |
|
5177 | 5191 | for exact integer powers of 2. |
|
5178 | 5192 | |
|
5179 | 5193 | * IPython/Magic.py (get_py_filename): fixed it not expanding '~' |
|
5180 | 5194 | properly. |
|
5181 | 5195 | |
|
5182 | 5196 | 2002-06-20 Fernando Perez <fperez@colorado.edu> |
|
5183 | 5197 | |
|
5184 | 5198 | * IPython/genutils.py (timing): new function like |
|
5185 | 5199 | Mathematica's. Similar to time_test, but returns more info. |
|
5186 | 5200 | |
|
5187 | 5201 | 2002-06-18 Fernando Perez <fperez@colorado.edu> |
|
5188 | 5202 | |
|
5189 | 5203 | * IPython/Magic.py (Magic.magic_save): modified @save and @r |
|
5190 | 5204 | according to Mike Heeter's suggestions. |
|
5191 | 5205 | |
|
5192 | 5206 | 2002-06-16 Fernando Perez <fperez@colorado.edu> |
|
5193 | 5207 | |
|
5194 | 5208 | * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot |
|
5195 | 5209 | system. GnuplotMagic is gone as a user-directory option. New files |
|
5196 | 5210 | make it easier to use all the gnuplot stuff both from external |
|
5197 | 5211 | programs as well as from IPython. Had to rewrite part of |
|
5198 | 5212 | hardcopy() b/c of a strange bug: often the ps files simply don't |
|
5199 | 5213 | get created, and require a repeat of the command (often several |
|
5200 | 5214 | times). |
|
5201 | 5215 | |
|
5202 | 5216 | * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to |
|
5203 | 5217 | resolve output channel at call time, so that if sys.stderr has |
|
5204 | 5218 | been redirected by user this gets honored. |
|
5205 | 5219 | |
|
5206 | 5220 | 2002-06-13 Fernando Perez <fperez@colorado.edu> |
|
5207 | 5221 | |
|
5208 | 5222 | * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to |
|
5209 | 5223 | IPShell. Kept a copy with the old names to avoid breaking people's |
|
5210 | 5224 | embedded code. |
|
5211 | 5225 | |
|
5212 | 5226 | * IPython/ipython: simplified it to the bare minimum after |
|
5213 | 5227 | Holger's suggestions. Added info about how to use it in |
|
5214 | 5228 | PYTHONSTARTUP. |
|
5215 | 5229 | |
|
5216 | 5230 | * IPython/Shell.py (IPythonShell): changed the options passing |
|
5217 | 5231 | from a string with funky %s replacements to a straight list. Maybe |
|
5218 | 5232 | a bit more typing, but it follows sys.argv conventions, so there's |
|
5219 | 5233 | less special-casing to remember. |
|
5220 | 5234 | |
|
5221 | 5235 | 2002-06-12 Fernando Perez <fperez@colorado.edu> |
|
5222 | 5236 | |
|
5223 | 5237 | * IPython/Magic.py (Magic.magic_r): new magic auto-repeat |
|
5224 | 5238 | command. Thanks to a suggestion by Mike Heeter. |
|
5225 | 5239 | (Magic.magic_pfile): added behavior to look at filenames if given |
|
5226 | 5240 | arg is not a defined object. |
|
5227 | 5241 | (Magic.magic_save): New @save function to save code snippets. Also |
|
5228 | 5242 | a Mike Heeter idea. |
|
5229 | 5243 | |
|
5230 | 5244 | * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to |
|
5231 | 5245 | plot() and replot(). Much more convenient now, especially for |
|
5232 | 5246 | interactive use. |
|
5233 | 5247 | |
|
5234 | 5248 | * IPython/Magic.py (Magic.magic_run): Added .py automatically to |
|
5235 | 5249 | filenames. |
|
5236 | 5250 | |
|
5237 | 5251 | 2002-06-02 Fernando Perez <fperez@colorado.edu> |
|
5238 | 5252 | |
|
5239 | 5253 | * IPython/Struct.py (Struct.__init__): modified to admit |
|
5240 | 5254 | initialization via another struct. |
|
5241 | 5255 | |
|
5242 | 5256 | * IPython/genutils.py (SystemExec.__init__): New stateful |
|
5243 | 5257 | interface to xsys and bq. Useful for writing system scripts. |
|
5244 | 5258 | |
|
5245 | 5259 | 2002-05-30 Fernando Perez <fperez@colorado.edu> |
|
5246 | 5260 | |
|
5247 | 5261 | * MANIFEST.in: Changed docfile selection to exclude all the lyx |
|
5248 | 5262 | documents. This will make the user download smaller (it's getting |
|
5249 | 5263 | too big). |
|
5250 | 5264 | |
|
5251 | 5265 | 2002-05-29 Fernando Perez <fperez@colorado.edu> |
|
5252 | 5266 | |
|
5253 | 5267 | * IPython/iplib.py (_FakeModule.__init__): New class introduced to |
|
5254 | 5268 | fix problems with shelve and pickle. Seems to work, but I don't |
|
5255 | 5269 | know if corner cases break it. Thanks to Mike Heeter |
|
5256 | 5270 | <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases. |
|
5257 | 5271 | |
|
5258 | 5272 | 2002-05-24 Fernando Perez <fperez@colorado.edu> |
|
5259 | 5273 | |
|
5260 | 5274 | * IPython/Magic.py (Macro.__init__): fixed magics embedded in |
|
5261 | 5275 | macros having broken. |
|
5262 | 5276 | |
|
5263 | 5277 | 2002-05-21 Fernando Perez <fperez@colorado.edu> |
|
5264 | 5278 | |
|
5265 | 5279 | * IPython/Magic.py (Magic.magic_logstart): fixed recently |
|
5266 | 5280 | introduced logging bug: all history before logging started was |
|
5267 | 5281 | being written one character per line! This came from the redesign |
|
5268 | 5282 | of the input history as a special list which slices to strings, |
|
5269 | 5283 | not to lists. |
|
5270 | 5284 | |
|
5271 | 5285 | 2002-05-20 Fernando Perez <fperez@colorado.edu> |
|
5272 | 5286 | |
|
5273 | 5287 | * IPython/Prompts.py (CachedOutput.__init__): made the color table |
|
5274 | 5288 | be an attribute of all classes in this module. The design of these |
|
5275 | 5289 | classes needs some serious overhauling. |
|
5276 | 5290 | |
|
5277 | 5291 | * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug |
|
5278 | 5292 | which was ignoring '_' in option names. |
|
5279 | 5293 | |
|
5280 | 5294 | * IPython/ultraTB.py (FormattedTB.__init__): Changed |
|
5281 | 5295 | 'Verbose_novars' to 'Context' and made it the new default. It's a |
|
5282 | 5296 | bit more readable and also safer than verbose. |
|
5283 | 5297 | |
|
5284 | 5298 | * IPython/PyColorize.py (Parser.__call__): Fixed coloring of |
|
5285 | 5299 | triple-quoted strings. |
|
5286 | 5300 | |
|
5287 | 5301 | * IPython/OInspect.py (__all__): new module exposing the object |
|
5288 | 5302 | introspection facilities. Now the corresponding magics are dummy |
|
5289 | 5303 | wrappers around this. Having this module will make it much easier |
|
5290 | 5304 | to put these functions into our modified pdb. |
|
5291 | 5305 | This new object inspector system uses the new colorizing module, |
|
5292 | 5306 | so source code and other things are nicely syntax highlighted. |
|
5293 | 5307 | |
|
5294 | 5308 | 2002-05-18 Fernando Perez <fperez@colorado.edu> |
|
5295 | 5309 | |
|
5296 | 5310 | * IPython/ColorANSI.py: Split the coloring tools into a separate |
|
5297 | 5311 | module so I can use them in other code easier (they were part of |
|
5298 | 5312 | ultraTB). |
|
5299 | 5313 | |
|
5300 | 5314 | 2002-05-17 Fernando Perez <fperez@colorado.edu> |
|
5301 | 5315 | |
|
5302 | 5316 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
5303 | 5317 | fixed it to set the global 'g' also to the called instance, as |
|
5304 | 5318 | long as 'g' was still a gnuplot instance (so it doesn't overwrite |
|
5305 | 5319 | user's 'g' variables). |
|
5306 | 5320 | |
|
5307 | 5321 | * IPython/iplib.py (InteractiveShell.__init__): Added In/Out |
|
5308 | 5322 | global variables (aliases to _ih,_oh) so that users which expect |
|
5309 | 5323 | In[5] or Out[7] to work aren't unpleasantly surprised. |
|
5310 | 5324 | (InputList.__getslice__): new class to allow executing slices of |
|
5311 | 5325 | input history directly. Very simple class, complements the use of |
|
5312 | 5326 | macros. |
|
5313 | 5327 | |
|
5314 | 5328 | 2002-05-16 Fernando Perez <fperez@colorado.edu> |
|
5315 | 5329 | |
|
5316 | 5330 | * setup.py (docdirbase): make doc directory be just doc/IPython |
|
5317 | 5331 | without version numbers, it will reduce clutter for users. |
|
5318 | 5332 | |
|
5319 | 5333 | * IPython/Magic.py (Magic.magic_run): Add explicit local dict to |
|
5320 | 5334 | execfile call to prevent possible memory leak. See for details: |
|
5321 | 5335 | http://mail.python.org/pipermail/python-list/2002-February/088476.html |
|
5322 | 5336 | |
|
5323 | 5337 | 2002-05-15 Fernando Perez <fperez@colorado.edu> |
|
5324 | 5338 | |
|
5325 | 5339 | * IPython/Magic.py (Magic.magic_psource): made the object |
|
5326 | 5340 | introspection names be more standard: pdoc, pdef, pfile and |
|
5327 | 5341 | psource. They all print/page their output, and it makes |
|
5328 | 5342 | remembering them easier. Kept old names for compatibility as |
|
5329 | 5343 | aliases. |
|
5330 | 5344 | |
|
5331 | 5345 | 2002-05-14 Fernando Perez <fperez@colorado.edu> |
|
5332 | 5346 | |
|
5333 | 5347 | * IPython/UserConfig/GnuplotMagic.py: I think I finally understood |
|
5334 | 5348 | what the mouse problem was. The trick is to use gnuplot with temp |
|
5335 | 5349 | files and NOT with pipes (for data communication), because having |
|
5336 | 5350 | both pipes and the mouse on is bad news. |
|
5337 | 5351 | |
|
5338 | 5352 | 2002-05-13 Fernando Perez <fperez@colorado.edu> |
|
5339 | 5353 | |
|
5340 | 5354 | * IPython/Magic.py (Magic._ofind): fixed namespace order search |
|
5341 | 5355 | bug. Information would be reported about builtins even when |
|
5342 | 5356 | user-defined functions overrode them. |
|
5343 | 5357 | |
|
5344 | 5358 | 2002-05-11 Fernando Perez <fperez@colorado.edu> |
|
5345 | 5359 | |
|
5346 | 5360 | * IPython/__init__.py (__all__): removed FlexCompleter from |
|
5347 | 5361 | __all__ so that things don't fail in platforms without readline. |
|
5348 | 5362 | |
|
5349 | 5363 | 2002-05-10 Fernando Perez <fperez@colorado.edu> |
|
5350 | 5364 | |
|
5351 | 5365 | * IPython/__init__.py (__all__): removed numutils from __all__ b/c |
|
5352 | 5366 | it requires Numeric, effectively making Numeric a dependency for |
|
5353 | 5367 | IPython. |
|
5354 | 5368 | |
|
5355 | 5369 | * Released 0.2.13 |
|
5356 | 5370 | |
|
5357 | 5371 | * IPython/Magic.py (Magic.magic_prun): big overhaul to the |
|
5358 | 5372 | profiler interface. Now all the major options from the profiler |
|
5359 | 5373 | module are directly supported in IPython, both for single |
|
5360 | 5374 | expressions (@prun) and for full programs (@run -p). |
|
5361 | 5375 | |
|
5362 | 5376 | 2002-05-09 Fernando Perez <fperez@colorado.edu> |
|
5363 | 5377 | |
|
5364 | 5378 | * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of |
|
5365 | 5379 | magic properly formatted for screen. |
|
5366 | 5380 | |
|
5367 | 5381 | * setup.py (make_shortcut): Changed things to put pdf version in |
|
5368 | 5382 | doc/ instead of doc/manual (had to change lyxport a bit). |
|
5369 | 5383 | |
|
5370 | 5384 | * IPython/Magic.py (Profile.string_stats): made profile runs go |
|
5371 | 5385 | through pager (they are long and a pager allows searching, saving, |
|
5372 | 5386 | etc.) |
|
5373 | 5387 | |
|
5374 | 5388 | 2002-05-08 Fernando Perez <fperez@colorado.edu> |
|
5375 | 5389 | |
|
5376 | 5390 | * Released 0.2.12 |
|
5377 | 5391 | |
|
5378 | 5392 | 2002-05-06 Fernando Perez <fperez@colorado.edu> |
|
5379 | 5393 | |
|
5380 | 5394 | * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently |
|
5381 | 5395 | introduced); 'hist n1 n2' was broken. |
|
5382 | 5396 | (Magic.magic_pdb): added optional on/off arguments to @pdb |
|
5383 | 5397 | (Magic.magic_run): added option -i to @run, which executes code in |
|
5384 | 5398 | the IPython namespace instead of a clean one. Also added @irun as |
|
5385 | 5399 | an alias to @run -i. |
|
5386 | 5400 | |
|
5387 | 5401 | * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance): |
|
5388 | 5402 | fixed (it didn't really do anything, the namespaces were wrong). |
|
5389 | 5403 | |
|
5390 | 5404 | * IPython/Debugger.py (__init__): Added workaround for python 2.1 |
|
5391 | 5405 | |
|
5392 | 5406 | * IPython/__init__.py (__all__): Fixed package namespace, now |
|
5393 | 5407 | 'import IPython' does give access to IPython.<all> as |
|
5394 | 5408 | expected. Also renamed __release__ to Release. |
|
5395 | 5409 | |
|
5396 | 5410 | * IPython/Debugger.py (__license__): created new Pdb class which |
|
5397 | 5411 | functions like a drop-in for the normal pdb.Pdb but does NOT |
|
5398 | 5412 | import readline by default. This way it doesn't muck up IPython's |
|
5399 | 5413 | readline handling, and now tab-completion finally works in the |
|
5400 | 5414 | debugger -- sort of. It completes things globally visible, but the |
|
5401 | 5415 | completer doesn't track the stack as pdb walks it. That's a bit |
|
5402 | 5416 | tricky, and I'll have to implement it later. |
|
5403 | 5417 | |
|
5404 | 5418 | 2002-05-05 Fernando Perez <fperez@colorado.edu> |
|
5405 | 5419 | |
|
5406 | 5420 | * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for |
|
5407 | 5421 | magic docstrings when printed via ? (explicit \'s were being |
|
5408 | 5422 | printed). |
|
5409 | 5423 | |
|
5410 | 5424 | * IPython/ipmaker.py (make_IPython): fixed namespace |
|
5411 | 5425 | identification bug. Now variables loaded via logs or command-line |
|
5412 | 5426 | files are recognized in the interactive namespace by @who. |
|
5413 | 5427 | |
|
5414 | 5428 | * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in |
|
5415 | 5429 | log replay system stemming from the string form of Structs. |
|
5416 | 5430 | |
|
5417 | 5431 | * IPython/Magic.py (Macro.__init__): improved macros to properly |
|
5418 | 5432 | handle magic commands in them. |
|
5419 | 5433 | (Magic.magic_logstart): usernames are now expanded so 'logstart |
|
5420 | 5434 | ~/mylog' now works. |
|
5421 | 5435 | |
|
5422 | 5436 | * IPython/iplib.py (complete): fixed bug where paths starting with |
|
5423 | 5437 | '/' would be completed as magic names. |
|
5424 | 5438 | |
|
5425 | 5439 | 2002-05-04 Fernando Perez <fperez@colorado.edu> |
|
5426 | 5440 | |
|
5427 | 5441 | * IPython/Magic.py (Magic.magic_run): added options -p and -f to |
|
5428 | 5442 | allow running full programs under the profiler's control. |
|
5429 | 5443 | |
|
5430 | 5444 | * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars |
|
5431 | 5445 | mode to report exceptions verbosely but without formatting |
|
5432 | 5446 | variables. This addresses the issue of ipython 'freezing' (it's |
|
5433 | 5447 | not frozen, but caught in an expensive formatting loop) when huge |
|
5434 | 5448 | variables are in the context of an exception. |
|
5435 | 5449 | (VerboseTB.text): Added '--->' markers at line where exception was |
|
5436 | 5450 | triggered. Much clearer to read, especially in NoColor modes. |
|
5437 | 5451 | |
|
5438 | 5452 | * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been |
|
5439 | 5453 | implemented in reverse when changing to the new parse_options(). |
|
5440 | 5454 | |
|
5441 | 5455 | 2002-05-03 Fernando Perez <fperez@colorado.edu> |
|
5442 | 5456 | |
|
5443 | 5457 | * IPython/Magic.py (Magic.parse_options): new function so that |
|
5444 | 5458 | magics can parse options easier. |
|
5445 | 5459 | (Magic.magic_prun): new function similar to profile.run(), |
|
5446 | 5460 | suggested by Chris Hart. |
|
5447 | 5461 | (Magic.magic_cd): fixed behavior so that it only changes if |
|
5448 | 5462 | directory actually is in history. |
|
5449 | 5463 | |
|
5450 | 5464 | * IPython/usage.py (__doc__): added information about potential |
|
5451 | 5465 | slowness of Verbose exception mode when there are huge data |
|
5452 | 5466 | structures to be formatted (thanks to Archie Paulson). |
|
5453 | 5467 | |
|
5454 | 5468 | * IPython/ipmaker.py (make_IPython): Changed default logging |
|
5455 | 5469 | (when simply called with -log) to use curr_dir/ipython.log in |
|
5456 | 5470 | rotate mode. Fixed crash which was occuring with -log before |
|
5457 | 5471 | (thanks to Jim Boyle). |
|
5458 | 5472 | |
|
5459 | 5473 | 2002-05-01 Fernando Perez <fperez@colorado.edu> |
|
5460 | 5474 | |
|
5461 | 5475 | * Released 0.2.11 for these fixes (mainly the ultraTB one which |
|
5462 | 5476 | was nasty -- though somewhat of a corner case). |
|
5463 | 5477 | |
|
5464 | 5478 | * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to |
|
5465 | 5479 | text (was a bug). |
|
5466 | 5480 | |
|
5467 | 5481 | 2002-04-30 Fernando Perez <fperez@colorado.edu> |
|
5468 | 5482 | |
|
5469 | 5483 | * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add |
|
5470 | 5484 | a print after ^D or ^C from the user so that the In[] prompt |
|
5471 | 5485 | doesn't over-run the gnuplot one. |
|
5472 | 5486 | |
|
5473 | 5487 | 2002-04-29 Fernando Perez <fperez@colorado.edu> |
|
5474 | 5488 | |
|
5475 | 5489 | * Released 0.2.10 |
|
5476 | 5490 | |
|
5477 | 5491 | * IPython/__release__.py (version): get date dynamically. |
|
5478 | 5492 | |
|
5479 | 5493 | * Misc. documentation updates thanks to Arnd's comments. Also ran |
|
5480 | 5494 | a full spellcheck on the manual (hadn't been done in a while). |
|
5481 | 5495 | |
|
5482 | 5496 | 2002-04-27 Fernando Perez <fperez@colorado.edu> |
|
5483 | 5497 | |
|
5484 | 5498 | * IPython/Magic.py (Magic.magic_logstart): Fixed bug where |
|
5485 | 5499 | starting a log in mid-session would reset the input history list. |
|
5486 | 5500 | |
|
5487 | 5501 | 2002-04-26 Fernando Perez <fperez@colorado.edu> |
|
5488 | 5502 | |
|
5489 | 5503 | * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not |
|
5490 | 5504 | all files were being included in an update. Now anything in |
|
5491 | 5505 | UserConfig that matches [A-Za-z]*.py will go (this excludes |
|
5492 | 5506 | __init__.py) |
|
5493 | 5507 | |
|
5494 | 5508 | 2002-04-25 Fernando Perez <fperez@colorado.edu> |
|
5495 | 5509 | |
|
5496 | 5510 | * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__ |
|
5497 | 5511 | to __builtins__ so that any form of embedded or imported code can |
|
5498 | 5512 | test for being inside IPython. |
|
5499 | 5513 | |
|
5500 | 5514 | * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance): |
|
5501 | 5515 | changed to GnuplotMagic because it's now an importable module, |
|
5502 | 5516 | this makes the name follow that of the standard Gnuplot module. |
|
5503 | 5517 | GnuplotMagic can now be loaded at any time in mid-session. |
|
5504 | 5518 | |
|
5505 | 5519 | 2002-04-24 Fernando Perez <fperez@colorado.edu> |
|
5506 | 5520 | |
|
5507 | 5521 | * IPython/numutils.py: removed SIUnits. It doesn't properly set |
|
5508 | 5522 | the globals (IPython has its own namespace) and the |
|
5509 | 5523 | PhysicalQuantity stuff is much better anyway. |
|
5510 | 5524 | |
|
5511 | 5525 | * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot |
|
5512 | 5526 | embedding example to standard user directory for |
|
5513 | 5527 | distribution. Also put it in the manual. |
|
5514 | 5528 | |
|
5515 | 5529 | * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot |
|
5516 | 5530 | instance as first argument (so it doesn't rely on some obscure |
|
5517 | 5531 | hidden global). |
|
5518 | 5532 | |
|
5519 | 5533 | * IPython/UserConfig/ipythonrc.py: put () back in accepted |
|
5520 | 5534 | delimiters. While it prevents ().TAB from working, it allows |
|
5521 | 5535 | completions in open (... expressions. This is by far a more common |
|
5522 | 5536 | case. |
|
5523 | 5537 | |
|
5524 | 5538 | 2002-04-23 Fernando Perez <fperez@colorado.edu> |
|
5525 | 5539 | |
|
5526 | 5540 | * IPython/Extensions/InterpreterPasteInput.py: new |
|
5527 | 5541 | syntax-processing module for pasting lines with >>> or ... at the |
|
5528 | 5542 | start. |
|
5529 | 5543 | |
|
5530 | 5544 | * IPython/Extensions/PhysicalQ_Interactive.py |
|
5531 | 5545 | (PhysicalQuantityInteractive.__int__): fixed to work with either |
|
5532 | 5546 | Numeric or math. |
|
5533 | 5547 | |
|
5534 | 5548 | * IPython/UserConfig/ipythonrc-numeric.py: reorganized the |
|
5535 | 5549 | provided profiles. Now we have: |
|
5536 | 5550 | -math -> math module as * and cmath with its own namespace. |
|
5537 | 5551 | -numeric -> Numeric as *, plus gnuplot & grace |
|
5538 | 5552 | -physics -> same as before |
|
5539 | 5553 | |
|
5540 | 5554 | * IPython/Magic.py (Magic.magic_magic): Fixed bug where |
|
5541 | 5555 | user-defined magics wouldn't be found by @magic if they were |
|
5542 | 5556 | defined as class methods. Also cleaned up the namespace search |
|
5543 | 5557 | logic and the string building (to use %s instead of many repeated |
|
5544 | 5558 | string adds). |
|
5545 | 5559 | |
|
5546 | 5560 | * IPython/UserConfig/example-magic.py (magic_foo): updated example |
|
5547 | 5561 | of user-defined magics to operate with class methods (cleaner, in |
|
5548 | 5562 | line with the gnuplot code). |
|
5549 | 5563 | |
|
5550 | 5564 | 2002-04-22 Fernando Perez <fperez@colorado.edu> |
|
5551 | 5565 | |
|
5552 | 5566 | * setup.py: updated dependency list so that manual is updated when |
|
5553 | 5567 | all included files change. |
|
5554 | 5568 | |
|
5555 | 5569 | * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring |
|
5556 | 5570 | the delimiter removal option (the fix is ugly right now). |
|
5557 | 5571 | |
|
5558 | 5572 | * IPython/UserConfig/ipythonrc-physics.py: simplified not to load |
|
5559 | 5573 | all of the math profile (quicker loading, no conflict between |
|
5560 | 5574 | g-9.8 and g-gnuplot). |
|
5561 | 5575 | |
|
5562 | 5576 | * IPython/CrashHandler.py (CrashHandler.__call__): changed default |
|
5563 | 5577 | name of post-mortem files to IPython_crash_report.txt. |
|
5564 | 5578 | |
|
5565 | 5579 | * Cleanup/update of the docs. Added all the new readline info and |
|
5566 | 5580 | formatted all lists as 'real lists'. |
|
5567 | 5581 | |
|
5568 | 5582 | * IPython/ipmaker.py (make_IPython): removed now-obsolete |
|
5569 | 5583 | tab-completion options, since the full readline parse_and_bind is |
|
5570 | 5584 | now accessible. |
|
5571 | 5585 | |
|
5572 | 5586 | * IPython/iplib.py (InteractiveShell.init_readline): Changed |
|
5573 | 5587 | handling of readline options. Now users can specify any string to |
|
5574 | 5588 | be passed to parse_and_bind(), as well as the delimiters to be |
|
5575 | 5589 | removed. |
|
5576 | 5590 | (InteractiveShell.__init__): Added __name__ to the global |
|
5577 | 5591 | namespace so that things like Itpl which rely on its existence |
|
5578 | 5592 | don't crash. |
|
5579 | 5593 | (InteractiveShell._prefilter): Defined the default with a _ so |
|
5580 | 5594 | that prefilter() is easier to override, while the default one |
|
5581 | 5595 | remains available. |
|
5582 | 5596 | |
|
5583 | 5597 | 2002-04-18 Fernando Perez <fperez@colorado.edu> |
|
5584 | 5598 | |
|
5585 | 5599 | * Added information about pdb in the docs. |
|
5586 | 5600 | |
|
5587 | 5601 | 2002-04-17 Fernando Perez <fperez@colorado.edu> |
|
5588 | 5602 | |
|
5589 | 5603 | * IPython/ipmaker.py (make_IPython): added rc_override option to |
|
5590 | 5604 | allow passing config options at creation time which may override |
|
5591 | 5605 | anything set in the config files or command line. This is |
|
5592 | 5606 | particularly useful for configuring embedded instances. |
|
5593 | 5607 | |
|
5594 | 5608 | 2002-04-15 Fernando Perez <fperez@colorado.edu> |
|
5595 | 5609 | |
|
5596 | 5610 | * IPython/Logger.py (Logger.log): Fixed a nasty bug which could |
|
5597 | 5611 | crash embedded instances because of the input cache falling out of |
|
5598 | 5612 | sync with the output counter. |
|
5599 | 5613 | |
|
5600 | 5614 | * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug |
|
5601 | 5615 | mode which calls pdb after an uncaught exception in IPython itself. |
|
5602 | 5616 | |
|
5603 | 5617 | 2002-04-14 Fernando Perez <fperez@colorado.edu> |
|
5604 | 5618 | |
|
5605 | 5619 | * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up |
|
5606 | 5620 | readline, fix it back after each call. |
|
5607 | 5621 | |
|
5608 | 5622 | * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private |
|
5609 | 5623 | method to force all access via __call__(), which guarantees that |
|
5610 | 5624 | traceback references are properly deleted. |
|
5611 | 5625 | |
|
5612 | 5626 | * IPython/Prompts.py (CachedOutput._display): minor fixes to |
|
5613 | 5627 | improve printing when pprint is in use. |
|
5614 | 5628 | |
|
5615 | 5629 | 2002-04-13 Fernando Perez <fperez@colorado.edu> |
|
5616 | 5630 | |
|
5617 | 5631 | * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit |
|
5618 | 5632 | exceptions aren't caught anymore. If the user triggers one, he |
|
5619 | 5633 | should know why he's doing it and it should go all the way up, |
|
5620 | 5634 | just like any other exception. So now @abort will fully kill the |
|
5621 | 5635 | embedded interpreter and the embedding code (unless that happens |
|
5622 | 5636 | to catch SystemExit). |
|
5623 | 5637 | |
|
5624 | 5638 | * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag |
|
5625 | 5639 | and a debugger() method to invoke the interactive pdb debugger |
|
5626 | 5640 | after printing exception information. Also added the corresponding |
|
5627 | 5641 | -pdb option and @pdb magic to control this feature, and updated |
|
5628 | 5642 | the docs. After a suggestion from Christopher Hart |
|
5629 | 5643 | (hart-AT-caltech.edu). |
|
5630 | 5644 | |
|
5631 | 5645 | 2002-04-12 Fernando Perez <fperez@colorado.edu> |
|
5632 | 5646 | |
|
5633 | 5647 | * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use |
|
5634 | 5648 | the exception handlers defined by the user (not the CrashHandler) |
|
5635 | 5649 | so that user exceptions don't trigger an ipython bug report. |
|
5636 | 5650 | |
|
5637 | 5651 | * IPython/ultraTB.py (ColorTB.__init__): made the color scheme |
|
5638 | 5652 | configurable (it should have always been so). |
|
5639 | 5653 | |
|
5640 | 5654 | 2002-03-26 Fernando Perez <fperez@colorado.edu> |
|
5641 | 5655 | |
|
5642 | 5656 | * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here |
|
5643 | 5657 | and there to fix embedding namespace issues. This should all be |
|
5644 | 5658 | done in a more elegant way. |
|
5645 | 5659 | |
|
5646 | 5660 | 2002-03-25 Fernando Perez <fperez@colorado.edu> |
|
5647 | 5661 | |
|
5648 | 5662 | * IPython/genutils.py (get_home_dir): Try to make it work under |
|
5649 | 5663 | win9x also. |
|
5650 | 5664 | |
|
5651 | 5665 | 2002-03-20 Fernando Perez <fperez@colorado.edu> |
|
5652 | 5666 | |
|
5653 | 5667 | * IPython/Shell.py (IPythonShellEmbed.__init__): leave |
|
5654 | 5668 | sys.displayhook untouched upon __init__. |
|
5655 | 5669 | |
|
5656 | 5670 | 2002-03-19 Fernando Perez <fperez@colorado.edu> |
|
5657 | 5671 | |
|
5658 | 5672 | * Released 0.2.9 (for embedding bug, basically). |
|
5659 | 5673 | |
|
5660 | 5674 | * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit |
|
5661 | 5675 | exceptions so that enclosing shell's state can be restored. |
|
5662 | 5676 | |
|
5663 | 5677 | * Changed magic_gnuplot.py to magic-gnuplot.py to standardize |
|
5664 | 5678 | naming conventions in the .ipython/ dir. |
|
5665 | 5679 | |
|
5666 | 5680 | * IPython/iplib.py (InteractiveShell.init_readline): removed '-' |
|
5667 | 5681 | from delimiters list so filenames with - in them get expanded. |
|
5668 | 5682 | |
|
5669 | 5683 | * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with |
|
5670 | 5684 | sys.displayhook not being properly restored after an embedded call. |
|
5671 | 5685 | |
|
5672 | 5686 | 2002-03-18 Fernando Perez <fperez@colorado.edu> |
|
5673 | 5687 | |
|
5674 | 5688 | * Released 0.2.8 |
|
5675 | 5689 | |
|
5676 | 5690 | * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where |
|
5677 | 5691 | some files weren't being included in a -upgrade. |
|
5678 | 5692 | (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous |
|
5679 | 5693 | on' so that the first tab completes. |
|
5680 | 5694 | (InteractiveShell.handle_magic): fixed bug with spaces around |
|
5681 | 5695 | quotes breaking many magic commands. |
|
5682 | 5696 | |
|
5683 | 5697 | * setup.py: added note about ignoring the syntax error messages at |
|
5684 | 5698 | installation. |
|
5685 | 5699 | |
|
5686 | 5700 | * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished |
|
5687 | 5701 | streamlining the gnuplot interface, now there's only one magic @gp. |
|
5688 | 5702 | |
|
5689 | 5703 | 2002-03-17 Fernando Perez <fperez@colorado.edu> |
|
5690 | 5704 | |
|
5691 | 5705 | * IPython/UserConfig/magic_gnuplot.py: new name for the |
|
5692 | 5706 | example-magic_pm.py file. Much enhanced system, now with a shell |
|
5693 | 5707 | for communicating directly with gnuplot, one command at a time. |
|
5694 | 5708 | |
|
5695 | 5709 | * IPython/Magic.py (Magic.magic_run): added option -n to prevent |
|
5696 | 5710 | setting __name__=='__main__'. |
|
5697 | 5711 | |
|
5698 | 5712 | * IPython/UserConfig/example-magic_pm.py (magic_pm): Added |
|
5699 | 5713 | mini-shell for accessing gnuplot from inside ipython. Should |
|
5700 | 5714 | extend it later for grace access too. Inspired by Arnd's |
|
5701 | 5715 | suggestion. |
|
5702 | 5716 | |
|
5703 | 5717 | * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when |
|
5704 | 5718 | calling magic functions with () in their arguments. Thanks to Arnd |
|
5705 | 5719 | Baecker for pointing this to me. |
|
5706 | 5720 | |
|
5707 | 5721 | * IPython/numutils.py (sum_flat): fixed bug. Would recurse |
|
5708 | 5722 | infinitely for integer or complex arrays (only worked with floats). |
|
5709 | 5723 | |
|
5710 | 5724 | 2002-03-16 Fernando Perez <fperez@colorado.edu> |
|
5711 | 5725 | |
|
5712 | 5726 | * setup.py: Merged setup and setup_windows into a single script |
|
5713 | 5727 | which properly handles things for windows users. |
|
5714 | 5728 | |
|
5715 | 5729 | 2002-03-15 Fernando Perez <fperez@colorado.edu> |
|
5716 | 5730 | |
|
5717 | 5731 | * Big change to the manual: now the magics are all automatically |
|
5718 | 5732 | documented. This information is generated from their docstrings |
|
5719 | 5733 | and put in a latex file included by the manual lyx file. This way |
|
5720 | 5734 | we get always up to date information for the magics. The manual |
|
5721 | 5735 | now also has proper version information, also auto-synced. |
|
5722 | 5736 | |
|
5723 | 5737 | For this to work, an undocumented --magic_docstrings option was added. |
|
5724 | 5738 | |
|
5725 | 5739 | 2002-03-13 Fernando Perez <fperez@colorado.edu> |
|
5726 | 5740 | |
|
5727 | 5741 | * IPython/ultraTB.py (TermColors): fixed problem with dark colors |
|
5728 | 5742 | under CDE terminals. An explicit ;2 color reset is needed in the escapes. |
|
5729 | 5743 | |
|
5730 | 5744 | 2002-03-12 Fernando Perez <fperez@colorado.edu> |
|
5731 | 5745 | |
|
5732 | 5746 | * IPython/ultraTB.py (TermColors): changed color escapes again to |
|
5733 | 5747 | fix the (old, reintroduced) line-wrapping bug. Basically, if |
|
5734 | 5748 | \001..\002 aren't given in the color escapes, lines get wrapped |
|
5735 | 5749 | weirdly. But giving those screws up old xterms and emacs terms. So |
|
5736 | 5750 | I added some logic for emacs terms to be ok, but I can't identify old |
|
5737 | 5751 | xterms separately ($TERM=='xterm' for many terminals, like konsole). |
|
5738 | 5752 | |
|
5739 | 5753 | 2002-03-10 Fernando Perez <fperez@colorado.edu> |
|
5740 | 5754 | |
|
5741 | 5755 | * IPython/usage.py (__doc__): Various documentation cleanups and |
|
5742 | 5756 | updates, both in usage docstrings and in the manual. |
|
5743 | 5757 | |
|
5744 | 5758 | * IPython/Prompts.py (CachedOutput.set_colors): cleanups for |
|
5745 | 5759 | handling of caching. Set minimum acceptabe value for having a |
|
5746 | 5760 | cache at 20 values. |
|
5747 | 5761 | |
|
5748 | 5762 | * IPython/iplib.py (InteractiveShell.user_setup): moved the |
|
5749 | 5763 | install_first_time function to a method, renamed it and added an |
|
5750 | 5764 | 'upgrade' mode. Now people can update their config directory with |
|
5751 | 5765 | a simple command line switch (-upgrade, also new). |
|
5752 | 5766 | |
|
5753 | 5767 | * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to |
|
5754 | 5768 | @file (convenient for automagic users under Python >= 2.2). |
|
5755 | 5769 | Removed @files (it seemed more like a plural than an abbrev. of |
|
5756 | 5770 | 'file show'). |
|
5757 | 5771 | |
|
5758 | 5772 | * IPython/iplib.py (install_first_time): Fixed crash if there were |
|
5759 | 5773 | backup files ('~') in .ipython/ install directory. |
|
5760 | 5774 | |
|
5761 | 5775 | * IPython/ipmaker.py (make_IPython): fixes for new prompt |
|
5762 | 5776 | system. Things look fine, but these changes are fairly |
|
5763 | 5777 | intrusive. Test them for a few days. |
|
5764 | 5778 | |
|
5765 | 5779 | * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of |
|
5766 | 5780 | the prompts system. Now all in/out prompt strings are user |
|
5767 | 5781 | controllable. This is particularly useful for embedding, as one |
|
5768 | 5782 | can tag embedded instances with particular prompts. |
|
5769 | 5783 | |
|
5770 | 5784 | Also removed global use of sys.ps1/2, which now allows nested |
|
5771 | 5785 | embeddings without any problems. Added command-line options for |
|
5772 | 5786 | the prompt strings. |
|
5773 | 5787 | |
|
5774 | 5788 | 2002-03-08 Fernando Perez <fperez@colorado.edu> |
|
5775 | 5789 | |
|
5776 | 5790 | * IPython/UserConfig/example-embed-short.py (ipshell): added |
|
5777 | 5791 | example file with the bare minimum code for embedding. |
|
5778 | 5792 | |
|
5779 | 5793 | * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added |
|
5780 | 5794 | functionality for the embeddable shell to be activated/deactivated |
|
5781 | 5795 | either globally or at each call. |
|
5782 | 5796 | |
|
5783 | 5797 | * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of |
|
5784 | 5798 | rewriting the prompt with '--->' for auto-inputs with proper |
|
5785 | 5799 | coloring. Now the previous UGLY hack in handle_auto() is gone, and |
|
5786 | 5800 | this is handled by the prompts class itself, as it should. |
|
5787 | 5801 | |
|
5788 | 5802 | 2002-03-05 Fernando Perez <fperez@colorado.edu> |
|
5789 | 5803 | |
|
5790 | 5804 | * IPython/Magic.py (Magic.magic_logstart): Changed @log to |
|
5791 | 5805 | @logstart to avoid name clashes with the math log function. |
|
5792 | 5806 | |
|
5793 | 5807 | * Big updates to X/Emacs section of the manual. |
|
5794 | 5808 | |
|
5795 | 5809 | * Removed ipython_emacs. Milan explained to me how to pass |
|
5796 | 5810 | arguments to ipython through Emacs. Some day I'm going to end up |
|
5797 | 5811 | learning some lisp... |
|
5798 | 5812 | |
|
5799 | 5813 | 2002-03-04 Fernando Perez <fperez@colorado.edu> |
|
5800 | 5814 | |
|
5801 | 5815 | * IPython/ipython_emacs: Created script to be used as the |
|
5802 | 5816 | py-python-command Emacs variable so we can pass IPython |
|
5803 | 5817 | parameters. I can't figure out how to tell Emacs directly to pass |
|
5804 | 5818 | parameters to IPython, so a dummy shell script will do it. |
|
5805 | 5819 | |
|
5806 | 5820 | Other enhancements made for things to work better under Emacs' |
|
5807 | 5821 | various types of terminals. Many thanks to Milan Zamazal |
|
5808 | 5822 | <pdm-AT-zamazal.org> for all the suggestions and pointers. |
|
5809 | 5823 | |
|
5810 | 5824 | 2002-03-01 Fernando Perez <fperez@colorado.edu> |
|
5811 | 5825 | |
|
5812 | 5826 | * IPython/ipmaker.py (make_IPython): added a --readline! option so |
|
5813 | 5827 | that loading of readline is now optional. This gives better |
|
5814 | 5828 | control to emacs users. |
|
5815 | 5829 | |
|
5816 | 5830 | * IPython/ultraTB.py (__date__): Modified color escape sequences |
|
5817 | 5831 | and now things work fine under xterm and in Emacs' term buffers |
|
5818 | 5832 | (though not shell ones). Well, in emacs you get colors, but all |
|
5819 | 5833 | seem to be 'light' colors (no difference between dark and light |
|
5820 | 5834 | ones). But the garbage chars are gone, and also in xterms. It |
|
5821 | 5835 | seems that now I'm using 'cleaner' ansi sequences. |
|
5822 | 5836 | |
|
5823 | 5837 | 2002-02-21 Fernando Perez <fperez@colorado.edu> |
|
5824 | 5838 | |
|
5825 | 5839 | * Released 0.2.7 (mainly to publish the scoping fix). |
|
5826 | 5840 | |
|
5827 | 5841 | * IPython/Logger.py (Logger.logstate): added. A corresponding |
|
5828 | 5842 | @logstate magic was created. |
|
5829 | 5843 | |
|
5830 | 5844 | * IPython/Magic.py: fixed nested scoping problem under Python |
|
5831 | 5845 | 2.1.x (automagic wasn't working). |
|
5832 | 5846 | |
|
5833 | 5847 | 2002-02-20 Fernando Perez <fperez@colorado.edu> |
|
5834 | 5848 | |
|
5835 | 5849 | * Released 0.2.6. |
|
5836 | 5850 | |
|
5837 | 5851 | * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet' |
|
5838 | 5852 | option so that logs can come out without any headers at all. |
|
5839 | 5853 | |
|
5840 | 5854 | * IPython/UserConfig/ipythonrc-scipy.py: created a profile for |
|
5841 | 5855 | SciPy. |
|
5842 | 5856 | |
|
5843 | 5857 | * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so |
|
5844 | 5858 | that embedded IPython calls don't require vars() to be explicitly |
|
5845 | 5859 | passed. Now they are extracted from the caller's frame (code |
|
5846 | 5860 | snatched from Eric Jones' weave). Added better documentation to |
|
5847 | 5861 | the section on embedding and the example file. |
|
5848 | 5862 | |
|
5849 | 5863 | * IPython/genutils.py (page): Changed so that under emacs, it just |
|
5850 | 5864 | prints the string. You can then page up and down in the emacs |
|
5851 | 5865 | buffer itself. This is how the builtin help() works. |
|
5852 | 5866 | |
|
5853 | 5867 | * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with |
|
5854 | 5868 | macro scoping: macros need to be executed in the user's namespace |
|
5855 | 5869 | to work as if they had been typed by the user. |
|
5856 | 5870 | |
|
5857 | 5871 | * IPython/Magic.py (Magic.magic_macro): Changed macros so they |
|
5858 | 5872 | execute automatically (no need to type 'exec...'). They then |
|
5859 | 5873 | behave like 'true macros'. The printing system was also modified |
|
5860 | 5874 | for this to work. |
|
5861 | 5875 | |
|
5862 | 5876 | 2002-02-19 Fernando Perez <fperez@colorado.edu> |
|
5863 | 5877 | |
|
5864 | 5878 | * IPython/genutils.py (page_file): new function for paging files |
|
5865 | 5879 | in an OS-independent way. Also necessary for file viewing to work |
|
5866 | 5880 | well inside Emacs buffers. |
|
5867 | 5881 | (page): Added checks for being in an emacs buffer. |
|
5868 | 5882 | (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed |
|
5869 | 5883 | same bug in iplib. |
|
5870 | 5884 | |
|
5871 | 5885 | 2002-02-18 Fernando Perez <fperez@colorado.edu> |
|
5872 | 5886 | |
|
5873 | 5887 | * IPython/iplib.py (InteractiveShell.init_readline): modified use |
|
5874 | 5888 | of readline so that IPython can work inside an Emacs buffer. |
|
5875 | 5889 | |
|
5876 | 5890 | * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to |
|
5877 | 5891 | method signatures (they weren't really bugs, but it looks cleaner |
|
5878 | 5892 | and keeps PyChecker happy). |
|
5879 | 5893 | |
|
5880 | 5894 | * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP |
|
5881 | 5895 | for implementing various user-defined hooks. Currently only |
|
5882 | 5896 | display is done. |
|
5883 | 5897 | |
|
5884 | 5898 | * IPython/Prompts.py (CachedOutput._display): changed display |
|
5885 | 5899 | functions so that they can be dynamically changed by users easily. |
|
5886 | 5900 | |
|
5887 | 5901 | * IPython/Extensions/numeric_formats.py (num_display): added an |
|
5888 | 5902 | extension for printing NumPy arrays in flexible manners. It |
|
5889 | 5903 | doesn't do anything yet, but all the structure is in |
|
5890 | 5904 | place. Ultimately the plan is to implement output format control |
|
5891 | 5905 | like in Octave. |
|
5892 | 5906 | |
|
5893 | 5907 | * IPython/Magic.py (Magic.lsmagic): changed so that bound magic |
|
5894 | 5908 | methods are found at run-time by all the automatic machinery. |
|
5895 | 5909 | |
|
5896 | 5910 | 2002-02-17 Fernando Perez <fperez@colorado.edu> |
|
5897 | 5911 | |
|
5898 | 5912 | * setup_Windows.py (make_shortcut): documented. Cleaned up the |
|
5899 | 5913 | whole file a little. |
|
5900 | 5914 | |
|
5901 | 5915 | * ToDo: closed this document. Now there's a new_design.lyx |
|
5902 | 5916 | document for all new ideas. Added making a pdf of it for the |
|
5903 | 5917 | end-user distro. |
|
5904 | 5918 | |
|
5905 | 5919 | * IPython/Logger.py (Logger.switch_log): Created this to replace |
|
5906 | 5920 | logon() and logoff(). It also fixes a nasty crash reported by |
|
5907 | 5921 | Philip Hisley <compsys-AT-starpower.net>. Many thanks to him. |
|
5908 | 5922 | |
|
5909 | 5923 | * IPython/iplib.py (complete): got auto-completion to work with |
|
5910 | 5924 | automagic (I had wanted this for a long time). |
|
5911 | 5925 | |
|
5912 | 5926 | * IPython/Magic.py (Magic.magic_files): Added @files as an alias |
|
5913 | 5927 | to @file, since file() is now a builtin and clashes with automagic |
|
5914 | 5928 | for @file. |
|
5915 | 5929 | |
|
5916 | 5930 | * Made some new files: Prompts, CrashHandler, Magic, Logger. All |
|
5917 | 5931 | of this was previously in iplib, which had grown to more than 2000 |
|
5918 | 5932 | lines, way too long. No new functionality, but it makes managing |
|
5919 | 5933 | the code a bit easier. |
|
5920 | 5934 | |
|
5921 | 5935 | * IPython/iplib.py (IPythonCrashHandler.__call__): Added version |
|
5922 | 5936 | information to crash reports. |
|
5923 | 5937 | |
|
5924 | 5938 | 2002-02-12 Fernando Perez <fperez@colorado.edu> |
|
5925 | 5939 | |
|
5926 | 5940 | * Released 0.2.5. |
|
5927 | 5941 | |
|
5928 | 5942 | 2002-02-11 Fernando Perez <fperez@colorado.edu> |
|
5929 | 5943 | |
|
5930 | 5944 | * Wrote a relatively complete Windows installer. It puts |
|
5931 | 5945 | everything in place, creates Start Menu entries and fixes the |
|
5932 | 5946 | color issues. Nothing fancy, but it works. |
|
5933 | 5947 | |
|
5934 | 5948 | 2002-02-10 Fernando Perez <fperez@colorado.edu> |
|
5935 | 5949 | |
|
5936 | 5950 | * IPython/iplib.py (InteractiveShell.safe_execfile): added an |
|
5937 | 5951 | os.path.expanduser() call so that we can type @run ~/myfile.py and |
|
5938 | 5952 | have thigs work as expected. |
|
5939 | 5953 | |
|
5940 | 5954 | * IPython/genutils.py (page): fixed exception handling so things |
|
5941 | 5955 | work both in Unix and Windows correctly. Quitting a pager triggers |
|
5942 | 5956 | an IOError/broken pipe in Unix, and in windows not finding a pager |
|
5943 | 5957 | is also an IOError, so I had to actually look at the return value |
|
5944 | 5958 | of the exception, not just the exception itself. Should be ok now. |
|
5945 | 5959 | |
|
5946 | 5960 | * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme): |
|
5947 | 5961 | modified to allow case-insensitive color scheme changes. |
|
5948 | 5962 | |
|
5949 | 5963 | 2002-02-09 Fernando Perez <fperez@colorado.edu> |
|
5950 | 5964 | |
|
5951 | 5965 | * IPython/genutils.py (native_line_ends): new function to leave |
|
5952 | 5966 | user config files with os-native line-endings. |
|
5953 | 5967 | |
|
5954 | 5968 | * README and manual updates. |
|
5955 | 5969 | |
|
5956 | 5970 | * IPython/genutils.py: fixed unicode bug: use types.StringTypes |
|
5957 | 5971 | instead of StringType to catch Unicode strings. |
|
5958 | 5972 | |
|
5959 | 5973 | * IPython/genutils.py (filefind): fixed bug for paths with |
|
5960 | 5974 | embedded spaces (very common in Windows). |
|
5961 | 5975 | |
|
5962 | 5976 | * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc |
|
5963 | 5977 | files under Windows, so that they get automatically associated |
|
5964 | 5978 | with a text editor. Windows makes it a pain to handle |
|
5965 | 5979 | extension-less files. |
|
5966 | 5980 | |
|
5967 | 5981 | * IPython/iplib.py (InteractiveShell.init_readline): Made the |
|
5968 | 5982 | warning about readline only occur for Posix. In Windows there's no |
|
5969 | 5983 | way to get readline, so why bother with the warning. |
|
5970 | 5984 | |
|
5971 | 5985 | * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__ |
|
5972 | 5986 | for __str__ instead of dir(self), since dir() changed in 2.2. |
|
5973 | 5987 | |
|
5974 | 5988 | * Ported to Windows! Tested on XP, I suspect it should work fine |
|
5975 | 5989 | on NT/2000, but I don't think it will work on 98 et al. That |
|
5976 | 5990 | series of Windows is such a piece of junk anyway that I won't try |
|
5977 | 5991 | porting it there. The XP port was straightforward, showed a few |
|
5978 | 5992 | bugs here and there (fixed all), in particular some string |
|
5979 | 5993 | handling stuff which required considering Unicode strings (which |
|
5980 | 5994 | Windows uses). This is good, but hasn't been too tested :) No |
|
5981 | 5995 | fancy installer yet, I'll put a note in the manual so people at |
|
5982 | 5996 | least make manually a shortcut. |
|
5983 | 5997 | |
|
5984 | 5998 | * IPython/iplib.py (Magic.magic_colors): Unified the color options |
|
5985 | 5999 | into a single one, "colors". This now controls both prompt and |
|
5986 | 6000 | exception color schemes, and can be changed both at startup |
|
5987 | 6001 | (either via command-line switches or via ipythonrc files) and at |
|
5988 | 6002 | runtime, with @colors. |
|
5989 | 6003 | (Magic.magic_run): renamed @prun to @run and removed the old |
|
5990 | 6004 | @run. The two were too similar to warrant keeping both. |
|
5991 | 6005 | |
|
5992 | 6006 | 2002-02-03 Fernando Perez <fperez@colorado.edu> |
|
5993 | 6007 | |
|
5994 | 6008 | * IPython/iplib.py (install_first_time): Added comment on how to |
|
5995 | 6009 | configure the color options for first-time users. Put a <return> |
|
5996 | 6010 | request at the end so that small-terminal users get a chance to |
|
5997 | 6011 | read the startup info. |
|
5998 | 6012 | |
|
5999 | 6013 | 2002-01-23 Fernando Perez <fperez@colorado.edu> |
|
6000 | 6014 | |
|
6001 | 6015 | * IPython/iplib.py (CachedOutput.update): Changed output memory |
|
6002 | 6016 | variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For |
|
6003 | 6017 | input history we still use _i. Did this b/c these variable are |
|
6004 | 6018 | very commonly used in interactive work, so the less we need to |
|
6005 | 6019 | type the better off we are. |
|
6006 | 6020 | (Magic.magic_prun): updated @prun to better handle the namespaces |
|
6007 | 6021 | the file will run in, including a fix for __name__ not being set |
|
6008 | 6022 | before. |
|
6009 | 6023 | |
|
6010 | 6024 | 2002-01-20 Fernando Perez <fperez@colorado.edu> |
|
6011 | 6025 | |
|
6012 | 6026 | * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of |
|
6013 | 6027 | extra garbage for Python 2.2. Need to look more carefully into |
|
6014 | 6028 | this later. |
|
6015 | 6029 | |
|
6016 | 6030 | 2002-01-19 Fernando Perez <fperez@colorado.edu> |
|
6017 | 6031 | |
|
6018 | 6032 | * IPython/iplib.py (InteractiveShell.showtraceback): fixed to |
|
6019 | 6033 | display SyntaxError exceptions properly formatted when they occur |
|
6020 | 6034 | (they can be triggered by imported code). |
|
6021 | 6035 | |
|
6022 | 6036 | 2002-01-18 Fernando Perez <fperez@colorado.edu> |
|
6023 | 6037 | |
|
6024 | 6038 | * IPython/iplib.py (InteractiveShell.safe_execfile): now |
|
6025 | 6039 | SyntaxError exceptions are reported nicely formatted, instead of |
|
6026 | 6040 | spitting out only offset information as before. |
|
6027 | 6041 | (Magic.magic_prun): Added the @prun function for executing |
|
6028 | 6042 | programs with command line args inside IPython. |
|
6029 | 6043 | |
|
6030 | 6044 | 2002-01-16 Fernando Perez <fperez@colorado.edu> |
|
6031 | 6045 | |
|
6032 | 6046 | * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist |
|
6033 | 6047 | to *not* include the last item given in a range. This brings their |
|
6034 | 6048 | behavior in line with Python's slicing: |
|
6035 | 6049 | a[n1:n2] -> a[n1]...a[n2-1] |
|
6036 | 6050 | It may be a bit less convenient, but I prefer to stick to Python's |
|
6037 | 6051 | conventions *everywhere*, so users never have to wonder. |
|
6038 | 6052 | (Magic.magic_macro): Added @macro function to ease the creation of |
|
6039 | 6053 | macros. |
|
6040 | 6054 | |
|
6041 | 6055 | 2002-01-05 Fernando Perez <fperez@colorado.edu> |
|
6042 | 6056 | |
|
6043 | 6057 | * Released 0.2.4. |
|
6044 | 6058 | |
|
6045 | 6059 | * IPython/iplib.py (Magic.magic_pdef): |
|
6046 | 6060 | (InteractiveShell.safe_execfile): report magic lines and error |
|
6047 | 6061 | lines without line numbers so one can easily copy/paste them for |
|
6048 | 6062 | re-execution. |
|
6049 | 6063 | |
|
6050 | 6064 | * Updated manual with recent changes. |
|
6051 | 6065 | |
|
6052 | 6066 | * IPython/iplib.py (Magic.magic_oinfo): added constructor |
|
6053 | 6067 | docstring printing when class? is called. Very handy for knowing |
|
6054 | 6068 | how to create class instances (as long as __init__ is well |
|
6055 | 6069 | documented, of course :) |
|
6056 | 6070 | (Magic.magic_doc): print both class and constructor docstrings. |
|
6057 | 6071 | (Magic.magic_pdef): give constructor info if passed a class and |
|
6058 | 6072 | __call__ info for callable object instances. |
|
6059 | 6073 | |
|
6060 | 6074 | 2002-01-04 Fernando Perez <fperez@colorado.edu> |
|
6061 | 6075 | |
|
6062 | 6076 | * Made deep_reload() off by default. It doesn't always work |
|
6063 | 6077 | exactly as intended, so it's probably safer to have it off. It's |
|
6064 | 6078 | still available as dreload() anyway, so nothing is lost. |
|
6065 | 6079 | |
|
6066 | 6080 | 2002-01-02 Fernando Perez <fperez@colorado.edu> |
|
6067 | 6081 | |
|
6068 | 6082 | * Released 0.2.3 (contacted R.Singh at CU about biopython course, |
|
6069 | 6083 | so I wanted an updated release). |
|
6070 | 6084 | |
|
6071 | 6085 | 2001-12-27 Fernando Perez <fperez@colorado.edu> |
|
6072 | 6086 | |
|
6073 | 6087 | * IPython/iplib.py (InteractiveShell.interact): Added the original |
|
6074 | 6088 | code from 'code.py' for this module in order to change the |
|
6075 | 6089 | handling of a KeyboardInterrupt. This was necessary b/c otherwise |
|
6076 | 6090 | the history cache would break when the user hit Ctrl-C, and |
|
6077 | 6091 | interact() offers no way to add any hooks to it. |
|
6078 | 6092 | |
|
6079 | 6093 | 2001-12-23 Fernando Perez <fperez@colorado.edu> |
|
6080 | 6094 | |
|
6081 | 6095 | * setup.py: added check for 'MANIFEST' before trying to remove |
|
6082 | 6096 | it. Thanks to Sean Reifschneider. |
|
6083 | 6097 | |
|
6084 | 6098 | 2001-12-22 Fernando Perez <fperez@colorado.edu> |
|
6085 | 6099 | |
|
6086 | 6100 | * Released 0.2.2. |
|
6087 | 6101 | |
|
6088 | 6102 | * Finished (reasonably) writing the manual. Later will add the |
|
6089 | 6103 | python-standard navigation stylesheets, but for the time being |
|
6090 | 6104 | it's fairly complete. Distribution will include html and pdf |
|
6091 | 6105 | versions. |
|
6092 | 6106 | |
|
6093 | 6107 | * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu |
|
6094 | 6108 | (MayaVi author). |
|
6095 | 6109 | |
|
6096 | 6110 | 2001-12-21 Fernando Perez <fperez@colorado.edu> |
|
6097 | 6111 | |
|
6098 | 6112 | * Released 0.2.1. Barring any nasty bugs, this is it as far as a |
|
6099 | 6113 | good public release, I think (with the manual and the distutils |
|
6100 | 6114 | installer). The manual can use some work, but that can go |
|
6101 | 6115 | slowly. Otherwise I think it's quite nice for end users. Next |
|
6102 | 6116 | summer, rewrite the guts of it... |
|
6103 | 6117 | |
|
6104 | 6118 | * Changed format of ipythonrc files to use whitespace as the |
|
6105 | 6119 | separator instead of an explicit '='. Cleaner. |
|
6106 | 6120 | |
|
6107 | 6121 | 2001-12-20 Fernando Perez <fperez@colorado.edu> |
|
6108 | 6122 | |
|
6109 | 6123 | * Started a manual in LyX. For now it's just a quick merge of the |
|
6110 | 6124 | various internal docstrings and READMEs. Later it may grow into a |
|
6111 | 6125 | nice, full-blown manual. |
|
6112 | 6126 | |
|
6113 | 6127 | * Set up a distutils based installer. Installation should now be |
|
6114 | 6128 | trivially simple for end-users. |
|
6115 | 6129 | |
|
6116 | 6130 | 2001-12-11 Fernando Perez <fperez@colorado.edu> |
|
6117 | 6131 | |
|
6118 | 6132 | * Released 0.2.0. First public release, announced it at |
|
6119 | 6133 | comp.lang.python. From now on, just bugfixes... |
|
6120 | 6134 | |
|
6121 | 6135 | * Went through all the files, set copyright/license notices and |
|
6122 | 6136 | cleaned up things. Ready for release. |
|
6123 | 6137 | |
|
6124 | 6138 | 2001-12-10 Fernando Perez <fperez@colorado.edu> |
|
6125 | 6139 | |
|
6126 | 6140 | * Changed the first-time installer not to use tarfiles. It's more |
|
6127 | 6141 | robust now and less unix-dependent. Also makes it easier for |
|
6128 | 6142 | people to later upgrade versions. |
|
6129 | 6143 | |
|
6130 | 6144 | * Changed @exit to @abort to reflect the fact that it's pretty |
|
6131 | 6145 | brutal (a sys.exit()). The difference between @abort and Ctrl-D |
|
6132 | 6146 | becomes significant only when IPyhton is embedded: in that case, |
|
6133 | 6147 | C-D closes IPython only, but @abort kills the enclosing program |
|
6134 | 6148 | too (unless it had called IPython inside a try catching |
|
6135 | 6149 | SystemExit). |
|
6136 | 6150 | |
|
6137 | 6151 | * Created Shell module which exposes the actuall IPython Shell |
|
6138 | 6152 | classes, currently the normal and the embeddable one. This at |
|
6139 | 6153 | least offers a stable interface we won't need to change when |
|
6140 | 6154 | (later) the internals are rewritten. That rewrite will be confined |
|
6141 | 6155 | to iplib and ipmaker, but the Shell interface should remain as is. |
|
6142 | 6156 | |
|
6143 | 6157 | * Added embed module which offers an embeddable IPShell object, |
|
6144 | 6158 | useful to fire up IPython *inside* a running program. Great for |
|
6145 | 6159 | debugging or dynamical data analysis. |
|
6146 | 6160 | |
|
6147 | 6161 | 2001-12-08 Fernando Perez <fperez@colorado.edu> |
|
6148 | 6162 | |
|
6149 | 6163 | * Fixed small bug preventing seeing info from methods of defined |
|
6150 | 6164 | objects (incorrect namespace in _ofind()). |
|
6151 | 6165 | |
|
6152 | 6166 | * Documentation cleanup. Moved the main usage docstrings to a |
|
6153 | 6167 | separate file, usage.py (cleaner to maintain, and hopefully in the |
|
6154 | 6168 | future some perlpod-like way of producing interactive, man and |
|
6155 | 6169 | html docs out of it will be found). |
|
6156 | 6170 | |
|
6157 | 6171 | * Added @profile to see your profile at any time. |
|
6158 | 6172 | |
|
6159 | 6173 | * Added @p as an alias for 'print'. It's especially convenient if |
|
6160 | 6174 | using automagic ('p x' prints x). |
|
6161 | 6175 | |
|
6162 | 6176 | * Small cleanups and fixes after a pychecker run. |
|
6163 | 6177 | |
|
6164 | 6178 | * Changed the @cd command to handle @cd - and @cd -<n> for |
|
6165 | 6179 | visiting any directory in _dh. |
|
6166 | 6180 | |
|
6167 | 6181 | * Introduced _dh, a history of visited directories. @dhist prints |
|
6168 | 6182 | it out with numbers. |
|
6169 | 6183 | |
|
6170 | 6184 | 2001-12-07 Fernando Perez <fperez@colorado.edu> |
|
6171 | 6185 | |
|
6172 | 6186 | * Released 0.1.22 |
|
6173 | 6187 | |
|
6174 | 6188 | * Made initialization a bit more robust against invalid color |
|
6175 | 6189 | options in user input (exit, not traceback-crash). |
|
6176 | 6190 | |
|
6177 | 6191 | * Changed the bug crash reporter to write the report only in the |
|
6178 | 6192 | user's .ipython directory. That way IPython won't litter people's |
|
6179 | 6193 | hard disks with crash files all over the place. Also print on |
|
6180 | 6194 | screen the necessary mail command. |
|
6181 | 6195 | |
|
6182 | 6196 | * With the new ultraTB, implemented LightBG color scheme for light |
|
6183 | 6197 | background terminals. A lot of people like white backgrounds, so I |
|
6184 | 6198 | guess we should at least give them something readable. |
|
6185 | 6199 | |
|
6186 | 6200 | 2001-12-06 Fernando Perez <fperez@colorado.edu> |
|
6187 | 6201 | |
|
6188 | 6202 | * Modified the structure of ultraTB. Now there's a proper class |
|
6189 | 6203 | for tables of color schemes which allow adding schemes easily and |
|
6190 | 6204 | switching the active scheme without creating a new instance every |
|
6191 | 6205 | time (which was ridiculous). The syntax for creating new schemes |
|
6192 | 6206 | is also cleaner. I think ultraTB is finally done, with a clean |
|
6193 | 6207 | class structure. Names are also much cleaner (now there's proper |
|
6194 | 6208 | color tables, no need for every variable to also have 'color' in |
|
6195 | 6209 | its name). |
|
6196 | 6210 | |
|
6197 | 6211 | * Broke down genutils into separate files. Now genutils only |
|
6198 | 6212 | contains utility functions, and classes have been moved to their |
|
6199 | 6213 | own files (they had enough independent functionality to warrant |
|
6200 | 6214 | it): ConfigLoader, OutputTrap, Struct. |
|
6201 | 6215 | |
|
6202 | 6216 | 2001-12-05 Fernando Perez <fperez@colorado.edu> |
|
6203 | 6217 | |
|
6204 | 6218 | * IPython turns 21! Released version 0.1.21, as a candidate for |
|
6205 | 6219 | public consumption. If all goes well, release in a few days. |
|
6206 | 6220 | |
|
6207 | 6221 | * Fixed path bug (files in Extensions/ directory wouldn't be found |
|
6208 | 6222 | unless IPython/ was explicitly in sys.path). |
|
6209 | 6223 | |
|
6210 | 6224 | * Extended the FlexCompleter class as MagicCompleter to allow |
|
6211 | 6225 | completion of @-starting lines. |
|
6212 | 6226 | |
|
6213 | 6227 | * Created __release__.py file as a central repository for release |
|
6214 | 6228 | info that other files can read from. |
|
6215 | 6229 | |
|
6216 | 6230 | * Fixed small bug in logging: when logging was turned on in |
|
6217 | 6231 | mid-session, old lines with special meanings (!@?) were being |
|
6218 | 6232 | logged without the prepended comment, which is necessary since |
|
6219 | 6233 | they are not truly valid python syntax. This should make session |
|
6220 | 6234 | restores produce less errors. |
|
6221 | 6235 | |
|
6222 | 6236 | * The namespace cleanup forced me to make a FlexCompleter class |
|
6223 | 6237 | which is nothing but a ripoff of rlcompleter, but with selectable |
|
6224 | 6238 | namespace (rlcompleter only works in __main__.__dict__). I'll try |
|
6225 | 6239 | to submit a note to the authors to see if this change can be |
|
6226 | 6240 | incorporated in future rlcompleter releases (Dec.6: done) |
|
6227 | 6241 | |
|
6228 | 6242 | * More fixes to namespace handling. It was a mess! Now all |
|
6229 | 6243 | explicit references to __main__.__dict__ are gone (except when |
|
6230 | 6244 | really needed) and everything is handled through the namespace |
|
6231 | 6245 | dicts in the IPython instance. We seem to be getting somewhere |
|
6232 | 6246 | with this, finally... |
|
6233 | 6247 | |
|
6234 | 6248 | * Small documentation updates. |
|
6235 | 6249 | |
|
6236 | 6250 | * Created the Extensions directory under IPython (with an |
|
6237 | 6251 | __init__.py). Put the PhysicalQ stuff there. This directory should |
|
6238 | 6252 | be used for all special-purpose extensions. |
|
6239 | 6253 | |
|
6240 | 6254 | * File renaming: |
|
6241 | 6255 | ipythonlib --> ipmaker |
|
6242 | 6256 | ipplib --> iplib |
|
6243 | 6257 | This makes a bit more sense in terms of what these files actually do. |
|
6244 | 6258 | |
|
6245 | 6259 | * Moved all the classes and functions in ipythonlib to ipplib, so |
|
6246 | 6260 | now ipythonlib only has make_IPython(). This will ease up its |
|
6247 | 6261 | splitting in smaller functional chunks later. |
|
6248 | 6262 | |
|
6249 | 6263 | * Cleaned up (done, I think) output of @whos. Better column |
|
6250 | 6264 | formatting, and now shows str(var) for as much as it can, which is |
|
6251 | 6265 | typically what one gets with a 'print var'. |
|
6252 | 6266 | |
|
6253 | 6267 | 2001-12-04 Fernando Perez <fperez@colorado.edu> |
|
6254 | 6268 | |
|
6255 | 6269 | * Fixed namespace problems. Now builtin/IPyhton/user names get |
|
6256 | 6270 | properly reported in their namespace. Internal namespace handling |
|
6257 | 6271 | is finally getting decent (not perfect yet, but much better than |
|
6258 | 6272 | the ad-hoc mess we had). |
|
6259 | 6273 | |
|
6260 | 6274 | * Removed -exit option. If people just want to run a python |
|
6261 | 6275 | script, that's what the normal interpreter is for. Less |
|
6262 | 6276 | unnecessary options, less chances for bugs. |
|
6263 | 6277 | |
|
6264 | 6278 | * Added a crash handler which generates a complete post-mortem if |
|
6265 | 6279 | IPython crashes. This will help a lot in tracking bugs down the |
|
6266 | 6280 | road. |
|
6267 | 6281 | |
|
6268 | 6282 | * Fixed nasty bug in auto-evaluation part of prefilter(). Names |
|
6269 | 6283 | which were boud to functions being reassigned would bypass the |
|
6270 | 6284 | logger, breaking the sync of _il with the prompt counter. This |
|
6271 | 6285 | would then crash IPython later when a new line was logged. |
|
6272 | 6286 | |
|
6273 | 6287 | 2001-12-02 Fernando Perez <fperez@colorado.edu> |
|
6274 | 6288 | |
|
6275 | 6289 | * Made IPython a package. This means people don't have to clutter |
|
6276 | 6290 | their sys.path with yet another directory. Changed the INSTALL |
|
6277 | 6291 | file accordingly. |
|
6278 | 6292 | |
|
6279 | 6293 | * Cleaned up the output of @who_ls, @who and @whos. @who_ls now |
|
6280 | 6294 | sorts its output (so @who shows it sorted) and @whos formats the |
|
6281 | 6295 | table according to the width of the first column. Nicer, easier to |
|
6282 | 6296 | read. Todo: write a generic table_format() which takes a list of |
|
6283 | 6297 | lists and prints it nicely formatted, with optional row/column |
|
6284 | 6298 | separators and proper padding and justification. |
|
6285 | 6299 | |
|
6286 | 6300 | * Released 0.1.20 |
|
6287 | 6301 | |
|
6288 | 6302 | * Fixed bug in @log which would reverse the inputcache list (a |
|
6289 | 6303 | copy operation was missing). |
|
6290 | 6304 | |
|
6291 | 6305 | * Code cleanup. @config was changed to use page(). Better, since |
|
6292 | 6306 | its output is always quite long. |
|
6293 | 6307 | |
|
6294 | 6308 | * Itpl is back as a dependency. I was having too many problems |
|
6295 | 6309 | getting the parametric aliases to work reliably, and it's just |
|
6296 | 6310 | easier to code weird string operations with it than playing %()s |
|
6297 | 6311 | games. It's only ~6k, so I don't think it's too big a deal. |
|
6298 | 6312 | |
|
6299 | 6313 | * Found (and fixed) a very nasty bug with history. !lines weren't |
|
6300 | 6314 | getting cached, and the out of sync caches would crash |
|
6301 | 6315 | IPython. Fixed it by reorganizing the prefilter/handlers/logger |
|
6302 | 6316 | division of labor a bit better. Bug fixed, cleaner structure. |
|
6303 | 6317 | |
|
6304 | 6318 | 2001-12-01 Fernando Perez <fperez@colorado.edu> |
|
6305 | 6319 | |
|
6306 | 6320 | * Released 0.1.19 |
|
6307 | 6321 | |
|
6308 | 6322 | * Added option -n to @hist to prevent line number printing. Much |
|
6309 | 6323 | easier to copy/paste code this way. |
|
6310 | 6324 | |
|
6311 | 6325 | * Created global _il to hold the input list. Allows easy |
|
6312 | 6326 | re-execution of blocks of code by slicing it (inspired by Janko's |
|
6313 | 6327 | comment on 'macros'). |
|
6314 | 6328 | |
|
6315 | 6329 | * Small fixes and doc updates. |
|
6316 | 6330 | |
|
6317 | 6331 | * Rewrote @history function (was @h). Renamed it to @hist, @h is |
|
6318 | 6332 | much too fragile with automagic. Handles properly multi-line |
|
6319 | 6333 | statements and takes parameters. |
|
6320 | 6334 | |
|
6321 | 6335 | 2001-11-30 Fernando Perez <fperez@colorado.edu> |
|
6322 | 6336 | |
|
6323 | 6337 | * Version 0.1.18 released. |
|
6324 | 6338 | |
|
6325 | 6339 | * Fixed nasty namespace bug in initial module imports. |
|
6326 | 6340 | |
|
6327 | 6341 | * Added copyright/license notes to all code files (except |
|
6328 | 6342 | DPyGetOpt). For the time being, LGPL. That could change. |
|
6329 | 6343 | |
|
6330 | 6344 | * Rewrote a much nicer README, updated INSTALL, cleaned up |
|
6331 | 6345 | ipythonrc-* samples. |
|
6332 | 6346 | |
|
6333 | 6347 | * Overall code/documentation cleanup. Basically ready for |
|
6334 | 6348 | release. Only remaining thing: licence decision (LGPL?). |
|
6335 | 6349 | |
|
6336 | 6350 | * Converted load_config to a class, ConfigLoader. Now recursion |
|
6337 | 6351 | control is better organized. Doesn't include the same file twice. |
|
6338 | 6352 | |
|
6339 | 6353 | 2001-11-29 Fernando Perez <fperez@colorado.edu> |
|
6340 | 6354 | |
|
6341 | 6355 | * Got input history working. Changed output history variables from |
|
6342 | 6356 | _p to _o so that _i is for input and _o for output. Just cleaner |
|
6343 | 6357 | convention. |
|
6344 | 6358 | |
|
6345 | 6359 | * Implemented parametric aliases. This pretty much allows the |
|
6346 | 6360 | alias system to offer full-blown shell convenience, I think. |
|
6347 | 6361 | |
|
6348 | 6362 | * Version 0.1.17 released, 0.1.18 opened. |
|
6349 | 6363 | |
|
6350 | 6364 | * dot_ipython/ipythonrc (alias): added documentation. |
|
6351 | 6365 | (xcolor): Fixed small bug (xcolors -> xcolor) |
|
6352 | 6366 | |
|
6353 | 6367 | * Changed the alias system. Now alias is a magic command to define |
|
6354 | 6368 | aliases just like the shell. Rationale: the builtin magics should |
|
6355 | 6369 | be there for things deeply connected to IPython's |
|
6356 | 6370 | architecture. And this is a much lighter system for what I think |
|
6357 | 6371 | is the really important feature: allowing users to define quickly |
|
6358 | 6372 | magics that will do shell things for them, so they can customize |
|
6359 | 6373 | IPython easily to match their work habits. If someone is really |
|
6360 | 6374 | desperate to have another name for a builtin alias, they can |
|
6361 | 6375 | always use __IP.magic_newname = __IP.magic_oldname. Hackish but |
|
6362 | 6376 | works. |
|
6363 | 6377 | |
|
6364 | 6378 | 2001-11-28 Fernando Perez <fperez@colorado.edu> |
|
6365 | 6379 | |
|
6366 | 6380 | * Changed @file so that it opens the source file at the proper |
|
6367 | 6381 | line. Since it uses less, if your EDITOR environment is |
|
6368 | 6382 | configured, typing v will immediately open your editor of choice |
|
6369 | 6383 | right at the line where the object is defined. Not as quick as |
|
6370 | 6384 | having a direct @edit command, but for all intents and purposes it |
|
6371 | 6385 | works. And I don't have to worry about writing @edit to deal with |
|
6372 | 6386 | all the editors, less does that. |
|
6373 | 6387 | |
|
6374 | 6388 | * Version 0.1.16 released, 0.1.17 opened. |
|
6375 | 6389 | |
|
6376 | 6390 | * Fixed some nasty bugs in the page/page_dumb combo that could |
|
6377 | 6391 | crash IPython. |
|
6378 | 6392 | |
|
6379 | 6393 | 2001-11-27 Fernando Perez <fperez@colorado.edu> |
|
6380 | 6394 | |
|
6381 | 6395 | * Version 0.1.15 released, 0.1.16 opened. |
|
6382 | 6396 | |
|
6383 | 6397 | * Finally got ? and ?? to work for undefined things: now it's |
|
6384 | 6398 | possible to type {}.get? and get information about the get method |
|
6385 | 6399 | of dicts, or os.path? even if only os is defined (so technically |
|
6386 | 6400 | os.path isn't). Works at any level. For example, after import os, |
|
6387 | 6401 | os?, os.path?, os.path.abspath? all work. This is great, took some |
|
6388 | 6402 | work in _ofind. |
|
6389 | 6403 | |
|
6390 | 6404 | * Fixed more bugs with logging. The sanest way to do it was to add |
|
6391 | 6405 | to @log a 'mode' parameter. Killed two in one shot (this mode |
|
6392 | 6406 | option was a request of Janko's). I think it's finally clean |
|
6393 | 6407 | (famous last words). |
|
6394 | 6408 | |
|
6395 | 6409 | * Added a page_dumb() pager which does a decent job of paging on |
|
6396 | 6410 | screen, if better things (like less) aren't available. One less |
|
6397 | 6411 | unix dependency (someday maybe somebody will port this to |
|
6398 | 6412 | windows). |
|
6399 | 6413 | |
|
6400 | 6414 | * Fixed problem in magic_log: would lock of logging out if log |
|
6401 | 6415 | creation failed (because it would still think it had succeeded). |
|
6402 | 6416 | |
|
6403 | 6417 | * Improved the page() function using curses to auto-detect screen |
|
6404 | 6418 | size. Now it can make a much better decision on whether to print |
|
6405 | 6419 | or page a string. Option screen_length was modified: a value 0 |
|
6406 | 6420 | means auto-detect, and that's the default now. |
|
6407 | 6421 | |
|
6408 | 6422 | * Version 0.1.14 released, 0.1.15 opened. I think this is ready to |
|
6409 | 6423 | go out. I'll test it for a few days, then talk to Janko about |
|
6410 | 6424 | licences and announce it. |
|
6411 | 6425 | |
|
6412 | 6426 | * Fixed the length of the auto-generated ---> prompt which appears |
|
6413 | 6427 | for auto-parens and auto-quotes. Getting this right isn't trivial, |
|
6414 | 6428 | with all the color escapes, different prompt types and optional |
|
6415 | 6429 | separators. But it seems to be working in all the combinations. |
|
6416 | 6430 | |
|
6417 | 6431 | 2001-11-26 Fernando Perez <fperez@colorado.edu> |
|
6418 | 6432 | |
|
6419 | 6433 | * Wrote a regexp filter to get option types from the option names |
|
6420 | 6434 | string. This eliminates the need to manually keep two duplicate |
|
6421 | 6435 | lists. |
|
6422 | 6436 | |
|
6423 | 6437 | * Removed the unneeded check_option_names. Now options are handled |
|
6424 | 6438 | in a much saner manner and it's easy to visually check that things |
|
6425 | 6439 | are ok. |
|
6426 | 6440 | |
|
6427 | 6441 | * Updated version numbers on all files I modified to carry a |
|
6428 | 6442 | notice so Janko and Nathan have clear version markers. |
|
6429 | 6443 | |
|
6430 | 6444 | * Updated docstring for ultraTB with my changes. I should send |
|
6431 | 6445 | this to Nathan. |
|
6432 | 6446 | |
|
6433 | 6447 | * Lots of small fixes. Ran everything through pychecker again. |
|
6434 | 6448 | |
|
6435 | 6449 | * Made loading of deep_reload an cmd line option. If it's not too |
|
6436 | 6450 | kosher, now people can just disable it. With -nodeep_reload it's |
|
6437 | 6451 | still available as dreload(), it just won't overwrite reload(). |
|
6438 | 6452 | |
|
6439 | 6453 | * Moved many options to the no| form (-opt and -noopt |
|
6440 | 6454 | accepted). Cleaner. |
|
6441 | 6455 | |
|
6442 | 6456 | * Changed magic_log so that if called with no parameters, it uses |
|
6443 | 6457 | 'rotate' mode. That way auto-generated logs aren't automatically |
|
6444 | 6458 | over-written. For normal logs, now a backup is made if it exists |
|
6445 | 6459 | (only 1 level of backups). A new 'backup' mode was added to the |
|
6446 | 6460 | Logger class to support this. This was a request by Janko. |
|
6447 | 6461 | |
|
6448 | 6462 | * Added @logoff/@logon to stop/restart an active log. |
|
6449 | 6463 | |
|
6450 | 6464 | * Fixed a lot of bugs in log saving/replay. It was pretty |
|
6451 | 6465 | broken. Now special lines (!@,/) appear properly in the command |
|
6452 | 6466 | history after a log replay. |
|
6453 | 6467 | |
|
6454 | 6468 | * Tried and failed to implement full session saving via pickle. My |
|
6455 | 6469 | idea was to pickle __main__.__dict__, but modules can't be |
|
6456 | 6470 | pickled. This would be a better alternative to replaying logs, but |
|
6457 | 6471 | seems quite tricky to get to work. Changed -session to be called |
|
6458 | 6472 | -logplay, which more accurately reflects what it does. And if we |
|
6459 | 6473 | ever get real session saving working, -session is now available. |
|
6460 | 6474 | |
|
6461 | 6475 | * Implemented color schemes for prompts also. As for tracebacks, |
|
6462 | 6476 | currently only NoColor and Linux are supported. But now the |
|
6463 | 6477 | infrastructure is in place, based on a generic ColorScheme |
|
6464 | 6478 | class. So writing and activating new schemes both for the prompts |
|
6465 | 6479 | and the tracebacks should be straightforward. |
|
6466 | 6480 | |
|
6467 | 6481 | * Version 0.1.13 released, 0.1.14 opened. |
|
6468 | 6482 | |
|
6469 | 6483 | * Changed handling of options for output cache. Now counter is |
|
6470 | 6484 | hardwired starting at 1 and one specifies the maximum number of |
|
6471 | 6485 | entries *in the outcache* (not the max prompt counter). This is |
|
6472 | 6486 | much better, since many statements won't increase the cache |
|
6473 | 6487 | count. It also eliminated some confusing options, now there's only |
|
6474 | 6488 | one: cache_size. |
|
6475 | 6489 | |
|
6476 | 6490 | * Added 'alias' magic function and magic_alias option in the |
|
6477 | 6491 | ipythonrc file. Now the user can easily define whatever names he |
|
6478 | 6492 | wants for the magic functions without having to play weird |
|
6479 | 6493 | namespace games. This gives IPython a real shell-like feel. |
|
6480 | 6494 | |
|
6481 | 6495 | * Fixed doc/?/?? for magics. Now all work, in all forms (explicit |
|
6482 | 6496 | @ or not). |
|
6483 | 6497 | |
|
6484 | 6498 | This was one of the last remaining 'visible' bugs (that I know |
|
6485 | 6499 | of). I think if I can clean up the session loading so it works |
|
6486 | 6500 | 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first |
|
6487 | 6501 | about licensing). |
|
6488 | 6502 | |
|
6489 | 6503 | 2001-11-25 Fernando Perez <fperez@colorado.edu> |
|
6490 | 6504 | |
|
6491 | 6505 | * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and |
|
6492 | 6506 | there's a cleaner distinction between what ? and ?? show. |
|
6493 | 6507 | |
|
6494 | 6508 | * Added screen_length option. Now the user can define his own |
|
6495 | 6509 | screen size for page() operations. |
|
6496 | 6510 | |
|
6497 | 6511 | * Implemented magic shell-like functions with automatic code |
|
6498 | 6512 | generation. Now adding another function is just a matter of adding |
|
6499 | 6513 | an entry to a dict, and the function is dynamically generated at |
|
6500 | 6514 | run-time. Python has some really cool features! |
|
6501 | 6515 | |
|
6502 | 6516 | * Renamed many options to cleanup conventions a little. Now all |
|
6503 | 6517 | are lowercase, and only underscores where needed. Also in the code |
|
6504 | 6518 | option name tables are clearer. |
|
6505 | 6519 | |
|
6506 | 6520 | * Changed prompts a little. Now input is 'In [n]:' instead of |
|
6507 | 6521 | 'In[n]:='. This allows it the numbers to be aligned with the |
|
6508 | 6522 | Out[n] numbers, and removes usage of ':=' which doesn't exist in |
|
6509 | 6523 | Python (it was a Mathematica thing). The '...' continuation prompt |
|
6510 | 6524 | was also changed a little to align better. |
|
6511 | 6525 | |
|
6512 | 6526 | * Fixed bug when flushing output cache. Not all _p<n> variables |
|
6513 | 6527 | exist, so their deletion needs to be wrapped in a try: |
|
6514 | 6528 | |
|
6515 | 6529 | * Figured out how to properly use inspect.formatargspec() (it |
|
6516 | 6530 | requires the args preceded by *). So I removed all the code from |
|
6517 | 6531 | _get_pdef in Magic, which was just replicating that. |
|
6518 | 6532 | |
|
6519 | 6533 | * Added test to prefilter to allow redefining magic function names |
|
6520 | 6534 | as variables. This is ok, since the @ form is always available, |
|
6521 | 6535 | but whe should allow the user to define a variable called 'ls' if |
|
6522 | 6536 | he needs it. |
|
6523 | 6537 | |
|
6524 | 6538 | * Moved the ToDo information from README into a separate ToDo. |
|
6525 | 6539 | |
|
6526 | 6540 | * General code cleanup and small bugfixes. I think it's close to a |
|
6527 | 6541 | state where it can be released, obviously with a big 'beta' |
|
6528 | 6542 | warning on it. |
|
6529 | 6543 | |
|
6530 | 6544 | * Got the magic function split to work. Now all magics are defined |
|
6531 | 6545 | in a separate class. It just organizes things a bit, and now |
|
6532 | 6546 | Xemacs behaves nicer (it was choking on InteractiveShell b/c it |
|
6533 | 6547 | was too long). |
|
6534 | 6548 | |
|
6535 | 6549 | * Changed @clear to @reset to avoid potential confusions with |
|
6536 | 6550 | the shell command clear. Also renamed @cl to @clear, which does |
|
6537 | 6551 | exactly what people expect it to from their shell experience. |
|
6538 | 6552 | |
|
6539 | 6553 | Added a check to the @reset command (since it's so |
|
6540 | 6554 | destructive, it's probably a good idea to ask for confirmation). |
|
6541 | 6555 | But now reset only works for full namespace resetting. Since the |
|
6542 | 6556 | del keyword is already there for deleting a few specific |
|
6543 | 6557 | variables, I don't see the point of having a redundant magic |
|
6544 | 6558 | function for the same task. |
|
6545 | 6559 | |
|
6546 | 6560 | 2001-11-24 Fernando Perez <fperez@colorado.edu> |
|
6547 | 6561 | |
|
6548 | 6562 | * Updated the builtin docs (esp. the ? ones). |
|
6549 | 6563 | |
|
6550 | 6564 | * Ran all the code through pychecker. Not terribly impressed with |
|
6551 | 6565 | it: lots of spurious warnings and didn't really find anything of |
|
6552 | 6566 | substance (just a few modules being imported and not used). |
|
6553 | 6567 | |
|
6554 | 6568 | * Implemented the new ultraTB functionality into IPython. New |
|
6555 | 6569 | option: xcolors. This chooses color scheme. xmode now only selects |
|
6556 | 6570 | between Plain and Verbose. Better orthogonality. |
|
6557 | 6571 | |
|
6558 | 6572 | * Large rewrite of ultraTB. Much cleaner now, with a separation of |
|
6559 | 6573 | mode and color scheme for the exception handlers. Now it's |
|
6560 | 6574 | possible to have the verbose traceback with no coloring. |
|
6561 | 6575 | |
|
6562 | 6576 | 2001-11-23 Fernando Perez <fperez@colorado.edu> |
|
6563 | 6577 | |
|
6564 | 6578 | * Version 0.1.12 released, 0.1.13 opened. |
|
6565 | 6579 | |
|
6566 | 6580 | * Removed option to set auto-quote and auto-paren escapes by |
|
6567 | 6581 | user. The chances of breaking valid syntax are just too high. If |
|
6568 | 6582 | someone *really* wants, they can always dig into the code. |
|
6569 | 6583 | |
|
6570 | 6584 | * Made prompt separators configurable. |
|
6571 | 6585 | |
|
6572 | 6586 | 2001-11-22 Fernando Perez <fperez@colorado.edu> |
|
6573 | 6587 | |
|
6574 | 6588 | * Small bugfixes in many places. |
|
6575 | 6589 | |
|
6576 | 6590 | * Removed the MyCompleter class from ipplib. It seemed redundant |
|
6577 | 6591 | with the C-p,C-n history search functionality. Less code to |
|
6578 | 6592 | maintain. |
|
6579 | 6593 | |
|
6580 | 6594 | * Moved all the original ipython.py code into ipythonlib.py. Right |
|
6581 | 6595 | now it's just one big dump into a function called make_IPython, so |
|
6582 | 6596 | no real modularity has been gained. But at least it makes the |
|
6583 | 6597 | wrapper script tiny, and since ipythonlib is a module, it gets |
|
6584 | 6598 | compiled and startup is much faster. |
|
6585 | 6599 | |
|
6586 | 6600 | This is a reasobably 'deep' change, so we should test it for a |
|
6587 | 6601 | while without messing too much more with the code. |
|
6588 | 6602 | |
|
6589 | 6603 | 2001-11-21 Fernando Perez <fperez@colorado.edu> |
|
6590 | 6604 | |
|
6591 | 6605 | * Version 0.1.11 released, 0.1.12 opened for further work. |
|
6592 | 6606 | |
|
6593 | 6607 | * Removed dependency on Itpl. It was only needed in one place. It |
|
6594 | 6608 | would be nice if this became part of python, though. It makes life |
|
6595 | 6609 | *a lot* easier in some cases. |
|
6596 | 6610 | |
|
6597 | 6611 | * Simplified the prefilter code a bit. Now all handlers are |
|
6598 | 6612 | expected to explicitly return a value (at least a blank string). |
|
6599 | 6613 | |
|
6600 | 6614 | * Heavy edits in ipplib. Removed the help system altogether. Now |
|
6601 | 6615 | obj?/?? is used for inspecting objects, a magic @doc prints |
|
6602 | 6616 | docstrings, and full-blown Python help is accessed via the 'help' |
|
6603 | 6617 | keyword. This cleans up a lot of code (less to maintain) and does |
|
6604 | 6618 | the job. Since 'help' is now a standard Python component, might as |
|
6605 | 6619 | well use it and remove duplicate functionality. |
|
6606 | 6620 | |
|
6607 | 6621 | Also removed the option to use ipplib as a standalone program. By |
|
6608 | 6622 | now it's too dependent on other parts of IPython to function alone. |
|
6609 | 6623 | |
|
6610 | 6624 | * Fixed bug in genutils.pager. It would crash if the pager was |
|
6611 | 6625 | exited immediately after opening (broken pipe). |
|
6612 | 6626 | |
|
6613 | 6627 | * Trimmed down the VerboseTB reporting a little. The header is |
|
6614 | 6628 | much shorter now and the repeated exception arguments at the end |
|
6615 | 6629 | have been removed. For interactive use the old header seemed a bit |
|
6616 | 6630 | excessive. |
|
6617 | 6631 | |
|
6618 | 6632 | * Fixed small bug in output of @whos for variables with multi-word |
|
6619 | 6633 | types (only first word was displayed). |
|
6620 | 6634 | |
|
6621 | 6635 | 2001-11-17 Fernando Perez <fperez@colorado.edu> |
|
6622 | 6636 | |
|
6623 | 6637 | * Version 0.1.10 released, 0.1.11 opened for further work. |
|
6624 | 6638 | |
|
6625 | 6639 | * Modified dirs and friends. dirs now *returns* the stack (not |
|
6626 | 6640 | prints), so one can manipulate it as a variable. Convenient to |
|
6627 | 6641 | travel along many directories. |
|
6628 | 6642 | |
|
6629 | 6643 | * Fixed bug in magic_pdef: would only work with functions with |
|
6630 | 6644 | arguments with default values. |
|
6631 | 6645 | |
|
6632 | 6646 | 2001-11-14 Fernando Perez <fperez@colorado.edu> |
|
6633 | 6647 | |
|
6634 | 6648 | * Added the PhysicsInput stuff to dot_ipython so it ships as an |
|
6635 | 6649 | example with IPython. Various other minor fixes and cleanups. |
|
6636 | 6650 | |
|
6637 | 6651 | * Version 0.1.9 released, 0.1.10 opened for further work. |
|
6638 | 6652 | |
|
6639 | 6653 | * Added sys.path to the list of directories searched in the |
|
6640 | 6654 | execfile= option. It used to be the current directory and the |
|
6641 | 6655 | user's IPYTHONDIR only. |
|
6642 | 6656 | |
|
6643 | 6657 | 2001-11-13 Fernando Perez <fperez@colorado.edu> |
|
6644 | 6658 | |
|
6645 | 6659 | * Reinstated the raw_input/prefilter separation that Janko had |
|
6646 | 6660 | initially. This gives a more convenient setup for extending the |
|
6647 | 6661 | pre-processor from the outside: raw_input always gets a string, |
|
6648 | 6662 | and prefilter has to process it. We can then redefine prefilter |
|
6649 | 6663 | from the outside and implement extensions for special |
|
6650 | 6664 | purposes. |
|
6651 | 6665 | |
|
6652 | 6666 | Today I got one for inputting PhysicalQuantity objects |
|
6653 | 6667 | (from Scientific) without needing any function calls at |
|
6654 | 6668 | all. Extremely convenient, and it's all done as a user-level |
|
6655 | 6669 | extension (no IPython code was touched). Now instead of: |
|
6656 | 6670 | a = PhysicalQuantity(4.2,'m/s**2') |
|
6657 | 6671 | one can simply say |
|
6658 | 6672 | a = 4.2 m/s**2 |
|
6659 | 6673 | or even |
|
6660 | 6674 | a = 4.2 m/s^2 |
|
6661 | 6675 | |
|
6662 | 6676 | I use this, but it's also a proof of concept: IPython really is |
|
6663 | 6677 | fully user-extensible, even at the level of the parsing of the |
|
6664 | 6678 | command line. It's not trivial, but it's perfectly doable. |
|
6665 | 6679 | |
|
6666 | 6680 | * Added 'add_flip' method to inclusion conflict resolver. Fixes |
|
6667 | 6681 | the problem of modules being loaded in the inverse order in which |
|
6668 | 6682 | they were defined in |
|
6669 | 6683 | |
|
6670 | 6684 | * Version 0.1.8 released, 0.1.9 opened for further work. |
|
6671 | 6685 | |
|
6672 | 6686 | * Added magics pdef, source and file. They respectively show the |
|
6673 | 6687 | definition line ('prototype' in C), source code and full python |
|
6674 | 6688 | file for any callable object. The object inspector oinfo uses |
|
6675 | 6689 | these to show the same information. |
|
6676 | 6690 | |
|
6677 | 6691 | * Version 0.1.7 released, 0.1.8 opened for further work. |
|
6678 | 6692 | |
|
6679 | 6693 | * Separated all the magic functions into a class called Magic. The |
|
6680 | 6694 | InteractiveShell class was becoming too big for Xemacs to handle |
|
6681 | 6695 | (de-indenting a line would lock it up for 10 seconds while it |
|
6682 | 6696 | backtracked on the whole class!) |
|
6683 | 6697 | |
|
6684 | 6698 | FIXME: didn't work. It can be done, but right now namespaces are |
|
6685 | 6699 | all messed up. Do it later (reverted it for now, so at least |
|
6686 | 6700 | everything works as before). |
|
6687 | 6701 | |
|
6688 | 6702 | * Got the object introspection system (magic_oinfo) working! I |
|
6689 | 6703 | think this is pretty much ready for release to Janko, so he can |
|
6690 | 6704 | test it for a while and then announce it. Pretty much 100% of what |
|
6691 | 6705 | I wanted for the 'phase 1' release is ready. Happy, tired. |
|
6692 | 6706 | |
|
6693 | 6707 | 2001-11-12 Fernando Perez <fperez@colorado.edu> |
|
6694 | 6708 | |
|
6695 | 6709 | * Version 0.1.6 released, 0.1.7 opened for further work. |
|
6696 | 6710 | |
|
6697 | 6711 | * Fixed bug in printing: it used to test for truth before |
|
6698 | 6712 | printing, so 0 wouldn't print. Now checks for None. |
|
6699 | 6713 | |
|
6700 | 6714 | * Fixed bug where auto-execs increase the prompt counter by 2 (b/c |
|
6701 | 6715 | they have to call len(str(sys.ps1)) ). But the fix is ugly, it |
|
6702 | 6716 | reaches by hand into the outputcache. Think of a better way to do |
|
6703 | 6717 | this later. |
|
6704 | 6718 | |
|
6705 | 6719 | * Various small fixes thanks to Nathan's comments. |
|
6706 | 6720 | |
|
6707 | 6721 | * Changed magic_pprint to magic_Pprint. This way it doesn't |
|
6708 | 6722 | collide with pprint() and the name is consistent with the command |
|
6709 | 6723 | line option. |
|
6710 | 6724 | |
|
6711 | 6725 | * Changed prompt counter behavior to be fully like |
|
6712 | 6726 | Mathematica's. That is, even input that doesn't return a result |
|
6713 | 6727 | raises the prompt counter. The old behavior was kind of confusing |
|
6714 | 6728 | (getting the same prompt number several times if the operation |
|
6715 | 6729 | didn't return a result). |
|
6716 | 6730 | |
|
6717 | 6731 | * Fixed Nathan's last name in a couple of places (Gray, not Graham). |
|
6718 | 6732 | |
|
6719 | 6733 | * Fixed -Classic mode (wasn't working anymore). |
|
6720 | 6734 | |
|
6721 | 6735 | * Added colored prompts using Nathan's new code. Colors are |
|
6722 | 6736 | currently hardwired, they can be user-configurable. For |
|
6723 | 6737 | developers, they can be chosen in file ipythonlib.py, at the |
|
6724 | 6738 | beginning of the CachedOutput class def. |
|
6725 | 6739 | |
|
6726 | 6740 | 2001-11-11 Fernando Perez <fperez@colorado.edu> |
|
6727 | 6741 | |
|
6728 | 6742 | * Version 0.1.5 released, 0.1.6 opened for further work. |
|
6729 | 6743 | |
|
6730 | 6744 | * Changed magic_env to *return* the environment as a dict (not to |
|
6731 | 6745 | print it). This way it prints, but it can also be processed. |
|
6732 | 6746 | |
|
6733 | 6747 | * Added Verbose exception reporting to interactive |
|
6734 | 6748 | exceptions. Very nice, now even 1/0 at the prompt gives a verbose |
|
6735 | 6749 | traceback. Had to make some changes to the ultraTB file. This is |
|
6736 | 6750 | probably the last 'big' thing in my mental todo list. This ties |
|
6737 | 6751 | in with the next entry: |
|
6738 | 6752 | |
|
6739 | 6753 | * Changed -Xi and -Xf to a single -xmode option. Now all the user |
|
6740 | 6754 | has to specify is Plain, Color or Verbose for all exception |
|
6741 | 6755 | handling. |
|
6742 | 6756 | |
|
6743 | 6757 | * Removed ShellServices option. All this can really be done via |
|
6744 | 6758 | the magic system. It's easier to extend, cleaner and has automatic |
|
6745 | 6759 | namespace protection and documentation. |
|
6746 | 6760 | |
|
6747 | 6761 | 2001-11-09 Fernando Perez <fperez@colorado.edu> |
|
6748 | 6762 | |
|
6749 | 6763 | * Fixed bug in output cache flushing (missing parameter to |
|
6750 | 6764 | __init__). Other small bugs fixed (found using pychecker). |
|
6751 | 6765 | |
|
6752 | 6766 | * Version 0.1.4 opened for bugfixing. |
|
6753 | 6767 | |
|
6754 | 6768 | 2001-11-07 Fernando Perez <fperez@colorado.edu> |
|
6755 | 6769 | |
|
6756 | 6770 | * Version 0.1.3 released, mainly because of the raw_input bug. |
|
6757 | 6771 | |
|
6758 | 6772 | * Fixed NASTY bug in raw_input: input line wasn't properly parsed |
|
6759 | 6773 | and when testing for whether things were callable, a call could |
|
6760 | 6774 | actually be made to certain functions. They would get called again |
|
6761 | 6775 | once 'really' executed, with a resulting double call. A disaster |
|
6762 | 6776 | in many cases (list.reverse() would never work!). |
|
6763 | 6777 | |
|
6764 | 6778 | * Removed prefilter() function, moved its code to raw_input (which |
|
6765 | 6779 | after all was just a near-empty caller for prefilter). This saves |
|
6766 | 6780 | a function call on every prompt, and simplifies the class a tiny bit. |
|
6767 | 6781 | |
|
6768 | 6782 | * Fix _ip to __ip name in magic example file. |
|
6769 | 6783 | |
|
6770 | 6784 | * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should |
|
6771 | 6785 | work with non-gnu versions of tar. |
|
6772 | 6786 | |
|
6773 | 6787 | 2001-11-06 Fernando Perez <fperez@colorado.edu> |
|
6774 | 6788 | |
|
6775 | 6789 | * Version 0.1.2. Just to keep track of the recent changes. |
|
6776 | 6790 | |
|
6777 | 6791 | * Fixed nasty bug in output prompt routine. It used to check 'if |
|
6778 | 6792 | arg != None...'. Problem is, this fails if arg implements a |
|
6779 | 6793 | special comparison (__cmp__) which disallows comparing to |
|
6780 | 6794 | None. Found it when trying to use the PhysicalQuantity module from |
|
6781 | 6795 | ScientificPython. |
|
6782 | 6796 | |
|
6783 | 6797 | 2001-11-05 Fernando Perez <fperez@colorado.edu> |
|
6784 | 6798 | |
|
6785 | 6799 | * Also added dirs. Now the pushd/popd/dirs family functions |
|
6786 | 6800 | basically like the shell, with the added convenience of going home |
|
6787 | 6801 | when called with no args. |
|
6788 | 6802 | |
|
6789 | 6803 | * pushd/popd slightly modified to mimic shell behavior more |
|
6790 | 6804 | closely. |
|
6791 | 6805 | |
|
6792 | 6806 | * Added env,pushd,popd from ShellServices as magic functions. I |
|
6793 | 6807 | think the cleanest will be to port all desired functions from |
|
6794 | 6808 | ShellServices as magics and remove ShellServices altogether. This |
|
6795 | 6809 | will provide a single, clean way of adding functionality |
|
6796 | 6810 | (shell-type or otherwise) to IP. |
|
6797 | 6811 | |
|
6798 | 6812 | 2001-11-04 Fernando Perez <fperez@colorado.edu> |
|
6799 | 6813 | |
|
6800 | 6814 | * Added .ipython/ directory to sys.path. This way users can keep |
|
6801 | 6815 | customizations there and access them via import. |
|
6802 | 6816 | |
|
6803 | 6817 | 2001-11-03 Fernando Perez <fperez@colorado.edu> |
|
6804 | 6818 | |
|
6805 | 6819 | * Opened version 0.1.1 for new changes. |
|
6806 | 6820 | |
|
6807 | 6821 | * Changed version number to 0.1.0: first 'public' release, sent to |
|
6808 | 6822 | Nathan and Janko. |
|
6809 | 6823 | |
|
6810 | 6824 | * Lots of small fixes and tweaks. |
|
6811 | 6825 | |
|
6812 | 6826 | * Minor changes to whos format. Now strings are shown, snipped if |
|
6813 | 6827 | too long. |
|
6814 | 6828 | |
|
6815 | 6829 | * Changed ShellServices to work on __main__ so they show up in @who |
|
6816 | 6830 | |
|
6817 | 6831 | * Help also works with ? at the end of a line: |
|
6818 | 6832 | ?sin and sin? |
|
6819 | 6833 | both produce the same effect. This is nice, as often I use the |
|
6820 | 6834 | tab-complete to find the name of a method, but I used to then have |
|
6821 | 6835 | to go to the beginning of the line to put a ? if I wanted more |
|
6822 | 6836 | info. Now I can just add the ? and hit return. Convenient. |
|
6823 | 6837 | |
|
6824 | 6838 | 2001-11-02 Fernando Perez <fperez@colorado.edu> |
|
6825 | 6839 | |
|
6826 | 6840 | * Python version check (>=2.1) added. |
|
6827 | 6841 | |
|
6828 | 6842 | * Added LazyPython documentation. At this point the docs are quite |
|
6829 | 6843 | a mess. A cleanup is in order. |
|
6830 | 6844 | |
|
6831 | 6845 | * Auto-installer created. For some bizarre reason, the zipfiles |
|
6832 | 6846 | module isn't working on my system. So I made a tar version |
|
6833 | 6847 | (hopefully the command line options in various systems won't kill |
|
6834 | 6848 | me). |
|
6835 | 6849 | |
|
6836 | 6850 | * Fixes to Struct in genutils. Now all dictionary-like methods are |
|
6837 | 6851 | protected (reasonably). |
|
6838 | 6852 | |
|
6839 | 6853 | * Added pager function to genutils and changed ? to print usage |
|
6840 | 6854 | note through it (it was too long). |
|
6841 | 6855 | |
|
6842 | 6856 | * Added the LazyPython functionality. Works great! I changed the |
|
6843 | 6857 | auto-quote escape to ';', it's on home row and next to '. But |
|
6844 | 6858 | both auto-quote and auto-paren (still /) escapes are command-line |
|
6845 | 6859 | parameters. |
|
6846 | 6860 | |
|
6847 | 6861 | |
|
6848 | 6862 | 2001-11-01 Fernando Perez <fperez@colorado.edu> |
|
6849 | 6863 | |
|
6850 | 6864 | * Version changed to 0.0.7. Fairly large change: configuration now |
|
6851 | 6865 | is all stored in a directory, by default .ipython. There, all |
|
6852 | 6866 | config files have normal looking names (not .names) |
|
6853 | 6867 | |
|
6854 | 6868 | * Version 0.0.6 Released first to Lucas and Archie as a test |
|
6855 | 6869 | run. Since it's the first 'semi-public' release, change version to |
|
6856 | 6870 | > 0.0.6 for any changes now. |
|
6857 | 6871 | |
|
6858 | 6872 | * Stuff I had put in the ipplib.py changelog: |
|
6859 | 6873 | |
|
6860 | 6874 | Changes to InteractiveShell: |
|
6861 | 6875 | |
|
6862 | 6876 | - Made the usage message a parameter. |
|
6863 | 6877 | |
|
6864 | 6878 | - Require the name of the shell variable to be given. It's a bit |
|
6865 | 6879 | of a hack, but allows the name 'shell' not to be hardwired in the |
|
6866 | 6880 | magic (@) handler, which is problematic b/c it requires |
|
6867 | 6881 | polluting the global namespace with 'shell'. This in turn is |
|
6868 | 6882 | fragile: if a user redefines a variable called shell, things |
|
6869 | 6883 | break. |
|
6870 | 6884 | |
|
6871 | 6885 | - magic @: all functions available through @ need to be defined |
|
6872 | 6886 | as magic_<name>, even though they can be called simply as |
|
6873 | 6887 | @<name>. This allows the special command @magic to gather |
|
6874 | 6888 | information automatically about all existing magic functions, |
|
6875 | 6889 | even if they are run-time user extensions, by parsing the shell |
|
6876 | 6890 | instance __dict__ looking for special magic_ names. |
|
6877 | 6891 | |
|
6878 | 6892 | - mainloop: added *two* local namespace parameters. This allows |
|
6879 | 6893 | the class to differentiate between parameters which were there |
|
6880 | 6894 | before and after command line initialization was processed. This |
|
6881 | 6895 | way, later @who can show things loaded at startup by the |
|
6882 | 6896 | user. This trick was necessary to make session saving/reloading |
|
6883 | 6897 | really work: ideally after saving/exiting/reloading a session, |
|
6884 | 6898 | *everything* should look the same, including the output of @who. I |
|
6885 | 6899 | was only able to make this work with this double namespace |
|
6886 | 6900 | trick. |
|
6887 | 6901 | |
|
6888 | 6902 | - added a header to the logfile which allows (almost) full |
|
6889 | 6903 | session restoring. |
|
6890 | 6904 | |
|
6891 | 6905 | - prepend lines beginning with @ or !, with a and log |
|
6892 | 6906 | them. Why? !lines: may be useful to know what you did @lines: |
|
6893 | 6907 | they may affect session state. So when restoring a session, at |
|
6894 | 6908 | least inform the user of their presence. I couldn't quite get |
|
6895 | 6909 | them to properly re-execute, but at least the user is warned. |
|
6896 | 6910 | |
|
6897 | 6911 | * Started ChangeLog. |
@@ -1,129 +1,131 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | |
|
3 | 3 | """An example of how to embed an IPython shell into a running program. |
|
4 | 4 | |
|
5 | 5 | Please see the documentation in the IPython.Shell module for more details. |
|
6 | 6 | |
|
7 | 7 | The accompanying file example-embed-short.py has quick code fragments for |
|
8 | 8 | embedding which you can cut and paste in your code once you understand how |
|
9 | 9 | things work. |
|
10 | 10 | |
|
11 | 11 | The code in this file is deliberately extra-verbose, meant for learning.""" |
|
12 | 12 | |
|
13 | 13 | # The basics to get you going: |
|
14 | 14 | |
|
15 | 15 | # IPython sets the __IPYTHON__ variable so you can know if you have nested |
|
16 | 16 | # copies running. |
|
17 | 17 | |
|
18 | 18 | # Try running this code both at the command line and from inside IPython (with |
|
19 | 19 | # %run example-embed.py) |
|
20 | 20 | try: |
|
21 | 21 | __IPYTHON__ |
|
22 | 22 | except NameError: |
|
23 | 23 | nested = 0 |
|
24 | 24 | args = [''] |
|
25 | 25 | else: |
|
26 | 26 | print "Running nested copies of IPython." |
|
27 | 27 | print "The prompts for the nested copy have been modified" |
|
28 | 28 | nested = 1 |
|
29 | 29 | # what the embedded instance will see as sys.argv: |
|
30 | 30 | args = ['-pi1','In <\\#>: ','-pi2',' .\\D.: ', |
|
31 | 31 | '-po','Out<\\#>: ','-nosep'] |
|
32 | 32 | |
|
33 | 33 | # First import the embeddable shell class |
|
34 | 34 | from IPython.Shell import IPShellEmbed |
|
35 | 35 | |
|
36 | 36 | # Now create an instance of the embeddable shell. The first argument is a |
|
37 | 37 | # string with options exactly as you would type them if you were starting |
|
38 | 38 | # IPython at the system command line. Any parameters you want to define for |
|
39 | 39 | # configuration can thus be specified here. |
|
40 | 40 | ipshell = IPShellEmbed(args, |
|
41 | 41 | banner = 'Dropping into IPython', |
|
42 | 42 | exit_msg = 'Leaving Interpreter, back to program.') |
|
43 | 43 | |
|
44 | 44 | # Make a second instance, you can have as many as you want. |
|
45 | 45 | if nested: |
|
46 | 46 | args[1] = 'In2<\\#>' |
|
47 | 47 | else: |
|
48 | 48 | args = ['-pi1','In2<\\#>: ','-pi2',' .\\D.: ', |
|
49 | 49 | '-po','Out<\\#>: ','-nosep'] |
|
50 | 50 | ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.') |
|
51 | 51 | |
|
52 | 52 | print '\nHello. This is printed from the main controller program.\n' |
|
53 | 53 | |
|
54 | 54 | # You can then call ipshell() anywhere you need it (with an optional |
|
55 | 55 | # message): |
|
56 | 56 | ipshell('***Called from top level. ' |
|
57 |
'Hit Ctrl-D to exit interpreter and continue program.' |
|
|
57 | 'Hit Ctrl-D to exit interpreter and continue program.\n' | |
|
58 | 'Note that if you use %kill_embedded, you can fully deactivate\n' | |
|
59 | 'This embedded instance so it will never turn on again') | |
|
58 | 60 | |
|
59 | 61 | print '\nBack in caller program, moving along...\n' |
|
60 | 62 | |
|
61 | 63 | #--------------------------------------------------------------------------- |
|
62 | 64 | # More details: |
|
63 | 65 | |
|
64 | 66 | # IPShellEmbed instances don't print the standard system banner and |
|
65 | 67 | # messages. The IPython banner (which actually may contain initialization |
|
66 | 68 | # messages) is available as <instance>.IP.BANNER in case you want it. |
|
67 | 69 | |
|
68 | 70 | # IPShellEmbed instances print the following information everytime they |
|
69 | 71 | # start: |
|
70 | 72 | |
|
71 | 73 | # - A global startup banner. |
|
72 | 74 | |
|
73 | 75 | # - A call-specific header string, which you can use to indicate where in the |
|
74 | 76 | # execution flow the shell is starting. |
|
75 | 77 | |
|
76 | 78 | # They also print an exit message every time they exit. |
|
77 | 79 | |
|
78 | 80 | # Both the startup banner and the exit message default to None, and can be set |
|
79 | 81 | # either at the instance constructor or at any other time with the |
|
80 | 82 | # set_banner() and set_exit_msg() methods. |
|
81 | 83 | |
|
82 | 84 | # The shell instance can be also put in 'dummy' mode globally or on a per-call |
|
83 | 85 | # basis. This gives you fine control for debugging without having to change |
|
84 | 86 | # code all over the place. |
|
85 | 87 | |
|
86 | 88 | # The code below illustrates all this. |
|
87 | 89 | |
|
88 | 90 | |
|
89 | 91 | # This is how the global banner and exit_msg can be reset at any point |
|
90 | 92 | ipshell.set_banner('Entering interpreter - New Banner') |
|
91 | 93 | ipshell.set_exit_msg('Leaving interpreter - New exit_msg') |
|
92 | 94 | |
|
93 | 95 | def foo(m): |
|
94 | 96 | s = 'spam' |
|
95 | 97 | ipshell('***In foo(). Try @whos, or print s or m:') |
|
96 | 98 | print 'foo says m = ',m |
|
97 | 99 | |
|
98 | 100 | def bar(n): |
|
99 | 101 | s = 'eggs' |
|
100 | 102 | ipshell('***In bar(). Try @whos, or print s or n:') |
|
101 | 103 | print 'bar says n = ',n |
|
102 | 104 | |
|
103 | 105 | # Some calls to the above functions which will trigger IPython: |
|
104 | 106 | print 'Main program calling foo("eggs")\n' |
|
105 | 107 | foo('eggs') |
|
106 | 108 | |
|
107 | 109 | # The shell can be put in 'dummy' mode where calls to it silently return. This |
|
108 | 110 | # allows you, for example, to globally turn off debugging for a program with a |
|
109 | 111 | # single call. |
|
110 | 112 | ipshell.set_dummy_mode(1) |
|
111 | 113 | print '\nTrying to call IPython which is now "dummy":' |
|
112 | 114 | ipshell() |
|
113 | 115 | print 'Nothing happened...' |
|
114 | 116 | # The global 'dummy' mode can still be overridden for a single call |
|
115 | 117 | print '\nOverriding dummy mode manually:' |
|
116 | 118 | ipshell(dummy=0) |
|
117 | 119 | |
|
118 | 120 | # Reactivate the IPython shell |
|
119 | 121 | ipshell.set_dummy_mode(0) |
|
120 | 122 | |
|
121 | 123 | print 'You can even have multiple embedded instances:' |
|
122 | 124 | ipshell2() |
|
123 | 125 | |
|
124 | 126 | print '\nMain program calling bar("spam")\n' |
|
125 | 127 | bar('spam') |
|
126 | 128 | |
|
127 | 129 | print 'Main program finished. Bye!' |
|
128 | 130 | |
|
129 | 131 | #********************** End of file <example-embed.py> *********************** |
General Comments 0
You need to be logged in to leave comments.
Login now