##// END OF EJS Templates
Fix doctest support: now running scripts that invoke the various doctest...
fperez -
Show More

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

@@ -1,83 +1,83 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project.
3 3
4 $Id: Release.py 2446 2007-06-14 22:30:58Z vivainio $"""
4 $Id: Release.py 2602 2007-08-12 22:45:38Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
8 8 #
9 9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 10 # <n8gray@caltech.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 # Name of the package for release purposes. This is the name which labels
17 17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 18 name = 'ipython'
19 19
20 20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 21 # the new substring. We have to avoid using either dashes or underscores,
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 23 # bdist_deb does not accept underscores (a Debian convention).
24 24
25 revision = '2445'
25 revision = '2601'
26 26
27 27 version = '0.8.2.svn.r' + revision.rstrip('M')
28 28
29 29 description = "An enhanced interactive Python shell."
30 30
31 31 long_description = \
32 32 """
33 33 IPython provides a replacement for the interactive Python interpreter with
34 34 extra functionality.
35 35
36 36 Main features:
37 37
38 38 * Comprehensive object introspection.
39 39
40 40 * Input history, persistent across sessions.
41 41
42 42 * Caching of output results during a session with automatically generated
43 43 references.
44 44
45 45 * Readline based name completion.
46 46
47 47 * Extensible system of 'magic' commands for controlling the environment and
48 48 performing many tasks related either to IPython or the operating system.
49 49
50 50 * Configuration system with easy switching between different setups (simpler
51 51 than changing $PYTHONSTARTUP environment variables every time).
52 52
53 53 * Session logging and reloading.
54 54
55 55 * Extensible syntax processing for special purpose situations.
56 56
57 57 * Access to the system shell with user-extensible alias system.
58 58
59 59 * Easily embeddable in other Python programs.
60 60
61 61 * Integrated access to the pdb debugger and the Python profiler.
62 62
63 63 The latest development version is always available at the IPython subversion
64 64 repository_.
65 65
66 66 .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev
67 67 """
68 68
69 69 license = 'BSD'
70 70
71 71 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
72 72 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
73 73 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
74 74 'Ville' : ('Ville Vainio','vivainio@gmail.com')
75 75 }
76 76
77 77 url = 'http://ipython.scipy.org'
78 78
79 79 download_url = 'http://ipython.scipy.org/dist'
80 80
81 81 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
82 82
83 83 keywords = ['Interactive','Interpreter','Shell']
@@ -1,1850 +1,1874 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 2577 2007-08-02 23:50:02Z fperez $"""
8 $Id: genutils.py 2602 2007-08-12 22:45:38Z 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 def dhook_wrap(func,*a,**k):
803 """Wrap a function call in a sys.displayhook controller.
804
805 Returns a wrapper around func which calls func, with all its arguments and
806 keywords unmodified, using the default sys.displayhook. Since IPython
807 modifies sys.displayhook, it breaks the behavior of certain systems that
808 rely on the default behavior, notably doctest.
809 """
810
811 def f(*a,**k):
812
813 dhook_s = sys.displayhook
814 sys.displayhook = sys.__displayhook__
815 try:
816 out = func(*a,**k)
817 finally:
818 sys.displayhook = dhook_s
819
820 return out
821
822 f.__doc__ = func.__doc__
823 return f
824
825 #----------------------------------------------------------------------------
802 826 class HomeDirError(Error):
803 827 pass
804 828
805 829 def get_home_dir():
806 830 """Return the closest possible equivalent to a 'home' directory.
807 831
808 832 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
809 833
810 834 Currently only Posix and NT are implemented, a HomeDirError exception is
811 835 raised for all other OSes. """
812 836
813 837 isdir = os.path.isdir
814 838 env = os.environ
815 839
816 840 # first, check py2exe distribution root directory for _ipython.
817 841 # This overrides all. Normally does not exist.
818 842
819 843 if '\\library.zip\\' in IPython.__file__.lower():
820 844 root, rest = IPython.__file__.lower().split('library.zip')
821 845 if isdir(root + '_ipython'):
822 846 os.environ["IPYKITROOT"] = root.rstrip('\\')
823 847 return root
824 848
825 849 try:
826 850 homedir = env['HOME']
827 851 if not isdir(homedir):
828 852 # in case a user stuck some string which does NOT resolve to a
829 853 # valid path, it's as good as if we hadn't foud it
830 854 raise KeyError
831 855 return homedir
832 856 except KeyError:
833 857 if os.name == 'posix':
834 858 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
835 859 elif os.name == 'nt':
836 860 # For some strange reason, win9x returns 'nt' for os.name.
837 861 try:
838 862 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
839 863 if not isdir(homedir):
840 864 homedir = os.path.join(env['USERPROFILE'])
841 865 if not isdir(homedir):
842 866 raise HomeDirError
843 867 return homedir
844 868 except:
845 869 try:
846 870 # Use the registry to get the 'My Documents' folder.
847 871 import _winreg as wreg
848 872 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
849 873 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
850 874 homedir = wreg.QueryValueEx(key,'Personal')[0]
851 875 key.Close()
852 876 if not isdir(homedir):
853 877 e = ('Invalid "Personal" folder registry key '
854 878 'typically "My Documents".\n'
855 879 'Value: %s\n'
856 880 'This is not a valid directory on your system.' %
857 881 homedir)
858 882 raise HomeDirError(e)
859 883 return homedir
860 884 except HomeDirError:
861 885 raise
862 886 except:
863 887 return 'C:\\'
864 888 elif os.name == 'dos':
865 889 # Desperate, may do absurd things in classic MacOS. May work under DOS.
866 890 return 'C:\\'
867 891 else:
868 892 raise HomeDirError,'support for your operating system not implemented.'
869 893
870 894 #****************************************************************************
871 895 # strings and text
872 896
873 897 class LSString(str):
874 898 """String derivative with a special access attributes.
875 899
876 900 These are normal strings, but with the special attributes:
877 901
878 902 .l (or .list) : value as list (split on newlines).
879 903 .n (or .nlstr): original value (the string itself).
880 904 .s (or .spstr): value as whitespace-separated string.
881 905 .p (or .paths): list of path objects
882 906
883 907 Any values which require transformations are computed only once and
884 908 cached.
885 909
886 910 Such strings are very useful to efficiently interact with the shell, which
887 911 typically only understands whitespace-separated options for commands."""
888 912
889 913 def get_list(self):
890 914 try:
891 915 return self.__list
892 916 except AttributeError:
893 917 self.__list = self.split('\n')
894 918 return self.__list
895 919
896 920 l = list = property(get_list)
897 921
898 922 def get_spstr(self):
899 923 try:
900 924 return self.__spstr
901 925 except AttributeError:
902 926 self.__spstr = self.replace('\n',' ')
903 927 return self.__spstr
904 928
905 929 s = spstr = property(get_spstr)
906 930
907 931 def get_nlstr(self):
908 932 return self
909 933
910 934 n = nlstr = property(get_nlstr)
911 935
912 936 def get_paths(self):
913 937 try:
914 938 return self.__paths
915 939 except AttributeError:
916 940 self.__paths = [path(p) for p in self.split('\n') if os.path.exists(p)]
917 941 return self.__paths
918 942
919 943 p = paths = property(get_paths)
920 944
921 945 def print_lsstring(arg):
922 946 """ Prettier (non-repr-like) and more informative printer for LSString """
923 947 print "LSString (.p, .n, .l, .s available). Value:"
924 948 print arg
925 949
926 950 print_lsstring = result_display.when_type(LSString)(print_lsstring)
927 951
928 952 #----------------------------------------------------------------------------
929 953 class SList(list):
930 954 """List derivative with a special access attributes.
931 955
932 956 These are normal lists, but with the special attributes:
933 957
934 958 .l (or .list) : value as list (the list itself).
935 959 .n (or .nlstr): value as a string, joined on newlines.
936 960 .s (or .spstr): value as a string, joined on spaces.
937 961 .p (or .paths): list of path objects
938 962
939 963 Any values which require transformations are computed only once and
940 964 cached."""
941 965
942 966 def get_list(self):
943 967 return self
944 968
945 969 l = list = property(get_list)
946 970
947 971 def get_spstr(self):
948 972 try:
949 973 return self.__spstr
950 974 except AttributeError:
951 975 self.__spstr = ' '.join(self)
952 976 return self.__spstr
953 977
954 978 s = spstr = property(get_spstr)
955 979
956 980 def get_nlstr(self):
957 981 try:
958 982 return self.__nlstr
959 983 except AttributeError:
960 984 self.__nlstr = '\n'.join(self)
961 985 return self.__nlstr
962 986
963 987 n = nlstr = property(get_nlstr)
964 988
965 989 def get_paths(self):
966 990 try:
967 991 return self.__paths
968 992 except AttributeError:
969 993 self.__paths = [path(p) for p in self if os.path.exists(p)]
970 994 return self.__paths
971 995
972 996 p = paths = property(get_paths)
973 997
974 998 #----------------------------------------------------------------------------
975 999 def esc_quotes(strng):
976 1000 """Return the input string with single and double quotes escaped out"""
977 1001
978 1002 return strng.replace('"','\\"').replace("'","\\'")
979 1003
980 1004 #----------------------------------------------------------------------------
981 1005 def make_quoted_expr(s):
982 1006 """Return string s in appropriate quotes, using raw string if possible.
983 1007
984 1008 Effectively this turns string: cd \ao\ao\
985 1009 to: r"cd \ao\ao\_"[:-1]
986 1010
987 1011 Note the use of raw string and padding at the end to allow trailing backslash.
988 1012
989 1013 """
990 1014
991 1015 tail = ''
992 1016 tailpadding = ''
993 1017 raw = ''
994 1018 if "\\" in s:
995 1019 raw = 'r'
996 1020 if s.endswith('\\'):
997 1021 tail = '[:-1]'
998 1022 tailpadding = '_'
999 1023 if '"' not in s:
1000 1024 quote = '"'
1001 1025 elif "'" not in s:
1002 1026 quote = "'"
1003 1027 elif '"""' not in s and not s.endswith('"'):
1004 1028 quote = '"""'
1005 1029 elif "'''" not in s and not s.endswith("'"):
1006 1030 quote = "'''"
1007 1031 else:
1008 1032 # give up, backslash-escaped string will do
1009 1033 return '"%s"' % esc_quotes(s)
1010 1034 res = itpl("$raw$quote$s$tailpadding$quote$tail")
1011 1035 return res
1012 1036
1013 1037
1014 1038 #----------------------------------------------------------------------------
1015 1039 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
1016 1040 """Take multiple lines of input.
1017 1041
1018 1042 A list with each line of input as a separate element is returned when a
1019 1043 termination string is entered (defaults to a single '.'). Input can also
1020 1044 terminate via EOF (^D in Unix, ^Z-RET in Windows).
1021 1045
1022 1046 Lines of input which end in \\ are joined into single entries (and a
1023 1047 secondary continuation prompt is issued as long as the user terminates
1024 1048 lines with \\). This allows entering very long strings which are still
1025 1049 meant to be treated as single entities.
1026 1050 """
1027 1051
1028 1052 try:
1029 1053 if header:
1030 1054 header += '\n'
1031 1055 lines = [raw_input(header + ps1)]
1032 1056 except EOFError:
1033 1057 return []
1034 1058 terminate = [terminate_str]
1035 1059 try:
1036 1060 while lines[-1:] != terminate:
1037 1061 new_line = raw_input(ps1)
1038 1062 while new_line.endswith('\\'):
1039 1063 new_line = new_line[:-1] + raw_input(ps2)
1040 1064 lines.append(new_line)
1041 1065
1042 1066 return lines[:-1] # don't return the termination command
1043 1067 except EOFError:
1044 1068 print
1045 1069 return lines
1046 1070
1047 1071 #----------------------------------------------------------------------------
1048 1072 def raw_input_ext(prompt='', ps2='... '):
1049 1073 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
1050 1074
1051 1075 line = raw_input(prompt)
1052 1076 while line.endswith('\\'):
1053 1077 line = line[:-1] + raw_input(ps2)
1054 1078 return line
1055 1079
1056 1080 #----------------------------------------------------------------------------
1057 1081 def ask_yes_no(prompt,default=None):
1058 1082 """Asks a question and returns a boolean (y/n) answer.
1059 1083
1060 1084 If default is given (one of 'y','n'), it is used if the user input is
1061 1085 empty. Otherwise the question is repeated until an answer is given.
1062 1086
1063 1087 An EOF is treated as the default answer. If there is no default, an
1064 1088 exception is raised to prevent infinite loops.
1065 1089
1066 1090 Valid answers are: y/yes/n/no (match is not case sensitive)."""
1067 1091
1068 1092 answers = {'y':True,'n':False,'yes':True,'no':False}
1069 1093 ans = None
1070 1094 while ans not in answers.keys():
1071 1095 try:
1072 1096 ans = raw_input(prompt+' ').lower()
1073 1097 if not ans: # response was an empty string
1074 1098 ans = default
1075 1099 except KeyboardInterrupt:
1076 1100 pass
1077 1101 except EOFError:
1078 1102 if default in answers.keys():
1079 1103 ans = default
1080 1104 print
1081 1105 else:
1082 1106 raise
1083 1107
1084 1108 return answers[ans]
1085 1109
1086 1110 #----------------------------------------------------------------------------
1087 1111 def marquee(txt='',width=78,mark='*'):
1088 1112 """Return the input string centered in a 'marquee'."""
1089 1113 if not txt:
1090 1114 return (mark*width)[:width]
1091 1115 nmark = (width-len(txt)-2)/len(mark)/2
1092 1116 if nmark < 0: nmark =0
1093 1117 marks = mark*nmark
1094 1118 return '%s %s %s' % (marks,txt,marks)
1095 1119
1096 1120 #----------------------------------------------------------------------------
1097 1121 class EvalDict:
1098 1122 """
1099 1123 Emulate a dict which evaluates its contents in the caller's frame.
1100 1124
1101 1125 Usage:
1102 1126 >>>number = 19
1103 1127 >>>text = "python"
1104 1128 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1105 1129 """
1106 1130
1107 1131 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1108 1132 # modified (shorter) version of:
1109 1133 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1110 1134 # Skip Montanaro (skip@pobox.com).
1111 1135
1112 1136 def __getitem__(self, name):
1113 1137 frame = sys._getframe(1)
1114 1138 return eval(name, frame.f_globals, frame.f_locals)
1115 1139
1116 1140 EvalString = EvalDict # for backwards compatibility
1117 1141 #----------------------------------------------------------------------------
1118 1142 def qw(words,flat=0,sep=None,maxsplit=-1):
1119 1143 """Similar to Perl's qw() operator, but with some more options.
1120 1144
1121 1145 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1122 1146
1123 1147 words can also be a list itself, and with flat=1, the output will be
1124 1148 recursively flattened. Examples:
1125 1149
1126 1150 >>> qw('1 2')
1127 1151 ['1', '2']
1128 1152 >>> qw(['a b','1 2',['m n','p q']])
1129 1153 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1130 1154 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1131 1155 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1132 1156
1133 1157 if type(words) in StringTypes:
1134 1158 return [word.strip() for word in words.split(sep,maxsplit)
1135 1159 if word and not word.isspace() ]
1136 1160 if flat:
1137 1161 return flatten(map(qw,words,[1]*len(words)))
1138 1162 return map(qw,words)
1139 1163
1140 1164 #----------------------------------------------------------------------------
1141 1165 def qwflat(words,sep=None,maxsplit=-1):
1142 1166 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1143 1167 return qw(words,1,sep,maxsplit)
1144 1168
1145 1169 #----------------------------------------------------------------------------
1146 1170 def qw_lol(indata):
1147 1171 """qw_lol('a b') -> [['a','b']],
1148 1172 otherwise it's just a call to qw().
1149 1173
1150 1174 We need this to make sure the modules_some keys *always* end up as a
1151 1175 list of lists."""
1152 1176
1153 1177 if type(indata) in StringTypes:
1154 1178 return [qw(indata)]
1155 1179 else:
1156 1180 return qw(indata)
1157 1181
1158 1182 #-----------------------------------------------------------------------------
1159 1183 def list_strings(arg):
1160 1184 """Always return a list of strings, given a string or list of strings
1161 1185 as input."""
1162 1186
1163 1187 if type(arg) in StringTypes: return [arg]
1164 1188 else: return arg
1165 1189
1166 1190 #----------------------------------------------------------------------------
1167 1191 def grep(pat,list,case=1):
1168 1192 """Simple minded grep-like function.
1169 1193 grep(pat,list) returns occurrences of pat in list, None on failure.
1170 1194
1171 1195 It only does simple string matching, with no support for regexps. Use the
1172 1196 option case=0 for case-insensitive matching."""
1173 1197
1174 1198 # This is pretty crude. At least it should implement copying only references
1175 1199 # to the original data in case it's big. Now it copies the data for output.
1176 1200 out=[]
1177 1201 if case:
1178 1202 for term in list:
1179 1203 if term.find(pat)>-1: out.append(term)
1180 1204 else:
1181 1205 lpat=pat.lower()
1182 1206 for term in list:
1183 1207 if term.lower().find(lpat)>-1: out.append(term)
1184 1208
1185 1209 if len(out): return out
1186 1210 else: return None
1187 1211
1188 1212 #----------------------------------------------------------------------------
1189 1213 def dgrep(pat,*opts):
1190 1214 """Return grep() on dir()+dir(__builtins__).
1191 1215
1192 1216 A very common use of grep() when working interactively."""
1193 1217
1194 1218 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1195 1219
1196 1220 #----------------------------------------------------------------------------
1197 1221 def idgrep(pat):
1198 1222 """Case-insensitive dgrep()"""
1199 1223
1200 1224 return dgrep(pat,0)
1201 1225
1202 1226 #----------------------------------------------------------------------------
1203 1227 def igrep(pat,list):
1204 1228 """Synonym for case-insensitive grep."""
1205 1229
1206 1230 return grep(pat,list,case=0)
1207 1231
1208 1232 #----------------------------------------------------------------------------
1209 1233 def indent(str,nspaces=4,ntabs=0):
1210 1234 """Indent a string a given number of spaces or tabstops.
1211 1235
1212 1236 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1213 1237 """
1214 1238 if str is None:
1215 1239 return
1216 1240 ind = '\t'*ntabs+' '*nspaces
1217 1241 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1218 1242 if outstr.endswith(os.linesep+ind):
1219 1243 return outstr[:-len(ind)]
1220 1244 else:
1221 1245 return outstr
1222 1246
1223 1247 #-----------------------------------------------------------------------------
1224 1248 def native_line_ends(filename,backup=1):
1225 1249 """Convert (in-place) a file to line-ends native to the current OS.
1226 1250
1227 1251 If the optional backup argument is given as false, no backup of the
1228 1252 original file is left. """
1229 1253
1230 1254 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1231 1255
1232 1256 bak_filename = filename + backup_suffixes[os.name]
1233 1257
1234 1258 original = open(filename).read()
1235 1259 shutil.copy2(filename,bak_filename)
1236 1260 try:
1237 1261 new = open(filename,'wb')
1238 1262 new.write(os.linesep.join(original.splitlines()))
1239 1263 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1240 1264 new.close()
1241 1265 except:
1242 1266 os.rename(bak_filename,filename)
1243 1267 if not backup:
1244 1268 try:
1245 1269 os.remove(bak_filename)
1246 1270 except:
1247 1271 pass
1248 1272
1249 1273 #----------------------------------------------------------------------------
1250 1274 def get_pager_cmd(pager_cmd = None):
1251 1275 """Return a pager command.
1252 1276
1253 1277 Makes some attempts at finding an OS-correct one."""
1254 1278
1255 1279 if os.name == 'posix':
1256 1280 default_pager_cmd = 'less -r' # -r for color control sequences
1257 1281 elif os.name in ['nt','dos']:
1258 1282 default_pager_cmd = 'type'
1259 1283
1260 1284 if pager_cmd is None:
1261 1285 try:
1262 1286 pager_cmd = os.environ['PAGER']
1263 1287 except:
1264 1288 pager_cmd = default_pager_cmd
1265 1289 return pager_cmd
1266 1290
1267 1291 #-----------------------------------------------------------------------------
1268 1292 def get_pager_start(pager,start):
1269 1293 """Return the string for paging files with an offset.
1270 1294
1271 1295 This is the '+N' argument which less and more (under Unix) accept.
1272 1296 """
1273 1297
1274 1298 if pager in ['less','more']:
1275 1299 if start:
1276 1300 start_string = '+' + str(start)
1277 1301 else:
1278 1302 start_string = ''
1279 1303 else:
1280 1304 start_string = ''
1281 1305 return start_string
1282 1306
1283 1307 #----------------------------------------------------------------------------
1284 1308 # (X)emacs on W32 doesn't like to be bypassed with msvcrt.getch()
1285 1309 if os.name == 'nt' and os.environ.get('TERM','dumb') != 'emacs':
1286 1310 import msvcrt
1287 1311 def page_more():
1288 1312 """ Smart pausing between pages
1289 1313
1290 1314 @return: True if need print more lines, False if quit
1291 1315 """
1292 1316 Term.cout.write('---Return to continue, q to quit--- ')
1293 1317 ans = msvcrt.getch()
1294 1318 if ans in ("q", "Q"):
1295 1319 result = False
1296 1320 else:
1297 1321 result = True
1298 1322 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1299 1323 return result
1300 1324 else:
1301 1325 def page_more():
1302 1326 ans = raw_input('---Return to continue, q to quit--- ')
1303 1327 if ans.lower().startswith('q'):
1304 1328 return False
1305 1329 else:
1306 1330 return True
1307 1331
1308 1332 esc_re = re.compile(r"(\x1b[^m]+m)")
1309 1333
1310 1334 def page_dumb(strng,start=0,screen_lines=25):
1311 1335 """Very dumb 'pager' in Python, for when nothing else works.
1312 1336
1313 1337 Only moves forward, same interface as page(), except for pager_cmd and
1314 1338 mode."""
1315 1339
1316 1340 out_ln = strng.splitlines()[start:]
1317 1341 screens = chop(out_ln,screen_lines-1)
1318 1342 if len(screens) == 1:
1319 1343 print >>Term.cout, os.linesep.join(screens[0])
1320 1344 else:
1321 1345 last_escape = ""
1322 1346 for scr in screens[0:-1]:
1323 1347 hunk = os.linesep.join(scr)
1324 1348 print >>Term.cout, last_escape + hunk
1325 1349 if not page_more():
1326 1350 return
1327 1351 esc_list = esc_re.findall(hunk)
1328 1352 if len(esc_list) > 0:
1329 1353 last_escape = esc_list[-1]
1330 1354 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1331 1355
1332 1356 #----------------------------------------------------------------------------
1333 1357 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1334 1358 """Print a string, piping through a pager after a certain length.
1335 1359
1336 1360 The screen_lines parameter specifies the number of *usable* lines of your
1337 1361 terminal screen (total lines minus lines you need to reserve to show other
1338 1362 information).
1339 1363
1340 1364 If you set screen_lines to a number <=0, page() will try to auto-determine
1341 1365 your screen size and will only use up to (screen_size+screen_lines) for
1342 1366 printing, paging after that. That is, if you want auto-detection but need
1343 1367 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1344 1368 auto-detection without any lines reserved simply use screen_lines = 0.
1345 1369
1346 1370 If a string won't fit in the allowed lines, it is sent through the
1347 1371 specified pager command. If none given, look for PAGER in the environment,
1348 1372 and ultimately default to less.
1349 1373
1350 1374 If no system pager works, the string is sent through a 'dumb pager'
1351 1375 written in python, very simplistic.
1352 1376 """
1353 1377
1354 1378 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1355 1379 TERM = os.environ.get('TERM','dumb')
1356 1380 if TERM in ['dumb','emacs'] and os.name != 'nt':
1357 1381 print strng
1358 1382 return
1359 1383 # chop off the topmost part of the string we don't want to see
1360 1384 str_lines = strng.split(os.linesep)[start:]
1361 1385 str_toprint = os.linesep.join(str_lines)
1362 1386 num_newlines = len(str_lines)
1363 1387 len_str = len(str_toprint)
1364 1388
1365 1389 # Dumb heuristics to guesstimate number of on-screen lines the string
1366 1390 # takes. Very basic, but good enough for docstrings in reasonable
1367 1391 # terminals. If someone later feels like refining it, it's not hard.
1368 1392 numlines = max(num_newlines,int(len_str/80)+1)
1369 1393
1370 1394 if os.name == "nt":
1371 1395 screen_lines_def = get_console_size(defaulty=25)[1]
1372 1396 else:
1373 1397 screen_lines_def = 25 # default value if we can't auto-determine
1374 1398
1375 1399 # auto-determine screen size
1376 1400 if screen_lines <= 0:
1377 1401 if TERM=='xterm':
1378 1402 try:
1379 1403 import curses
1380 1404 if hasattr(curses,'initscr'):
1381 1405 use_curses = 1
1382 1406 else:
1383 1407 use_curses = 0
1384 1408 except ImportError:
1385 1409 use_curses = 0
1386 1410 else:
1387 1411 # curses causes problems on many terminals other than xterm.
1388 1412 use_curses = 0
1389 1413 if use_curses:
1390 1414 scr = curses.initscr()
1391 1415 screen_lines_real,screen_cols = scr.getmaxyx()
1392 1416 curses.endwin()
1393 1417 screen_lines += screen_lines_real
1394 1418 #print '***Screen size:',screen_lines_real,'lines x',\
1395 1419 #screen_cols,'columns.' # dbg
1396 1420 else:
1397 1421 screen_lines += screen_lines_def
1398 1422
1399 1423 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1400 1424 if numlines <= screen_lines :
1401 1425 #print '*** normal print' # dbg
1402 1426 print >>Term.cout, str_toprint
1403 1427 else:
1404 1428 # Try to open pager and default to internal one if that fails.
1405 1429 # All failure modes are tagged as 'retval=1', to match the return
1406 1430 # value of a failed system command. If any intermediate attempt
1407 1431 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1408 1432 pager_cmd = get_pager_cmd(pager_cmd)
1409 1433 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1410 1434 if os.name == 'nt':
1411 1435 if pager_cmd.startswith('type'):
1412 1436 # The default WinXP 'type' command is failing on complex strings.
1413 1437 retval = 1
1414 1438 else:
1415 1439 tmpname = tempfile.mktemp('.txt')
1416 1440 tmpfile = file(tmpname,'wt')
1417 1441 tmpfile.write(strng)
1418 1442 tmpfile.close()
1419 1443 cmd = "%s < %s" % (pager_cmd,tmpname)
1420 1444 if os.system(cmd):
1421 1445 retval = 1
1422 1446 else:
1423 1447 retval = None
1424 1448 os.remove(tmpname)
1425 1449 else:
1426 1450 try:
1427 1451 retval = None
1428 1452 # if I use popen4, things hang. No idea why.
1429 1453 #pager,shell_out = os.popen4(pager_cmd)
1430 1454 pager = os.popen(pager_cmd,'w')
1431 1455 pager.write(strng)
1432 1456 pager.close()
1433 1457 retval = pager.close() # success returns None
1434 1458 except IOError,msg: # broken pipe when user quits
1435 1459 if msg.args == (32,'Broken pipe'):
1436 1460 retval = None
1437 1461 else:
1438 1462 retval = 1
1439 1463 except OSError:
1440 1464 # Other strange problems, sometimes seen in Win2k/cygwin
1441 1465 retval = 1
1442 1466 if retval is not None:
1443 1467 page_dumb(strng,screen_lines=screen_lines)
1444 1468
1445 1469 #----------------------------------------------------------------------------
1446 1470 def page_file(fname,start = 0, pager_cmd = None):
1447 1471 """Page a file, using an optional pager command and starting line.
1448 1472 """
1449 1473
1450 1474 pager_cmd = get_pager_cmd(pager_cmd)
1451 1475 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1452 1476
1453 1477 try:
1454 1478 if os.environ['TERM'] in ['emacs','dumb']:
1455 1479 raise EnvironmentError
1456 1480 xsys(pager_cmd + ' ' + fname)
1457 1481 except:
1458 1482 try:
1459 1483 if start > 0:
1460 1484 start -= 1
1461 1485 page(open(fname).read(),start)
1462 1486 except:
1463 1487 print 'Unable to show file',`fname`
1464 1488
1465 1489 #----------------------------------------------------------------------------
1466 1490 def snip_print(str,width = 75,print_full = 0,header = ''):
1467 1491 """Print a string snipping the midsection to fit in width.
1468 1492
1469 1493 print_full: mode control:
1470 1494 - 0: only snip long strings
1471 1495 - 1: send to page() directly.
1472 1496 - 2: snip long strings and ask for full length viewing with page()
1473 1497 Return 1 if snipping was necessary, 0 otherwise."""
1474 1498
1475 1499 if print_full == 1:
1476 1500 page(header+str)
1477 1501 return 0
1478 1502
1479 1503 print header,
1480 1504 if len(str) < width:
1481 1505 print str
1482 1506 snip = 0
1483 1507 else:
1484 1508 whalf = int((width -5)/2)
1485 1509 print str[:whalf] + ' <...> ' + str[-whalf:]
1486 1510 snip = 1
1487 1511 if snip and print_full == 2:
1488 1512 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1489 1513 page(str)
1490 1514 return snip
1491 1515
1492 1516 #****************************************************************************
1493 1517 # lists, dicts and structures
1494 1518
1495 1519 def belong(candidates,checklist):
1496 1520 """Check whether a list of items appear in a given list of options.
1497 1521
1498 1522 Returns a list of 1 and 0, one for each candidate given."""
1499 1523
1500 1524 return [x in checklist for x in candidates]
1501 1525
1502 1526 #----------------------------------------------------------------------------
1503 1527 def uniq_stable(elems):
1504 1528 """uniq_stable(elems) -> list
1505 1529
1506 1530 Return from an iterable, a list of all the unique elements in the input,
1507 1531 but maintaining the order in which they first appear.
1508 1532
1509 1533 A naive solution to this problem which just makes a dictionary with the
1510 1534 elements as keys fails to respect the stability condition, since
1511 1535 dictionaries are unsorted by nature.
1512 1536
1513 1537 Note: All elements in the input must be valid dictionary keys for this
1514 1538 routine to work, as it internally uses a dictionary for efficiency
1515 1539 reasons."""
1516 1540
1517 1541 unique = []
1518 1542 unique_dict = {}
1519 1543 for nn in elems:
1520 1544 if nn not in unique_dict:
1521 1545 unique.append(nn)
1522 1546 unique_dict[nn] = None
1523 1547 return unique
1524 1548
1525 1549 #----------------------------------------------------------------------------
1526 1550 class NLprinter:
1527 1551 """Print an arbitrarily nested list, indicating index numbers.
1528 1552
1529 1553 An instance of this class called nlprint is available and callable as a
1530 1554 function.
1531 1555
1532 1556 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1533 1557 and using 'sep' to separate the index from the value. """
1534 1558
1535 1559 def __init__(self):
1536 1560 self.depth = 0
1537 1561
1538 1562 def __call__(self,lst,pos='',**kw):
1539 1563 """Prints the nested list numbering levels."""
1540 1564 kw.setdefault('indent',' ')
1541 1565 kw.setdefault('sep',': ')
1542 1566 kw.setdefault('start',0)
1543 1567 kw.setdefault('stop',len(lst))
1544 1568 # we need to remove start and stop from kw so they don't propagate
1545 1569 # into a recursive call for a nested list.
1546 1570 start = kw['start']; del kw['start']
1547 1571 stop = kw['stop']; del kw['stop']
1548 1572 if self.depth == 0 and 'header' in kw.keys():
1549 1573 print kw['header']
1550 1574
1551 1575 for idx in range(start,stop):
1552 1576 elem = lst[idx]
1553 1577 if type(elem)==type([]):
1554 1578 self.depth += 1
1555 1579 self.__call__(elem,itpl('$pos$idx,'),**kw)
1556 1580 self.depth -= 1
1557 1581 else:
1558 1582 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1559 1583
1560 1584 nlprint = NLprinter()
1561 1585 #----------------------------------------------------------------------------
1562 1586 def all_belong(candidates,checklist):
1563 1587 """Check whether a list of items ALL appear in a given list of options.
1564 1588
1565 1589 Returns a single 1 or 0 value."""
1566 1590
1567 1591 return 1-(0 in [x in checklist for x in candidates])
1568 1592
1569 1593 #----------------------------------------------------------------------------
1570 1594 def sort_compare(lst1,lst2,inplace = 1):
1571 1595 """Sort and compare two lists.
1572 1596
1573 1597 By default it does it in place, thus modifying the lists. Use inplace = 0
1574 1598 to avoid that (at the cost of temporary copy creation)."""
1575 1599 if not inplace:
1576 1600 lst1 = lst1[:]
1577 1601 lst2 = lst2[:]
1578 1602 lst1.sort(); lst2.sort()
1579 1603 return lst1 == lst2
1580 1604
1581 1605 #----------------------------------------------------------------------------
1582 1606 def mkdict(**kwargs):
1583 1607 """Return a dict from a keyword list.
1584 1608
1585 1609 It's just syntactic sugar for making ditcionary creation more convenient:
1586 1610 # the standard way
1587 1611 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1588 1612 # a cleaner way
1589 1613 >>>data = dict(red=1, green=2, blue=3)
1590 1614
1591 1615 If you need more than this, look at the Struct() class."""
1592 1616
1593 1617 return kwargs
1594 1618
1595 1619 #----------------------------------------------------------------------------
1596 1620 def list2dict(lst):
1597 1621 """Takes a list of (key,value) pairs and turns it into a dict."""
1598 1622
1599 1623 dic = {}
1600 1624 for k,v in lst: dic[k] = v
1601 1625 return dic
1602 1626
1603 1627 #----------------------------------------------------------------------------
1604 1628 def list2dict2(lst,default=''):
1605 1629 """Takes a list and turns it into a dict.
1606 1630 Much slower than list2dict, but more versatile. This version can take
1607 1631 lists with sublists of arbitrary length (including sclars)."""
1608 1632
1609 1633 dic = {}
1610 1634 for elem in lst:
1611 1635 if type(elem) in (types.ListType,types.TupleType):
1612 1636 size = len(elem)
1613 1637 if size == 0:
1614 1638 pass
1615 1639 elif size == 1:
1616 1640 dic[elem] = default
1617 1641 else:
1618 1642 k,v = elem[0], elem[1:]
1619 1643 if len(v) == 1: v = v[0]
1620 1644 dic[k] = v
1621 1645 else:
1622 1646 dic[elem] = default
1623 1647 return dic
1624 1648
1625 1649 #----------------------------------------------------------------------------
1626 1650 def flatten(seq):
1627 1651 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1628 1652
1629 1653 return [x for subseq in seq for x in subseq]
1630 1654
1631 1655 #----------------------------------------------------------------------------
1632 1656 def get_slice(seq,start=0,stop=None,step=1):
1633 1657 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1634 1658 if stop == None:
1635 1659 stop = len(seq)
1636 1660 item = lambda i: seq[i]
1637 1661 return map(item,xrange(start,stop,step))
1638 1662
1639 1663 #----------------------------------------------------------------------------
1640 1664 def chop(seq,size):
1641 1665 """Chop a sequence into chunks of the given size."""
1642 1666 chunk = lambda i: seq[i:i+size]
1643 1667 return map(chunk,xrange(0,len(seq),size))
1644 1668
1645 1669 #----------------------------------------------------------------------------
1646 1670 # with is a keyword as of python 2.5, so this function is renamed to withobj
1647 1671 # from its old 'with' name.
1648 1672 def with_obj(object, **args):
1649 1673 """Set multiple attributes for an object, similar to Pascal's with.
1650 1674
1651 1675 Example:
1652 1676 with_obj(jim,
1653 1677 born = 1960,
1654 1678 haircolour = 'Brown',
1655 1679 eyecolour = 'Green')
1656 1680
1657 1681 Credit: Greg Ewing, in
1658 1682 http://mail.python.org/pipermail/python-list/2001-May/040703.html.
1659 1683
1660 1684 NOTE: up until IPython 0.7.2, this was called simply 'with', but 'with'
1661 1685 has become a keyword for Python 2.5, so we had to rename it."""
1662 1686
1663 1687 object.__dict__.update(args)
1664 1688
1665 1689 #----------------------------------------------------------------------------
1666 1690 def setattr_list(obj,alist,nspace = None):
1667 1691 """Set a list of attributes for an object taken from a namespace.
1668 1692
1669 1693 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1670 1694 alist with their values taken from nspace, which must be a dict (something
1671 1695 like locals() will often do) If nspace isn't given, locals() of the
1672 1696 *caller* is used, so in most cases you can omit it.
1673 1697
1674 1698 Note that alist can be given as a string, which will be automatically
1675 1699 split into a list on whitespace. If given as a list, it must be a list of
1676 1700 *strings* (the variable names themselves), not of variables."""
1677 1701
1678 1702 # this grabs the local variables from the *previous* call frame -- that is
1679 1703 # the locals from the function that called setattr_list().
1680 1704 # - snipped from weave.inline()
1681 1705 if nspace is None:
1682 1706 call_frame = sys._getframe().f_back
1683 1707 nspace = call_frame.f_locals
1684 1708
1685 1709 if type(alist) in StringTypes:
1686 1710 alist = alist.split()
1687 1711 for attr in alist:
1688 1712 val = eval(attr,nspace)
1689 1713 setattr(obj,attr,val)
1690 1714
1691 1715 #----------------------------------------------------------------------------
1692 1716 def getattr_list(obj,alist,*args):
1693 1717 """getattr_list(obj,alist[, default]) -> attribute list.
1694 1718
1695 1719 Get a list of named attributes for an object. When a default argument is
1696 1720 given, it is returned when the attribute doesn't exist; without it, an
1697 1721 exception is raised in that case.
1698 1722
1699 1723 Note that alist can be given as a string, which will be automatically
1700 1724 split into a list on whitespace. If given as a list, it must be a list of
1701 1725 *strings* (the variable names themselves), not of variables."""
1702 1726
1703 1727 if type(alist) in StringTypes:
1704 1728 alist = alist.split()
1705 1729 if args:
1706 1730 if len(args)==1:
1707 1731 default = args[0]
1708 1732 return map(lambda attr: getattr(obj,attr,default),alist)
1709 1733 else:
1710 1734 raise ValueError,'getattr_list() takes only one optional argument'
1711 1735 else:
1712 1736 return map(lambda attr: getattr(obj,attr),alist)
1713 1737
1714 1738 #----------------------------------------------------------------------------
1715 1739 def map_method(method,object_list,*argseq,**kw):
1716 1740 """map_method(method,object_list,*args,**kw) -> list
1717 1741
1718 1742 Return a list of the results of applying the methods to the items of the
1719 1743 argument sequence(s). If more than one sequence is given, the method is
1720 1744 called with an argument list consisting of the corresponding item of each
1721 1745 sequence. All sequences must be of the same length.
1722 1746
1723 1747 Keyword arguments are passed verbatim to all objects called.
1724 1748
1725 1749 This is Python code, so it's not nearly as fast as the builtin map()."""
1726 1750
1727 1751 out_list = []
1728 1752 idx = 0
1729 1753 for object in object_list:
1730 1754 try:
1731 1755 handler = getattr(object, method)
1732 1756 except AttributeError:
1733 1757 out_list.append(None)
1734 1758 else:
1735 1759 if argseq:
1736 1760 args = map(lambda lst:lst[idx],argseq)
1737 1761 #print 'ob',object,'hand',handler,'ar',args # dbg
1738 1762 out_list.append(handler(args,**kw))
1739 1763 else:
1740 1764 out_list.append(handler(**kw))
1741 1765 idx += 1
1742 1766 return out_list
1743 1767
1744 1768 #----------------------------------------------------------------------------
1745 1769 def get_class_members(cls):
1746 1770 ret = dir(cls)
1747 1771 if hasattr(cls,'__bases__'):
1748 1772 for base in cls.__bases__:
1749 1773 ret.extend(get_class_members(base))
1750 1774 return ret
1751 1775
1752 1776 #----------------------------------------------------------------------------
1753 1777 def dir2(obj):
1754 1778 """dir2(obj) -> list of strings
1755 1779
1756 1780 Extended version of the Python builtin dir(), which does a few extra
1757 1781 checks, and supports common objects with unusual internals that confuse
1758 1782 dir(), such as Traits and PyCrust.
1759 1783
1760 1784 This version is guaranteed to return only a list of true strings, whereas
1761 1785 dir() returns anything that objects inject into themselves, even if they
1762 1786 are later not really valid for attribute access (many extension libraries
1763 1787 have such bugs).
1764 1788 """
1765 1789
1766 1790 # Start building the attribute list via dir(), and then complete it
1767 1791 # with a few extra special-purpose calls.
1768 1792 words = dir(obj)
1769 1793
1770 1794 if hasattr(obj,'__class__'):
1771 1795 words.append('__class__')
1772 1796 words.extend(get_class_members(obj.__class__))
1773 1797 #if '__base__' in words: 1/0
1774 1798
1775 1799 # Some libraries (such as traits) may introduce duplicates, we want to
1776 1800 # track and clean this up if it happens
1777 1801 may_have_dupes = False
1778 1802
1779 1803 # this is the 'dir' function for objects with Enthought's traits
1780 1804 if hasattr(obj, 'trait_names'):
1781 1805 try:
1782 1806 words.extend(obj.trait_names())
1783 1807 may_have_dupes = True
1784 1808 except TypeError:
1785 1809 # This will happen if `obj` is a class and not an instance.
1786 1810 pass
1787 1811
1788 1812 # Support for PyCrust-style _getAttributeNames magic method.
1789 1813 if hasattr(obj, '_getAttributeNames'):
1790 1814 try:
1791 1815 words.extend(obj._getAttributeNames())
1792 1816 may_have_dupes = True
1793 1817 except TypeError:
1794 1818 # `obj` is a class and not an instance. Ignore
1795 1819 # this error.
1796 1820 pass
1797 1821
1798 1822 if may_have_dupes:
1799 1823 # eliminate possible duplicates, as some traits may also
1800 1824 # appear as normal attributes in the dir() call.
1801 1825 words = list(set(words))
1802 1826 words.sort()
1803 1827
1804 1828 # filter out non-string attributes which may be stuffed by dir() calls
1805 1829 # and poor coding in third-party modules
1806 1830 return [w for w in words if isinstance(w, basestring)]
1807 1831
1808 1832 #----------------------------------------------------------------------------
1809 1833 def import_fail_info(mod_name,fns=None):
1810 1834 """Inform load failure for a module."""
1811 1835
1812 1836 if fns == None:
1813 1837 warn("Loading of %s failed.\n" % (mod_name,))
1814 1838 else:
1815 1839 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1816 1840
1817 1841 #----------------------------------------------------------------------------
1818 1842 # Proposed popitem() extension, written as a method
1819 1843
1820 1844
1821 1845 class NotGiven: pass
1822 1846
1823 1847 def popkey(dct,key,default=NotGiven):
1824 1848 """Return dct[key] and delete dct[key].
1825 1849
1826 1850 If default is given, return it if dct[key] doesn't exist, otherwise raise
1827 1851 KeyError. """
1828 1852
1829 1853 try:
1830 1854 val = dct[key]
1831 1855 except KeyError:
1832 1856 if default is NotGiven:
1833 1857 raise
1834 1858 else:
1835 1859 return default
1836 1860 else:
1837 1861 del dct[key]
1838 1862 return val
1839 1863
1840 1864 def wrap_deprecated(func, suggest = '<nothing>'):
1841 1865 def newFunc(*args, **kwargs):
1842 1866 warnings.warn("Call to deprecated function %s, use %s instead" %
1843 1867 ( func.__name__, suggest),
1844 1868 category=DeprecationWarning,
1845 1869 stacklevel = 2)
1846 1870 return func(*args, **kwargs)
1847 1871 return newFunc
1848 1872
1849 1873 #*************************** end of file <genutils.py> **********************
1850 1874
@@ -1,2489 +1,2498 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 2596 2007-08-08 11:41:01Z vivainio $
9 $Id: iplib.py 2602 2007-08-12 22:45:38Z 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 import doctest
44 45 import exceptions
45 46 import glob
46 47 import inspect
47 48 import keyword
48 49 import new
49 50 import os
50 51 import pydoc
51 52 import re
52 53 import shutil
53 54 import string
54 55 import sys
55 56 import tempfile
56 57 import traceback
57 58 import types
58 59 import pickleshare
59 60 from sets import Set
60 61 from pprint import pprint, pformat
61 62
62 63 # IPython's own modules
63 64 #import IPython
64 65 from IPython import Debugger,OInspect,PyColorize,ultraTB
65 66 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 67 from IPython.FakeModule import FakeModule
67 68 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 69 from IPython.Logger import Logger
69 70 from IPython.Magic import Magic
70 71 from IPython.Prompts import CachedOutput
71 72 from IPython.ipstruct import Struct
72 73 from IPython.background_jobs import BackgroundJobManager
73 74 from IPython.usage import cmd_line_usage,interactive_usage
74 75 from IPython.genutils import *
75 76 from IPython.strdispatch import StrDispatch
76 77 import IPython.ipapi
77 78 import IPython.history
78 79 import IPython.prefilter as prefilter
79 80 import IPython.shadowns
80 81 # Globals
81 82
82 83 # store the builtin raw_input globally, and use this always, in case user code
83 84 # overwrites it (like wx.py.PyShell does)
84 85 raw_input_original = raw_input
85 86
86 87 # compiled regexps for autoindent management
87 88 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
88 89
89 90
90 91 #****************************************************************************
91 92 # Some utility function definitions
92 93
93 94 ini_spaces_re = re.compile(r'^(\s+)')
94 95
95 96 def num_ini_spaces(strng):
96 97 """Return the number of initial spaces in a string"""
97 98
98 99 ini_spaces = ini_spaces_re.match(strng)
99 100 if ini_spaces:
100 101 return ini_spaces.end()
101 102 else:
102 103 return 0
103 104
104 105 def softspace(file, newvalue):
105 106 """Copied from code.py, to remove the dependency"""
106 107
107 108 oldvalue = 0
108 109 try:
109 110 oldvalue = file.softspace
110 111 except AttributeError:
111 112 pass
112 113 try:
113 114 file.softspace = newvalue
114 115 except (AttributeError, TypeError):
115 116 # "attribute-less object" or "read-only attributes"
116 117 pass
117 118 return oldvalue
118 119
119 120
120 121 #****************************************************************************
121 122 # Local use exceptions
122 123 class SpaceInInput(exceptions.Exception): pass
123 124
124 125
125 126 #****************************************************************************
126 127 # Local use classes
127 128 class Bunch: pass
128 129
129 130 class Undefined: pass
130 131
131 132 class Quitter(object):
132 133 """Simple class to handle exit, similar to Python 2.5's.
133 134
134 135 It handles exiting in an ipython-safe manner, which the one in Python 2.5
135 136 doesn't do (obviously, since it doesn't know about ipython)."""
136 137
137 138 def __init__(self,shell,name):
138 139 self.shell = shell
139 140 self.name = name
140 141
141 142 def __repr__(self):
142 143 return 'Type %s() to exit.' % self.name
143 144 __str__ = __repr__
144 145
145 146 def __call__(self):
146 147 self.shell.exit()
147 148
148 149 class InputList(list):
149 150 """Class to store user input.
150 151
151 152 It's basically a list, but slices return a string instead of a list, thus
152 153 allowing things like (assuming 'In' is an instance):
153 154
154 155 exec In[4:7]
155 156
156 157 or
157 158
158 159 exec In[5:9] + In[14] + In[21:25]"""
159 160
160 161 def __getslice__(self,i,j):
161 162 return ''.join(list.__getslice__(self,i,j))
162 163
163 164 class SyntaxTB(ultraTB.ListTB):
164 165 """Extension which holds some state: the last exception value"""
165 166
166 167 def __init__(self,color_scheme = 'NoColor'):
167 168 ultraTB.ListTB.__init__(self,color_scheme)
168 169 self.last_syntax_error = None
169 170
170 171 def __call__(self, etype, value, elist):
171 172 self.last_syntax_error = value
172 173 ultraTB.ListTB.__call__(self,etype,value,elist)
173 174
174 175 def clear_err_state(self):
175 176 """Return the current error state and clear it"""
176 177 e = self.last_syntax_error
177 178 self.last_syntax_error = None
178 179 return e
179 180
180 181 #****************************************************************************
181 182 # Main IPython class
182 183
183 184 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
184 185 # until a full rewrite is made. I've cleaned all cross-class uses of
185 186 # attributes and methods, but too much user code out there relies on the
186 187 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
187 188 #
188 189 # But at least now, all the pieces have been separated and we could, in
189 190 # principle, stop using the mixin. This will ease the transition to the
190 191 # chainsaw branch.
191 192
192 193 # For reference, the following is the list of 'self.foo' uses in the Magic
193 194 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
194 195 # class, to prevent clashes.
195 196
196 197 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
197 198 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
198 199 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
199 200 # 'self.value']
200 201
201 202 class InteractiveShell(object,Magic):
202 203 """An enhanced console for Python."""
203 204
204 205 # class attribute to indicate whether the class supports threads or not.
205 206 # Subclasses with thread support should override this as needed.
206 207 isthreaded = False
207 208
208 209 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
209 210 user_ns = None,user_global_ns=None,banner2='',
210 211 custom_exceptions=((),None),embedded=False):
211 212
212 213 # log system
213 214 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
214 215
215 216 # some minimal strict typechecks. For some core data structures, I
216 217 # want actual basic python types, not just anything that looks like
217 218 # one. This is especially true for namespaces.
218 219 for ns in (user_ns,user_global_ns):
219 220 if ns is not None and type(ns) != types.DictType:
220 221 raise TypeError,'namespace must be a dictionary'
221 222
222 223 # Job manager (for jobs run as background threads)
223 224 self.jobs = BackgroundJobManager()
224 225
225 226 # Store the actual shell's name
226 227 self.name = name
227 228
228 229 # We need to know whether the instance is meant for embedding, since
229 230 # global/local namespaces need to be handled differently in that case
230 231 self.embedded = embedded
231 232 if embedded:
232 233 # Control variable so users can, from within the embedded instance,
233 234 # permanently deactivate it.
234 235 self.embedded_active = True
235 236
236 237 # command compiler
237 238 self.compile = codeop.CommandCompiler()
238 239
239 240 # User input buffer
240 241 self.buffer = []
241 242
242 243 # Default name given in compilation of code
243 244 self.filename = '<ipython console>'
244 245
245 246 # Install our own quitter instead of the builtins. For python2.3-2.4,
246 247 # this brings in behavior like 2.5, and for 2.5 it's identical.
247 248 __builtin__.exit = Quitter(self,'exit')
248 249 __builtin__.quit = Quitter(self,'quit')
249 250
250 251 # Make an empty namespace, which extension writers can rely on both
251 252 # existing and NEVER being used by ipython itself. This gives them a
252 253 # convenient location for storing additional information and state
253 254 # their extensions may require, without fear of collisions with other
254 255 # ipython names that may develop later.
255 256 self.meta = Struct()
256 257
257 258 # Create the namespace where the user will operate. user_ns is
258 259 # normally the only one used, and it is passed to the exec calls as
259 260 # the locals argument. But we do carry a user_global_ns namespace
260 261 # given as the exec 'globals' argument, This is useful in embedding
261 262 # situations where the ipython shell opens in a context where the
262 263 # distinction between locals and globals is meaningful.
263 264
264 265 # FIXME. For some strange reason, __builtins__ is showing up at user
265 266 # level as a dict instead of a module. This is a manual fix, but I
266 267 # should really track down where the problem is coming from. Alex
267 268 # Schmolck reported this problem first.
268 269
269 270 # A useful post by Alex Martelli on this topic:
270 271 # Re: inconsistent value from __builtins__
271 272 # Von: Alex Martelli <aleaxit@yahoo.com>
272 273 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
273 274 # Gruppen: comp.lang.python
274 275
275 276 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
276 277 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
277 278 # > <type 'dict'>
278 279 # > >>> print type(__builtins__)
279 280 # > <type 'module'>
280 281 # > Is this difference in return value intentional?
281 282
282 283 # Well, it's documented that '__builtins__' can be either a dictionary
283 284 # or a module, and it's been that way for a long time. Whether it's
284 285 # intentional (or sensible), I don't know. In any case, the idea is
285 286 # that if you need to access the built-in namespace directly, you
286 287 # should start with "import __builtin__" (note, no 's') which will
287 288 # definitely give you a module. Yeah, it's somewhat confusing:-(.
288 289
289 290 # These routines return properly built dicts as needed by the rest of
290 291 # the code, and can also be used by extension writers to generate
291 292 # properly initialized namespaces.
292 293 user_ns = IPython.ipapi.make_user_ns(user_ns)
293 294 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
294 295
295 296 # Assign namespaces
296 297 # This is the namespace where all normal user variables live
297 298 self.user_ns = user_ns
298 299 # Embedded instances require a separate namespace for globals.
299 300 # Normally this one is unused by non-embedded instances.
300 301 self.user_global_ns = user_global_ns
301 302 # A namespace to keep track of internal data structures to prevent
302 303 # them from cluttering user-visible stuff. Will be updated later
303 304 self.internal_ns = {}
304 305
305 306 # Namespace of system aliases. Each entry in the alias
306 307 # table must be a 2-tuple of the form (N,name), where N is the number
307 308 # of positional arguments of the alias.
308 309 self.alias_table = {}
309 310
310 311 # A table holding all the namespaces IPython deals with, so that
311 312 # introspection facilities can search easily.
312 313 self.ns_table = {'user':user_ns,
313 314 'user_global':user_global_ns,
314 315 'alias':self.alias_table,
315 316 'internal':self.internal_ns,
316 317 'builtin':__builtin__.__dict__
317 318 }
318 319
319 320 # The user namespace MUST have a pointer to the shell itself.
320 321 self.user_ns[name] = self
321 322
322 323 # We need to insert into sys.modules something that looks like a
323 324 # module but which accesses the IPython namespace, for shelve and
324 325 # pickle to work interactively. Normally they rely on getting
325 326 # everything out of __main__, but for embedding purposes each IPython
326 327 # instance has its own private namespace, so we can't go shoving
327 328 # everything into __main__.
328 329
329 330 # note, however, that we should only do this for non-embedded
330 331 # ipythons, which really mimic the __main__.__dict__ with their own
331 332 # namespace. Embedded instances, on the other hand, should not do
332 333 # this because they need to manage the user local/global namespaces
333 334 # only, but they live within a 'normal' __main__ (meaning, they
334 335 # shouldn't overtake the execution environment of the script they're
335 336 # embedded in).
336 337
337 338 if not embedded:
338 339 try:
339 340 main_name = self.user_ns['__name__']
340 341 except KeyError:
341 342 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
342 343 else:
343 344 #print "pickle hack in place" # dbg
344 345 #print 'main_name:',main_name # dbg
345 346 sys.modules[main_name] = FakeModule(self.user_ns)
346 347
347 348 # List of input with multi-line handling.
348 349 # Fill its zero entry, user counter starts at 1
349 350 self.input_hist = InputList(['\n'])
350 351 # This one will hold the 'raw' input history, without any
351 352 # pre-processing. This will allow users to retrieve the input just as
352 353 # it was exactly typed in by the user, with %hist -r.
353 354 self.input_hist_raw = InputList(['\n'])
354 355
355 356 # list of visited directories
356 357 try:
357 358 self.dir_hist = [os.getcwd()]
358 359 except OSError:
359 360 self.dir_hist = []
360 361
361 362 # dict of output history
362 363 self.output_hist = {}
363 364
364 365 # Get system encoding at startup time. Certain terminals (like Emacs
365 366 # under Win32 have it set to None, and we need to have a known valid
366 367 # encoding to use in the raw_input() method
367 368 self.stdin_encoding = sys.stdin.encoding or 'ascii'
368 369
369 370 # dict of things NOT to alias (keywords, builtins and some magics)
370 371 no_alias = {}
371 372 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
372 373 for key in keyword.kwlist + no_alias_magics:
373 374 no_alias[key] = 1
374 375 no_alias.update(__builtin__.__dict__)
375 376 self.no_alias = no_alias
376 377
377 378 # make global variables for user access to these
378 379 self.user_ns['_ih'] = self.input_hist
379 380 self.user_ns['_oh'] = self.output_hist
380 381 self.user_ns['_dh'] = self.dir_hist
381 382
382 383 # user aliases to input and output histories
383 384 self.user_ns['In'] = self.input_hist
384 385 self.user_ns['Out'] = self.output_hist
385 386
386 387 self.user_ns['_sh'] = IPython.shadowns
387 388 # Object variable to store code object waiting execution. This is
388 389 # used mainly by the multithreaded shells, but it can come in handy in
389 390 # other situations. No need to use a Queue here, since it's a single
390 391 # item which gets cleared once run.
391 392 self.code_to_run = None
392 393
393 394 # escapes for automatic behavior on the command line
394 395 self.ESC_SHELL = '!'
395 396 self.ESC_SH_CAP = '!!'
396 397 self.ESC_HELP = '?'
397 398 self.ESC_MAGIC = '%'
398 399 self.ESC_QUOTE = ','
399 400 self.ESC_QUOTE2 = ';'
400 401 self.ESC_PAREN = '/'
401 402
402 403 # And their associated handlers
403 404 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
404 405 self.ESC_QUOTE : self.handle_auto,
405 406 self.ESC_QUOTE2 : self.handle_auto,
406 407 self.ESC_MAGIC : self.handle_magic,
407 408 self.ESC_HELP : self.handle_help,
408 409 self.ESC_SHELL : self.handle_shell_escape,
409 410 self.ESC_SH_CAP : self.handle_shell_escape,
410 411 }
411 412
412 413 # class initializations
413 414 Magic.__init__(self,self)
414 415
415 416 # Python source parser/formatter for syntax highlighting
416 417 pyformat = PyColorize.Parser().format
417 418 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
418 419
419 420 # hooks holds pointers used for user-side customizations
420 421 self.hooks = Struct()
421 422
422 423 self.strdispatchers = {}
423 424
424 425 # Set all default hooks, defined in the IPython.hooks module.
425 426 hooks = IPython.hooks
426 427 for hook_name in hooks.__all__:
427 428 # default hooks have priority 100, i.e. low; user hooks should have
428 429 # 0-100 priority
429 430 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
430 431 #print "bound hook",hook_name
431 432
432 433 # Flag to mark unconditional exit
433 434 self.exit_now = False
434 435
435 436 self.usage_min = """\
436 437 An enhanced console for Python.
437 438 Some of its features are:
438 439 - Readline support if the readline library is present.
439 440 - Tab completion in the local namespace.
440 441 - Logging of input, see command-line options.
441 442 - System shell escape via ! , eg !ls.
442 443 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
443 444 - Keeps track of locally defined variables via %who, %whos.
444 445 - Show object information with a ? eg ?x or x? (use ?? for more info).
445 446 """
446 447 if usage: self.usage = usage
447 448 else: self.usage = self.usage_min
448 449
449 450 # Storage
450 451 self.rc = rc # This will hold all configuration information
451 452 self.pager = 'less'
452 453 # temporary files used for various purposes. Deleted at exit.
453 454 self.tempfiles = []
454 455
455 456 # Keep track of readline usage (later set by init_readline)
456 457 self.has_readline = False
457 458
458 459 # template for logfile headers. It gets resolved at runtime by the
459 460 # logstart method.
460 461 self.loghead_tpl = \
461 462 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
462 463 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
463 464 #log# opts = %s
464 465 #log# args = %s
465 466 #log# It is safe to make manual edits below here.
466 467 #log#-----------------------------------------------------------------------
467 468 """
468 469 # for pushd/popd management
469 470 try:
470 471 self.home_dir = get_home_dir()
471 472 except HomeDirError,msg:
472 473 fatal(msg)
473 474
474 475 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
475 476
476 477 # Functions to call the underlying shell.
477 478
478 479 # The first is similar to os.system, but it doesn't return a value,
479 480 # and it allows interpolation of variables in the user's namespace.
480 481 self.system = lambda cmd: \
481 482 shell(self.var_expand(cmd,depth=2),
482 483 header=self.rc.system_header,
483 484 verbose=self.rc.system_verbose)
484 485
485 486 # These are for getoutput and getoutputerror:
486 487 self.getoutput = lambda cmd: \
487 488 getoutput(self.var_expand(cmd,depth=2),
488 489 header=self.rc.system_header,
489 490 verbose=self.rc.system_verbose)
490 491
491 492 self.getoutputerror = lambda cmd: \
492 493 getoutputerror(self.var_expand(cmd,depth=2),
493 494 header=self.rc.system_header,
494 495 verbose=self.rc.system_verbose)
495 496
496 497
497 498 # keep track of where we started running (mainly for crash post-mortem)
498 499 self.starting_dir = os.getcwd()
499 500
500 501 # Various switches which can be set
501 502 self.CACHELENGTH = 5000 # this is cheap, it's just text
502 503 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
503 504 self.banner2 = banner2
504 505
505 506 # TraceBack handlers:
506 507
507 508 # Syntax error handler.
508 509 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
509 510
510 511 # The interactive one is initialized with an offset, meaning we always
511 512 # want to remove the topmost item in the traceback, which is our own
512 513 # internal code. Valid modes: ['Plain','Context','Verbose']
513 514 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
514 515 color_scheme='NoColor',
515 516 tb_offset = 1)
516 517
517 518 # IPython itself shouldn't crash. This will produce a detailed
518 519 # post-mortem if it does. But we only install the crash handler for
519 520 # non-threaded shells, the threaded ones use a normal verbose reporter
520 521 # and lose the crash handler. This is because exceptions in the main
521 522 # thread (such as in GUI code) propagate directly to sys.excepthook,
522 523 # and there's no point in printing crash dumps for every user exception.
523 524 if self.isthreaded:
524 525 ipCrashHandler = ultraTB.FormattedTB()
525 526 else:
526 527 from IPython import CrashHandler
527 528 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
528 529 self.set_crash_handler(ipCrashHandler)
529 530
530 531 # and add any custom exception handlers the user may have specified
531 532 self.set_custom_exc(*custom_exceptions)
532 533
533 534 # indentation management
534 535 self.autoindent = False
535 536 self.indent_current_nsp = 0
536 537
537 538 # Make some aliases automatically
538 539 # Prepare list of shell aliases to auto-define
539 540 if os.name == 'posix':
540 541 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
541 542 'mv mv -i','rm rm -i','cp cp -i',
542 543 'cat cat','less less','clear clear',
543 544 # a better ls
544 545 'ls ls -F',
545 546 # long ls
546 547 'll ls -lF')
547 548 # Extra ls aliases with color, which need special treatment on BSD
548 549 # variants
549 550 ls_extra = ( # color ls
550 551 'lc ls -F -o --color',
551 552 # ls normal files only
552 553 'lf ls -F -o --color %l | grep ^-',
553 554 # ls symbolic links
554 555 'lk ls -F -o --color %l | grep ^l',
555 556 # directories or links to directories,
556 557 'ldir ls -F -o --color %l | grep /$',
557 558 # things which are executable
558 559 'lx ls -F -o --color %l | grep ^-..x',
559 560 )
560 561 # The BSDs don't ship GNU ls, so they don't understand the
561 562 # --color switch out of the box
562 563 if 'bsd' in sys.platform:
563 564 ls_extra = ( # ls normal files only
564 565 'lf ls -lF | grep ^-',
565 566 # ls symbolic links
566 567 'lk ls -lF | grep ^l',
567 568 # directories or links to directories,
568 569 'ldir ls -lF | grep /$',
569 570 # things which are executable
570 571 'lx ls -lF | grep ^-..x',
571 572 )
572 573 auto_alias = auto_alias + ls_extra
573 574 elif os.name in ['nt','dos']:
574 575 auto_alias = ('dir dir /on', 'ls dir /on',
575 576 'ddir dir /ad /on', 'ldir dir /ad /on',
576 577 'mkdir mkdir','rmdir rmdir','echo echo',
577 578 'ren ren','cls cls','copy copy')
578 579 else:
579 580 auto_alias = ()
580 581 self.auto_alias = [s.split(None,1) for s in auto_alias]
581 582 # Call the actual (public) initializer
582 583 self.init_auto_alias()
583 584
584 585 # Produce a public API instance
585 586 self.api = IPython.ipapi.IPApi(self)
586 587
587 588 # track which builtins we add, so we can clean up later
588 589 self.builtins_added = {}
589 590 # This method will add the necessary builtins for operation, but
590 591 # tracking what it did via the builtins_added dict.
591 592 self.add_builtins()
592 593
593 594 # end __init__
594 595
595 596 def var_expand(self,cmd,depth=0):
596 597 """Expand python variables in a string.
597 598
598 599 The depth argument indicates how many frames above the caller should
599 600 be walked to look for the local namespace where to expand variables.
600 601
601 602 The global namespace for expansion is always the user's interactive
602 603 namespace.
603 604 """
604 605
605 606 return str(ItplNS(cmd.replace('#','\#'),
606 607 self.user_ns, # globals
607 608 # Skip our own frame in searching for locals:
608 609 sys._getframe(depth+1).f_locals # locals
609 610 ))
610 611
611 612 def pre_config_initialization(self):
612 613 """Pre-configuration init method
613 614
614 615 This is called before the configuration files are processed to
615 616 prepare the services the config files might need.
616 617
617 618 self.rc already has reasonable default values at this point.
618 619 """
619 620 rc = self.rc
620 621 try:
621 622 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
622 623 except exceptions.UnicodeDecodeError:
623 624 print "Your ipythondir can't be decoded to unicode!"
624 625 print "Please set HOME environment variable to something that"
625 626 print r"only has ASCII characters, e.g. c:\home"
626 627 print "Now it is",rc.ipythondir
627 628 sys.exit()
628 629 self.shadowhist = IPython.history.ShadowHist(self.db)
629 630
630 631
631 632 def post_config_initialization(self):
632 633 """Post configuration init method
633 634
634 635 This is called after the configuration files have been processed to
635 636 'finalize' the initialization."""
636 637
637 638 rc = self.rc
638 639
639 640 # Object inspector
640 641 self.inspector = OInspect.Inspector(OInspect.InspectColors,
641 642 PyColorize.ANSICodeColors,
642 643 'NoColor',
643 644 rc.object_info_string_level)
644 645
645 646 self.rl_next_input = None
646 647 self.rl_do_indent = False
647 648 # Load readline proper
648 649 if rc.readline:
649 650 self.init_readline()
650 651
651 652
652 653 # local shortcut, this is used a LOT
653 654 self.log = self.logger.log
654 655
655 656 # Initialize cache, set in/out prompts and printing system
656 657 self.outputcache = CachedOutput(self,
657 658 rc.cache_size,
658 659 rc.pprint,
659 660 input_sep = rc.separate_in,
660 661 output_sep = rc.separate_out,
661 662 output_sep2 = rc.separate_out2,
662 663 ps1 = rc.prompt_in1,
663 664 ps2 = rc.prompt_in2,
664 665 ps_out = rc.prompt_out,
665 666 pad_left = rc.prompts_pad_left)
666 667
667 668 # user may have over-ridden the default print hook:
668 669 try:
669 670 self.outputcache.__class__.display = self.hooks.display
670 671 except AttributeError:
671 672 pass
672 673
673 674 # I don't like assigning globally to sys, because it means when
674 675 # embedding instances, each embedded instance overrides the previous
675 676 # choice. But sys.displayhook seems to be called internally by exec,
676 677 # so I don't see a way around it. We first save the original and then
677 678 # overwrite it.
678 679 self.sys_displayhook = sys.displayhook
679 680 sys.displayhook = self.outputcache
680
681
682 # Monkeypatch doctest so that its core test runner method is protected
683 # from IPython's modified displayhook. Doctest expects the default
684 # displayhook behavior deep down, so our modification breaks it
685 # completely. For this reason, a hard monkeypatch seems like a
686 # reasonable solution rather than asking users to manually use a
687 # different doctest runner when under IPython.
688 doctest.DocTestRunner.run = dhook_wrap(doctest.DocTestRunner.run)
689
681 690 # Set user colors (don't do it in the constructor above so that it
682 691 # doesn't crash if colors option is invalid)
683 692 self.magic_colors(rc.colors)
684 693
685 694 # Set calling of pdb on exceptions
686 695 self.call_pdb = rc.pdb
687 696
688 697 # Load user aliases
689 698 for alias in rc.alias:
690 699 self.magic_alias(alias)
691 700 self.hooks.late_startup_hook()
692 701
693 702 batchrun = False
694 703 for batchfile in [path(arg) for arg in self.rc.args
695 704 if arg.lower().endswith('.ipy')]:
696 705 if not batchfile.isfile():
697 706 print "No such batch file:", batchfile
698 707 continue
699 708 self.api.runlines(batchfile.text())
700 709 batchrun = True
701 710 if batchrun:
702 711 self.exit_now = True
703 712
704 713 def add_builtins(self):
705 714 """Store ipython references into the builtin namespace.
706 715
707 716 Some parts of ipython operate via builtins injected here, which hold a
708 717 reference to IPython itself."""
709 718
710 719 # TODO: deprecate all except _ip; 'jobs' should be installed
711 720 # by an extension and the rest are under _ip, ipalias is redundant
712 721 builtins_new = dict(__IPYTHON__ = self,
713 722 ip_set_hook = self.set_hook,
714 723 jobs = self.jobs,
715 724 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
716 725 ipalias = wrap_deprecated(self.ipalias),
717 726 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
718 727 _ip = self.api
719 728 )
720 729 for biname,bival in builtins_new.items():
721 730 try:
722 731 # store the orignal value so we can restore it
723 732 self.builtins_added[biname] = __builtin__.__dict__[biname]
724 733 except KeyError:
725 734 # or mark that it wasn't defined, and we'll just delete it at
726 735 # cleanup
727 736 self.builtins_added[biname] = Undefined
728 737 __builtin__.__dict__[biname] = bival
729 738
730 739 # Keep in the builtins a flag for when IPython is active. We set it
731 740 # with setdefault so that multiple nested IPythons don't clobber one
732 741 # another. Each will increase its value by one upon being activated,
733 742 # which also gives us a way to determine the nesting level.
734 743 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
735 744
736 745 def clean_builtins(self):
737 746 """Remove any builtins which might have been added by add_builtins, or
738 747 restore overwritten ones to their previous values."""
739 748 for biname,bival in self.builtins_added.items():
740 749 if bival is Undefined:
741 750 del __builtin__.__dict__[biname]
742 751 else:
743 752 __builtin__.__dict__[biname] = bival
744 753 self.builtins_added.clear()
745 754
746 755 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
747 756 """set_hook(name,hook) -> sets an internal IPython hook.
748 757
749 758 IPython exposes some of its internal API as user-modifiable hooks. By
750 759 adding your function to one of these hooks, you can modify IPython's
751 760 behavior to call at runtime your own routines."""
752 761
753 762 # At some point in the future, this should validate the hook before it
754 763 # accepts it. Probably at least check that the hook takes the number
755 764 # of args it's supposed to.
756 765
757 766 f = new.instancemethod(hook,self,self.__class__)
758 767
759 768 # check if the hook is for strdispatcher first
760 769 if str_key is not None:
761 770 sdp = self.strdispatchers.get(name, StrDispatch())
762 771 sdp.add_s(str_key, f, priority )
763 772 self.strdispatchers[name] = sdp
764 773 return
765 774 if re_key is not None:
766 775 sdp = self.strdispatchers.get(name, StrDispatch())
767 776 sdp.add_re(re.compile(re_key), f, priority )
768 777 self.strdispatchers[name] = sdp
769 778 return
770 779
771 780 dp = getattr(self.hooks, name, None)
772 781 if name not in IPython.hooks.__all__:
773 782 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
774 783 if not dp:
775 784 dp = IPython.hooks.CommandChainDispatcher()
776 785
777 786 try:
778 787 dp.add(f,priority)
779 788 except AttributeError:
780 789 # it was not commandchain, plain old func - replace
781 790 dp = f
782 791
783 792 setattr(self.hooks,name, dp)
784 793
785 794
786 795 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
787 796
788 797 def set_crash_handler(self,crashHandler):
789 798 """Set the IPython crash handler.
790 799
791 800 This must be a callable with a signature suitable for use as
792 801 sys.excepthook."""
793 802
794 803 # Install the given crash handler as the Python exception hook
795 804 sys.excepthook = crashHandler
796 805
797 806 # The instance will store a pointer to this, so that runtime code
798 807 # (such as magics) can access it. This is because during the
799 808 # read-eval loop, it gets temporarily overwritten (to deal with GUI
800 809 # frameworks).
801 810 self.sys_excepthook = sys.excepthook
802 811
803 812
804 813 def set_custom_exc(self,exc_tuple,handler):
805 814 """set_custom_exc(exc_tuple,handler)
806 815
807 816 Set a custom exception handler, which will be called if any of the
808 817 exceptions in exc_tuple occur in the mainloop (specifically, in the
809 818 runcode() method.
810 819
811 820 Inputs:
812 821
813 822 - exc_tuple: a *tuple* of valid exceptions to call the defined
814 823 handler for. It is very important that you use a tuple, and NOT A
815 824 LIST here, because of the way Python's except statement works. If
816 825 you only want to trap a single exception, use a singleton tuple:
817 826
818 827 exc_tuple == (MyCustomException,)
819 828
820 829 - handler: this must be defined as a function with the following
821 830 basic interface: def my_handler(self,etype,value,tb).
822 831
823 832 This will be made into an instance method (via new.instancemethod)
824 833 of IPython itself, and it will be called if any of the exceptions
825 834 listed in the exc_tuple are caught. If the handler is None, an
826 835 internal basic one is used, which just prints basic info.
827 836
828 837 WARNING: by putting in your own exception handler into IPython's main
829 838 execution loop, you run a very good chance of nasty crashes. This
830 839 facility should only be used if you really know what you are doing."""
831 840
832 841 assert type(exc_tuple)==type(()) , \
833 842 "The custom exceptions must be given AS A TUPLE."
834 843
835 844 def dummy_handler(self,etype,value,tb):
836 845 print '*** Simple custom exception handler ***'
837 846 print 'Exception type :',etype
838 847 print 'Exception value:',value
839 848 print 'Traceback :',tb
840 849 print 'Source code :','\n'.join(self.buffer)
841 850
842 851 if handler is None: handler = dummy_handler
843 852
844 853 self.CustomTB = new.instancemethod(handler,self,self.__class__)
845 854 self.custom_exceptions = exc_tuple
846 855
847 856 def set_custom_completer(self,completer,pos=0):
848 857 """set_custom_completer(completer,pos=0)
849 858
850 859 Adds a new custom completer function.
851 860
852 861 The position argument (defaults to 0) is the index in the completers
853 862 list where you want the completer to be inserted."""
854 863
855 864 newcomp = new.instancemethod(completer,self.Completer,
856 865 self.Completer.__class__)
857 866 self.Completer.matchers.insert(pos,newcomp)
858 867
859 868 def set_completer(self):
860 869 """reset readline's completer to be our own."""
861 870 self.readline.set_completer(self.Completer.complete)
862 871
863 872 def _get_call_pdb(self):
864 873 return self._call_pdb
865 874
866 875 def _set_call_pdb(self,val):
867 876
868 877 if val not in (0,1,False,True):
869 878 raise ValueError,'new call_pdb value must be boolean'
870 879
871 880 # store value in instance
872 881 self._call_pdb = val
873 882
874 883 # notify the actual exception handlers
875 884 self.InteractiveTB.call_pdb = val
876 885 if self.isthreaded:
877 886 try:
878 887 self.sys_excepthook.call_pdb = val
879 888 except:
880 889 warn('Failed to activate pdb for threaded exception handler')
881 890
882 891 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
883 892 'Control auto-activation of pdb at exceptions')
884 893
885 894
886 895 # These special functions get installed in the builtin namespace, to
887 896 # provide programmatic (pure python) access to magics, aliases and system
888 897 # calls. This is important for logging, user scripting, and more.
889 898
890 899 # We are basically exposing, via normal python functions, the three
891 900 # mechanisms in which ipython offers special call modes (magics for
892 901 # internal control, aliases for direct system access via pre-selected
893 902 # names, and !cmd for calling arbitrary system commands).
894 903
895 904 def ipmagic(self,arg_s):
896 905 """Call a magic function by name.
897 906
898 907 Input: a string containing the name of the magic function to call and any
899 908 additional arguments to be passed to the magic.
900 909
901 910 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
902 911 prompt:
903 912
904 913 In[1]: %name -opt foo bar
905 914
906 915 To call a magic without arguments, simply use ipmagic('name').
907 916
908 917 This provides a proper Python function to call IPython's magics in any
909 918 valid Python code you can type at the interpreter, including loops and
910 919 compound statements. It is added by IPython to the Python builtin
911 920 namespace upon initialization."""
912 921
913 922 args = arg_s.split(' ',1)
914 923 magic_name = args[0]
915 924 magic_name = magic_name.lstrip(self.ESC_MAGIC)
916 925
917 926 try:
918 927 magic_args = args[1]
919 928 except IndexError:
920 929 magic_args = ''
921 930 fn = getattr(self,'magic_'+magic_name,None)
922 931 if fn is None:
923 932 error("Magic function `%s` not found." % magic_name)
924 933 else:
925 934 magic_args = self.var_expand(magic_args,1)
926 935 return fn(magic_args)
927 936
928 937 def ipalias(self,arg_s):
929 938 """Call an alias by name.
930 939
931 940 Input: a string containing the name of the alias to call and any
932 941 additional arguments to be passed to the magic.
933 942
934 943 ipalias('name -opt foo bar') is equivalent to typing at the ipython
935 944 prompt:
936 945
937 946 In[1]: name -opt foo bar
938 947
939 948 To call an alias without arguments, simply use ipalias('name').
940 949
941 950 This provides a proper Python function to call IPython's aliases in any
942 951 valid Python code you can type at the interpreter, including loops and
943 952 compound statements. It is added by IPython to the Python builtin
944 953 namespace upon initialization."""
945 954
946 955 args = arg_s.split(' ',1)
947 956 alias_name = args[0]
948 957 try:
949 958 alias_args = args[1]
950 959 except IndexError:
951 960 alias_args = ''
952 961 if alias_name in self.alias_table:
953 962 self.call_alias(alias_name,alias_args)
954 963 else:
955 964 error("Alias `%s` not found." % alias_name)
956 965
957 966 def ipsystem(self,arg_s):
958 967 """Make a system call, using IPython."""
959 968
960 969 self.system(arg_s)
961 970
962 971 def complete(self,text):
963 972 """Return a sorted list of all possible completions on text.
964 973
965 974 Inputs:
966 975
967 976 - text: a string of text to be completed on.
968 977
969 978 This is a wrapper around the completion mechanism, similar to what
970 979 readline does at the command line when the TAB key is hit. By
971 980 exposing it as a method, it can be used by other non-readline
972 981 environments (such as GUIs) for text completion.
973 982
974 983 Simple usage example:
975 984
976 985 In [1]: x = 'hello'
977 986
978 987 In [2]: __IP.complete('x.l')
979 988 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
980 989
981 990 complete = self.Completer.complete
982 991 state = 0
983 992 # use a dict so we get unique keys, since ipyhton's multiple
984 993 # completers can return duplicates. When we make 2.4 a requirement,
985 994 # start using sets instead, which are faster.
986 995 comps = {}
987 996 while True:
988 997 newcomp = complete(text,state,line_buffer=text)
989 998 if newcomp is None:
990 999 break
991 1000 comps[newcomp] = 1
992 1001 state += 1
993 1002 outcomps = comps.keys()
994 1003 outcomps.sort()
995 1004 return outcomps
996 1005
997 1006 def set_completer_frame(self, frame=None):
998 1007 if frame:
999 1008 self.Completer.namespace = frame.f_locals
1000 1009 self.Completer.global_namespace = frame.f_globals
1001 1010 else:
1002 1011 self.Completer.namespace = self.user_ns
1003 1012 self.Completer.global_namespace = self.user_global_ns
1004 1013
1005 1014 def init_auto_alias(self):
1006 1015 """Define some aliases automatically.
1007 1016
1008 1017 These are ALL parameter-less aliases"""
1009 1018
1010 1019 for alias,cmd in self.auto_alias:
1011 1020 self.alias_table[alias] = (0,cmd)
1012 1021
1013 1022 def alias_table_validate(self,verbose=0):
1014 1023 """Update information about the alias table.
1015 1024
1016 1025 In particular, make sure no Python keywords/builtins are in it."""
1017 1026
1018 1027 no_alias = self.no_alias
1019 1028 for k in self.alias_table.keys():
1020 1029 if k in no_alias:
1021 1030 del self.alias_table[k]
1022 1031 if verbose:
1023 1032 print ("Deleting alias <%s>, it's a Python "
1024 1033 "keyword or builtin." % k)
1025 1034
1026 1035 def set_autoindent(self,value=None):
1027 1036 """Set the autoindent flag, checking for readline support.
1028 1037
1029 1038 If called with no arguments, it acts as a toggle."""
1030 1039
1031 1040 if not self.has_readline:
1032 1041 if os.name == 'posix':
1033 1042 warn("The auto-indent feature requires the readline library")
1034 1043 self.autoindent = 0
1035 1044 return
1036 1045 if value is None:
1037 1046 self.autoindent = not self.autoindent
1038 1047 else:
1039 1048 self.autoindent = value
1040 1049
1041 1050 def rc_set_toggle(self,rc_field,value=None):
1042 1051 """Set or toggle a field in IPython's rc config. structure.
1043 1052
1044 1053 If called with no arguments, it acts as a toggle.
1045 1054
1046 1055 If called with a non-existent field, the resulting AttributeError
1047 1056 exception will propagate out."""
1048 1057
1049 1058 rc_val = getattr(self.rc,rc_field)
1050 1059 if value is None:
1051 1060 value = not rc_val
1052 1061 setattr(self.rc,rc_field,value)
1053 1062
1054 1063 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1055 1064 """Install the user configuration directory.
1056 1065
1057 1066 Can be called when running for the first time or to upgrade the user's
1058 1067 .ipython/ directory with the mode parameter. Valid modes are 'install'
1059 1068 and 'upgrade'."""
1060 1069
1061 1070 def wait():
1062 1071 try:
1063 1072 raw_input("Please press <RETURN> to start IPython.")
1064 1073 except EOFError:
1065 1074 print >> Term.cout
1066 1075 print '*'*70
1067 1076
1068 1077 cwd = os.getcwd() # remember where we started
1069 1078 glb = glob.glob
1070 1079 print '*'*70
1071 1080 if mode == 'install':
1072 1081 print \
1073 1082 """Welcome to IPython. I will try to create a personal configuration directory
1074 1083 where you can customize many aspects of IPython's functionality in:\n"""
1075 1084 else:
1076 1085 print 'I am going to upgrade your configuration in:'
1077 1086
1078 1087 print ipythondir
1079 1088
1080 1089 rcdirend = os.path.join('IPython','UserConfig')
1081 1090 cfg = lambda d: os.path.join(d,rcdirend)
1082 1091 try:
1083 1092 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1084 1093 except IOError:
1085 1094 warning = """
1086 1095 Installation error. IPython's directory was not found.
1087 1096
1088 1097 Check the following:
1089 1098
1090 1099 The ipython/IPython directory should be in a directory belonging to your
1091 1100 PYTHONPATH environment variable (that is, it should be in a directory
1092 1101 belonging to sys.path). You can copy it explicitly there or just link to it.
1093 1102
1094 1103 IPython will proceed with builtin defaults.
1095 1104 """
1096 1105 warn(warning)
1097 1106 wait()
1098 1107 return
1099 1108
1100 1109 if mode == 'install':
1101 1110 try:
1102 1111 shutil.copytree(rcdir,ipythondir)
1103 1112 os.chdir(ipythondir)
1104 1113 rc_files = glb("ipythonrc*")
1105 1114 for rc_file in rc_files:
1106 1115 os.rename(rc_file,rc_file+rc_suffix)
1107 1116 except:
1108 1117 warning = """
1109 1118
1110 1119 There was a problem with the installation:
1111 1120 %s
1112 1121 Try to correct it or contact the developers if you think it's a bug.
1113 1122 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1114 1123 warn(warning)
1115 1124 wait()
1116 1125 return
1117 1126
1118 1127 elif mode == 'upgrade':
1119 1128 try:
1120 1129 os.chdir(ipythondir)
1121 1130 except:
1122 1131 print """
1123 1132 Can not upgrade: changing to directory %s failed. Details:
1124 1133 %s
1125 1134 """ % (ipythondir,sys.exc_info()[1])
1126 1135 wait()
1127 1136 return
1128 1137 else:
1129 1138 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1130 1139 for new_full_path in sources:
1131 1140 new_filename = os.path.basename(new_full_path)
1132 1141 if new_filename.startswith('ipythonrc'):
1133 1142 new_filename = new_filename + rc_suffix
1134 1143 # The config directory should only contain files, skip any
1135 1144 # directories which may be there (like CVS)
1136 1145 if os.path.isdir(new_full_path):
1137 1146 continue
1138 1147 if os.path.exists(new_filename):
1139 1148 old_file = new_filename+'.old'
1140 1149 if os.path.exists(old_file):
1141 1150 os.remove(old_file)
1142 1151 os.rename(new_filename,old_file)
1143 1152 shutil.copy(new_full_path,new_filename)
1144 1153 else:
1145 1154 raise ValueError,'unrecognized mode for install:',`mode`
1146 1155
1147 1156 # Fix line-endings to those native to each platform in the config
1148 1157 # directory.
1149 1158 try:
1150 1159 os.chdir(ipythondir)
1151 1160 except:
1152 1161 print """
1153 1162 Problem: changing to directory %s failed.
1154 1163 Details:
1155 1164 %s
1156 1165
1157 1166 Some configuration files may have incorrect line endings. This should not
1158 1167 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1159 1168 wait()
1160 1169 else:
1161 1170 for fname in glb('ipythonrc*'):
1162 1171 try:
1163 1172 native_line_ends(fname,backup=0)
1164 1173 except IOError:
1165 1174 pass
1166 1175
1167 1176 if mode == 'install':
1168 1177 print """
1169 1178 Successful installation!
1170 1179
1171 1180 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1172 1181 IPython manual (there are both HTML and PDF versions supplied with the
1173 1182 distribution) to make sure that your system environment is properly configured
1174 1183 to take advantage of IPython's features.
1175 1184
1176 1185 Important note: the configuration system has changed! The old system is
1177 1186 still in place, but its setting may be partly overridden by the settings in
1178 1187 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1179 1188 if some of the new settings bother you.
1180 1189
1181 1190 """
1182 1191 else:
1183 1192 print """
1184 1193 Successful upgrade!
1185 1194
1186 1195 All files in your directory:
1187 1196 %(ipythondir)s
1188 1197 which would have been overwritten by the upgrade were backed up with a .old
1189 1198 extension. If you had made particular customizations in those files you may
1190 1199 want to merge them back into the new files.""" % locals()
1191 1200 wait()
1192 1201 os.chdir(cwd)
1193 1202 # end user_setup()
1194 1203
1195 1204 def atexit_operations(self):
1196 1205 """This will be executed at the time of exit.
1197 1206
1198 1207 Saving of persistent data should be performed here. """
1199 1208
1200 1209 #print '*** IPython exit cleanup ***' # dbg
1201 1210 # input history
1202 1211 self.savehist()
1203 1212
1204 1213 # Cleanup all tempfiles left around
1205 1214 for tfile in self.tempfiles:
1206 1215 try:
1207 1216 os.unlink(tfile)
1208 1217 except OSError:
1209 1218 pass
1210 1219
1211 1220 self.hooks.shutdown_hook()
1212 1221
1213 1222 def savehist(self):
1214 1223 """Save input history to a file (via readline library)."""
1215 1224 try:
1216 1225 self.readline.write_history_file(self.histfile)
1217 1226 except:
1218 1227 print 'Unable to save IPython command history to file: ' + \
1219 1228 `self.histfile`
1220 1229
1221 1230 def reloadhist(self):
1222 1231 """Reload the input history from disk file."""
1223 1232
1224 1233 if self.has_readline:
1225 1234 self.readline.clear_history()
1226 1235 self.readline.read_history_file(self.shell.histfile)
1227 1236
1228 1237 def history_saving_wrapper(self, func):
1229 1238 """ Wrap func for readline history saving
1230 1239
1231 1240 Convert func into callable that saves & restores
1232 1241 history around the call """
1233 1242
1234 1243 if not self.has_readline:
1235 1244 return func
1236 1245
1237 1246 def wrapper():
1238 1247 self.savehist()
1239 1248 try:
1240 1249 func()
1241 1250 finally:
1242 1251 readline.read_history_file(self.histfile)
1243 1252 return wrapper
1244 1253
1245 1254
1246 1255 def pre_readline(self):
1247 1256 """readline hook to be used at the start of each line.
1248 1257
1249 1258 Currently it handles auto-indent only."""
1250 1259
1251 1260 #debugx('self.indent_current_nsp','pre_readline:')
1252 1261
1253 1262 if self.rl_do_indent:
1254 1263 self.readline.insert_text(self.indent_current_str())
1255 1264 if self.rl_next_input is not None:
1256 1265 self.readline.insert_text(self.rl_next_input)
1257 1266 self.rl_next_input = None
1258 1267
1259 1268 def init_readline(self):
1260 1269 """Command history completion/saving/reloading."""
1261 1270
1262 1271 import IPython.rlineimpl as readline
1263 1272 if not readline.have_readline:
1264 1273 self.has_readline = 0
1265 1274 self.readline = None
1266 1275 # no point in bugging windows users with this every time:
1267 1276 warn('Readline services not available on this platform.')
1268 1277 else:
1269 1278 sys.modules['readline'] = readline
1270 1279 import atexit
1271 1280 from IPython.completer import IPCompleter
1272 1281 self.Completer = IPCompleter(self,
1273 1282 self.user_ns,
1274 1283 self.user_global_ns,
1275 1284 self.rc.readline_omit__names,
1276 1285 self.alias_table)
1277 1286 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1278 1287 self.strdispatchers['complete_command'] = sdisp
1279 1288 self.Completer.custom_completers = sdisp
1280 1289 # Platform-specific configuration
1281 1290 if os.name == 'nt':
1282 1291 self.readline_startup_hook = readline.set_pre_input_hook
1283 1292 else:
1284 1293 self.readline_startup_hook = readline.set_startup_hook
1285 1294
1286 1295 # Load user's initrc file (readline config)
1287 1296 inputrc_name = os.environ.get('INPUTRC')
1288 1297 if inputrc_name is None:
1289 1298 home_dir = get_home_dir()
1290 1299 if home_dir is not None:
1291 1300 inputrc_name = os.path.join(home_dir,'.inputrc')
1292 1301 if os.path.isfile(inputrc_name):
1293 1302 try:
1294 1303 readline.read_init_file(inputrc_name)
1295 1304 except:
1296 1305 warn('Problems reading readline initialization file <%s>'
1297 1306 % inputrc_name)
1298 1307
1299 1308 self.has_readline = 1
1300 1309 self.readline = readline
1301 1310 # save this in sys so embedded copies can restore it properly
1302 1311 sys.ipcompleter = self.Completer.complete
1303 1312 self.set_completer()
1304 1313
1305 1314 # Configure readline according to user's prefs
1306 1315 for rlcommand in self.rc.readline_parse_and_bind:
1307 1316 readline.parse_and_bind(rlcommand)
1308 1317
1309 1318 # remove some chars from the delimiters list
1310 1319 delims = readline.get_completer_delims()
1311 1320 delims = delims.translate(string._idmap,
1312 1321 self.rc.readline_remove_delims)
1313 1322 readline.set_completer_delims(delims)
1314 1323 # otherwise we end up with a monster history after a while:
1315 1324 readline.set_history_length(1000)
1316 1325 try:
1317 1326 #print '*** Reading readline history' # dbg
1318 1327 readline.read_history_file(self.histfile)
1319 1328 except IOError:
1320 1329 pass # It doesn't exist yet.
1321 1330
1322 1331 atexit.register(self.atexit_operations)
1323 1332 del atexit
1324 1333
1325 1334 # Configure auto-indent for all platforms
1326 1335 self.set_autoindent(self.rc.autoindent)
1327 1336
1328 1337 def ask_yes_no(self,prompt,default=True):
1329 1338 if self.rc.quiet:
1330 1339 return True
1331 1340 return ask_yes_no(prompt,default)
1332 1341
1333 1342 def _should_recompile(self,e):
1334 1343 """Utility routine for edit_syntax_error"""
1335 1344
1336 1345 if e.filename in ('<ipython console>','<input>','<string>',
1337 1346 '<console>','<BackgroundJob compilation>',
1338 1347 None):
1339 1348
1340 1349 return False
1341 1350 try:
1342 1351 if (self.rc.autoedit_syntax and
1343 1352 not self.ask_yes_no('Return to editor to correct syntax error? '
1344 1353 '[Y/n] ','y')):
1345 1354 return False
1346 1355 except EOFError:
1347 1356 return False
1348 1357
1349 1358 def int0(x):
1350 1359 try:
1351 1360 return int(x)
1352 1361 except TypeError:
1353 1362 return 0
1354 1363 # always pass integer line and offset values to editor hook
1355 1364 self.hooks.fix_error_editor(e.filename,
1356 1365 int0(e.lineno),int0(e.offset),e.msg)
1357 1366 return True
1358 1367
1359 1368 def edit_syntax_error(self):
1360 1369 """The bottom half of the syntax error handler called in the main loop.
1361 1370
1362 1371 Loop until syntax error is fixed or user cancels.
1363 1372 """
1364 1373
1365 1374 while self.SyntaxTB.last_syntax_error:
1366 1375 # copy and clear last_syntax_error
1367 1376 err = self.SyntaxTB.clear_err_state()
1368 1377 if not self._should_recompile(err):
1369 1378 return
1370 1379 try:
1371 1380 # may set last_syntax_error again if a SyntaxError is raised
1372 1381 self.safe_execfile(err.filename,self.user_ns)
1373 1382 except:
1374 1383 self.showtraceback()
1375 1384 else:
1376 1385 try:
1377 1386 f = file(err.filename)
1378 1387 try:
1379 1388 sys.displayhook(f.read())
1380 1389 finally:
1381 1390 f.close()
1382 1391 except:
1383 1392 self.showtraceback()
1384 1393
1385 1394 def showsyntaxerror(self, filename=None):
1386 1395 """Display the syntax error that just occurred.
1387 1396
1388 1397 This doesn't display a stack trace because there isn't one.
1389 1398
1390 1399 If a filename is given, it is stuffed in the exception instead
1391 1400 of what was there before (because Python's parser always uses
1392 1401 "<string>" when reading from a string).
1393 1402 """
1394 1403 etype, value, last_traceback = sys.exc_info()
1395 1404
1396 1405 # See note about these variables in showtraceback() below
1397 1406 sys.last_type = etype
1398 1407 sys.last_value = value
1399 1408 sys.last_traceback = last_traceback
1400 1409
1401 1410 if filename and etype is SyntaxError:
1402 1411 # Work hard to stuff the correct filename in the exception
1403 1412 try:
1404 1413 msg, (dummy_filename, lineno, offset, line) = value
1405 1414 except:
1406 1415 # Not the format we expect; leave it alone
1407 1416 pass
1408 1417 else:
1409 1418 # Stuff in the right filename
1410 1419 try:
1411 1420 # Assume SyntaxError is a class exception
1412 1421 value = SyntaxError(msg, (filename, lineno, offset, line))
1413 1422 except:
1414 1423 # If that failed, assume SyntaxError is a string
1415 1424 value = msg, (filename, lineno, offset, line)
1416 1425 self.SyntaxTB(etype,value,[])
1417 1426
1418 1427 def debugger(self,force=False):
1419 1428 """Call the pydb/pdb debugger.
1420 1429
1421 1430 Keywords:
1422 1431
1423 1432 - force(False): by default, this routine checks the instance call_pdb
1424 1433 flag and does not actually invoke the debugger if the flag is false.
1425 1434 The 'force' option forces the debugger to activate even if the flag
1426 1435 is false.
1427 1436 """
1428 1437
1429 1438 if not (force or self.call_pdb):
1430 1439 return
1431 1440
1432 1441 if not hasattr(sys,'last_traceback'):
1433 1442 error('No traceback has been produced, nothing to debug.')
1434 1443 return
1435 1444
1436 1445 # use pydb if available
1437 1446 if Debugger.has_pydb:
1438 1447 from pydb import pm
1439 1448 else:
1440 1449 # fallback to our internal debugger
1441 1450 pm = lambda : self.InteractiveTB.debugger(force=True)
1442 1451 self.history_saving_wrapper(pm)()
1443 1452
1444 1453 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1445 1454 """Display the exception that just occurred.
1446 1455
1447 1456 If nothing is known about the exception, this is the method which
1448 1457 should be used throughout the code for presenting user tracebacks,
1449 1458 rather than directly invoking the InteractiveTB object.
1450 1459
1451 1460 A specific showsyntaxerror() also exists, but this method can take
1452 1461 care of calling it if needed, so unless you are explicitly catching a
1453 1462 SyntaxError exception, don't try to analyze the stack manually and
1454 1463 simply call this method."""
1455 1464
1456 1465
1457 1466 # Though this won't be called by syntax errors in the input line,
1458 1467 # there may be SyntaxError cases whith imported code.
1459 1468
1460 1469
1461 1470 if exc_tuple is None:
1462 1471 etype, value, tb = sys.exc_info()
1463 1472 else:
1464 1473 etype, value, tb = exc_tuple
1465 1474
1466 1475 if etype is SyntaxError:
1467 1476 self.showsyntaxerror(filename)
1468 1477 else:
1469 1478 # WARNING: these variables are somewhat deprecated and not
1470 1479 # necessarily safe to use in a threaded environment, but tools
1471 1480 # like pdb depend on their existence, so let's set them. If we
1472 1481 # find problems in the field, we'll need to revisit their use.
1473 1482 sys.last_type = etype
1474 1483 sys.last_value = value
1475 1484 sys.last_traceback = tb
1476 1485
1477 1486 if etype in self.custom_exceptions:
1478 1487 self.CustomTB(etype,value,tb)
1479 1488 else:
1480 1489 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1481 1490 if self.InteractiveTB.call_pdb and self.has_readline:
1482 1491 # pdb mucks up readline, fix it back
1483 1492 self.set_completer()
1484 1493
1485 1494
1486 1495 def mainloop(self,banner=None):
1487 1496 """Creates the local namespace and starts the mainloop.
1488 1497
1489 1498 If an optional banner argument is given, it will override the
1490 1499 internally created default banner."""
1491 1500
1492 1501 if self.rc.c: # Emulate Python's -c option
1493 1502 self.exec_init_cmd()
1494 1503 if banner is None:
1495 1504 if not self.rc.banner:
1496 1505 banner = ''
1497 1506 # banner is string? Use it directly!
1498 1507 elif isinstance(self.rc.banner,basestring):
1499 1508 banner = self.rc.banner
1500 1509 else:
1501 1510 banner = self.BANNER+self.banner2
1502 1511
1503 1512 self.interact(banner)
1504 1513
1505 1514 def exec_init_cmd(self):
1506 1515 """Execute a command given at the command line.
1507 1516
1508 1517 This emulates Python's -c option."""
1509 1518
1510 1519 #sys.argv = ['-c']
1511 1520 self.push(self.prefilter(self.rc.c, False))
1512 1521 self.exit_now = True
1513 1522
1514 1523 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1515 1524 """Embeds IPython into a running python program.
1516 1525
1517 1526 Input:
1518 1527
1519 1528 - header: An optional header message can be specified.
1520 1529
1521 1530 - local_ns, global_ns: working namespaces. If given as None, the
1522 1531 IPython-initialized one is updated with __main__.__dict__, so that
1523 1532 program variables become visible but user-specific configuration
1524 1533 remains possible.
1525 1534
1526 1535 - stack_depth: specifies how many levels in the stack to go to
1527 1536 looking for namespaces (when local_ns and global_ns are None). This
1528 1537 allows an intermediate caller to make sure that this function gets
1529 1538 the namespace from the intended level in the stack. By default (0)
1530 1539 it will get its locals and globals from the immediate caller.
1531 1540
1532 1541 Warning: it's possible to use this in a program which is being run by
1533 1542 IPython itself (via %run), but some funny things will happen (a few
1534 1543 globals get overwritten). In the future this will be cleaned up, as
1535 1544 there is no fundamental reason why it can't work perfectly."""
1536 1545
1537 1546 # Get locals and globals from caller
1538 1547 if local_ns is None or global_ns is None:
1539 1548 call_frame = sys._getframe(stack_depth).f_back
1540 1549
1541 1550 if local_ns is None:
1542 1551 local_ns = call_frame.f_locals
1543 1552 if global_ns is None:
1544 1553 global_ns = call_frame.f_globals
1545 1554
1546 1555 # Update namespaces and fire up interpreter
1547 1556
1548 1557 # The global one is easy, we can just throw it in
1549 1558 self.user_global_ns = global_ns
1550 1559
1551 1560 # but the user/local one is tricky: ipython needs it to store internal
1552 1561 # data, but we also need the locals. We'll copy locals in the user
1553 1562 # one, but will track what got copied so we can delete them at exit.
1554 1563 # This is so that a later embedded call doesn't see locals from a
1555 1564 # previous call (which most likely existed in a separate scope).
1556 1565 local_varnames = local_ns.keys()
1557 1566 self.user_ns.update(local_ns)
1558 1567
1559 1568 # Patch for global embedding to make sure that things don't overwrite
1560 1569 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1561 1570 # FIXME. Test this a bit more carefully (the if.. is new)
1562 1571 if local_ns is None and global_ns is None:
1563 1572 self.user_global_ns.update(__main__.__dict__)
1564 1573
1565 1574 # make sure the tab-completer has the correct frame information, so it
1566 1575 # actually completes using the frame's locals/globals
1567 1576 self.set_completer_frame()
1568 1577
1569 1578 # before activating the interactive mode, we need to make sure that
1570 1579 # all names in the builtin namespace needed by ipython point to
1571 1580 # ourselves, and not to other instances.
1572 1581 self.add_builtins()
1573 1582
1574 1583 self.interact(header)
1575 1584
1576 1585 # now, purge out the user namespace from anything we might have added
1577 1586 # from the caller's local namespace
1578 1587 delvar = self.user_ns.pop
1579 1588 for var in local_varnames:
1580 1589 delvar(var,None)
1581 1590 # and clean builtins we may have overridden
1582 1591 self.clean_builtins()
1583 1592
1584 1593 def interact(self, banner=None):
1585 1594 """Closely emulate the interactive Python console.
1586 1595
1587 1596 The optional banner argument specify the banner to print
1588 1597 before the first interaction; by default it prints a banner
1589 1598 similar to the one printed by the real Python interpreter,
1590 1599 followed by the current class name in parentheses (so as not
1591 1600 to confuse this with the real interpreter -- since it's so
1592 1601 close!).
1593 1602
1594 1603 """
1595 1604
1596 1605 if self.exit_now:
1597 1606 # batch run -> do not interact
1598 1607 return
1599 1608 cprt = 'Type "copyright", "credits" or "license" for more information.'
1600 1609 if banner is None:
1601 1610 self.write("Python %s on %s\n%s\n(%s)\n" %
1602 1611 (sys.version, sys.platform, cprt,
1603 1612 self.__class__.__name__))
1604 1613 else:
1605 1614 self.write(banner)
1606 1615
1607 1616 more = 0
1608 1617
1609 1618 # Mark activity in the builtins
1610 1619 __builtin__.__dict__['__IPYTHON__active'] += 1
1611 1620
1612 1621 if readline.have_readline:
1613 1622 self.readline_startup_hook(self.pre_readline)
1614 1623 # exit_now is set by a call to %Exit or %Quit
1615 1624
1616 1625 while not self.exit_now:
1617 1626 if more:
1618 1627 prompt = self.hooks.generate_prompt(True)
1619 1628 if self.autoindent:
1620 1629 self.rl_do_indent = True
1621 1630
1622 1631 else:
1623 1632 prompt = self.hooks.generate_prompt(False)
1624 1633 try:
1625 1634 line = self.raw_input(prompt,more)
1626 1635 if self.exit_now:
1627 1636 # quick exit on sys.std[in|out] close
1628 1637 break
1629 1638 if self.autoindent:
1630 1639 self.rl_do_indent = False
1631 1640
1632 1641 except KeyboardInterrupt:
1633 1642 self.write('\nKeyboardInterrupt\n')
1634 1643 self.resetbuffer()
1635 1644 # keep cache in sync with the prompt counter:
1636 1645 self.outputcache.prompt_count -= 1
1637 1646
1638 1647 if self.autoindent:
1639 1648 self.indent_current_nsp = 0
1640 1649 more = 0
1641 1650 except EOFError:
1642 1651 if self.autoindent:
1643 1652 self.rl_do_indent = False
1644 1653 self.readline_startup_hook(None)
1645 1654 self.write('\n')
1646 1655 self.exit()
1647 1656 except bdb.BdbQuit:
1648 1657 warn('The Python debugger has exited with a BdbQuit exception.\n'
1649 1658 'Because of how pdb handles the stack, it is impossible\n'
1650 1659 'for IPython to properly format this particular exception.\n'
1651 1660 'IPython will resume normal operation.')
1652 1661 except:
1653 1662 # exceptions here are VERY RARE, but they can be triggered
1654 1663 # asynchronously by signal handlers, for example.
1655 1664 self.showtraceback()
1656 1665 else:
1657 1666 more = self.push(line)
1658 1667 if (self.SyntaxTB.last_syntax_error and
1659 1668 self.rc.autoedit_syntax):
1660 1669 self.edit_syntax_error()
1661 1670
1662 1671 # We are off again...
1663 1672 __builtin__.__dict__['__IPYTHON__active'] -= 1
1664 1673
1665 1674 def excepthook(self, etype, value, tb):
1666 1675 """One more defense for GUI apps that call sys.excepthook.
1667 1676
1668 1677 GUI frameworks like wxPython trap exceptions and call
1669 1678 sys.excepthook themselves. I guess this is a feature that
1670 1679 enables them to keep running after exceptions that would
1671 1680 otherwise kill their mainloop. This is a bother for IPython
1672 1681 which excepts to catch all of the program exceptions with a try:
1673 1682 except: statement.
1674 1683
1675 1684 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1676 1685 any app directly invokes sys.excepthook, it will look to the user like
1677 1686 IPython crashed. In order to work around this, we can disable the
1678 1687 CrashHandler and replace it with this excepthook instead, which prints a
1679 1688 regular traceback using our InteractiveTB. In this fashion, apps which
1680 1689 call sys.excepthook will generate a regular-looking exception from
1681 1690 IPython, and the CrashHandler will only be triggered by real IPython
1682 1691 crashes.
1683 1692
1684 1693 This hook should be used sparingly, only in places which are not likely
1685 1694 to be true IPython errors.
1686 1695 """
1687 1696 self.showtraceback((etype,value,tb),tb_offset=0)
1688 1697
1689 1698 def expand_aliases(self,fn,rest):
1690 1699 """ Expand multiple levels of aliases:
1691 1700
1692 1701 if:
1693 1702
1694 1703 alias foo bar /tmp
1695 1704 alias baz foo
1696 1705
1697 1706 then:
1698 1707
1699 1708 baz huhhahhei -> bar /tmp huhhahhei
1700 1709
1701 1710 """
1702 1711 line = fn + " " + rest
1703 1712
1704 1713 done = Set()
1705 1714 while 1:
1706 1715 pre,fn,rest = prefilter.splitUserInput(line,
1707 1716 prefilter.shell_line_split)
1708 1717 if fn in self.alias_table:
1709 1718 if fn in done:
1710 1719 warn("Cyclic alias definition, repeated '%s'" % fn)
1711 1720 return ""
1712 1721 done.add(fn)
1713 1722
1714 1723 l2 = self.transform_alias(fn,rest)
1715 1724 # dir -> dir
1716 1725 # print "alias",line, "->",l2 #dbg
1717 1726 if l2 == line:
1718 1727 break
1719 1728 # ls -> ls -F should not recurse forever
1720 1729 if l2.split(None,1)[0] == line.split(None,1)[0]:
1721 1730 line = l2
1722 1731 break
1723 1732
1724 1733 line=l2
1725 1734
1726 1735
1727 1736 # print "al expand to",line #dbg
1728 1737 else:
1729 1738 break
1730 1739
1731 1740 return line
1732 1741
1733 1742 def transform_alias(self, alias,rest=''):
1734 1743 """ Transform alias to system command string.
1735 1744 """
1736 1745 nargs,cmd = self.alias_table[alias]
1737 1746 if ' ' in cmd and os.path.isfile(cmd):
1738 1747 cmd = '"%s"' % cmd
1739 1748
1740 1749 # Expand the %l special to be the user's input line
1741 1750 if cmd.find('%l') >= 0:
1742 1751 cmd = cmd.replace('%l',rest)
1743 1752 rest = ''
1744 1753 if nargs==0:
1745 1754 # Simple, argument-less aliases
1746 1755 cmd = '%s %s' % (cmd,rest)
1747 1756 else:
1748 1757 # Handle aliases with positional arguments
1749 1758 args = rest.split(None,nargs)
1750 1759 if len(args)< nargs:
1751 1760 error('Alias <%s> requires %s arguments, %s given.' %
1752 1761 (alias,nargs,len(args)))
1753 1762 return None
1754 1763 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1755 1764 # Now call the macro, evaluating in the user's namespace
1756 1765 #print 'new command: <%r>' % cmd # dbg
1757 1766 return cmd
1758 1767
1759 1768 def call_alias(self,alias,rest=''):
1760 1769 """Call an alias given its name and the rest of the line.
1761 1770
1762 1771 This is only used to provide backwards compatibility for users of
1763 1772 ipalias(), use of which is not recommended for anymore."""
1764 1773
1765 1774 # Now call the macro, evaluating in the user's namespace
1766 1775 cmd = self.transform_alias(alias, rest)
1767 1776 try:
1768 1777 self.system(cmd)
1769 1778 except:
1770 1779 self.showtraceback()
1771 1780
1772 1781 def indent_current_str(self):
1773 1782 """return the current level of indentation as a string"""
1774 1783 return self.indent_current_nsp * ' '
1775 1784
1776 1785 def autoindent_update(self,line):
1777 1786 """Keep track of the indent level."""
1778 1787
1779 1788 #debugx('line')
1780 1789 #debugx('self.indent_current_nsp')
1781 1790 if self.autoindent:
1782 1791 if line:
1783 1792 inisp = num_ini_spaces(line)
1784 1793 if inisp < self.indent_current_nsp:
1785 1794 self.indent_current_nsp = inisp
1786 1795
1787 1796 if line[-1] == ':':
1788 1797 self.indent_current_nsp += 4
1789 1798 elif dedent_re.match(line):
1790 1799 self.indent_current_nsp -= 4
1791 1800 else:
1792 1801 self.indent_current_nsp = 0
1793 1802 def runlines(self,lines):
1794 1803 """Run a string of one or more lines of source.
1795 1804
1796 1805 This method is capable of running a string containing multiple source
1797 1806 lines, as if they had been entered at the IPython prompt. Since it
1798 1807 exposes IPython's processing machinery, the given strings can contain
1799 1808 magic calls (%magic), special shell access (!cmd), etc."""
1800 1809
1801 1810 # We must start with a clean buffer, in case this is run from an
1802 1811 # interactive IPython session (via a magic, for example).
1803 1812 self.resetbuffer()
1804 1813 lines = lines.split('\n')
1805 1814 more = 0
1806 1815
1807 1816 for line in lines:
1808 1817 # skip blank lines so we don't mess up the prompt counter, but do
1809 1818 # NOT skip even a blank line if we are in a code block (more is
1810 1819 # true)
1811 1820
1812 1821
1813 1822 if line or more:
1814 1823 # push to raw history, so hist line numbers stay in sync
1815 1824 self.input_hist_raw.append("# " + line + "\n")
1816 1825 more = self.push(self.prefilter(line,more))
1817 1826 # IPython's runsource returns None if there was an error
1818 1827 # compiling the code. This allows us to stop processing right
1819 1828 # away, so the user gets the error message at the right place.
1820 1829 if more is None:
1821 1830 break
1822 1831 else:
1823 1832 self.input_hist_raw.append("\n")
1824 1833 # final newline in case the input didn't have it, so that the code
1825 1834 # actually does get executed
1826 1835 if more:
1827 1836 self.push('\n')
1828 1837
1829 1838 def runsource(self, source, filename='<input>', symbol='single'):
1830 1839 """Compile and run some source in the interpreter.
1831 1840
1832 1841 Arguments are as for compile_command().
1833 1842
1834 1843 One several things can happen:
1835 1844
1836 1845 1) The input is incorrect; compile_command() raised an
1837 1846 exception (SyntaxError or OverflowError). A syntax traceback
1838 1847 will be printed by calling the showsyntaxerror() method.
1839 1848
1840 1849 2) The input is incomplete, and more input is required;
1841 1850 compile_command() returned None. Nothing happens.
1842 1851
1843 1852 3) The input is complete; compile_command() returned a code
1844 1853 object. The code is executed by calling self.runcode() (which
1845 1854 also handles run-time exceptions, except for SystemExit).
1846 1855
1847 1856 The return value is:
1848 1857
1849 1858 - True in case 2
1850 1859
1851 1860 - False in the other cases, unless an exception is raised, where
1852 1861 None is returned instead. This can be used by external callers to
1853 1862 know whether to continue feeding input or not.
1854 1863
1855 1864 The return value can be used to decide whether to use sys.ps1 or
1856 1865 sys.ps2 to prompt the next line."""
1857 1866
1858 1867 # if the source code has leading blanks, add 'if 1:\n' to it
1859 1868 # this allows execution of indented pasted code. It is tempting
1860 1869 # to add '\n' at the end of source to run commands like ' a=1'
1861 1870 # directly, but this fails for more complicated scenarios
1862 1871 if source[:1] in [' ', '\t']:
1863 1872 source = 'if 1:\n%s' % source
1864 1873
1865 1874 try:
1866 1875 code = self.compile(source,filename,symbol)
1867 1876 except (OverflowError, SyntaxError, ValueError):
1868 1877 # Case 1
1869 1878 self.showsyntaxerror(filename)
1870 1879 return None
1871 1880
1872 1881 if code is None:
1873 1882 # Case 2
1874 1883 return True
1875 1884
1876 1885 # Case 3
1877 1886 # We store the code object so that threaded shells and
1878 1887 # custom exception handlers can access all this info if needed.
1879 1888 # The source corresponding to this can be obtained from the
1880 1889 # buffer attribute as '\n'.join(self.buffer).
1881 1890 self.code_to_run = code
1882 1891 # now actually execute the code object
1883 1892 if self.runcode(code) == 0:
1884 1893 return False
1885 1894 else:
1886 1895 return None
1887 1896
1888 1897 def runcode(self,code_obj):
1889 1898 """Execute a code object.
1890 1899
1891 1900 When an exception occurs, self.showtraceback() is called to display a
1892 1901 traceback.
1893 1902
1894 1903 Return value: a flag indicating whether the code to be run completed
1895 1904 successfully:
1896 1905
1897 1906 - 0: successful execution.
1898 1907 - 1: an error occurred.
1899 1908 """
1900 1909
1901 1910 # Set our own excepthook in case the user code tries to call it
1902 1911 # directly, so that the IPython crash handler doesn't get triggered
1903 1912 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1904 1913
1905 1914 # we save the original sys.excepthook in the instance, in case config
1906 1915 # code (such as magics) needs access to it.
1907 1916 self.sys_excepthook = old_excepthook
1908 1917 outflag = 1 # happens in more places, so it's easier as default
1909 1918 try:
1910 1919 try:
1911 1920 # Embedded instances require separate global/local namespaces
1912 1921 # so they can see both the surrounding (local) namespace and
1913 1922 # the module-level globals when called inside another function.
1914 1923 if self.embedded:
1915 1924 exec code_obj in self.user_global_ns, self.user_ns
1916 1925 # Normal (non-embedded) instances should only have a single
1917 1926 # namespace for user code execution, otherwise functions won't
1918 1927 # see interactive top-level globals.
1919 1928 else:
1920 1929 exec code_obj in self.user_ns
1921 1930 finally:
1922 1931 # Reset our crash handler in place
1923 1932 sys.excepthook = old_excepthook
1924 1933 except SystemExit:
1925 1934 self.resetbuffer()
1926 1935 self.showtraceback()
1927 1936 warn("Type %exit or %quit to exit IPython "
1928 1937 "(%Exit or %Quit do so unconditionally).",level=1)
1929 1938 except self.custom_exceptions:
1930 1939 etype,value,tb = sys.exc_info()
1931 1940 self.CustomTB(etype,value,tb)
1932 1941 except:
1933 1942 self.showtraceback()
1934 1943 else:
1935 1944 outflag = 0
1936 1945 if softspace(sys.stdout, 0):
1937 1946 print
1938 1947 # Flush out code object which has been run (and source)
1939 1948 self.code_to_run = None
1940 1949 return outflag
1941 1950
1942 1951 def push(self, line):
1943 1952 """Push a line to the interpreter.
1944 1953
1945 1954 The line should not have a trailing newline; it may have
1946 1955 internal newlines. The line is appended to a buffer and the
1947 1956 interpreter's runsource() method is called with the
1948 1957 concatenated contents of the buffer as source. If this
1949 1958 indicates that the command was executed or invalid, the buffer
1950 1959 is reset; otherwise, the command is incomplete, and the buffer
1951 1960 is left as it was after the line was appended. The return
1952 1961 value is 1 if more input is required, 0 if the line was dealt
1953 1962 with in some way (this is the same as runsource()).
1954 1963 """
1955 1964
1956 1965 # autoindent management should be done here, and not in the
1957 1966 # interactive loop, since that one is only seen by keyboard input. We
1958 1967 # need this done correctly even for code run via runlines (which uses
1959 1968 # push).
1960 1969
1961 1970 #print 'push line: <%s>' % line # dbg
1962 1971 for subline in line.splitlines():
1963 1972 self.autoindent_update(subline)
1964 1973 self.buffer.append(line)
1965 1974 more = self.runsource('\n'.join(self.buffer), self.filename)
1966 1975 if not more:
1967 1976 self.resetbuffer()
1968 1977 return more
1969 1978
1970 1979 def split_user_input(self, line):
1971 1980 # This is really a hold-over to support ipapi and some extensions
1972 1981 return prefilter.splitUserInput(line)
1973 1982
1974 1983 def resetbuffer(self):
1975 1984 """Reset the input buffer."""
1976 1985 self.buffer[:] = []
1977 1986
1978 1987 def raw_input(self,prompt='',continue_prompt=False):
1979 1988 """Write a prompt and read a line.
1980 1989
1981 1990 The returned line does not include the trailing newline.
1982 1991 When the user enters the EOF key sequence, EOFError is raised.
1983 1992
1984 1993 Optional inputs:
1985 1994
1986 1995 - prompt(''): a string to be printed to prompt the user.
1987 1996
1988 1997 - continue_prompt(False): whether this line is the first one or a
1989 1998 continuation in a sequence of inputs.
1990 1999 """
1991 2000
1992 2001 # Code run by the user may have modified the readline completer state.
1993 2002 # We must ensure that our completer is back in place.
1994 2003 if self.has_readline:
1995 2004 self.set_completer()
1996 2005
1997 2006 try:
1998 2007 line = raw_input_original(prompt).decode(self.stdin_encoding)
1999 2008 except ValueError:
2000 2009 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
2001 2010 " or sys.stdout.close()!\nExiting IPython!")
2002 2011 self.exit_now = True
2003 2012 return ""
2004 2013
2005 2014 # Try to be reasonably smart about not re-indenting pasted input more
2006 2015 # than necessary. We do this by trimming out the auto-indent initial
2007 2016 # spaces, if the user's actual input started itself with whitespace.
2008 2017 #debugx('self.buffer[-1]')
2009 2018
2010 2019 if self.autoindent:
2011 2020 if num_ini_spaces(line) > self.indent_current_nsp:
2012 2021 line = line[self.indent_current_nsp:]
2013 2022 self.indent_current_nsp = 0
2014 2023
2015 2024 # store the unfiltered input before the user has any chance to modify
2016 2025 # it.
2017 2026 if line.strip():
2018 2027 if continue_prompt:
2019 2028 self.input_hist_raw[-1] += '%s\n' % line
2020 2029 if self.has_readline: # and some config option is set?
2021 2030 try:
2022 2031 histlen = self.readline.get_current_history_length()
2023 2032 newhist = self.input_hist_raw[-1].rstrip()
2024 2033 self.readline.remove_history_item(histlen-1)
2025 2034 self.readline.replace_history_item(histlen-2,newhist)
2026 2035 except AttributeError:
2027 2036 pass # re{move,place}_history_item are new in 2.4.
2028 2037 else:
2029 2038 self.input_hist_raw.append('%s\n' % line)
2030 2039 # only entries starting at first column go to shadow history
2031 2040 if line.lstrip() == line:
2032 2041 self.shadowhist.add(line.strip())
2033 2042 else:
2034 2043 self.input_hist_raw.append('\n')
2035 2044 try:
2036 2045 lineout = self.prefilter(line,continue_prompt)
2037 2046 except:
2038 2047 # blanket except, in case a user-defined prefilter crashes, so it
2039 2048 # can't take all of ipython with it.
2040 2049 self.showtraceback()
2041 2050 return ''
2042 2051 else:
2043 2052 return lineout
2044 2053
2045 2054 def _prefilter(self, line, continue_prompt):
2046 2055 """Calls different preprocessors, depending on the form of line."""
2047 2056
2048 2057 # All handlers *must* return a value, even if it's blank ('').
2049 2058
2050 2059 # Lines are NOT logged here. Handlers should process the line as
2051 2060 # needed, update the cache AND log it (so that the input cache array
2052 2061 # stays synced).
2053 2062
2054 2063 #.....................................................................
2055 2064 # Code begins
2056 2065
2057 2066 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2058 2067
2059 2068 # save the line away in case we crash, so the post-mortem handler can
2060 2069 # record it
2061 2070 self._last_input_line = line
2062 2071
2063 2072 #print '***line: <%s>' % line # dbg
2064 2073
2065 2074 if not line:
2066 2075 # Return immediately on purely empty lines, so that if the user
2067 2076 # previously typed some whitespace that started a continuation
2068 2077 # prompt, he can break out of that loop with just an empty line.
2069 2078 # This is how the default python prompt works.
2070 2079
2071 2080 # Only return if the accumulated input buffer was just whitespace!
2072 2081 if ''.join(self.buffer).isspace():
2073 2082 self.buffer[:] = []
2074 2083 return ''
2075 2084
2076 2085 line_info = prefilter.LineInfo(line, continue_prompt)
2077 2086
2078 2087 # the input history needs to track even empty lines
2079 2088 stripped = line.strip()
2080 2089
2081 2090 if not stripped:
2082 2091 if not continue_prompt:
2083 2092 self.outputcache.prompt_count -= 1
2084 2093 return self.handle_normal(line_info)
2085 2094
2086 2095 # print '***cont',continue_prompt # dbg
2087 2096 # special handlers are only allowed for single line statements
2088 2097 if continue_prompt and not self.rc.multi_line_specials:
2089 2098 return self.handle_normal(line_info)
2090 2099
2091 2100
2092 2101 # See whether any pre-existing handler can take care of it
2093 2102 rewritten = self.hooks.input_prefilter(stripped)
2094 2103 if rewritten != stripped: # ok, some prefilter did something
2095 2104 rewritten = line_info.pre + rewritten # add indentation
2096 2105 return self.handle_normal(prefilter.LineInfo(rewritten,
2097 2106 continue_prompt))
2098 2107
2099 2108 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2100 2109
2101 2110 return prefilter.prefilter(line_info, self)
2102 2111
2103 2112
2104 2113 def _prefilter_dumb(self, line, continue_prompt):
2105 2114 """simple prefilter function, for debugging"""
2106 2115 return self.handle_normal(line,continue_prompt)
2107 2116
2108 2117
2109 2118 def multiline_prefilter(self, line, continue_prompt):
2110 2119 """ Run _prefilter for each line of input
2111 2120
2112 2121 Covers cases where there are multiple lines in the user entry,
2113 2122 which is the case when the user goes back to a multiline history
2114 2123 entry and presses enter.
2115 2124
2116 2125 """
2117 2126 out = []
2118 2127 for l in line.rstrip('\n').split('\n'):
2119 2128 out.append(self._prefilter(l, continue_prompt))
2120 2129 return '\n'.join(out)
2121 2130
2122 2131 # Set the default prefilter() function (this can be user-overridden)
2123 2132 prefilter = multiline_prefilter
2124 2133
2125 2134 def handle_normal(self,line_info):
2126 2135 """Handle normal input lines. Use as a template for handlers."""
2127 2136
2128 2137 # With autoindent on, we need some way to exit the input loop, and I
2129 2138 # don't want to force the user to have to backspace all the way to
2130 2139 # clear the line. The rule will be in this case, that either two
2131 2140 # lines of pure whitespace in a row, or a line of pure whitespace but
2132 2141 # of a size different to the indent level, will exit the input loop.
2133 2142 line = line_info.line
2134 2143 continue_prompt = line_info.continue_prompt
2135 2144
2136 2145 if (continue_prompt and self.autoindent and line.isspace() and
2137 2146 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2138 2147 (self.buffer[-1]).isspace() )):
2139 2148 line = ''
2140 2149
2141 2150 self.log(line,line,continue_prompt)
2142 2151 return line
2143 2152
2144 2153 def handle_alias(self,line_info):
2145 2154 """Handle alias input lines. """
2146 2155 tgt = self.alias_table[line_info.iFun]
2147 2156 # print "=>",tgt #dbg
2148 2157 if callable(tgt):
2149 2158 line_out = "_sh." + line_info.iFun + '(r"""' + line_info.theRest + '""")'
2150 2159 else:
2151 2160 transformed = self.expand_aliases(line_info.iFun,line_info.theRest)
2152 2161
2153 2162 # pre is needed, because it carries the leading whitespace. Otherwise
2154 2163 # aliases won't work in indented sections.
2155 2164 line_out = '%s_ip.system(%s)' % (line_info.preWhitespace,
2156 2165 make_quoted_expr( transformed ))
2157 2166
2158 2167 self.log(line_info.line,line_out,line_info.continue_prompt)
2159 2168 #print 'line out:',line_out # dbg
2160 2169 return line_out
2161 2170
2162 2171 def handle_shell_escape(self, line_info):
2163 2172 """Execute the line in a shell, empty return value"""
2164 2173 #print 'line in :', `line` # dbg
2165 2174 line = line_info.line
2166 2175 if line.lstrip().startswith('!!'):
2167 2176 # rewrite LineInfo's line, iFun and theRest to properly hold the
2168 2177 # call to %sx and the actual command to be executed, so
2169 2178 # handle_magic can work correctly. Note that this works even if
2170 2179 # the line is indented, so it handles multi_line_specials
2171 2180 # properly.
2172 2181 new_rest = line.lstrip()[2:]
2173 2182 line_info.line = '%ssx %s' % (self.ESC_MAGIC,new_rest)
2174 2183 line_info.iFun = 'sx'
2175 2184 line_info.theRest = new_rest
2176 2185 return self.handle_magic(line_info)
2177 2186 else:
2178 2187 cmd = line.lstrip().lstrip('!')
2179 2188 line_out = '%s_ip.system(%s)' % (line_info.preWhitespace,
2180 2189 make_quoted_expr(cmd))
2181 2190 # update cache/log and return
2182 2191 self.log(line,line_out,line_info.continue_prompt)
2183 2192 return line_out
2184 2193
2185 2194 def handle_magic(self, line_info):
2186 2195 """Execute magic functions."""
2187 2196 iFun = line_info.iFun
2188 2197 theRest = line_info.theRest
2189 2198 cmd = '%s_ip.magic(%s)' % (line_info.preWhitespace,
2190 2199 make_quoted_expr(iFun + " " + theRest))
2191 2200 self.log(line_info.line,cmd,line_info.continue_prompt)
2192 2201 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2193 2202 return cmd
2194 2203
2195 2204 def handle_auto(self, line_info):
2196 2205 """Hande lines which can be auto-executed, quoting if requested."""
2197 2206
2198 2207 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2199 2208 line = line_info.line
2200 2209 iFun = line_info.iFun
2201 2210 theRest = line_info.theRest
2202 2211 pre = line_info.pre
2203 2212 continue_prompt = line_info.continue_prompt
2204 2213 obj = line_info.ofind(self)['obj']
2205 2214
2206 2215 # This should only be active for single-line input!
2207 2216 if continue_prompt:
2208 2217 self.log(line,line,continue_prompt)
2209 2218 return line
2210 2219
2211 2220 force_auto = isinstance(obj, IPython.ipapi.IPyAutocall)
2212 2221 auto_rewrite = True
2213 2222
2214 2223 if pre == self.ESC_QUOTE:
2215 2224 # Auto-quote splitting on whitespace
2216 2225 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2217 2226 elif pre == self.ESC_QUOTE2:
2218 2227 # Auto-quote whole string
2219 2228 newcmd = '%s("%s")' % (iFun,theRest)
2220 2229 elif pre == self.ESC_PAREN:
2221 2230 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2222 2231 else:
2223 2232 # Auto-paren.
2224 2233 # We only apply it to argument-less calls if the autocall
2225 2234 # parameter is set to 2. We only need to check that autocall is <
2226 2235 # 2, since this function isn't called unless it's at least 1.
2227 2236 if not theRest and (self.rc.autocall < 2) and not force_auto:
2228 2237 newcmd = '%s %s' % (iFun,theRest)
2229 2238 auto_rewrite = False
2230 2239 else:
2231 2240 if not force_auto and theRest.startswith('['):
2232 2241 if hasattr(obj,'__getitem__'):
2233 2242 # Don't autocall in this case: item access for an object
2234 2243 # which is BOTH callable and implements __getitem__.
2235 2244 newcmd = '%s %s' % (iFun,theRest)
2236 2245 auto_rewrite = False
2237 2246 else:
2238 2247 # if the object doesn't support [] access, go ahead and
2239 2248 # autocall
2240 2249 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2241 2250 elif theRest.endswith(';'):
2242 2251 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2243 2252 else:
2244 2253 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2245 2254
2246 2255 if auto_rewrite:
2247 2256 rw = self.outputcache.prompt1.auto_rewrite() + newcmd
2248 2257
2249 2258 try:
2250 2259 # plain ascii works better w/ pyreadline, on some machines, so
2251 2260 # we use it and only print uncolored rewrite if we have unicode
2252 2261 rw = str(rw)
2253 2262 print >>Term.cout, rw
2254 2263 except UnicodeEncodeError:
2255 2264 print "-------------->" + newcmd
2256 2265
2257 2266 # log what is now valid Python, not the actual user input (without the
2258 2267 # final newline)
2259 2268 self.log(line,newcmd,continue_prompt)
2260 2269 return newcmd
2261 2270
2262 2271 def handle_help(self, line_info):
2263 2272 """Try to get some help for the object.
2264 2273
2265 2274 obj? or ?obj -> basic information.
2266 2275 obj?? or ??obj -> more details.
2267 2276 """
2268 2277
2269 2278 line = line_info.line
2270 2279 # We need to make sure that we don't process lines which would be
2271 2280 # otherwise valid python, such as "x=1 # what?"
2272 2281 try:
2273 2282 codeop.compile_command(line)
2274 2283 except SyntaxError:
2275 2284 # We should only handle as help stuff which is NOT valid syntax
2276 2285 if line[0]==self.ESC_HELP:
2277 2286 line = line[1:]
2278 2287 elif line[-1]==self.ESC_HELP:
2279 2288 line = line[:-1]
2280 2289 self.log(line,'#?'+line,line_info.continue_prompt)
2281 2290 if line:
2282 2291 #print 'line:<%r>' % line # dbg
2283 2292 self.magic_pinfo(line)
2284 2293 else:
2285 2294 page(self.usage,screen_lines=self.rc.screen_length)
2286 2295 return '' # Empty string is needed here!
2287 2296 except:
2288 2297 # Pass any other exceptions through to the normal handler
2289 2298 return self.handle_normal(line_info)
2290 2299 else:
2291 2300 # If the code compiles ok, we should handle it normally
2292 2301 return self.handle_normal(line_info)
2293 2302
2294 2303 def getapi(self):
2295 2304 """ Get an IPApi object for this shell instance
2296 2305
2297 2306 Getting an IPApi object is always preferable to accessing the shell
2298 2307 directly, but this holds true especially for extensions.
2299 2308
2300 2309 It should always be possible to implement an extension with IPApi
2301 2310 alone. If not, contact maintainer to request an addition.
2302 2311
2303 2312 """
2304 2313 return self.api
2305 2314
2306 2315 def handle_emacs(self, line_info):
2307 2316 """Handle input lines marked by python-mode."""
2308 2317
2309 2318 # Currently, nothing is done. Later more functionality can be added
2310 2319 # here if needed.
2311 2320
2312 2321 # The input cache shouldn't be updated
2313 2322 return line_info.line
2314 2323
2315 2324
2316 2325 def mktempfile(self,data=None):
2317 2326 """Make a new tempfile and return its filename.
2318 2327
2319 2328 This makes a call to tempfile.mktemp, but it registers the created
2320 2329 filename internally so ipython cleans it up at exit time.
2321 2330
2322 2331 Optional inputs:
2323 2332
2324 2333 - data(None): if data is given, it gets written out to the temp file
2325 2334 immediately, and the file is closed again."""
2326 2335
2327 2336 filename = tempfile.mktemp('.py','ipython_edit_')
2328 2337 self.tempfiles.append(filename)
2329 2338
2330 2339 if data:
2331 2340 tmp_file = open(filename,'w')
2332 2341 tmp_file.write(data)
2333 2342 tmp_file.close()
2334 2343 return filename
2335 2344
2336 2345 def write(self,data):
2337 2346 """Write a string to the default output"""
2338 2347 Term.cout.write(data)
2339 2348
2340 2349 def write_err(self,data):
2341 2350 """Write a string to the default error output"""
2342 2351 Term.cerr.write(data)
2343 2352
2344 2353 def exit(self):
2345 2354 """Handle interactive exit.
2346 2355
2347 2356 This method sets the exit_now attribute."""
2348 2357
2349 2358 if self.rc.confirm_exit:
2350 2359 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2351 2360 self.exit_now = True
2352 2361 else:
2353 2362 self.exit_now = True
2354 2363
2355 2364 def safe_execfile(self,fname,*where,**kw):
2356 2365 """A safe version of the builtin execfile().
2357 2366
2358 2367 This version will never throw an exception, and knows how to handle
2359 2368 ipython logs as well."""
2360 2369
2361 2370 def syspath_cleanup():
2362 2371 """Internal cleanup routine for sys.path."""
2363 2372 if add_dname:
2364 2373 try:
2365 2374 sys.path.remove(dname)
2366 2375 except ValueError:
2367 2376 # For some reason the user has already removed it, ignore.
2368 2377 pass
2369 2378
2370 2379 fname = os.path.expanduser(fname)
2371 2380
2372 2381 # Find things also in current directory. This is needed to mimic the
2373 2382 # behavior of running a script from the system command line, where
2374 2383 # Python inserts the script's directory into sys.path
2375 2384 dname = os.path.dirname(os.path.abspath(fname))
2376 2385 add_dname = False
2377 2386 if dname not in sys.path:
2378 2387 sys.path.insert(0,dname)
2379 2388 add_dname = True
2380 2389
2381 2390 try:
2382 2391 xfile = open(fname)
2383 2392 except:
2384 2393 print >> Term.cerr, \
2385 2394 'Could not open file <%s> for safe execution.' % fname
2386 2395 syspath_cleanup()
2387 2396 return None
2388 2397
2389 2398 kw.setdefault('islog',0)
2390 2399 kw.setdefault('quiet',1)
2391 2400 kw.setdefault('exit_ignore',0)
2392 2401 first = xfile.readline()
2393 2402 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2394 2403 xfile.close()
2395 2404 # line by line execution
2396 2405 if first.startswith(loghead) or kw['islog']:
2397 2406 print 'Loading log file <%s> one line at a time...' % fname
2398 2407 if kw['quiet']:
2399 2408 stdout_save = sys.stdout
2400 2409 sys.stdout = StringIO.StringIO()
2401 2410 try:
2402 2411 globs,locs = where[0:2]
2403 2412 except:
2404 2413 try:
2405 2414 globs = locs = where[0]
2406 2415 except:
2407 2416 globs = locs = globals()
2408 2417 badblocks = []
2409 2418
2410 2419 # we also need to identify indented blocks of code when replaying
2411 2420 # logs and put them together before passing them to an exec
2412 2421 # statement. This takes a bit of regexp and look-ahead work in the
2413 2422 # file. It's easiest if we swallow the whole thing in memory
2414 2423 # first, and manually walk through the lines list moving the
2415 2424 # counter ourselves.
2416 2425 indent_re = re.compile('\s+\S')
2417 2426 xfile = open(fname)
2418 2427 filelines = xfile.readlines()
2419 2428 xfile.close()
2420 2429 nlines = len(filelines)
2421 2430 lnum = 0
2422 2431 while lnum < nlines:
2423 2432 line = filelines[lnum]
2424 2433 lnum += 1
2425 2434 # don't re-insert logger status info into cache
2426 2435 if line.startswith('#log#'):
2427 2436 continue
2428 2437 else:
2429 2438 # build a block of code (maybe a single line) for execution
2430 2439 block = line
2431 2440 try:
2432 2441 next = filelines[lnum] # lnum has already incremented
2433 2442 except:
2434 2443 next = None
2435 2444 while next and indent_re.match(next):
2436 2445 block += next
2437 2446 lnum += 1
2438 2447 try:
2439 2448 next = filelines[lnum]
2440 2449 except:
2441 2450 next = None
2442 2451 # now execute the block of one or more lines
2443 2452 try:
2444 2453 exec block in globs,locs
2445 2454 except SystemExit:
2446 2455 pass
2447 2456 except:
2448 2457 badblocks.append(block.rstrip())
2449 2458 if kw['quiet']: # restore stdout
2450 2459 sys.stdout.close()
2451 2460 sys.stdout = stdout_save
2452 2461 print 'Finished replaying log file <%s>' % fname
2453 2462 if badblocks:
2454 2463 print >> sys.stderr, ('\nThe following lines/blocks in file '
2455 2464 '<%s> reported errors:' % fname)
2456 2465
2457 2466 for badline in badblocks:
2458 2467 print >> sys.stderr, badline
2459 2468 else: # regular file execution
2460 2469 try:
2461 2470 if sys.platform == 'win32' and sys.version_info < (2,5,1):
2462 2471 # Work around a bug in Python for Windows. The bug was
2463 2472 # fixed in in Python 2.5 r54159 and 54158, but that's still
2464 2473 # SVN Python as of March/07. For details, see:
2465 2474 # http://projects.scipy.org/ipython/ipython/ticket/123
2466 2475 try:
2467 2476 globs,locs = where[0:2]
2468 2477 except:
2469 2478 try:
2470 2479 globs = locs = where[0]
2471 2480 except:
2472 2481 globs = locs = globals()
2473 2482 exec file(fname) in globs,locs
2474 2483 else:
2475 2484 execfile(fname,*where)
2476 2485 except SyntaxError:
2477 2486 self.showsyntaxerror()
2478 2487 warn('Failure executing file: <%s>' % fname)
2479 2488 except SystemExit,status:
2480 2489 if not kw['exit_ignore']:
2481 2490 self.showtraceback()
2482 2491 warn('Failure executing file: <%s>' % fname)
2483 2492 except:
2484 2493 self.showtraceback()
2485 2494 warn('Failure executing file: <%s>' % fname)
2486 2495
2487 2496 syspath_cleanup()
2488 2497
2489 2498 #************************* end of file <iplib.py> *****************************
@@ -1,6965 +1,6971 b''
1 2007-08-12 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/iplib.py (InteractiveShell.post_config_initialization):
4 fix problems with doctests failing when run inside IPython due to
5 IPython's modifications of sys.displayhook.
6
1 7 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
2 8
3 9 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
4 10 a string with names.
5 11
6 12 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
7 13
8 14 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
9 15 magic to toggle on/off the doctest pasting support without having
10 16 to leave a session to switch to a separate profile.
11 17
12 18 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
13 19
14 20 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
15 21 introduce a blank line between inputs, to conform to doctest
16 22 requirements.
17 23
18 24 * IPython/OInspect.py (Inspector.pinfo): fix another part where
19 25 auto-generated docstrings for new-style classes were showing up.
20 26
21 27 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
22 28
23 29 * api_changes: Add new file to track backward-incompatible
24 30 user-visible changes.
25 31
26 32 2007-08-06 Ville Vainio <vivainio@gmail.com>
27 33
28 34 * ipmaker.py: fix bug where user_config_ns didn't exist at all
29 35 before all the config files were handled.
30 36
31 37 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
32 38
33 39 * IPython/irunner.py (RunnerFactory): Add new factory class for
34 40 creating reusable runners based on filenames.
35 41
36 42 * IPython/Extensions/ipy_profile_doctest.py: New profile for
37 43 doctest support. It sets prompts/exceptions as similar to
38 44 standard Python as possible, so that ipython sessions in this
39 45 profile can be easily pasted as doctests with minimal
40 46 modifications. It also enables pasting of doctests from external
41 47 sources (even if they have leading whitespace), so that you can
42 48 rerun doctests from existing sources.
43 49
44 50 * IPython/iplib.py (_prefilter): fix a buglet where after entering
45 51 some whitespace, the prompt would become a continuation prompt
46 52 with no way of exiting it other than Ctrl-C. This fix brings us
47 53 into conformity with how the default python prompt works.
48 54
49 55 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
50 56 Add support for pasting not only lines that start with '>>>', but
51 57 also with ' >>>'. That is, arbitrary whitespace can now precede
52 58 the prompts. This makes the system useful for pasting doctests
53 59 from docstrings back into a normal session.
54 60
55 61 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
56 62
57 63 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
58 64 r1357, which had killed multiple invocations of an embedded
59 65 ipython (this means that example-embed has been broken for over 1
60 66 year!!!). Rather than possibly breaking the batch stuff for which
61 67 the code in iplib.py/interact was introduced, I worked around the
62 68 problem in the embedding class in Shell.py. We really need a
63 69 bloody test suite for this code, I'm sick of finding stuff that
64 70 used to work breaking left and right every time I use an old
65 71 feature I hadn't touched in a few months.
66 72 (kill_embedded): Add a new magic that only shows up in embedded
67 73 mode, to allow users to permanently deactivate an embedded instance.
68 74
69 75 2007-08-01 Ville Vainio <vivainio@gmail.com>
70 76
71 77 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
72 78 history gets out of sync on runlines (e.g. when running macros).
73 79
74 80 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
75 81
76 82 * IPython/Magic.py (magic_colors): fix win32-related error message
77 83 that could appear under *nix when readline was missing. Patch by
78 84 Scott Jackson, closes #175.
79 85
80 86 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
81 87
82 88 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
83 89 completer that it traits-aware, so that traits objects don't show
84 90 all of their internal attributes all the time.
85 91
86 92 * IPython/genutils.py (dir2): moved this code from inside
87 93 completer.py to expose it publicly, so I could use it in the
88 94 wildcards bugfix.
89 95
90 96 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
91 97 Stefan with Traits.
92 98
93 99 * IPython/completer.py (Completer.attr_matches): change internal
94 100 var name from 'object' to 'obj', since 'object' is now a builtin
95 101 and this can lead to weird bugs if reusing this code elsewhere.
96 102
97 103 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
98 104
99 105 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
100 106 'foo?' and update the code to prevent printing of default
101 107 docstrings that started appearing after I added support for
102 108 new-style classes. The approach I'm using isn't ideal (I just
103 109 special-case those strings) but I'm not sure how to more robustly
104 110 differentiate between truly user-written strings and Python's
105 111 automatic ones.
106 112
107 113 2007-07-09 Ville Vainio <vivainio@gmail.com>
108 114
109 115 * completer.py: Applied Matthew Neeley's patch:
110 116 Dynamic attributes from trait_names and _getAttributeNames are added
111 117 to the list of tab completions, but when this happens, the attribute
112 118 list is turned into a set, so the attributes are unordered when
113 119 printed, which makes it hard to find the right completion. This patch
114 120 turns this set back into a list and sort it.
115 121
116 122 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
117 123
118 124 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
119 125 classes in various inspector functions.
120 126
121 127 2007-06-28 Ville Vainio <vivainio@gmail.com>
122 128
123 129 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
124 130 Implement "shadow" namespace, and callable aliases that reside there.
125 131 Use them by:
126 132
127 133 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
128 134
129 135 foo hello world
130 136 (gets translated to:)
131 137 _sh.foo(r"""hello world""")
132 138
133 139 In practice, this kind of alias can take the role of a magic function
134 140
135 141 * New generic inspect_object, called on obj? and obj??
136 142
137 143 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
138 144
139 145 * IPython/ultraTB.py (findsource): fix a problem with
140 146 inspect.getfile that can cause crashes during traceback construction.
141 147
142 148 2007-06-14 Ville Vainio <vivainio@gmail.com>
143 149
144 150 * iplib.py (handle_auto): Try to use ascii for printing "--->"
145 151 autocall rewrite indication, becausesometimes unicode fails to print
146 152 properly (and you get ' - - - '). Use plain uncoloured ---> for
147 153 unicode.
148 154
149 155 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
150 156
151 157 . pickleshare 'hash' commands (hget, hset, hcompress,
152 158 hdict) for efficient shadow history storage.
153 159
154 160 2007-06-13 Ville Vainio <vivainio@gmail.com>
155 161
156 162 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
157 163 Added kw arg 'interactive', tell whether vars should be visible
158 164 with %whos.
159 165
160 166 2007-06-11 Ville Vainio <vivainio@gmail.com>
161 167
162 168 * pspersistence.py, Magic.py, iplib.py: directory history now saved
163 169 to db
164 170
165 171 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
166 172 Also, it exits IPython immediately after evaluating the command (just like
167 173 std python)
168 174
169 175 2007-06-05 Walter Doerwald <walter@livinglogic.de>
170 176
171 177 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
172 178 Python string and captures the output. (Idea and original patch by
173 179 St�fan van der Walt)
174 180
175 181 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
176 182
177 183 * IPython/ultraTB.py (VerboseTB.text): update printing of
178 184 exception types for Python 2.5 (now all exceptions in the stdlib
179 185 are new-style classes).
180 186
181 187 2007-05-31 Walter Doerwald <walter@livinglogic.de>
182 188
183 189 * IPython/Extensions/igrid.py: Add new commands refresh and
184 190 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
185 191 the iterator once (refresh) or after every x seconds (refresh_timer).
186 192 Add a working implementation of "searchexpression", where the text
187 193 entered is not the text to search for, but an expression that must
188 194 be true. Added display of shortcuts to the menu. Added commands "pickinput"
189 195 and "pickinputattr" that put the object or attribute under the cursor
190 196 in the input line. Split the statusbar to be able to display the currently
191 197 active refresh interval. (Patch by Nik Tautenhahn)
192 198
193 199 2007-05-29 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
194 200
195 201 * fixing set_term_title to use ctypes as default
196 202
197 203 * fixing set_term_title fallback to work when curent dir
198 204 is on a windows network share
199 205
200 206 2007-05-28 Ville Vainio <vivainio@gmail.com>
201 207
202 208 * %cpaste: strip + with > from left (diffs).
203 209
204 210 * iplib.py: Fix crash when readline not installed
205 211
206 212 2007-05-26 Ville Vainio <vivainio@gmail.com>
207 213
208 214 * generics.py: intruduce easy to extend result_display generic
209 215 function (using simplegeneric.py).
210 216
211 217 * Fixed the append functionality of %set.
212 218
213 219 2007-05-25 Ville Vainio <vivainio@gmail.com>
214 220
215 221 * New magic: %rep (fetch / run old commands from history)
216 222
217 223 * New extension: mglob (%mglob magic), for powerful glob / find /filter
218 224 like functionality
219 225
220 226 % maghistory.py: %hist -g PATTERM greps the history for pattern
221 227
222 228 2007-05-24 Walter Doerwald <walter@livinglogic.de>
223 229
224 230 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
225 231 browse the IPython input history
226 232
227 233 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
228 234 (mapped to "i") can be used to put the object under the curser in the input
229 235 line. pickinputattr (mapped to "I") does the same for the attribute under
230 236 the cursor.
231 237
232 238 2007-05-24 Ville Vainio <vivainio@gmail.com>
233 239
234 240 * Grand magic cleansing (changeset [2380]):
235 241
236 242 * Introduce ipy_legacy.py where the following magics were
237 243 moved:
238 244
239 245 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
240 246
241 247 If you need them, either use default profile or "import ipy_legacy"
242 248 in your ipy_user_conf.py
243 249
244 250 * Move sh and scipy profile to Extensions from UserConfig. this implies
245 251 you should not edit them, but you don't need to run %upgrade when
246 252 upgrading IPython anymore.
247 253
248 254 * %hist/%history now operates in "raw" mode by default. To get the old
249 255 behaviour, run '%hist -n' (native mode).
250 256
251 257 * split ipy_stock_completers.py to ipy_stock_completers.py and
252 258 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
253 259 installed as default.
254 260
255 261 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
256 262 handling.
257 263
258 264 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
259 265 input if readline is available.
260 266
261 267 2007-05-23 Ville Vainio <vivainio@gmail.com>
262 268
263 269 * macro.py: %store uses __getstate__ properly
264 270
265 271 * exesetup.py: added new setup script for creating
266 272 standalone IPython executables with py2exe (i.e.
267 273 no python installation required).
268 274
269 275 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
270 276 its place.
271 277
272 278 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
273 279
274 280 2007-05-21 Ville Vainio <vivainio@gmail.com>
275 281
276 282 * platutil_win32.py (set_term_title): handle
277 283 failure of 'title' system call properly.
278 284
279 285 2007-05-17 Walter Doerwald <walter@livinglogic.de>
280 286
281 287 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
282 288 (Bug detected by Paul Mueller).
283 289
284 290 2007-05-16 Ville Vainio <vivainio@gmail.com>
285 291
286 292 * ipy_profile_sci.py, ipython_win_post_install.py: Create
287 293 new "sci" profile, effectively a modern version of the old
288 294 "scipy" profile (which is now slated for deprecation).
289 295
290 296 2007-05-15 Ville Vainio <vivainio@gmail.com>
291 297
292 298 * pycolorize.py, pycolor.1: Paul Mueller's patches that
293 299 make pycolorize read input from stdin when run without arguments.
294 300
295 301 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
296 302
297 303 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
298 304 it in sh profile (instead of ipy_system_conf.py).
299 305
300 306 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
301 307 aliases are now lower case on windows (MyCommand.exe => mycommand).
302 308
303 309 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
304 310 Macros are now callable objects that inherit from ipapi.IPyAutocall,
305 311 i.e. get autocalled regardless of system autocall setting.
306 312
307 313 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
308 314
309 315 * IPython/rlineimpl.py: check for clear_history in readline and
310 316 make it a dummy no-op if not available. This function isn't
311 317 guaranteed to be in the API and appeared in Python 2.4, so we need
312 318 to check it ourselves. Also, clean up this file quite a bit.
313 319
314 320 * ipython.1: update man page and full manual with information
315 321 about threads (remove outdated warning). Closes #151.
316 322
317 323 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
318 324
319 325 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
320 326 in trunk (note that this made it into the 0.8.1 release already,
321 327 but the changelogs didn't get coordinated). Many thanks to Gael
322 328 Varoquaux <gael.varoquaux-AT-normalesup.org>
323 329
324 330 2007-05-09 *** Released version 0.8.1
325 331
326 332 2007-05-10 Walter Doerwald <walter@livinglogic.de>
327 333
328 334 * IPython/Extensions/igrid.py: Incorporate html help into
329 335 the module, so we don't have to search for the file.
330 336
331 337 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
332 338
333 339 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
334 340
335 341 2007-04-30 Ville Vainio <vivainio@gmail.com>
336 342
337 343 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
338 344 user has illegal (non-ascii) home directory name
339 345
340 346 2007-04-27 Ville Vainio <vivainio@gmail.com>
341 347
342 348 * platutils_win32.py: implement set_term_title for windows
343 349
344 350 * Update version number
345 351
346 352 * ipy_profile_sh.py: more informative prompt (2 dir levels)
347 353
348 354 2007-04-26 Walter Doerwald <walter@livinglogic.de>
349 355
350 356 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
351 357 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
352 358 bug discovered by Ville).
353 359
354 360 2007-04-26 Ville Vainio <vivainio@gmail.com>
355 361
356 362 * Extensions/ipy_completers.py: Olivier's module completer now
357 363 saves the list of root modules if it takes > 4 secs on the first run.
358 364
359 365 * Magic.py (%rehashx): %rehashx now clears the completer cache
360 366
361 367
362 368 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
363 369
364 370 * ipython.el: fix incorrect color scheme, reported by Stefan.
365 371 Closes #149.
366 372
367 373 * IPython/PyColorize.py (Parser.format2): fix state-handling
368 374 logic. I still don't like how that code handles state, but at
369 375 least now it should be correct, if inelegant. Closes #146.
370 376
371 377 2007-04-25 Ville Vainio <vivainio@gmail.com>
372 378
373 379 * Extensions/ipy_which.py: added extension for %which magic, works
374 380 a lot like unix 'which' but also finds and expands aliases, and
375 381 allows wildcards.
376 382
377 383 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
378 384 as opposed to returning nothing.
379 385
380 386 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
381 387 ipy_stock_completers on default profile, do import on sh profile.
382 388
383 389 2007-04-22 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
384 390
385 391 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
386 392 like ipython.py foo.py which raised a IndexError.
387 393
388 394 2007-04-21 Ville Vainio <vivainio@gmail.com>
389 395
390 396 * Extensions/ipy_extutil.py: added extension to manage other ipython
391 397 extensions. Now only supports 'ls' == list extensions.
392 398
393 399 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
394 400
395 401 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
396 402 would prevent use of the exception system outside of a running
397 403 IPython instance.
398 404
399 405 2007-04-20 Ville Vainio <vivainio@gmail.com>
400 406
401 407 * Extensions/ipy_render.py: added extension for easy
402 408 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
403 409 'Iptl' template notation,
404 410
405 411 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
406 412 safer & faster 'import' completer.
407 413
408 414 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
409 415 and _ip.defalias(name, command).
410 416
411 417 * Extensions/ipy_exportdb.py: New extension for exporting all the
412 418 %store'd data in a portable format (normal ipapi calls like
413 419 defmacro() etc.)
414 420
415 421 2007-04-19 Ville Vainio <vivainio@gmail.com>
416 422
417 423 * upgrade_dir.py: skip junk files like *.pyc
418 424
419 425 * Release.py: version number to 0.8.1
420 426
421 427 2007-04-18 Ville Vainio <vivainio@gmail.com>
422 428
423 429 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
424 430 and later on win32.
425 431
426 432 2007-04-16 Ville Vainio <vivainio@gmail.com>
427 433
428 434 * iplib.py (showtraceback): Do not crash when running w/o readline.
429 435
430 436 2007-04-12 Walter Doerwald <walter@livinglogic.de>
431 437
432 438 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
433 439 sorted (case sensitive with files and dirs mixed).
434 440
435 441 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
436 442
437 443 * IPython/Release.py (version): Open trunk for 0.8.1 development.
438 444
439 445 2007-04-10 *** Released version 0.8.0
440 446
441 447 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
442 448
443 449 * Tag 0.8.0 for release.
444 450
445 451 * IPython/iplib.py (reloadhist): add API function to cleanly
446 452 reload the readline history, which was growing inappropriately on
447 453 every %run call.
448 454
449 455 * win32_manual_post_install.py (run): apply last part of Nicolas
450 456 Pernetty's patch (I'd accidentally applied it in a different
451 457 directory and this particular file didn't get patched).
452 458
453 459 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
454 460
455 461 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
456 462 find the main thread id and use the proper API call. Thanks to
457 463 Stefan for the fix.
458 464
459 465 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
460 466 unit tests to reflect fixed ticket #52, and add more tests sent by
461 467 him.
462 468
463 469 * IPython/iplib.py (raw_input): restore the readline completer
464 470 state on every input, in case third-party code messed it up.
465 471 (_prefilter): revert recent addition of early-escape checks which
466 472 prevent many valid alias calls from working.
467 473
468 474 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
469 475 flag for sigint handler so we don't run a full signal() call on
470 476 each runcode access.
471 477
472 478 * IPython/Magic.py (magic_whos): small improvement to diagnostic
473 479 message.
474 480
475 481 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
476 482
477 483 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
478 484 asynchronous exceptions working, i.e., Ctrl-C can actually
479 485 interrupt long-running code in the multithreaded shells.
480 486
481 487 This is using Tomer Filiba's great ctypes-based trick:
482 488 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
483 489 this in the past, but hadn't been able to make it work before. So
484 490 far it looks like it's actually running, but this needs more
485 491 testing. If it really works, I'll be *very* happy, and we'll owe
486 492 a huge thank you to Tomer. My current implementation is ugly,
487 493 hackish and uses nasty globals, but I don't want to try and clean
488 494 anything up until we know if it actually works.
489 495
490 496 NOTE: this feature needs ctypes to work. ctypes is included in
491 497 Python2.5, but 2.4 users will need to manually install it. This
492 498 feature makes multi-threaded shells so much more usable that it's
493 499 a minor price to pay (ctypes is very easy to install, already a
494 500 requirement for win32 and available in major linux distros).
495 501
496 502 2007-04-04 Ville Vainio <vivainio@gmail.com>
497 503
498 504 * Extensions/ipy_completers.py, ipy_stock_completers.py:
499 505 Moved implementations of 'bundled' completers to ipy_completers.py,
500 506 they are only enabled in ipy_stock_completers.py.
501 507
502 508 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
503 509
504 510 * IPython/PyColorize.py (Parser.format2): Fix identation of
505 511 colorzied output and return early if color scheme is NoColor, to
506 512 avoid unnecessary and expensive tokenization. Closes #131.
507 513
508 514 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
509 515
510 516 * IPython/Debugger.py: disable the use of pydb version 1.17. It
511 517 has a critical bug (a missing import that makes post-mortem not
512 518 work at all). Unfortunately as of this time, this is the version
513 519 shipped with Ubuntu Edgy, so quite a few people have this one. I
514 520 hope Edgy will update to a more recent package.
515 521
516 522 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
517 523
518 524 * IPython/iplib.py (_prefilter): close #52, second part of a patch
519 525 set by Stefan (only the first part had been applied before).
520 526
521 527 * IPython/Extensions/ipy_stock_completers.py (module_completer):
522 528 remove usage of the dangerous pkgutil.walk_packages(). See
523 529 details in comments left in the code.
524 530
525 531 * IPython/Magic.py (magic_whos): add support for numpy arrays
526 532 similar to what we had for Numeric.
527 533
528 534 * IPython/completer.py (IPCompleter.complete): extend the
529 535 complete() call API to support completions by other mechanisms
530 536 than readline. Closes #109.
531 537
532 538 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
533 539 protect against a bug in Python's execfile(). Closes #123.
534 540
535 541 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
536 542
537 543 * IPython/iplib.py (split_user_input): ensure that when splitting
538 544 user input, the part that can be treated as a python name is pure
539 545 ascii (Python identifiers MUST be pure ascii). Part of the
540 546 ongoing Unicode support work.
541 547
542 548 * IPython/Prompts.py (prompt_specials_color): Add \N for the
543 549 actual prompt number, without any coloring. This allows users to
544 550 produce numbered prompts with their own colors. Added after a
545 551 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
546 552
547 553 2007-03-31 Walter Doerwald <walter@livinglogic.de>
548 554
549 555 * IPython/Extensions/igrid.py: Map the return key
550 556 to enter() and shift-return to enterattr().
551 557
552 558 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
553 559
554 560 * IPython/Magic.py (magic_psearch): add unicode support by
555 561 encoding to ascii the input, since this routine also only deals
556 562 with valid Python names. Fixes a bug reported by Stefan.
557 563
558 564 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
559 565
560 566 * IPython/Magic.py (_inspect): convert unicode input into ascii
561 567 before trying to evaluate it as a Python identifier. This fixes a
562 568 problem that the new unicode support had introduced when analyzing
563 569 long definition lines for functions.
564 570
565 571 2007-03-24 Walter Doerwald <walter@livinglogic.de>
566 572
567 573 * IPython/Extensions/igrid.py: Fix picking. Using
568 574 igrid with wxPython 2.6 and -wthread should work now.
569 575 igrid.display() simply tries to create a frame without
570 576 an application. Only if this fails an application is created.
571 577
572 578 2007-03-23 Walter Doerwald <walter@livinglogic.de>
573 579
574 580 * IPython/Extensions/path.py: Updated to version 2.2.
575 581
576 582 2007-03-23 Ville Vainio <vivainio@gmail.com>
577 583
578 584 * iplib.py: recursive alias expansion now works better, so that
579 585 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
580 586 doesn't trip up the process, if 'd' has been aliased to 'ls'.
581 587
582 588 * Extensions/ipy_gnuglobal.py added, provides %global magic
583 589 for users of http://www.gnu.org/software/global
584 590
585 591 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
586 592 Closes #52. Patch by Stefan van der Walt.
587 593
588 594 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
589 595
590 596 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
591 597 respect the __file__ attribute when using %run. Thanks to a bug
592 598 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
593 599
594 600 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
595 601
596 602 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
597 603 input. Patch sent by Stefan.
598 604
599 605 2007-03-20 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
600 606 * IPython/Extensions/ipy_stock_completer.py
601 607 shlex_split, fix bug in shlex_split. len function
602 608 call was missing an if statement. Caused shlex_split to
603 609 sometimes return "" as last element.
604 610
605 611 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
606 612
607 613 * IPython/completer.py
608 614 (IPCompleter.file_matches.single_dir_expand): fix a problem
609 615 reported by Stefan, where directories containign a single subdir
610 616 would be completed too early.
611 617
612 618 * IPython/Shell.py (_load_pylab): Make the execution of 'from
613 619 pylab import *' when -pylab is given be optional. A new flag,
614 620 pylab_import_all controls this behavior, the default is True for
615 621 backwards compatibility.
616 622
617 623 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
618 624 modified) R. Bernstein's patch for fully syntax highlighted
619 625 tracebacks. The functionality is also available under ultraTB for
620 626 non-ipython users (someone using ultraTB but outside an ipython
621 627 session). They can select the color scheme by setting the
622 628 module-level global DEFAULT_SCHEME. The highlight functionality
623 629 also works when debugging.
624 630
625 631 * IPython/genutils.py (IOStream.close): small patch by
626 632 R. Bernstein for improved pydb support.
627 633
628 634 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
629 635 DaveS <davls@telus.net> to improve support of debugging under
630 636 NTEmacs, including improved pydb behavior.
631 637
632 638 * IPython/Magic.py (magic_prun): Fix saving of profile info for
633 639 Python 2.5, where the stats object API changed a little. Thanks
634 640 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
635 641
636 642 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
637 643 Pernetty's patch to improve support for (X)Emacs under Win32.
638 644
639 645 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
640 646
641 647 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
642 648 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
643 649 a report by Nik Tautenhahn.
644 650
645 651 2007-03-16 Walter Doerwald <walter@livinglogic.de>
646 652
647 653 * setup.py: Add the igrid help files to the list of data files
648 654 to be installed alongside igrid.
649 655 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
650 656 Show the input object of the igrid browser as the window tile.
651 657 Show the object the cursor is on in the statusbar.
652 658
653 659 2007-03-15 Ville Vainio <vivainio@gmail.com>
654 660
655 661 * Extensions/ipy_stock_completers.py: Fixed exception
656 662 on mismatching quotes in %run completer. Patch by
657 663 J�rgen Stenarson. Closes #127.
658 664
659 665 2007-03-14 Ville Vainio <vivainio@gmail.com>
660 666
661 667 * Extensions/ext_rehashdir.py: Do not do auto_alias
662 668 in %rehashdir, it clobbers %store'd aliases.
663 669
664 670 * UserConfig/ipy_profile_sh.py: envpersist.py extension
665 671 (beefed up %env) imported for sh profile.
666 672
667 673 2007-03-10 Walter Doerwald <walter@livinglogic.de>
668 674
669 675 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
670 676 as the default browser.
671 677 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
672 678 As igrid displays all attributes it ever encounters, fetch() (which has
673 679 been renamed to _fetch()) doesn't have to recalculate the display attributes
674 680 every time a new item is fetched. This should speed up scrolling.
675 681
676 682 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
677 683
678 684 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
679 685 Schmolck's recently reported tab-completion bug (my previous one
680 686 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
681 687
682 688 2007-03-09 Walter Doerwald <walter@livinglogic.de>
683 689
684 690 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
685 691 Close help window if exiting igrid.
686 692
687 693 2007-03-02 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
688 694
689 695 * IPython/Extensions/ipy_defaults.py: Check if readline is available
690 696 before calling functions from readline.
691 697
692 698 2007-03-02 Walter Doerwald <walter@livinglogic.de>
693 699
694 700 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
695 701 igrid is a wxPython-based display object for ipipe. If your system has
696 702 wx installed igrid will be the default display. Without wx ipipe falls
697 703 back to ibrowse (which needs curses). If no curses is installed ipipe
698 704 falls back to idump.
699 705
700 706 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
701 707
702 708 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
703 709 my changes from yesterday, they introduced bugs. Will reactivate
704 710 once I get a correct solution, which will be much easier thanks to
705 711 Dan Milstein's new prefilter test suite.
706 712
707 713 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
708 714
709 715 * IPython/iplib.py (split_user_input): fix input splitting so we
710 716 don't attempt attribute accesses on things that can't possibly be
711 717 valid Python attributes. After a bug report by Alex Schmolck.
712 718 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
713 719 %magic with explicit % prefix.
714 720
715 721 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
716 722
717 723 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
718 724 avoid a DeprecationWarning from GTK.
719 725
720 726 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
721 727
722 728 * IPython/genutils.py (clock): I modified clock() to return total
723 729 time, user+system. This is a more commonly needed metric. I also
724 730 introduced the new clocku/clocks to get only user/system time if
725 731 one wants those instead.
726 732
727 733 ***WARNING: API CHANGE*** clock() used to return only user time,
728 734 so if you want exactly the same results as before, use clocku
729 735 instead.
730 736
731 737 2007-02-22 Ville Vainio <vivainio@gmail.com>
732 738
733 739 * IPython/Extensions/ipy_p4.py: Extension for improved
734 740 p4 (perforce version control system) experience.
735 741 Adds %p4 magic with p4 command completion and
736 742 automatic -G argument (marshall output as python dict)
737 743
738 744 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
739 745
740 746 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
741 747 stop marks.
742 748 (ClearingMixin): a simple mixin to easily make a Demo class clear
743 749 the screen in between blocks and have empty marquees. The
744 750 ClearDemo and ClearIPDemo classes that use it are included.
745 751
746 752 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
747 753
748 754 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
749 755 protect against exceptions at Python shutdown time. Patch
750 756 sumbmitted to upstream.
751 757
752 758 2007-02-14 Walter Doerwald <walter@livinglogic.de>
753 759
754 760 * IPython/Extensions/ibrowse.py: If entering the first object level
755 761 (i.e. the object for which the browser has been started) fails,
756 762 now the error is raised directly (aborting the browser) instead of
757 763 running into an empty levels list later.
758 764
759 765 2007-02-03 Walter Doerwald <walter@livinglogic.de>
760 766
761 767 * IPython/Extensions/ipipe.py: Add an xrepr implementation
762 768 for the noitem object.
763 769
764 770 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
765 771
766 772 * IPython/completer.py (Completer.attr_matches): Fix small
767 773 tab-completion bug with Enthought Traits objects with units.
768 774 Thanks to a bug report by Tom Denniston
769 775 <tom.denniston-AT-alum.dartmouth.org>.
770 776
771 777 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
772 778
773 779 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
774 780 bug where only .ipy or .py would be completed. Once the first
775 781 argument to %run has been given, all completions are valid because
776 782 they are the arguments to the script, which may well be non-python
777 783 filenames.
778 784
779 785 * IPython/irunner.py (InteractiveRunner.run_source): major updates
780 786 to irunner to allow it to correctly support real doctesting of
781 787 out-of-process ipython code.
782 788
783 789 * IPython/Magic.py (magic_cd): Make the setting of the terminal
784 790 title an option (-noterm_title) because it completely breaks
785 791 doctesting.
786 792
787 793 * IPython/demo.py: fix IPythonDemo class that was not actually working.
788 794
789 795 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
790 796
791 797 * IPython/irunner.py (main): fix small bug where extensions were
792 798 not being correctly recognized.
793 799
794 800 2007-01-23 Walter Doerwald <walter@livinglogic.de>
795 801
796 802 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
797 803 a string containing a single line yields the string itself as the
798 804 only item.
799 805
800 806 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
801 807 object if it's the same as the one on the last level (This avoids
802 808 infinite recursion for one line strings).
803 809
804 810 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
805 811
806 812 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
807 813 all output streams before printing tracebacks. This ensures that
808 814 user output doesn't end up interleaved with traceback output.
809 815
810 816 2007-01-10 Ville Vainio <vivainio@gmail.com>
811 817
812 818 * Extensions/envpersist.py: Turbocharged %env that remembers
813 819 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
814 820 "%env VISUAL=jed".
815 821
816 822 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
817 823
818 824 * IPython/iplib.py (showtraceback): ensure that we correctly call
819 825 custom handlers in all cases (some with pdb were slipping through,
820 826 but I'm not exactly sure why).
821 827
822 828 * IPython/Debugger.py (Tracer.__init__): added new class to
823 829 support set_trace-like usage of IPython's enhanced debugger.
824 830
825 831 2006-12-24 Ville Vainio <vivainio@gmail.com>
826 832
827 833 * ipmaker.py: more informative message when ipy_user_conf
828 834 import fails (suggest running %upgrade).
829 835
830 836 * tools/run_ipy_in_profiler.py: Utility to see where
831 837 the time during IPython startup is spent.
832 838
833 839 2006-12-20 Ville Vainio <vivainio@gmail.com>
834 840
835 841 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
836 842
837 843 * ipapi.py: Add new ipapi method, expand_alias.
838 844
839 845 * Release.py: Bump up version to 0.7.4.svn
840 846
841 847 2006-12-17 Ville Vainio <vivainio@gmail.com>
842 848
843 849 * Extensions/jobctrl.py: Fixed &cmd arg arg...
844 850 to work properly on posix too
845 851
846 852 * Release.py: Update revnum (version is still just 0.7.3).
847 853
848 854 2006-12-15 Ville Vainio <vivainio@gmail.com>
849 855
850 856 * scripts/ipython_win_post_install: create ipython.py in
851 857 prefix + "/scripts".
852 858
853 859 * Release.py: Update version to 0.7.3.
854 860
855 861 2006-12-14 Ville Vainio <vivainio@gmail.com>
856 862
857 863 * scripts/ipython_win_post_install: Overwrite old shortcuts
858 864 if they already exist
859 865
860 866 * Release.py: release 0.7.3rc2
861 867
862 868 2006-12-13 Ville Vainio <vivainio@gmail.com>
863 869
864 870 * Branch and update Release.py for 0.7.3rc1
865 871
866 872 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
867 873
868 874 * IPython/Shell.py (IPShellWX): update for current WX naming
869 875 conventions, to avoid a deprecation warning with current WX
870 876 versions. Thanks to a report by Danny Shevitz.
871 877
872 878 2006-12-12 Ville Vainio <vivainio@gmail.com>
873 879
874 880 * ipmaker.py: apply david cournapeau's patch to make
875 881 import_some work properly even when ipythonrc does
876 882 import_some on empty list (it was an old bug!).
877 883
878 884 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
879 885 Add deprecation note to ipythonrc and a url to wiki
880 886 in ipy_user_conf.py
881 887
882 888
883 889 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
884 890 as if it was typed on IPython command prompt, i.e.
885 891 as IPython script.
886 892
887 893 * example-magic.py, magic_grepl.py: remove outdated examples
888 894
889 895 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
890 896
891 897 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
892 898 is called before any exception has occurred.
893 899
894 900 2006-12-08 Ville Vainio <vivainio@gmail.com>
895 901
896 902 * Extensions/ipy_stock_completers.py: fix cd completer
897 903 to translate /'s to \'s again.
898 904
899 905 * completer.py: prevent traceback on file completions w/
900 906 backslash.
901 907
902 908 * Release.py: Update release number to 0.7.3b3 for release
903 909
904 910 2006-12-07 Ville Vainio <vivainio@gmail.com>
905 911
906 912 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
907 913 while executing external code. Provides more shell-like behaviour
908 914 and overall better response to ctrl + C / ctrl + break.
909 915
910 916 * tools/make_tarball.py: new script to create tarball straight from svn
911 917 (setup.py sdist doesn't work on win32).
912 918
913 919 * Extensions/ipy_stock_completers.py: fix cd completer to give up
914 920 on dirnames with spaces and use the default completer instead.
915 921
916 922 * Revision.py: Change version to 0.7.3b2 for release.
917 923
918 924 2006-12-05 Ville Vainio <vivainio@gmail.com>
919 925
920 926 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
921 927 pydb patch 4 (rm debug printing, py 2.5 checking)
922 928
923 929 2006-11-30 Walter Doerwald <walter@livinglogic.de>
924 930 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
925 931 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
926 932 "refreshfind" (mapped to "R") does the same but tries to go back to the same
927 933 object the cursor was on before the refresh. The command "markrange" is
928 934 mapped to "%" now.
929 935 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
930 936
931 937 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
932 938
933 939 * IPython/Magic.py (magic_debug): new %debug magic to activate the
934 940 interactive debugger on the last traceback, without having to call
935 941 %pdb and rerun your code. Made minor changes in various modules,
936 942 should automatically recognize pydb if available.
937 943
938 944 2006-11-28 Ville Vainio <vivainio@gmail.com>
939 945
940 946 * completer.py: If the text start with !, show file completions
941 947 properly. This helps when trying to complete command name
942 948 for shell escapes.
943 949
944 950 2006-11-27 Ville Vainio <vivainio@gmail.com>
945 951
946 952 * ipy_stock_completers.py: bzr completer submitted by Stefan van
947 953 der Walt. Clean up svn and hg completers by using a common
948 954 vcs_completer.
949 955
950 956 2006-11-26 Ville Vainio <vivainio@gmail.com>
951 957
952 958 * Remove ipconfig and %config; you should use _ip.options structure
953 959 directly instead!
954 960
955 961 * genutils.py: add wrap_deprecated function for deprecating callables
956 962
957 963 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
958 964 _ip.system instead. ipalias is redundant.
959 965
960 966 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
961 967 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
962 968 explicit.
963 969
964 970 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
965 971 completer. Try it by entering 'hg ' and pressing tab.
966 972
967 973 * macro.py: Give Macro a useful __repr__ method
968 974
969 975 * Magic.py: %whos abbreviates the typename of Macro for brevity.
970 976
971 977 2006-11-24 Walter Doerwald <walter@livinglogic.de>
972 978 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
973 979 we don't get a duplicate ipipe module, where registration of the xrepr
974 980 implementation for Text is useless.
975 981
976 982 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
977 983
978 984 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
979 985
980 986 2006-11-24 Ville Vainio <vivainio@gmail.com>
981 987
982 988 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
983 989 try to use "cProfile" instead of the slower pure python
984 990 "profile"
985 991
986 992 2006-11-23 Ville Vainio <vivainio@gmail.com>
987 993
988 994 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
989 995 Qt+IPython+Designer link in documentation.
990 996
991 997 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
992 998 correct Pdb object to %pydb.
993 999
994 1000
995 1001 2006-11-22 Walter Doerwald <walter@livinglogic.de>
996 1002 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
997 1003 generic xrepr(), otherwise the list implementation would kick in.
998 1004
999 1005 2006-11-21 Ville Vainio <vivainio@gmail.com>
1000 1006
1001 1007 * upgrade_dir.py: Now actually overwrites a nonmodified user file
1002 1008 with one from UserConfig.
1003 1009
1004 1010 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
1005 1011 it was missing which broke the sh profile.
1006 1012
1007 1013 * completer.py: file completer now uses explicit '/' instead
1008 1014 of os.path.join, expansion of 'foo' was broken on win32
1009 1015 if there was one directory with name 'foobar'.
1010 1016
1011 1017 * A bunch of patches from Kirill Smelkov:
1012 1018
1013 1019 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1014 1020
1015 1021 * [patch 7/9] Implement %page -r (page in raw mode) -
1016 1022
1017 1023 * [patch 5/9] ScientificPython webpage has moved
1018 1024
1019 1025 * [patch 4/9] The manual mentions %ds, should be %dhist
1020 1026
1021 1027 * [patch 3/9] Kill old bits from %prun doc.
1022 1028
1023 1029 * [patch 1/9] Fix typos here and there.
1024 1030
1025 1031 2006-11-08 Ville Vainio <vivainio@gmail.com>
1026 1032
1027 1033 * completer.py (attr_matches): catch all exceptions raised
1028 1034 by eval of expr with dots.
1029 1035
1030 1036 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1031 1037
1032 1038 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1033 1039 input if it starts with whitespace. This allows you to paste
1034 1040 indented input from any editor without manually having to type in
1035 1041 the 'if 1:', which is convenient when working interactively.
1036 1042 Slightly modifed version of a patch by Bo Peng
1037 1043 <bpeng-AT-rice.edu>.
1038 1044
1039 1045 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1040 1046
1041 1047 * IPython/irunner.py (main): modified irunner so it automatically
1042 1048 recognizes the right runner to use based on the extension (.py for
1043 1049 python, .ipy for ipython and .sage for sage).
1044 1050
1045 1051 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1046 1052 visible in ipapi as ip.config(), to programatically control the
1047 1053 internal rc object. There's an accompanying %config magic for
1048 1054 interactive use, which has been enhanced to match the
1049 1055 funtionality in ipconfig.
1050 1056
1051 1057 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1052 1058 so it's not just a toggle, it now takes an argument. Add support
1053 1059 for a customizable header when making system calls, as the new
1054 1060 system_header variable in the ipythonrc file.
1055 1061
1056 1062 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1057 1063
1058 1064 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1059 1065 generic functions (using Philip J. Eby's simplegeneric package).
1060 1066 This makes it possible to customize the display of third-party classes
1061 1067 without having to monkeypatch them. xiter() no longer supports a mode
1062 1068 argument and the XMode class has been removed. The same functionality can
1063 1069 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1064 1070 One consequence of the switch to generic functions is that xrepr() and
1065 1071 xattrs() implementation must define the default value for the mode
1066 1072 argument themselves and xattrs() implementations must return real
1067 1073 descriptors.
1068 1074
1069 1075 * IPython/external: This new subpackage will contain all third-party
1070 1076 packages that are bundled with IPython. (The first one is simplegeneric).
1071 1077
1072 1078 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1073 1079 directory which as been dropped in r1703.
1074 1080
1075 1081 * IPython/Extensions/ipipe.py (iless): Fixed.
1076 1082
1077 1083 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1078 1084
1079 1085 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1080 1086
1081 1087 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1082 1088 handling in variable expansion so that shells and magics recognize
1083 1089 function local scopes correctly. Bug reported by Brian.
1084 1090
1085 1091 * scripts/ipython: remove the very first entry in sys.path which
1086 1092 Python auto-inserts for scripts, so that sys.path under IPython is
1087 1093 as similar as possible to that under plain Python.
1088 1094
1089 1095 * IPython/completer.py (IPCompleter.file_matches): Fix
1090 1096 tab-completion so that quotes are not closed unless the completion
1091 1097 is unambiguous. After a request by Stefan. Minor cleanups in
1092 1098 ipy_stock_completers.
1093 1099
1094 1100 2006-11-02 Ville Vainio <vivainio@gmail.com>
1095 1101
1096 1102 * ipy_stock_completers.py: Add %run and %cd completers.
1097 1103
1098 1104 * completer.py: Try running custom completer for both
1099 1105 "foo" and "%foo" if the command is just "foo". Ignore case
1100 1106 when filtering possible completions.
1101 1107
1102 1108 * UserConfig/ipy_user_conf.py: install stock completers as default
1103 1109
1104 1110 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1105 1111 simplified readline history save / restore through a wrapper
1106 1112 function
1107 1113
1108 1114
1109 1115 2006-10-31 Ville Vainio <vivainio@gmail.com>
1110 1116
1111 1117 * strdispatch.py, completer.py, ipy_stock_completers.py:
1112 1118 Allow str_key ("command") in completer hooks. Implement
1113 1119 trivial completer for 'import' (stdlib modules only). Rename
1114 1120 ipy_linux_package_managers.py to ipy_stock_completers.py.
1115 1121 SVN completer.
1116 1122
1117 1123 * Extensions/ledit.py: %magic line editor for easily and
1118 1124 incrementally manipulating lists of strings. The magic command
1119 1125 name is %led.
1120 1126
1121 1127 2006-10-30 Ville Vainio <vivainio@gmail.com>
1122 1128
1123 1129 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1124 1130 Bernsteins's patches for pydb integration.
1125 1131 http://bashdb.sourceforge.net/pydb/
1126 1132
1127 1133 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1128 1134 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1129 1135 custom completer hook to allow the users to implement their own
1130 1136 completers. See ipy_linux_package_managers.py for example. The
1131 1137 hook name is 'complete_command'.
1132 1138
1133 1139 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1134 1140
1135 1141 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1136 1142 Numeric leftovers.
1137 1143
1138 1144 * ipython.el (py-execute-region): apply Stefan's patch to fix
1139 1145 garbled results if the python shell hasn't been previously started.
1140 1146
1141 1147 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1142 1148 pretty generic function and useful for other things.
1143 1149
1144 1150 * IPython/OInspect.py (getsource): Add customizable source
1145 1151 extractor. After a request/patch form W. Stein (SAGE).
1146 1152
1147 1153 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1148 1154 window size to a more reasonable value from what pexpect does,
1149 1155 since their choice causes wrapping bugs with long input lines.
1150 1156
1151 1157 2006-10-28 Ville Vainio <vivainio@gmail.com>
1152 1158
1153 1159 * Magic.py (%run): Save and restore the readline history from
1154 1160 file around %run commands to prevent side effects from
1155 1161 %runned programs that might use readline (e.g. pydb).
1156 1162
1157 1163 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1158 1164 invoking the pydb enhanced debugger.
1159 1165
1160 1166 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1161 1167
1162 1168 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1163 1169 call the base class method and propagate the return value to
1164 1170 ifile. This is now done by path itself.
1165 1171
1166 1172 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1167 1173
1168 1174 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1169 1175 api: set_crash_handler(), to expose the ability to change the
1170 1176 internal crash handler.
1171 1177
1172 1178 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1173 1179 the various parameters of the crash handler so that apps using
1174 1180 IPython as their engine can customize crash handling. Ipmlemented
1175 1181 at the request of SAGE.
1176 1182
1177 1183 2006-10-14 Ville Vainio <vivainio@gmail.com>
1178 1184
1179 1185 * Magic.py, ipython.el: applied first "safe" part of Rocky
1180 1186 Bernstein's patch set for pydb integration.
1181 1187
1182 1188 * Magic.py (%unalias, %alias): %store'd aliases can now be
1183 1189 removed with '%unalias'. %alias w/o args now shows most
1184 1190 interesting (stored / manually defined) aliases last
1185 1191 where they catch the eye w/o scrolling.
1186 1192
1187 1193 * Magic.py (%rehashx), ext_rehashdir.py: files with
1188 1194 'py' extension are always considered executable, even
1189 1195 when not in PATHEXT environment variable.
1190 1196
1191 1197 2006-10-12 Ville Vainio <vivainio@gmail.com>
1192 1198
1193 1199 * jobctrl.py: Add new "jobctrl" extension for spawning background
1194 1200 processes with "&find /". 'import jobctrl' to try it out. Requires
1195 1201 'subprocess' module, standard in python 2.4+.
1196 1202
1197 1203 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1198 1204 so if foo -> bar and bar -> baz, then foo -> baz.
1199 1205
1200 1206 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1201 1207
1202 1208 * IPython/Magic.py (Magic.parse_options): add a new posix option
1203 1209 to allow parsing of input args in magics that doesn't strip quotes
1204 1210 (if posix=False). This also closes %timeit bug reported by
1205 1211 Stefan.
1206 1212
1207 1213 2006-10-03 Ville Vainio <vivainio@gmail.com>
1208 1214
1209 1215 * iplib.py (raw_input, interact): Return ValueError catching for
1210 1216 raw_input. Fixes infinite loop for sys.stdin.close() or
1211 1217 sys.stdout.close().
1212 1218
1213 1219 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1214 1220
1215 1221 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1216 1222 to help in handling doctests. irunner is now pretty useful for
1217 1223 running standalone scripts and simulate a full interactive session
1218 1224 in a format that can be then pasted as a doctest.
1219 1225
1220 1226 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1221 1227 on top of the default (useless) ones. This also fixes the nasty
1222 1228 way in which 2.5's Quitter() exits (reverted [1785]).
1223 1229
1224 1230 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1225 1231 2.5.
1226 1232
1227 1233 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1228 1234 color scheme is updated as well when color scheme is changed
1229 1235 interactively.
1230 1236
1231 1237 2006-09-27 Ville Vainio <vivainio@gmail.com>
1232 1238
1233 1239 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1234 1240 infinite loop and just exit. It's a hack, but will do for a while.
1235 1241
1236 1242 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1237 1243
1238 1244 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1239 1245 the constructor, this makes it possible to get a list of only directories
1240 1246 or only files.
1241 1247
1242 1248 2006-08-12 Ville Vainio <vivainio@gmail.com>
1243 1249
1244 1250 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1245 1251 they broke unittest
1246 1252
1247 1253 2006-08-11 Ville Vainio <vivainio@gmail.com>
1248 1254
1249 1255 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1250 1256 by resolving issue properly, i.e. by inheriting FakeModule
1251 1257 from types.ModuleType. Pickling ipython interactive data
1252 1258 should still work as usual (testing appreciated).
1253 1259
1254 1260 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1255 1261
1256 1262 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1257 1263 running under python 2.3 with code from 2.4 to fix a bug with
1258 1264 help(). Reported by the Debian maintainers, Norbert Tretkowski
1259 1265 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1260 1266 <afayolle-AT-debian.org>.
1261 1267
1262 1268 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1263 1269
1264 1270 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1265 1271 (which was displaying "quit" twice).
1266 1272
1267 1273 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1268 1274
1269 1275 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1270 1276 the mode argument).
1271 1277
1272 1278 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1273 1279
1274 1280 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1275 1281 not running under IPython.
1276 1282
1277 1283 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1278 1284 and make it iterable (iterating over the attribute itself). Add two new
1279 1285 magic strings for __xattrs__(): If the string starts with "-", the attribute
1280 1286 will not be displayed in ibrowse's detail view (but it can still be
1281 1287 iterated over). This makes it possible to add attributes that are large
1282 1288 lists or generator methods to the detail view. Replace magic attribute names
1283 1289 and _attrname() and _getattr() with "descriptors": For each type of magic
1284 1290 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1285 1291 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1286 1292 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1287 1293 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1288 1294 are still supported.
1289 1295
1290 1296 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1291 1297 fails in ibrowse.fetch(), the exception object is added as the last item
1292 1298 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1293 1299 a generator throws an exception midway through execution.
1294 1300
1295 1301 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1296 1302 encoding into methods.
1297 1303
1298 1304 2006-07-26 Ville Vainio <vivainio@gmail.com>
1299 1305
1300 1306 * iplib.py: history now stores multiline input as single
1301 1307 history entries. Patch by Jorgen Cederlof.
1302 1308
1303 1309 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1304 1310
1305 1311 * IPython/Extensions/ibrowse.py: Make cursor visible over
1306 1312 non existing attributes.
1307 1313
1308 1314 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1309 1315
1310 1316 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1311 1317 error output of the running command doesn't mess up the screen.
1312 1318
1313 1319 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1314 1320
1315 1321 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1316 1322 argument. This sorts the items themselves.
1317 1323
1318 1324 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1319 1325
1320 1326 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1321 1327 Compile expression strings into code objects. This should speed
1322 1328 up ifilter and friends somewhat.
1323 1329
1324 1330 2006-07-08 Ville Vainio <vivainio@gmail.com>
1325 1331
1326 1332 * Magic.py: %cpaste now strips > from the beginning of lines
1327 1333 to ease pasting quoted code from emails. Contributed by
1328 1334 Stefan van der Walt.
1329 1335
1330 1336 2006-06-29 Ville Vainio <vivainio@gmail.com>
1331 1337
1332 1338 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1333 1339 mode, patch contributed by Darren Dale. NEEDS TESTING!
1334 1340
1335 1341 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1336 1342
1337 1343 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1338 1344 a blue background. Fix fetching new display rows when the browser
1339 1345 scrolls more than a screenful (e.g. by using the goto command).
1340 1346
1341 1347 2006-06-27 Ville Vainio <vivainio@gmail.com>
1342 1348
1343 1349 * Magic.py (_inspect, _ofind) Apply David Huard's
1344 1350 patch for displaying the correct docstring for 'property'
1345 1351 attributes.
1346 1352
1347 1353 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1348 1354
1349 1355 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1350 1356 commands into the methods implementing them.
1351 1357
1352 1358 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1353 1359
1354 1360 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1355 1361 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1356 1362 autoindent support was authored by Jin Liu.
1357 1363
1358 1364 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1359 1365
1360 1366 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1361 1367 for keymaps with a custom class that simplifies handling.
1362 1368
1363 1369 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1364 1370
1365 1371 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1366 1372 resizing. This requires Python 2.5 to work.
1367 1373
1368 1374 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1369 1375
1370 1376 * IPython/Extensions/ibrowse.py: Add two new commands to
1371 1377 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1372 1378 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1373 1379 attributes again. Remapped the help command to "?". Display
1374 1380 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1375 1381 as keys for the "home" and "end" commands. Add three new commands
1376 1382 to the input mode for "find" and friends: "delend" (CTRL-K)
1377 1383 deletes to the end of line. "incsearchup" searches upwards in the
1378 1384 command history for an input that starts with the text before the cursor.
1379 1385 "incsearchdown" does the same downwards. Removed a bogus mapping of
1380 1386 the x key to "delete".
1381 1387
1382 1388 2006-06-15 Ville Vainio <vivainio@gmail.com>
1383 1389
1384 1390 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1385 1391 used to create prompts dynamically, instead of the "old" way of
1386 1392 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1387 1393 way still works (it's invoked by the default hook), of course.
1388 1394
1389 1395 * Prompts.py: added generate_output_prompt hook for altering output
1390 1396 prompt
1391 1397
1392 1398 * Release.py: Changed version string to 0.7.3.svn.
1393 1399
1394 1400 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1395 1401
1396 1402 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1397 1403 the call to fetch() always tries to fetch enough data for at least one
1398 1404 full screen. This makes it possible to simply call moveto(0,0,True) in
1399 1405 the constructor. Fix typos and removed the obsolete goto attribute.
1400 1406
1401 1407 2006-06-12 Ville Vainio <vivainio@gmail.com>
1402 1408
1403 1409 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1404 1410 allowing $variable interpolation within multiline statements,
1405 1411 though so far only with "sh" profile for a testing period.
1406 1412 The patch also enables splitting long commands with \ but it
1407 1413 doesn't work properly yet.
1408 1414
1409 1415 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1410 1416
1411 1417 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1412 1418 input history and the position of the cursor in the input history for
1413 1419 the find, findbackwards and goto command.
1414 1420
1415 1421 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1416 1422
1417 1423 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1418 1424 implements the basic functionality of browser commands that require
1419 1425 input. Reimplement the goto, find and findbackwards commands as
1420 1426 subclasses of _CommandInput. Add an input history and keymaps to those
1421 1427 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1422 1428 execute commands.
1423 1429
1424 1430 2006-06-07 Ville Vainio <vivainio@gmail.com>
1425 1431
1426 1432 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1427 1433 running the batch files instead of leaving the session open.
1428 1434
1429 1435 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1430 1436
1431 1437 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1432 1438 the original fix was incomplete. Patch submitted by W. Maier.
1433 1439
1434 1440 2006-06-07 Ville Vainio <vivainio@gmail.com>
1435 1441
1436 1442 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1437 1443 Confirmation prompts can be supressed by 'quiet' option.
1438 1444 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1439 1445
1440 1446 2006-06-06 *** Released version 0.7.2
1441 1447
1442 1448 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1443 1449
1444 1450 * IPython/Release.py (version): Made 0.7.2 final for release.
1445 1451 Repo tagged and release cut.
1446 1452
1447 1453 2006-06-05 Ville Vainio <vivainio@gmail.com>
1448 1454
1449 1455 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1450 1456 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1451 1457
1452 1458 * upgrade_dir.py: try import 'path' module a bit harder
1453 1459 (for %upgrade)
1454 1460
1455 1461 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1456 1462
1457 1463 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1458 1464 instead of looping 20 times.
1459 1465
1460 1466 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1461 1467 correctly at initialization time. Bug reported by Krishna Mohan
1462 1468 Gundu <gkmohan-AT-gmail.com> on the user list.
1463 1469
1464 1470 * IPython/Release.py (version): Mark 0.7.2 version to start
1465 1471 testing for release on 06/06.
1466 1472
1467 1473 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1468 1474
1469 1475 * scripts/irunner: thin script interface so users don't have to
1470 1476 find the module and call it as an executable, since modules rarely
1471 1477 live in people's PATH.
1472 1478
1473 1479 * IPython/irunner.py (InteractiveRunner.__init__): added
1474 1480 delaybeforesend attribute to control delays with newer versions of
1475 1481 pexpect. Thanks to detailed help from pexpect's author, Noah
1476 1482 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1477 1483 correctly (it works in NoColor mode).
1478 1484
1479 1485 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1480 1486 SAGE list, from improper log() calls.
1481 1487
1482 1488 2006-05-31 Ville Vainio <vivainio@gmail.com>
1483 1489
1484 1490 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1485 1491 with args in parens to work correctly with dirs that have spaces.
1486 1492
1487 1493 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1488 1494
1489 1495 * IPython/Logger.py (Logger.logstart): add option to log raw input
1490 1496 instead of the processed one. A -r flag was added to the
1491 1497 %logstart magic used for controlling logging.
1492 1498
1493 1499 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1494 1500
1495 1501 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1496 1502 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1497 1503 recognize the option. After a bug report by Will Maier. This
1498 1504 closes #64 (will do it after confirmation from W. Maier).
1499 1505
1500 1506 * IPython/irunner.py: New module to run scripts as if manually
1501 1507 typed into an interactive environment, based on pexpect. After a
1502 1508 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1503 1509 ipython-user list. Simple unittests in the tests/ directory.
1504 1510
1505 1511 * tools/release: add Will Maier, OpenBSD port maintainer, to
1506 1512 recepients list. We are now officially part of the OpenBSD ports:
1507 1513 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1508 1514 work.
1509 1515
1510 1516 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1511 1517
1512 1518 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1513 1519 so that it doesn't break tkinter apps.
1514 1520
1515 1521 * IPython/iplib.py (_prefilter): fix bug where aliases would
1516 1522 shadow variables when autocall was fully off. Reported by SAGE
1517 1523 author William Stein.
1518 1524
1519 1525 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1520 1526 at what detail level strings are computed when foo? is requested.
1521 1527 This allows users to ask for example that the string form of an
1522 1528 object is only computed when foo?? is called, or even never, by
1523 1529 setting the object_info_string_level >= 2 in the configuration
1524 1530 file. This new option has been added and documented. After a
1525 1531 request by SAGE to be able to control the printing of very large
1526 1532 objects more easily.
1527 1533
1528 1534 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1529 1535
1530 1536 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1531 1537 from sys.argv, to be 100% consistent with how Python itself works
1532 1538 (as seen for example with python -i file.py). After a bug report
1533 1539 by Jeffrey Collins.
1534 1540
1535 1541 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1536 1542 nasty bug which was preventing custom namespaces with -pylab,
1537 1543 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1538 1544 compatibility (long gone from mpl).
1539 1545
1540 1546 * IPython/ipapi.py (make_session): name change: create->make. We
1541 1547 use make in other places (ipmaker,...), it's shorter and easier to
1542 1548 type and say, etc. I'm trying to clean things before 0.7.2 so
1543 1549 that I can keep things stable wrt to ipapi in the chainsaw branch.
1544 1550
1545 1551 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1546 1552 python-mode recognizes our debugger mode. Add support for
1547 1553 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1548 1554 <m.liu.jin-AT-gmail.com> originally written by
1549 1555 doxgen-AT-newsmth.net (with minor modifications for xemacs
1550 1556 compatibility)
1551 1557
1552 1558 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1553 1559 tracebacks when walking the stack so that the stack tracking system
1554 1560 in emacs' python-mode can identify the frames correctly.
1555 1561
1556 1562 * IPython/ipmaker.py (make_IPython): make the internal (and
1557 1563 default config) autoedit_syntax value false by default. Too many
1558 1564 users have complained to me (both on and off-list) about problems
1559 1565 with this option being on by default, so I'm making it default to
1560 1566 off. It can still be enabled by anyone via the usual mechanisms.
1561 1567
1562 1568 * IPython/completer.py (Completer.attr_matches): add support for
1563 1569 PyCrust-style _getAttributeNames magic method. Patch contributed
1564 1570 by <mscott-AT-goldenspud.com>. Closes #50.
1565 1571
1566 1572 * IPython/iplib.py (InteractiveShell.__init__): remove the
1567 1573 deletion of exit/quit from __builtin__, which can break
1568 1574 third-party tools like the Zope debugging console. The
1569 1575 %exit/%quit magics remain. In general, it's probably a good idea
1570 1576 not to delete anything from __builtin__, since we never know what
1571 1577 that will break. In any case, python now (for 2.5) will support
1572 1578 'real' exit/quit, so this issue is moot. Closes #55.
1573 1579
1574 1580 * IPython/genutils.py (with_obj): rename the 'with' function to
1575 1581 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1576 1582 becomes a language keyword. Closes #53.
1577 1583
1578 1584 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1579 1585 __file__ attribute to this so it fools more things into thinking
1580 1586 it is a real module. Closes #59.
1581 1587
1582 1588 * IPython/Magic.py (magic_edit): add -n option to open the editor
1583 1589 at a specific line number. After a patch by Stefan van der Walt.
1584 1590
1585 1591 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1586 1592
1587 1593 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1588 1594 reason the file could not be opened. After automatic crash
1589 1595 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1590 1596 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1591 1597 (_should_recompile): Don't fire editor if using %bg, since there
1592 1598 is no file in the first place. From the same report as above.
1593 1599 (raw_input): protect against faulty third-party prefilters. After
1594 1600 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1595 1601 while running under SAGE.
1596 1602
1597 1603 2006-05-23 Ville Vainio <vivainio@gmail.com>
1598 1604
1599 1605 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1600 1606 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1601 1607 now returns None (again), unless dummy is specifically allowed by
1602 1608 ipapi.get(allow_dummy=True).
1603 1609
1604 1610 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1605 1611
1606 1612 * IPython: remove all 2.2-compatibility objects and hacks from
1607 1613 everywhere, since we only support 2.3 at this point. Docs
1608 1614 updated.
1609 1615
1610 1616 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1611 1617 Anything requiring extra validation can be turned into a Python
1612 1618 property in the future. I used a property for the db one b/c
1613 1619 there was a nasty circularity problem with the initialization
1614 1620 order, which right now I don't have time to clean up.
1615 1621
1616 1622 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1617 1623 another locking bug reported by Jorgen. I'm not 100% sure though,
1618 1624 so more testing is needed...
1619 1625
1620 1626 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1621 1627
1622 1628 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1623 1629 local variables from any routine in user code (typically executed
1624 1630 with %run) directly into the interactive namespace. Very useful
1625 1631 when doing complex debugging.
1626 1632 (IPythonNotRunning): Changed the default None object to a dummy
1627 1633 whose attributes can be queried as well as called without
1628 1634 exploding, to ease writing code which works transparently both in
1629 1635 and out of ipython and uses some of this API.
1630 1636
1631 1637 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1632 1638
1633 1639 * IPython/hooks.py (result_display): Fix the fact that our display
1634 1640 hook was using str() instead of repr(), as the default python
1635 1641 console does. This had gone unnoticed b/c it only happened if
1636 1642 %Pprint was off, but the inconsistency was there.
1637 1643
1638 1644 2006-05-15 Ville Vainio <vivainio@gmail.com>
1639 1645
1640 1646 * Oinspect.py: Only show docstring for nonexisting/binary files
1641 1647 when doing object??, closing ticket #62
1642 1648
1643 1649 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1644 1650
1645 1651 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1646 1652 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1647 1653 was being released in a routine which hadn't checked if it had
1648 1654 been the one to acquire it.
1649 1655
1650 1656 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1651 1657
1652 1658 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1653 1659
1654 1660 2006-04-11 Ville Vainio <vivainio@gmail.com>
1655 1661
1656 1662 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1657 1663 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1658 1664 prefilters, allowing stuff like magics and aliases in the file.
1659 1665
1660 1666 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1661 1667 added. Supported now are "%clear in" and "%clear out" (clear input and
1662 1668 output history, respectively). Also fixed CachedOutput.flush to
1663 1669 properly flush the output cache.
1664 1670
1665 1671 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1666 1672 half-success (and fail explicitly).
1667 1673
1668 1674 2006-03-28 Ville Vainio <vivainio@gmail.com>
1669 1675
1670 1676 * iplib.py: Fix quoting of aliases so that only argless ones
1671 1677 are quoted
1672 1678
1673 1679 2006-03-28 Ville Vainio <vivainio@gmail.com>
1674 1680
1675 1681 * iplib.py: Quote aliases with spaces in the name.
1676 1682 "c:\program files\blah\bin" is now legal alias target.
1677 1683
1678 1684 * ext_rehashdir.py: Space no longer allowed as arg
1679 1685 separator, since space is legal in path names.
1680 1686
1681 1687 2006-03-16 Ville Vainio <vivainio@gmail.com>
1682 1688
1683 1689 * upgrade_dir.py: Take path.py from Extensions, correcting
1684 1690 %upgrade magic
1685 1691
1686 1692 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1687 1693
1688 1694 * hooks.py: Only enclose editor binary in quotes if legal and
1689 1695 necessary (space in the name, and is an existing file). Fixes a bug
1690 1696 reported by Zachary Pincus.
1691 1697
1692 1698 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1693 1699
1694 1700 * Manual: thanks to a tip on proper color handling for Emacs, by
1695 1701 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1696 1702
1697 1703 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1698 1704 by applying the provided patch. Thanks to Liu Jin
1699 1705 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1700 1706 XEmacs/Linux, I'm trusting the submitter that it actually helps
1701 1707 under win32/GNU Emacs. Will revisit if any problems are reported.
1702 1708
1703 1709 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1704 1710
1705 1711 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1706 1712 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1707 1713
1708 1714 2006-03-12 Ville Vainio <vivainio@gmail.com>
1709 1715
1710 1716 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1711 1717 Torsten Marek.
1712 1718
1713 1719 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1714 1720
1715 1721 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1716 1722 line ranges works again.
1717 1723
1718 1724 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1719 1725
1720 1726 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1721 1727 and friends, after a discussion with Zach Pincus on ipython-user.
1722 1728 I'm not 100% sure, but after thinking about it quite a bit, it may
1723 1729 be OK. Testing with the multithreaded shells didn't reveal any
1724 1730 problems, but let's keep an eye out.
1725 1731
1726 1732 In the process, I fixed a few things which were calling
1727 1733 self.InteractiveTB() directly (like safe_execfile), which is a
1728 1734 mistake: ALL exception reporting should be done by calling
1729 1735 self.showtraceback(), which handles state and tab-completion and
1730 1736 more.
1731 1737
1732 1738 2006-03-01 Ville Vainio <vivainio@gmail.com>
1733 1739
1734 1740 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1735 1741 To use, do "from ipipe import *".
1736 1742
1737 1743 2006-02-24 Ville Vainio <vivainio@gmail.com>
1738 1744
1739 1745 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1740 1746 "cleanly" and safely than the older upgrade mechanism.
1741 1747
1742 1748 2006-02-21 Ville Vainio <vivainio@gmail.com>
1743 1749
1744 1750 * Magic.py: %save works again.
1745 1751
1746 1752 2006-02-15 Ville Vainio <vivainio@gmail.com>
1747 1753
1748 1754 * Magic.py: %Pprint works again
1749 1755
1750 1756 * Extensions/ipy_sane_defaults.py: Provide everything provided
1751 1757 in default ipythonrc, to make it possible to have a completely empty
1752 1758 ipythonrc (and thus completely rc-file free configuration)
1753 1759
1754 1760 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1755 1761
1756 1762 * IPython/hooks.py (editor): quote the call to the editor command,
1757 1763 to allow commands with spaces in them. Problem noted by watching
1758 1764 Ian Oswald's video about textpad under win32 at
1759 1765 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1760 1766
1761 1767 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1762 1768 describing magics (we haven't used @ for a loong time).
1763 1769
1764 1770 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1765 1771 contributed by marienz to close
1766 1772 http://www.scipy.net/roundup/ipython/issue53.
1767 1773
1768 1774 2006-02-10 Ville Vainio <vivainio@gmail.com>
1769 1775
1770 1776 * genutils.py: getoutput now works in win32 too
1771 1777
1772 1778 * completer.py: alias and magic completion only invoked
1773 1779 at the first "item" in the line, to avoid "cd %store"
1774 1780 nonsense.
1775 1781
1776 1782 2006-02-09 Ville Vainio <vivainio@gmail.com>
1777 1783
1778 1784 * test/*: Added a unit testing framework (finally).
1779 1785 '%run runtests.py' to run test_*.
1780 1786
1781 1787 * ipapi.py: Exposed runlines and set_custom_exc
1782 1788
1783 1789 2006-02-07 Ville Vainio <vivainio@gmail.com>
1784 1790
1785 1791 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1786 1792 instead use "f(1 2)" as before.
1787 1793
1788 1794 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1789 1795
1790 1796 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1791 1797 facilities, for demos processed by the IPython input filter
1792 1798 (IPythonDemo), and for running a script one-line-at-a-time as a
1793 1799 demo, both for pure Python (LineDemo) and for IPython-processed
1794 1800 input (IPythonLineDemo). After a request by Dave Kohel, from the
1795 1801 SAGE team.
1796 1802 (Demo.edit): added an edit() method to the demo objects, to edit
1797 1803 the in-memory copy of the last executed block.
1798 1804
1799 1805 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1800 1806 processing to %edit, %macro and %save. These commands can now be
1801 1807 invoked on the unprocessed input as it was typed by the user
1802 1808 (without any prefilters applied). After requests by the SAGE team
1803 1809 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1804 1810
1805 1811 2006-02-01 Ville Vainio <vivainio@gmail.com>
1806 1812
1807 1813 * setup.py, eggsetup.py: easy_install ipython==dev works
1808 1814 correctly now (on Linux)
1809 1815
1810 1816 * ipy_user_conf,ipmaker: user config changes, removed spurious
1811 1817 warnings
1812 1818
1813 1819 * iplib: if rc.banner is string, use it as is.
1814 1820
1815 1821 * Magic: %pycat accepts a string argument and pages it's contents.
1816 1822
1817 1823
1818 1824 2006-01-30 Ville Vainio <vivainio@gmail.com>
1819 1825
1820 1826 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1821 1827 Now %store and bookmarks work through PickleShare, meaning that
1822 1828 concurrent access is possible and all ipython sessions see the
1823 1829 same database situation all the time, instead of snapshot of
1824 1830 the situation when the session was started. Hence, %bookmark
1825 1831 results are immediately accessible from othes sessions. The database
1826 1832 is also available for use by user extensions. See:
1827 1833 http://www.python.org/pypi/pickleshare
1828 1834
1829 1835 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1830 1836
1831 1837 * aliases can now be %store'd
1832 1838
1833 1839 * path.py moved to Extensions so that pickleshare does not need
1834 1840 IPython-specific import. Extensions added to pythonpath right
1835 1841 at __init__.
1836 1842
1837 1843 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1838 1844 called with _ip.system and the pre-transformed command string.
1839 1845
1840 1846 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1841 1847
1842 1848 * IPython/iplib.py (interact): Fix that we were not catching
1843 1849 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1844 1850 logic here had to change, but it's fixed now.
1845 1851
1846 1852 2006-01-29 Ville Vainio <vivainio@gmail.com>
1847 1853
1848 1854 * iplib.py: Try to import pyreadline on Windows.
1849 1855
1850 1856 2006-01-27 Ville Vainio <vivainio@gmail.com>
1851 1857
1852 1858 * iplib.py: Expose ipapi as _ip in builtin namespace.
1853 1859 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1854 1860 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1855 1861 syntax now produce _ip.* variant of the commands.
1856 1862
1857 1863 * "_ip.options().autoedit_syntax = 2" automatically throws
1858 1864 user to editor for syntax error correction without prompting.
1859 1865
1860 1866 2006-01-27 Ville Vainio <vivainio@gmail.com>
1861 1867
1862 1868 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1863 1869 'ipython' at argv[0]) executed through command line.
1864 1870 NOTE: this DEPRECATES calling ipython with multiple scripts
1865 1871 ("ipython a.py b.py c.py")
1866 1872
1867 1873 * iplib.py, hooks.py: Added configurable input prefilter,
1868 1874 named 'input_prefilter'. See ext_rescapture.py for example
1869 1875 usage.
1870 1876
1871 1877 * ext_rescapture.py, Magic.py: Better system command output capture
1872 1878 through 'var = !ls' (deprecates user-visible %sc). Same notation
1873 1879 applies for magics, 'var = %alias' assigns alias list to var.
1874 1880
1875 1881 * ipapi.py: added meta() for accessing extension-usable data store.
1876 1882
1877 1883 * iplib.py: added InteractiveShell.getapi(). New magics should be
1878 1884 written doing self.getapi() instead of using the shell directly.
1879 1885
1880 1886 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1881 1887 %store foo >> ~/myfoo.txt to store variables to files (in clean
1882 1888 textual form, not a restorable pickle).
1883 1889
1884 1890 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1885 1891
1886 1892 * usage.py, Magic.py: added %quickref
1887 1893
1888 1894 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1889 1895
1890 1896 * GetoptErrors when invoking magics etc. with wrong args
1891 1897 are now more helpful:
1892 1898 GetoptError: option -l not recognized (allowed: "qb" )
1893 1899
1894 1900 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1895 1901
1896 1902 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1897 1903 computationally intensive blocks don't appear to stall the demo.
1898 1904
1899 1905 2006-01-24 Ville Vainio <vivainio@gmail.com>
1900 1906
1901 1907 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1902 1908 value to manipulate resulting history entry.
1903 1909
1904 1910 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1905 1911 to instance methods of IPApi class, to make extending an embedded
1906 1912 IPython feasible. See ext_rehashdir.py for example usage.
1907 1913
1908 1914 * Merged 1071-1076 from branches/0.7.1
1909 1915
1910 1916
1911 1917 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1912 1918
1913 1919 * tools/release (daystamp): Fix build tools to use the new
1914 1920 eggsetup.py script to build lightweight eggs.
1915 1921
1916 1922 * Applied changesets 1062 and 1064 before 0.7.1 release.
1917 1923
1918 1924 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1919 1925 see the raw input history (without conversions like %ls ->
1920 1926 ipmagic("ls")). After a request from W. Stein, SAGE
1921 1927 (http://modular.ucsd.edu/sage) developer. This information is
1922 1928 stored in the input_hist_raw attribute of the IPython instance, so
1923 1929 developers can access it if needed (it's an InputList instance).
1924 1930
1925 1931 * Versionstring = 0.7.2.svn
1926 1932
1927 1933 * eggsetup.py: A separate script for constructing eggs, creates
1928 1934 proper launch scripts even on Windows (an .exe file in
1929 1935 \python24\scripts).
1930 1936
1931 1937 * ipapi.py: launch_new_instance, launch entry point needed for the
1932 1938 egg.
1933 1939
1934 1940 2006-01-23 Ville Vainio <vivainio@gmail.com>
1935 1941
1936 1942 * Added %cpaste magic for pasting python code
1937 1943
1938 1944 2006-01-22 Ville Vainio <vivainio@gmail.com>
1939 1945
1940 1946 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1941 1947
1942 1948 * Versionstring = 0.7.2.svn
1943 1949
1944 1950 * eggsetup.py: A separate script for constructing eggs, creates
1945 1951 proper launch scripts even on Windows (an .exe file in
1946 1952 \python24\scripts).
1947 1953
1948 1954 * ipapi.py: launch_new_instance, launch entry point needed for the
1949 1955 egg.
1950 1956
1951 1957 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1952 1958
1953 1959 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1954 1960 %pfile foo would print the file for foo even if it was a binary.
1955 1961 Now, extensions '.so' and '.dll' are skipped.
1956 1962
1957 1963 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1958 1964 bug, where macros would fail in all threaded modes. I'm not 100%
1959 1965 sure, so I'm going to put out an rc instead of making a release
1960 1966 today, and wait for feedback for at least a few days.
1961 1967
1962 1968 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1963 1969 it...) the handling of pasting external code with autoindent on.
1964 1970 To get out of a multiline input, the rule will appear for most
1965 1971 users unchanged: two blank lines or change the indent level
1966 1972 proposed by IPython. But there is a twist now: you can
1967 1973 add/subtract only *one or two spaces*. If you add/subtract three
1968 1974 or more (unless you completely delete the line), IPython will
1969 1975 accept that line, and you'll need to enter a second one of pure
1970 1976 whitespace. I know it sounds complicated, but I can't find a
1971 1977 different solution that covers all the cases, with the right
1972 1978 heuristics. Hopefully in actual use, nobody will really notice
1973 1979 all these strange rules and things will 'just work'.
1974 1980
1975 1981 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1976 1982
1977 1983 * IPython/iplib.py (interact): catch exceptions which can be
1978 1984 triggered asynchronously by signal handlers. Thanks to an
1979 1985 automatic crash report, submitted by Colin Kingsley
1980 1986 <tercel-AT-gentoo.org>.
1981 1987
1982 1988 2006-01-20 Ville Vainio <vivainio@gmail.com>
1983 1989
1984 1990 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1985 1991 (%rehashdir, very useful, try it out) of how to extend ipython
1986 1992 with new magics. Also added Extensions dir to pythonpath to make
1987 1993 importing extensions easy.
1988 1994
1989 1995 * %store now complains when trying to store interactively declared
1990 1996 classes / instances of those classes.
1991 1997
1992 1998 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1993 1999 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1994 2000 if they exist, and ipy_user_conf.py with some defaults is created for
1995 2001 the user.
1996 2002
1997 2003 * Startup rehashing done by the config file, not InterpreterExec.
1998 2004 This means system commands are available even without selecting the
1999 2005 pysh profile. It's the sensible default after all.
2000 2006
2001 2007 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
2002 2008
2003 2009 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
2004 2010 multiline code with autoindent on working. But I am really not
2005 2011 sure, so this needs more testing. Will commit a debug-enabled
2006 2012 version for now, while I test it some more, so that Ville and
2007 2013 others may also catch any problems. Also made
2008 2014 self.indent_current_str() a method, to ensure that there's no
2009 2015 chance of the indent space count and the corresponding string
2010 2016 falling out of sync. All code needing the string should just call
2011 2017 the method.
2012 2018
2013 2019 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2014 2020
2015 2021 * IPython/Magic.py (magic_edit): fix check for when users don't
2016 2022 save their output files, the try/except was in the wrong section.
2017 2023
2018 2024 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2019 2025
2020 2026 * IPython/Magic.py (magic_run): fix __file__ global missing from
2021 2027 script's namespace when executed via %run. After a report by
2022 2028 Vivian.
2023 2029
2024 2030 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2025 2031 when using python 2.4. The parent constructor changed in 2.4, and
2026 2032 we need to track it directly (we can't call it, as it messes up
2027 2033 readline and tab-completion inside our pdb would stop working).
2028 2034 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2029 2035
2030 2036 2006-01-16 Ville Vainio <vivainio@gmail.com>
2031 2037
2032 2038 * Ipython/magic.py: Reverted back to old %edit functionality
2033 2039 that returns file contents on exit.
2034 2040
2035 2041 * IPython/path.py: Added Jason Orendorff's "path" module to
2036 2042 IPython tree, http://www.jorendorff.com/articles/python/path/.
2037 2043 You can get path objects conveniently through %sc, and !!, e.g.:
2038 2044 sc files=ls
2039 2045 for p in files.paths: # or files.p
2040 2046 print p,p.mtime
2041 2047
2042 2048 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2043 2049 now work again without considering the exclusion regexp -
2044 2050 hence, things like ',foo my/path' turn to 'foo("my/path")'
2045 2051 instead of syntax error.
2046 2052
2047 2053
2048 2054 2006-01-14 Ville Vainio <vivainio@gmail.com>
2049 2055
2050 2056 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2051 2057 ipapi decorators for python 2.4 users, options() provides access to rc
2052 2058 data.
2053 2059
2054 2060 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2055 2061 as path separators (even on Linux ;-). Space character after
2056 2062 backslash (as yielded by tab completer) is still space;
2057 2063 "%cd long\ name" works as expected.
2058 2064
2059 2065 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2060 2066 as "chain of command", with priority. API stays the same,
2061 2067 TryNext exception raised by a hook function signals that
2062 2068 current hook failed and next hook should try handling it, as
2063 2069 suggested by Walter Dörwald <walter@livinglogic.de>. Walter also
2064 2070 requested configurable display hook, which is now implemented.
2065 2071
2066 2072 2006-01-13 Ville Vainio <vivainio@gmail.com>
2067 2073
2068 2074 * IPython/platutils*.py: platform specific utility functions,
2069 2075 so far only set_term_title is implemented (change terminal
2070 2076 label in windowing systems). %cd now changes the title to
2071 2077 current dir.
2072 2078
2073 2079 * IPython/Release.py: Added myself to "authors" list,
2074 2080 had to create new files.
2075 2081
2076 2082 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2077 2083 shell escape; not a known bug but had potential to be one in the
2078 2084 future.
2079 2085
2080 2086 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2081 2087 extension API for IPython! See the module for usage example. Fix
2082 2088 OInspect for docstring-less magic functions.
2083 2089
2084 2090
2085 2091 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2086 2092
2087 2093 * IPython/iplib.py (raw_input): temporarily deactivate all
2088 2094 attempts at allowing pasting of code with autoindent on. It
2089 2095 introduced bugs (reported by Prabhu) and I can't seem to find a
2090 2096 robust combination which works in all cases. Will have to revisit
2091 2097 later.
2092 2098
2093 2099 * IPython/genutils.py: remove isspace() function. We've dropped
2094 2100 2.2 compatibility, so it's OK to use the string method.
2095 2101
2096 2102 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2097 2103
2098 2104 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2099 2105 matching what NOT to autocall on, to include all python binary
2100 2106 operators (including things like 'and', 'or', 'is' and 'in').
2101 2107 Prompted by a bug report on 'foo & bar', but I realized we had
2102 2108 many more potential bug cases with other operators. The regexp is
2103 2109 self.re_exclude_auto, it's fairly commented.
2104 2110
2105 2111 2006-01-12 Ville Vainio <vivainio@gmail.com>
2106 2112
2107 2113 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2108 2114 Prettified and hardened string/backslash quoting with ipsystem(),
2109 2115 ipalias() and ipmagic(). Now even \ characters are passed to
2110 2116 %magics, !shell escapes and aliases exactly as they are in the
2111 2117 ipython command line. Should improve backslash experience,
2112 2118 particularly in Windows (path delimiter for some commands that
2113 2119 won't understand '/'), but Unix benefits as well (regexps). %cd
2114 2120 magic still doesn't support backslash path delimiters, though. Also
2115 2121 deleted all pretense of supporting multiline command strings in
2116 2122 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2117 2123
2118 2124 * doc/build_doc_instructions.txt added. Documentation on how to
2119 2125 use doc/update_manual.py, added yesterday. Both files contributed
2120 2126 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2121 2127 doc/*.sh for deprecation at a later date.
2122 2128
2123 2129 * /ipython.py Added ipython.py to root directory for
2124 2130 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2125 2131 ipython.py) and development convenience (no need to keep doing
2126 2132 "setup.py install" between changes).
2127 2133
2128 2134 * Made ! and !! shell escapes work (again) in multiline expressions:
2129 2135 if 1:
2130 2136 !ls
2131 2137 !!ls
2132 2138
2133 2139 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2134 2140
2135 2141 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2136 2142 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2137 2143 module in case-insensitive installation. Was causing crashes
2138 2144 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2139 2145
2140 2146 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2141 2147 <marienz-AT-gentoo.org>, closes
2142 2148 http://www.scipy.net/roundup/ipython/issue51.
2143 2149
2144 2150 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2145 2151
2146 2152 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2147 2153 problem of excessive CPU usage under *nix and keyboard lag under
2148 2154 win32.
2149 2155
2150 2156 2006-01-10 *** Released version 0.7.0
2151 2157
2152 2158 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2153 2159
2154 2160 * IPython/Release.py (revision): tag version number to 0.7.0,
2155 2161 ready for release.
2156 2162
2157 2163 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2158 2164 it informs the user of the name of the temp. file used. This can
2159 2165 help if you decide later to reuse that same file, so you know
2160 2166 where to copy the info from.
2161 2167
2162 2168 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2163 2169
2164 2170 * setup_bdist_egg.py: little script to build an egg. Added
2165 2171 support in the release tools as well.
2166 2172
2167 2173 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2168 2174
2169 2175 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2170 2176 version selection (new -wxversion command line and ipythonrc
2171 2177 parameter). Patch contributed by Arnd Baecker
2172 2178 <arnd.baecker-AT-web.de>.
2173 2179
2174 2180 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2175 2181 embedded instances, for variables defined at the interactive
2176 2182 prompt of the embedded ipython. Reported by Arnd.
2177 2183
2178 2184 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2179 2185 it can be used as a (stateful) toggle, or with a direct parameter.
2180 2186
2181 2187 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2182 2188 could be triggered in certain cases and cause the traceback
2183 2189 printer not to work.
2184 2190
2185 2191 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2186 2192
2187 2193 * IPython/iplib.py (_should_recompile): Small fix, closes
2188 2194 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2189 2195
2190 2196 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2191 2197
2192 2198 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2193 2199 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2194 2200 Moad for help with tracking it down.
2195 2201
2196 2202 * IPython/iplib.py (handle_auto): fix autocall handling for
2197 2203 objects which support BOTH __getitem__ and __call__ (so that f [x]
2198 2204 is left alone, instead of becoming f([x]) automatically).
2199 2205
2200 2206 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2201 2207 Ville's patch.
2202 2208
2203 2209 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2204 2210
2205 2211 * IPython/iplib.py (handle_auto): changed autocall semantics to
2206 2212 include 'smart' mode, where the autocall transformation is NOT
2207 2213 applied if there are no arguments on the line. This allows you to
2208 2214 just type 'foo' if foo is a callable to see its internal form,
2209 2215 instead of having it called with no arguments (typically a
2210 2216 mistake). The old 'full' autocall still exists: for that, you
2211 2217 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2212 2218
2213 2219 * IPython/completer.py (Completer.attr_matches): add
2214 2220 tab-completion support for Enthoughts' traits. After a report by
2215 2221 Arnd and a patch by Prabhu.
2216 2222
2217 2223 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2218 2224
2219 2225 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2220 2226 Schmolck's patch to fix inspect.getinnerframes().
2221 2227
2222 2228 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2223 2229 for embedded instances, regarding handling of namespaces and items
2224 2230 added to the __builtin__ one. Multiple embedded instances and
2225 2231 recursive embeddings should work better now (though I'm not sure
2226 2232 I've got all the corner cases fixed, that code is a bit of a brain
2227 2233 twister).
2228 2234
2229 2235 * IPython/Magic.py (magic_edit): added support to edit in-memory
2230 2236 macros (automatically creates the necessary temp files). %edit
2231 2237 also doesn't return the file contents anymore, it's just noise.
2232 2238
2233 2239 * IPython/completer.py (Completer.attr_matches): revert change to
2234 2240 complete only on attributes listed in __all__. I realized it
2235 2241 cripples the tab-completion system as a tool for exploring the
2236 2242 internals of unknown libraries (it renders any non-__all__
2237 2243 attribute off-limits). I got bit by this when trying to see
2238 2244 something inside the dis module.
2239 2245
2240 2246 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2241 2247
2242 2248 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2243 2249 namespace for users and extension writers to hold data in. This
2244 2250 follows the discussion in
2245 2251 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2246 2252
2247 2253 * IPython/completer.py (IPCompleter.complete): small patch to help
2248 2254 tab-completion under Emacs, after a suggestion by John Barnard
2249 2255 <barnarj-AT-ccf.org>.
2250 2256
2251 2257 * IPython/Magic.py (Magic.extract_input_slices): added support for
2252 2258 the slice notation in magics to use N-M to represent numbers N...M
2253 2259 (closed endpoints). This is used by %macro and %save.
2254 2260
2255 2261 * IPython/completer.py (Completer.attr_matches): for modules which
2256 2262 define __all__, complete only on those. After a patch by Jeffrey
2257 2263 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2258 2264 speed up this routine.
2259 2265
2260 2266 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2261 2267 don't know if this is the end of it, but the behavior now is
2262 2268 certainly much more correct. Note that coupled with macros,
2263 2269 slightly surprising (at first) behavior may occur: a macro will in
2264 2270 general expand to multiple lines of input, so upon exiting, the
2265 2271 in/out counters will both be bumped by the corresponding amount
2266 2272 (as if the macro's contents had been typed interactively). Typing
2267 2273 %hist will reveal the intermediate (silently processed) lines.
2268 2274
2269 2275 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2270 2276 pickle to fail (%run was overwriting __main__ and not restoring
2271 2277 it, but pickle relies on __main__ to operate).
2272 2278
2273 2279 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2274 2280 using properties, but forgot to make the main InteractiveShell
2275 2281 class a new-style class. Properties fail silently, and
2276 2282 mysteriously, with old-style class (getters work, but
2277 2283 setters don't do anything).
2278 2284
2279 2285 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2280 2286
2281 2287 * IPython/Magic.py (magic_history): fix history reporting bug (I
2282 2288 know some nasties are still there, I just can't seem to find a
2283 2289 reproducible test case to track them down; the input history is
2284 2290 falling out of sync...)
2285 2291
2286 2292 * IPython/iplib.py (handle_shell_escape): fix bug where both
2287 2293 aliases and system accesses where broken for indented code (such
2288 2294 as loops).
2289 2295
2290 2296 * IPython/genutils.py (shell): fix small but critical bug for
2291 2297 win32 system access.
2292 2298
2293 2299 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2294 2300
2295 2301 * IPython/iplib.py (showtraceback): remove use of the
2296 2302 sys.last_{type/value/traceback} structures, which are non
2297 2303 thread-safe.
2298 2304 (_prefilter): change control flow to ensure that we NEVER
2299 2305 introspect objects when autocall is off. This will guarantee that
2300 2306 having an input line of the form 'x.y', where access to attribute
2301 2307 'y' has side effects, doesn't trigger the side effect TWICE. It
2302 2308 is important to note that, with autocall on, these side effects
2303 2309 can still happen.
2304 2310 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2305 2311 trio. IPython offers these three kinds of special calls which are
2306 2312 not python code, and it's a good thing to have their call method
2307 2313 be accessible as pure python functions (not just special syntax at
2308 2314 the command line). It gives us a better internal implementation
2309 2315 structure, as well as exposing these for user scripting more
2310 2316 cleanly.
2311 2317
2312 2318 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2313 2319 file. Now that they'll be more likely to be used with the
2314 2320 persistance system (%store), I want to make sure their module path
2315 2321 doesn't change in the future, so that we don't break things for
2316 2322 users' persisted data.
2317 2323
2318 2324 * IPython/iplib.py (autoindent_update): move indentation
2319 2325 management into the _text_ processing loop, not the keyboard
2320 2326 interactive one. This is necessary to correctly process non-typed
2321 2327 multiline input (such as macros).
2322 2328
2323 2329 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2324 2330 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2325 2331 which was producing problems in the resulting manual.
2326 2332 (magic_whos): improve reporting of instances (show their class,
2327 2333 instead of simply printing 'instance' which isn't terribly
2328 2334 informative).
2329 2335
2330 2336 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2331 2337 (minor mods) to support network shares under win32.
2332 2338
2333 2339 * IPython/winconsole.py (get_console_size): add new winconsole
2334 2340 module and fixes to page_dumb() to improve its behavior under
2335 2341 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2336 2342
2337 2343 * IPython/Magic.py (Macro): simplified Macro class to just
2338 2344 subclass list. We've had only 2.2 compatibility for a very long
2339 2345 time, yet I was still avoiding subclassing the builtin types. No
2340 2346 more (I'm also starting to use properties, though I won't shift to
2341 2347 2.3-specific features quite yet).
2342 2348 (magic_store): added Ville's patch for lightweight variable
2343 2349 persistence, after a request on the user list by Matt Wilkie
2344 2350 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2345 2351 details.
2346 2352
2347 2353 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2348 2354 changed the default logfile name from 'ipython.log' to
2349 2355 'ipython_log.py'. These logs are real python files, and now that
2350 2356 we have much better multiline support, people are more likely to
2351 2357 want to use them as such. Might as well name them correctly.
2352 2358
2353 2359 * IPython/Magic.py: substantial cleanup. While we can't stop
2354 2360 using magics as mixins, due to the existing customizations 'out
2355 2361 there' which rely on the mixin naming conventions, at least I
2356 2362 cleaned out all cross-class name usage. So once we are OK with
2357 2363 breaking compatibility, the two systems can be separated.
2358 2364
2359 2365 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2360 2366 anymore, and the class is a fair bit less hideous as well. New
2361 2367 features were also introduced: timestamping of input, and logging
2362 2368 of output results. These are user-visible with the -t and -o
2363 2369 options to %logstart. Closes
2364 2370 http://www.scipy.net/roundup/ipython/issue11 and a request by
2365 2371 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2366 2372
2367 2373 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2368 2374
2369 2375 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2370 2376 better handle backslashes in paths. See the thread 'More Windows
2371 2377 questions part 2 - \/ characters revisited' on the iypthon user
2372 2378 list:
2373 2379 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2374 2380
2375 2381 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2376 2382
2377 2383 (InteractiveShell.__init__): change threaded shells to not use the
2378 2384 ipython crash handler. This was causing more problems than not,
2379 2385 as exceptions in the main thread (GUI code, typically) would
2380 2386 always show up as a 'crash', when they really weren't.
2381 2387
2382 2388 The colors and exception mode commands (%colors/%xmode) have been
2383 2389 synchronized to also take this into account, so users can get
2384 2390 verbose exceptions for their threaded code as well. I also added
2385 2391 support for activating pdb inside this exception handler as well,
2386 2392 so now GUI authors can use IPython's enhanced pdb at runtime.
2387 2393
2388 2394 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2389 2395 true by default, and add it to the shipped ipythonrc file. Since
2390 2396 this asks the user before proceeding, I think it's OK to make it
2391 2397 true by default.
2392 2398
2393 2399 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2394 2400 of the previous special-casing of input in the eval loop. I think
2395 2401 this is cleaner, as they really are commands and shouldn't have
2396 2402 a special role in the middle of the core code.
2397 2403
2398 2404 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2399 2405
2400 2406 * IPython/iplib.py (edit_syntax_error): added support for
2401 2407 automatically reopening the editor if the file had a syntax error
2402 2408 in it. Thanks to scottt who provided the patch at:
2403 2409 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2404 2410 version committed).
2405 2411
2406 2412 * IPython/iplib.py (handle_normal): add suport for multi-line
2407 2413 input with emtpy lines. This fixes
2408 2414 http://www.scipy.net/roundup/ipython/issue43 and a similar
2409 2415 discussion on the user list.
2410 2416
2411 2417 WARNING: a behavior change is necessarily introduced to support
2412 2418 blank lines: now a single blank line with whitespace does NOT
2413 2419 break the input loop, which means that when autoindent is on, by
2414 2420 default hitting return on the next (indented) line does NOT exit.
2415 2421
2416 2422 Instead, to exit a multiline input you can either have:
2417 2423
2418 2424 - TWO whitespace lines (just hit return again), or
2419 2425 - a single whitespace line of a different length than provided
2420 2426 by the autoindent (add or remove a space).
2421 2427
2422 2428 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2423 2429 module to better organize all readline-related functionality.
2424 2430 I've deleted FlexCompleter and put all completion clases here.
2425 2431
2426 2432 * IPython/iplib.py (raw_input): improve indentation management.
2427 2433 It is now possible to paste indented code with autoindent on, and
2428 2434 the code is interpreted correctly (though it still looks bad on
2429 2435 screen, due to the line-oriented nature of ipython).
2430 2436 (MagicCompleter.complete): change behavior so that a TAB key on an
2431 2437 otherwise empty line actually inserts a tab, instead of completing
2432 2438 on the entire global namespace. This makes it easier to use the
2433 2439 TAB key for indentation. After a request by Hans Meine
2434 2440 <hans_meine-AT-gmx.net>
2435 2441 (_prefilter): add support so that typing plain 'exit' or 'quit'
2436 2442 does a sensible thing. Originally I tried to deviate as little as
2437 2443 possible from the default python behavior, but even that one may
2438 2444 change in this direction (thread on python-dev to that effect).
2439 2445 Regardless, ipython should do the right thing even if CPython's
2440 2446 '>>>' prompt doesn't.
2441 2447 (InteractiveShell): removed subclassing code.InteractiveConsole
2442 2448 class. By now we'd overridden just about all of its methods: I've
2443 2449 copied the remaining two over, and now ipython is a standalone
2444 2450 class. This will provide a clearer picture for the chainsaw
2445 2451 branch refactoring.
2446 2452
2447 2453 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2448 2454
2449 2455 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2450 2456 failures for objects which break when dir() is called on them.
2451 2457
2452 2458 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2453 2459 distinct local and global namespaces in the completer API. This
2454 2460 change allows us to properly handle completion with distinct
2455 2461 scopes, including in embedded instances (this had never really
2456 2462 worked correctly).
2457 2463
2458 2464 Note: this introduces a change in the constructor for
2459 2465 MagicCompleter, as a new global_namespace parameter is now the
2460 2466 second argument (the others were bumped one position).
2461 2467
2462 2468 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2463 2469
2464 2470 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2465 2471 embedded instances (which can be done now thanks to Vivian's
2466 2472 frame-handling fixes for pdb).
2467 2473 (InteractiveShell.__init__): Fix namespace handling problem in
2468 2474 embedded instances. We were overwriting __main__ unconditionally,
2469 2475 and this should only be done for 'full' (non-embedded) IPython;
2470 2476 embedded instances must respect the caller's __main__. Thanks to
2471 2477 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2472 2478
2473 2479 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2474 2480
2475 2481 * setup.py: added download_url to setup(). This registers the
2476 2482 download address at PyPI, which is not only useful to humans
2477 2483 browsing the site, but is also picked up by setuptools (the Eggs
2478 2484 machinery). Thanks to Ville and R. Kern for the info/discussion
2479 2485 on this.
2480 2486
2481 2487 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2482 2488
2483 2489 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2484 2490 This brings a lot of nice functionality to the pdb mode, which now
2485 2491 has tab-completion, syntax highlighting, and better stack handling
2486 2492 than before. Many thanks to Vivian De Smedt
2487 2493 <vivian-AT-vdesmedt.com> for the original patches.
2488 2494
2489 2495 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2490 2496
2491 2497 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2492 2498 sequence to consistently accept the banner argument. The
2493 2499 inconsistency was tripping SAGE, thanks to Gary Zablackis
2494 2500 <gzabl-AT-yahoo.com> for the report.
2495 2501
2496 2502 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2497 2503
2498 2504 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2499 2505 Fix bug where a naked 'alias' call in the ipythonrc file would
2500 2506 cause a crash. Bug reported by Jorgen Stenarson.
2501 2507
2502 2508 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2503 2509
2504 2510 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2505 2511 startup time.
2506 2512
2507 2513 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2508 2514 instances had introduced a bug with globals in normal code. Now
2509 2515 it's working in all cases.
2510 2516
2511 2517 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2512 2518 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2513 2519 has been introduced to set the default case sensitivity of the
2514 2520 searches. Users can still select either mode at runtime on a
2515 2521 per-search basis.
2516 2522
2517 2523 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2518 2524
2519 2525 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2520 2526 attributes in wildcard searches for subclasses. Modified version
2521 2527 of a patch by Jorgen.
2522 2528
2523 2529 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2524 2530
2525 2531 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2526 2532 embedded instances. I added a user_global_ns attribute to the
2527 2533 InteractiveShell class to handle this.
2528 2534
2529 2535 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2530 2536
2531 2537 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2532 2538 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2533 2539 (reported under win32, but may happen also in other platforms).
2534 2540 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2535 2541
2536 2542 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2537 2543
2538 2544 * IPython/Magic.py (magic_psearch): new support for wildcard
2539 2545 patterns. Now, typing ?a*b will list all names which begin with a
2540 2546 and end in b, for example. The %psearch magic has full
2541 2547 docstrings. Many thanks to Jörgen Stenarson
2542 2548 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2543 2549 implementing this functionality.
2544 2550
2545 2551 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2546 2552
2547 2553 * Manual: fixed long-standing annoyance of double-dashes (as in
2548 2554 --prefix=~, for example) being stripped in the HTML version. This
2549 2555 is a latex2html bug, but a workaround was provided. Many thanks
2550 2556 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2551 2557 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2552 2558 rolling. This seemingly small issue had tripped a number of users
2553 2559 when first installing, so I'm glad to see it gone.
2554 2560
2555 2561 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2556 2562
2557 2563 * IPython/Extensions/numeric_formats.py: fix missing import,
2558 2564 reported by Stephen Walton.
2559 2565
2560 2566 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2561 2567
2562 2568 * IPython/demo.py: finish demo module, fully documented now.
2563 2569
2564 2570 * IPython/genutils.py (file_read): simple little utility to read a
2565 2571 file and ensure it's closed afterwards.
2566 2572
2567 2573 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2568 2574
2569 2575 * IPython/demo.py (Demo.__init__): added support for individually
2570 2576 tagging blocks for automatic execution.
2571 2577
2572 2578 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2573 2579 syntax-highlighted python sources, requested by John.
2574 2580
2575 2581 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2576 2582
2577 2583 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2578 2584 finishing.
2579 2585
2580 2586 * IPython/genutils.py (shlex_split): moved from Magic to here,
2581 2587 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2582 2588
2583 2589 * IPython/demo.py (Demo.__init__): added support for silent
2584 2590 blocks, improved marks as regexps, docstrings written.
2585 2591 (Demo.__init__): better docstring, added support for sys.argv.
2586 2592
2587 2593 * IPython/genutils.py (marquee): little utility used by the demo
2588 2594 code, handy in general.
2589 2595
2590 2596 * IPython/demo.py (Demo.__init__): new class for interactive
2591 2597 demos. Not documented yet, I just wrote it in a hurry for
2592 2598 scipy'05. Will docstring later.
2593 2599
2594 2600 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2595 2601
2596 2602 * IPython/Shell.py (sigint_handler): Drastic simplification which
2597 2603 also seems to make Ctrl-C work correctly across threads! This is
2598 2604 so simple, that I can't beleive I'd missed it before. Needs more
2599 2605 testing, though.
2600 2606 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2601 2607 like this before...
2602 2608
2603 2609 * IPython/genutils.py (get_home_dir): add protection against
2604 2610 non-dirs in win32 registry.
2605 2611
2606 2612 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2607 2613 bug where dict was mutated while iterating (pysh crash).
2608 2614
2609 2615 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2610 2616
2611 2617 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2612 2618 spurious newlines added by this routine. After a report by
2613 2619 F. Mantegazza.
2614 2620
2615 2621 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2616 2622
2617 2623 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2618 2624 calls. These were a leftover from the GTK 1.x days, and can cause
2619 2625 problems in certain cases (after a report by John Hunter).
2620 2626
2621 2627 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2622 2628 os.getcwd() fails at init time. Thanks to patch from David Remahl
2623 2629 <chmod007-AT-mac.com>.
2624 2630 (InteractiveShell.__init__): prevent certain special magics from
2625 2631 being shadowed by aliases. Closes
2626 2632 http://www.scipy.net/roundup/ipython/issue41.
2627 2633
2628 2634 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2629 2635
2630 2636 * IPython/iplib.py (InteractiveShell.complete): Added new
2631 2637 top-level completion method to expose the completion mechanism
2632 2638 beyond readline-based environments.
2633 2639
2634 2640 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2635 2641
2636 2642 * tools/ipsvnc (svnversion): fix svnversion capture.
2637 2643
2638 2644 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2639 2645 attribute to self, which was missing. Before, it was set by a
2640 2646 routine which in certain cases wasn't being called, so the
2641 2647 instance could end up missing the attribute. This caused a crash.
2642 2648 Closes http://www.scipy.net/roundup/ipython/issue40.
2643 2649
2644 2650 2005-08-16 Fernando Perez <fperez@colorado.edu>
2645 2651
2646 2652 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2647 2653 contains non-string attribute. Closes
2648 2654 http://www.scipy.net/roundup/ipython/issue38.
2649 2655
2650 2656 2005-08-14 Fernando Perez <fperez@colorado.edu>
2651 2657
2652 2658 * tools/ipsvnc: Minor improvements, to add changeset info.
2653 2659
2654 2660 2005-08-12 Fernando Perez <fperez@colorado.edu>
2655 2661
2656 2662 * IPython/iplib.py (runsource): remove self.code_to_run_src
2657 2663 attribute. I realized this is nothing more than
2658 2664 '\n'.join(self.buffer), and having the same data in two different
2659 2665 places is just asking for synchronization bugs. This may impact
2660 2666 people who have custom exception handlers, so I need to warn
2661 2667 ipython-dev about it (F. Mantegazza may use them).
2662 2668
2663 2669 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2664 2670
2665 2671 * IPython/genutils.py: fix 2.2 compatibility (generators)
2666 2672
2667 2673 2005-07-18 Fernando Perez <fperez@colorado.edu>
2668 2674
2669 2675 * IPython/genutils.py (get_home_dir): fix to help users with
2670 2676 invalid $HOME under win32.
2671 2677
2672 2678 2005-07-17 Fernando Perez <fperez@colorado.edu>
2673 2679
2674 2680 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2675 2681 some old hacks and clean up a bit other routines; code should be
2676 2682 simpler and a bit faster.
2677 2683
2678 2684 * IPython/iplib.py (interact): removed some last-resort attempts
2679 2685 to survive broken stdout/stderr. That code was only making it
2680 2686 harder to abstract out the i/o (necessary for gui integration),
2681 2687 and the crashes it could prevent were extremely rare in practice
2682 2688 (besides being fully user-induced in a pretty violent manner).
2683 2689
2684 2690 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2685 2691 Nothing major yet, but the code is simpler to read; this should
2686 2692 make it easier to do more serious modifications in the future.
2687 2693
2688 2694 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2689 2695 which broke in .15 (thanks to a report by Ville).
2690 2696
2691 2697 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2692 2698 be quite correct, I know next to nothing about unicode). This
2693 2699 will allow unicode strings to be used in prompts, amongst other
2694 2700 cases. It also will prevent ipython from crashing when unicode
2695 2701 shows up unexpectedly in many places. If ascii encoding fails, we
2696 2702 assume utf_8. Currently the encoding is not a user-visible
2697 2703 setting, though it could be made so if there is demand for it.
2698 2704
2699 2705 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2700 2706
2701 2707 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2702 2708
2703 2709 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2704 2710
2705 2711 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2706 2712 code can work transparently for 2.2/2.3.
2707 2713
2708 2714 2005-07-16 Fernando Perez <fperez@colorado.edu>
2709 2715
2710 2716 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2711 2717 out of the color scheme table used for coloring exception
2712 2718 tracebacks. This allows user code to add new schemes at runtime.
2713 2719 This is a minimally modified version of the patch at
2714 2720 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2715 2721 for the contribution.
2716 2722
2717 2723 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2718 2724 slightly modified version of the patch in
2719 2725 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2720 2726 to remove the previous try/except solution (which was costlier).
2721 2727 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2722 2728
2723 2729 2005-06-08 Fernando Perez <fperez@colorado.edu>
2724 2730
2725 2731 * IPython/iplib.py (write/write_err): Add methods to abstract all
2726 2732 I/O a bit more.
2727 2733
2728 2734 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2729 2735 warning, reported by Aric Hagberg, fix by JD Hunter.
2730 2736
2731 2737 2005-06-02 *** Released version 0.6.15
2732 2738
2733 2739 2005-06-01 Fernando Perez <fperez@colorado.edu>
2734 2740
2735 2741 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2736 2742 tab-completion of filenames within open-quoted strings. Note that
2737 2743 this requires that in ~/.ipython/ipythonrc, users change the
2738 2744 readline delimiters configuration to read:
2739 2745
2740 2746 readline_remove_delims -/~
2741 2747
2742 2748
2743 2749 2005-05-31 *** Released version 0.6.14
2744 2750
2745 2751 2005-05-29 Fernando Perez <fperez@colorado.edu>
2746 2752
2747 2753 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2748 2754 with files not on the filesystem. Reported by Eliyahu Sandler
2749 2755 <eli@gondolin.net>
2750 2756
2751 2757 2005-05-22 Fernando Perez <fperez@colorado.edu>
2752 2758
2753 2759 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2754 2760 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2755 2761
2756 2762 2005-05-19 Fernando Perez <fperez@colorado.edu>
2757 2763
2758 2764 * IPython/iplib.py (safe_execfile): close a file which could be
2759 2765 left open (causing problems in win32, which locks open files).
2760 2766 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2761 2767
2762 2768 2005-05-18 Fernando Perez <fperez@colorado.edu>
2763 2769
2764 2770 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2765 2771 keyword arguments correctly to safe_execfile().
2766 2772
2767 2773 2005-05-13 Fernando Perez <fperez@colorado.edu>
2768 2774
2769 2775 * ipython.1: Added info about Qt to manpage, and threads warning
2770 2776 to usage page (invoked with --help).
2771 2777
2772 2778 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2773 2779 new matcher (it goes at the end of the priority list) to do
2774 2780 tab-completion on named function arguments. Submitted by George
2775 2781 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2776 2782 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2777 2783 for more details.
2778 2784
2779 2785 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2780 2786 SystemExit exceptions in the script being run. Thanks to a report
2781 2787 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2782 2788 producing very annoying behavior when running unit tests.
2783 2789
2784 2790 2005-05-12 Fernando Perez <fperez@colorado.edu>
2785 2791
2786 2792 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2787 2793 which I'd broken (again) due to a changed regexp. In the process,
2788 2794 added ';' as an escape to auto-quote the whole line without
2789 2795 splitting its arguments. Thanks to a report by Jerry McRae
2790 2796 <qrs0xyc02-AT-sneakemail.com>.
2791 2797
2792 2798 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2793 2799 possible crashes caused by a TokenError. Reported by Ed Schofield
2794 2800 <schofield-AT-ftw.at>.
2795 2801
2796 2802 2005-05-06 Fernando Perez <fperez@colorado.edu>
2797 2803
2798 2804 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2799 2805
2800 2806 2005-04-29 Fernando Perez <fperez@colorado.edu>
2801 2807
2802 2808 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2803 2809 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2804 2810 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2805 2811 which provides support for Qt interactive usage (similar to the
2806 2812 existing one for WX and GTK). This had been often requested.
2807 2813
2808 2814 2005-04-14 *** Released version 0.6.13
2809 2815
2810 2816 2005-04-08 Fernando Perez <fperez@colorado.edu>
2811 2817
2812 2818 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2813 2819 from _ofind, which gets called on almost every input line. Now,
2814 2820 we only try to get docstrings if they are actually going to be
2815 2821 used (the overhead of fetching unnecessary docstrings can be
2816 2822 noticeable for certain objects, such as Pyro proxies).
2817 2823
2818 2824 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2819 2825 for completers. For some reason I had been passing them the state
2820 2826 variable, which completers never actually need, and was in
2821 2827 conflict with the rlcompleter API. Custom completers ONLY need to
2822 2828 take the text parameter.
2823 2829
2824 2830 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2825 2831 work correctly in pysh. I've also moved all the logic which used
2826 2832 to be in pysh.py here, which will prevent problems with future
2827 2833 upgrades. However, this time I must warn users to update their
2828 2834 pysh profile to include the line
2829 2835
2830 2836 import_all IPython.Extensions.InterpreterExec
2831 2837
2832 2838 because otherwise things won't work for them. They MUST also
2833 2839 delete pysh.py and the line
2834 2840
2835 2841 execfile pysh.py
2836 2842
2837 2843 from their ipythonrc-pysh.
2838 2844
2839 2845 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2840 2846 robust in the face of objects whose dir() returns non-strings
2841 2847 (which it shouldn't, but some broken libs like ITK do). Thanks to
2842 2848 a patch by John Hunter (implemented differently, though). Also
2843 2849 minor improvements by using .extend instead of + on lists.
2844 2850
2845 2851 * pysh.py:
2846 2852
2847 2853 2005-04-06 Fernando Perez <fperez@colorado.edu>
2848 2854
2849 2855 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2850 2856 by default, so that all users benefit from it. Those who don't
2851 2857 want it can still turn it off.
2852 2858
2853 2859 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2854 2860 config file, I'd forgotten about this, so users were getting it
2855 2861 off by default.
2856 2862
2857 2863 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2858 2864 consistency. Now magics can be called in multiline statements,
2859 2865 and python variables can be expanded in magic calls via $var.
2860 2866 This makes the magic system behave just like aliases or !system
2861 2867 calls.
2862 2868
2863 2869 2005-03-28 Fernando Perez <fperez@colorado.edu>
2864 2870
2865 2871 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2866 2872 expensive string additions for building command. Add support for
2867 2873 trailing ';' when autocall is used.
2868 2874
2869 2875 2005-03-26 Fernando Perez <fperez@colorado.edu>
2870 2876
2871 2877 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2872 2878 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2873 2879 ipython.el robust against prompts with any number of spaces
2874 2880 (including 0) after the ':' character.
2875 2881
2876 2882 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2877 2883 continuation prompt, which misled users to think the line was
2878 2884 already indented. Closes debian Bug#300847, reported to me by
2879 2885 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2880 2886
2881 2887 2005-03-23 Fernando Perez <fperez@colorado.edu>
2882 2888
2883 2889 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2884 2890 properly aligned if they have embedded newlines.
2885 2891
2886 2892 * IPython/iplib.py (runlines): Add a public method to expose
2887 2893 IPython's code execution machinery, so that users can run strings
2888 2894 as if they had been typed at the prompt interactively.
2889 2895 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2890 2896 methods which can call the system shell, but with python variable
2891 2897 expansion. The three such methods are: __IPYTHON__.system,
2892 2898 .getoutput and .getoutputerror. These need to be documented in a
2893 2899 'public API' section (to be written) of the manual.
2894 2900
2895 2901 2005-03-20 Fernando Perez <fperez@colorado.edu>
2896 2902
2897 2903 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2898 2904 for custom exception handling. This is quite powerful, and it
2899 2905 allows for user-installable exception handlers which can trap
2900 2906 custom exceptions at runtime and treat them separately from
2901 2907 IPython's default mechanisms. At the request of Frédéric
2902 2908 Mantegazza <mantegazza-AT-ill.fr>.
2903 2909 (InteractiveShell.set_custom_completer): public API function to
2904 2910 add new completers at runtime.
2905 2911
2906 2912 2005-03-19 Fernando Perez <fperez@colorado.edu>
2907 2913
2908 2914 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2909 2915 allow objects which provide their docstrings via non-standard
2910 2916 mechanisms (like Pyro proxies) to still be inspected by ipython's
2911 2917 ? system.
2912 2918
2913 2919 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2914 2920 automatic capture system. I tried quite hard to make it work
2915 2921 reliably, and simply failed. I tried many combinations with the
2916 2922 subprocess module, but eventually nothing worked in all needed
2917 2923 cases (not blocking stdin for the child, duplicating stdout
2918 2924 without blocking, etc). The new %sc/%sx still do capture to these
2919 2925 magical list/string objects which make shell use much more
2920 2926 conveninent, so not all is lost.
2921 2927
2922 2928 XXX - FIX MANUAL for the change above!
2923 2929
2924 2930 (runsource): I copied code.py's runsource() into ipython to modify
2925 2931 it a bit. Now the code object and source to be executed are
2926 2932 stored in ipython. This makes this info accessible to third-party
2927 2933 tools, like custom exception handlers. After a request by Frédéric
2928 2934 Mantegazza <mantegazza-AT-ill.fr>.
2929 2935
2930 2936 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2931 2937 history-search via readline (like C-p/C-n). I'd wanted this for a
2932 2938 long time, but only recently found out how to do it. For users
2933 2939 who already have their ipythonrc files made and want this, just
2934 2940 add:
2935 2941
2936 2942 readline_parse_and_bind "\e[A": history-search-backward
2937 2943 readline_parse_and_bind "\e[B": history-search-forward
2938 2944
2939 2945 2005-03-18 Fernando Perez <fperez@colorado.edu>
2940 2946
2941 2947 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2942 2948 LSString and SList classes which allow transparent conversions
2943 2949 between list mode and whitespace-separated string.
2944 2950 (magic_r): Fix recursion problem in %r.
2945 2951
2946 2952 * IPython/genutils.py (LSString): New class to be used for
2947 2953 automatic storage of the results of all alias/system calls in _o
2948 2954 and _e (stdout/err). These provide a .l/.list attribute which
2949 2955 does automatic splitting on newlines. This means that for most
2950 2956 uses, you'll never need to do capturing of output with %sc/%sx
2951 2957 anymore, since ipython keeps this always done for you. Note that
2952 2958 only the LAST results are stored, the _o/e variables are
2953 2959 overwritten on each call. If you need to save their contents
2954 2960 further, simply bind them to any other name.
2955 2961
2956 2962 2005-03-17 Fernando Perez <fperez@colorado.edu>
2957 2963
2958 2964 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2959 2965 prompt namespace handling.
2960 2966
2961 2967 2005-03-16 Fernando Perez <fperez@colorado.edu>
2962 2968
2963 2969 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2964 2970 classic prompts to be '>>> ' (final space was missing, and it
2965 2971 trips the emacs python mode).
2966 2972 (BasePrompt.__str__): Added safe support for dynamic prompt
2967 2973 strings. Now you can set your prompt string to be '$x', and the
2968 2974 value of x will be printed from your interactive namespace. The
2969 2975 interpolation syntax includes the full Itpl support, so
2970 2976 ${foo()+x+bar()} is a valid prompt string now, and the function
2971 2977 calls will be made at runtime.
2972 2978
2973 2979 2005-03-15 Fernando Perez <fperez@colorado.edu>
2974 2980
2975 2981 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2976 2982 avoid name clashes in pylab. %hist still works, it just forwards
2977 2983 the call to %history.
2978 2984
2979 2985 2005-03-02 *** Released version 0.6.12
2980 2986
2981 2987 2005-03-02 Fernando Perez <fperez@colorado.edu>
2982 2988
2983 2989 * IPython/iplib.py (handle_magic): log magic calls properly as
2984 2990 ipmagic() function calls.
2985 2991
2986 2992 * IPython/Magic.py (magic_time): Improved %time to support
2987 2993 statements and provide wall-clock as well as CPU time.
2988 2994
2989 2995 2005-02-27 Fernando Perez <fperez@colorado.edu>
2990 2996
2991 2997 * IPython/hooks.py: New hooks module, to expose user-modifiable
2992 2998 IPython functionality in a clean manner. For now only the editor
2993 2999 hook is actually written, and other thigns which I intend to turn
2994 3000 into proper hooks aren't yet there. The display and prefilter
2995 3001 stuff, for example, should be hooks. But at least now the
2996 3002 framework is in place, and the rest can be moved here with more
2997 3003 time later. IPython had had a .hooks variable for a long time for
2998 3004 this purpose, but I'd never actually used it for anything.
2999 3005
3000 3006 2005-02-26 Fernando Perez <fperez@colorado.edu>
3001 3007
3002 3008 * IPython/ipmaker.py (make_IPython): make the default ipython
3003 3009 directory be called _ipython under win32, to follow more the
3004 3010 naming peculiarities of that platform (where buggy software like
3005 3011 Visual Sourcesafe breaks with .named directories). Reported by
3006 3012 Ville Vainio.
3007 3013
3008 3014 2005-02-23 Fernando Perez <fperez@colorado.edu>
3009 3015
3010 3016 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3011 3017 auto_aliases for win32 which were causing problems. Users can
3012 3018 define the ones they personally like.
3013 3019
3014 3020 2005-02-21 Fernando Perez <fperez@colorado.edu>
3015 3021
3016 3022 * IPython/Magic.py (magic_time): new magic to time execution of
3017 3023 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3018 3024
3019 3025 2005-02-19 Fernando Perez <fperez@colorado.edu>
3020 3026
3021 3027 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3022 3028 into keys (for prompts, for example).
3023 3029
3024 3030 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3025 3031 prompts in case users want them. This introduces a small behavior
3026 3032 change: ipython does not automatically add a space to all prompts
3027 3033 anymore. To get the old prompts with a space, users should add it
3028 3034 manually to their ipythonrc file, so for example prompt_in1 should
3029 3035 now read 'In [\#]: ' instead of 'In [\#]:'.
3030 3036 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3031 3037 file) to control left-padding of secondary prompts.
3032 3038
3033 3039 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3034 3040 the profiler can't be imported. Fix for Debian, which removed
3035 3041 profile.py because of License issues. I applied a slightly
3036 3042 modified version of the original Debian patch at
3037 3043 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3038 3044
3039 3045 2005-02-17 Fernando Perez <fperez@colorado.edu>
3040 3046
3041 3047 * IPython/genutils.py (native_line_ends): Fix bug which would
3042 3048 cause improper line-ends under win32 b/c I was not opening files
3043 3049 in binary mode. Bug report and fix thanks to Ville.
3044 3050
3045 3051 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3046 3052 trying to catch spurious foo[1] autocalls. My fix actually broke
3047 3053 ',/' autoquote/call with explicit escape (bad regexp).
3048 3054
3049 3055 2005-02-15 *** Released version 0.6.11
3050 3056
3051 3057 2005-02-14 Fernando Perez <fperez@colorado.edu>
3052 3058
3053 3059 * IPython/background_jobs.py: New background job management
3054 3060 subsystem. This is implemented via a new set of classes, and
3055 3061 IPython now provides a builtin 'jobs' object for background job
3056 3062 execution. A convenience %bg magic serves as a lightweight
3057 3063 frontend for starting the more common type of calls. This was
3058 3064 inspired by discussions with B. Granger and the BackgroundCommand
3059 3065 class described in the book Python Scripting for Computational
3060 3066 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3061 3067 (although ultimately no code from this text was used, as IPython's
3062 3068 system is a separate implementation).
3063 3069
3064 3070 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3065 3071 to control the completion of single/double underscore names
3066 3072 separately. As documented in the example ipytonrc file, the
3067 3073 readline_omit__names variable can now be set to 2, to omit even
3068 3074 single underscore names. Thanks to a patch by Brian Wong
3069 3075 <BrianWong-AT-AirgoNetworks.Com>.
3070 3076 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3071 3077 be autocalled as foo([1]) if foo were callable. A problem for
3072 3078 things which are both callable and implement __getitem__.
3073 3079 (init_readline): Fix autoindentation for win32. Thanks to a patch
3074 3080 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3075 3081
3076 3082 2005-02-12 Fernando Perez <fperez@colorado.edu>
3077 3083
3078 3084 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3079 3085 which I had written long ago to sort out user error messages which
3080 3086 may occur during startup. This seemed like a good idea initially,
3081 3087 but it has proven a disaster in retrospect. I don't want to
3082 3088 change much code for now, so my fix is to set the internal 'debug'
3083 3089 flag to true everywhere, whose only job was precisely to control
3084 3090 this subsystem. This closes issue 28 (as well as avoiding all
3085 3091 sorts of strange hangups which occur from time to time).
3086 3092
3087 3093 2005-02-07 Fernando Perez <fperez@colorado.edu>
3088 3094
3089 3095 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3090 3096 previous call produced a syntax error.
3091 3097
3092 3098 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3093 3099 classes without constructor.
3094 3100
3095 3101 2005-02-06 Fernando Perez <fperez@colorado.edu>
3096 3102
3097 3103 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3098 3104 completions with the results of each matcher, so we return results
3099 3105 to the user from all namespaces. This breaks with ipython
3100 3106 tradition, but I think it's a nicer behavior. Now you get all
3101 3107 possible completions listed, from all possible namespaces (python,
3102 3108 filesystem, magics...) After a request by John Hunter
3103 3109 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3104 3110
3105 3111 2005-02-05 Fernando Perez <fperez@colorado.edu>
3106 3112
3107 3113 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3108 3114 the call had quote characters in it (the quotes were stripped).
3109 3115
3110 3116 2005-01-31 Fernando Perez <fperez@colorado.edu>
3111 3117
3112 3118 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3113 3119 Itpl.itpl() to make the code more robust against psyco
3114 3120 optimizations.
3115 3121
3116 3122 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3117 3123 of causing an exception. Quicker, cleaner.
3118 3124
3119 3125 2005-01-28 Fernando Perez <fperez@colorado.edu>
3120 3126
3121 3127 * scripts/ipython_win_post_install.py (install): hardcode
3122 3128 sys.prefix+'python.exe' as the executable path. It turns out that
3123 3129 during the post-installation run, sys.executable resolves to the
3124 3130 name of the binary installer! I should report this as a distutils
3125 3131 bug, I think. I updated the .10 release with this tiny fix, to
3126 3132 avoid annoying the lists further.
3127 3133
3128 3134 2005-01-27 *** Released version 0.6.10
3129 3135
3130 3136 2005-01-27 Fernando Perez <fperez@colorado.edu>
3131 3137
3132 3138 * IPython/numutils.py (norm): Added 'inf' as optional name for
3133 3139 L-infinity norm, included references to mathworld.com for vector
3134 3140 norm definitions.
3135 3141 (amin/amax): added amin/amax for array min/max. Similar to what
3136 3142 pylab ships with after the recent reorganization of names.
3137 3143 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3138 3144
3139 3145 * ipython.el: committed Alex's recent fixes and improvements.
3140 3146 Tested with python-mode from CVS, and it looks excellent. Since
3141 3147 python-mode hasn't released anything in a while, I'm temporarily
3142 3148 putting a copy of today's CVS (v 4.70) of python-mode in:
3143 3149 http://ipython.scipy.org/tmp/python-mode.el
3144 3150
3145 3151 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3146 3152 sys.executable for the executable name, instead of assuming it's
3147 3153 called 'python.exe' (the post-installer would have produced broken
3148 3154 setups on systems with a differently named python binary).
3149 3155
3150 3156 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3151 3157 references to os.linesep, to make the code more
3152 3158 platform-independent. This is also part of the win32 coloring
3153 3159 fixes.
3154 3160
3155 3161 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3156 3162 lines, which actually cause coloring bugs because the length of
3157 3163 the line is very difficult to correctly compute with embedded
3158 3164 escapes. This was the source of all the coloring problems under
3159 3165 Win32. I think that _finally_, Win32 users have a properly
3160 3166 working ipython in all respects. This would never have happened
3161 3167 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3162 3168
3163 3169 2005-01-26 *** Released version 0.6.9
3164 3170
3165 3171 2005-01-25 Fernando Perez <fperez@colorado.edu>
3166 3172
3167 3173 * setup.py: finally, we have a true Windows installer, thanks to
3168 3174 the excellent work of Viktor Ransmayr
3169 3175 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3170 3176 Windows users. The setup routine is quite a bit cleaner thanks to
3171 3177 this, and the post-install script uses the proper functions to
3172 3178 allow a clean de-installation using the standard Windows Control
3173 3179 Panel.
3174 3180
3175 3181 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3176 3182 environment variable under all OSes (including win32) if
3177 3183 available. This will give consistency to win32 users who have set
3178 3184 this variable for any reason. If os.environ['HOME'] fails, the
3179 3185 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3180 3186
3181 3187 2005-01-24 Fernando Perez <fperez@colorado.edu>
3182 3188
3183 3189 * IPython/numutils.py (empty_like): add empty_like(), similar to
3184 3190 zeros_like() but taking advantage of the new empty() Numeric routine.
3185 3191
3186 3192 2005-01-23 *** Released version 0.6.8
3187 3193
3188 3194 2005-01-22 Fernando Perez <fperez@colorado.edu>
3189 3195
3190 3196 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3191 3197 automatic show() calls. After discussing things with JDH, it
3192 3198 turns out there are too many corner cases where this can go wrong.
3193 3199 It's best not to try to be 'too smart', and simply have ipython
3194 3200 reproduce as much as possible the default behavior of a normal
3195 3201 python shell.
3196 3202
3197 3203 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3198 3204 line-splitting regexp and _prefilter() to avoid calling getattr()
3199 3205 on assignments. This closes
3200 3206 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3201 3207 readline uses getattr(), so a simple <TAB> keypress is still
3202 3208 enough to trigger getattr() calls on an object.
3203 3209
3204 3210 2005-01-21 Fernando Perez <fperez@colorado.edu>
3205 3211
3206 3212 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3207 3213 docstring under pylab so it doesn't mask the original.
3208 3214
3209 3215 2005-01-21 *** Released version 0.6.7
3210 3216
3211 3217 2005-01-21 Fernando Perez <fperez@colorado.edu>
3212 3218
3213 3219 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3214 3220 signal handling for win32 users in multithreaded mode.
3215 3221
3216 3222 2005-01-17 Fernando Perez <fperez@colorado.edu>
3217 3223
3218 3224 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3219 3225 instances with no __init__. After a crash report by Norbert Nemec
3220 3226 <Norbert-AT-nemec-online.de>.
3221 3227
3222 3228 2005-01-14 Fernando Perez <fperez@colorado.edu>
3223 3229
3224 3230 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3225 3231 names for verbose exceptions, when multiple dotted names and the
3226 3232 'parent' object were present on the same line.
3227 3233
3228 3234 2005-01-11 Fernando Perez <fperez@colorado.edu>
3229 3235
3230 3236 * IPython/genutils.py (flag_calls): new utility to trap and flag
3231 3237 calls in functions. I need it to clean up matplotlib support.
3232 3238 Also removed some deprecated code in genutils.
3233 3239
3234 3240 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3235 3241 that matplotlib scripts called with %run, which don't call show()
3236 3242 themselves, still have their plotting windows open.
3237 3243
3238 3244 2005-01-05 Fernando Perez <fperez@colorado.edu>
3239 3245
3240 3246 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3241 3247 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3242 3248
3243 3249 2004-12-19 Fernando Perez <fperez@colorado.edu>
3244 3250
3245 3251 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3246 3252 parent_runcode, which was an eyesore. The same result can be
3247 3253 obtained with Python's regular superclass mechanisms.
3248 3254
3249 3255 2004-12-17 Fernando Perez <fperez@colorado.edu>
3250 3256
3251 3257 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3252 3258 reported by Prabhu.
3253 3259 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3254 3260 sys.stderr) instead of explicitly calling sys.stderr. This helps
3255 3261 maintain our I/O abstractions clean, for future GUI embeddings.
3256 3262
3257 3263 * IPython/genutils.py (info): added new utility for sys.stderr
3258 3264 unified info message handling (thin wrapper around warn()).
3259 3265
3260 3266 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3261 3267 composite (dotted) names on verbose exceptions.
3262 3268 (VerboseTB.nullrepr): harden against another kind of errors which
3263 3269 Python's inspect module can trigger, and which were crashing
3264 3270 IPython. Thanks to a report by Marco Lombardi
3265 3271 <mlombard-AT-ma010192.hq.eso.org>.
3266 3272
3267 3273 2004-12-13 *** Released version 0.6.6
3268 3274
3269 3275 2004-12-12 Fernando Perez <fperez@colorado.edu>
3270 3276
3271 3277 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3272 3278 generated by pygtk upon initialization if it was built without
3273 3279 threads (for matplotlib users). After a crash reported by
3274 3280 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3275 3281
3276 3282 * IPython/ipmaker.py (make_IPython): fix small bug in the
3277 3283 import_some parameter for multiple imports.
3278 3284
3279 3285 * IPython/iplib.py (ipmagic): simplified the interface of
3280 3286 ipmagic() to take a single string argument, just as it would be
3281 3287 typed at the IPython cmd line.
3282 3288 (ipalias): Added new ipalias() with an interface identical to
3283 3289 ipmagic(). This completes exposing a pure python interface to the
3284 3290 alias and magic system, which can be used in loops or more complex
3285 3291 code where IPython's automatic line mangling is not active.
3286 3292
3287 3293 * IPython/genutils.py (timing): changed interface of timing to
3288 3294 simply run code once, which is the most common case. timings()
3289 3295 remains unchanged, for the cases where you want multiple runs.
3290 3296
3291 3297 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3292 3298 bug where Python2.2 crashes with exec'ing code which does not end
3293 3299 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3294 3300 before.
3295 3301
3296 3302 2004-12-10 Fernando Perez <fperez@colorado.edu>
3297 3303
3298 3304 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3299 3305 -t to -T, to accomodate the new -t flag in %run (the %run and
3300 3306 %prun options are kind of intermixed, and it's not easy to change
3301 3307 this with the limitations of python's getopt).
3302 3308
3303 3309 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3304 3310 the execution of scripts. It's not as fine-tuned as timeit.py,
3305 3311 but it works from inside ipython (and under 2.2, which lacks
3306 3312 timeit.py). Optionally a number of runs > 1 can be given for
3307 3313 timing very short-running code.
3308 3314
3309 3315 * IPython/genutils.py (uniq_stable): new routine which returns a
3310 3316 list of unique elements in any iterable, but in stable order of
3311 3317 appearance. I needed this for the ultraTB fixes, and it's a handy
3312 3318 utility.
3313 3319
3314 3320 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3315 3321 dotted names in Verbose exceptions. This had been broken since
3316 3322 the very start, now x.y will properly be printed in a Verbose
3317 3323 traceback, instead of x being shown and y appearing always as an
3318 3324 'undefined global'. Getting this to work was a bit tricky,
3319 3325 because by default python tokenizers are stateless. Saved by
3320 3326 python's ability to easily add a bit of state to an arbitrary
3321 3327 function (without needing to build a full-blown callable object).
3322 3328
3323 3329 Also big cleanup of this code, which had horrendous runtime
3324 3330 lookups of zillions of attributes for colorization. Moved all
3325 3331 this code into a few templates, which make it cleaner and quicker.
3326 3332
3327 3333 Printout quality was also improved for Verbose exceptions: one
3328 3334 variable per line, and memory addresses are printed (this can be
3329 3335 quite handy in nasty debugging situations, which is what Verbose
3330 3336 is for).
3331 3337
3332 3338 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3333 3339 the command line as scripts to be loaded by embedded instances.
3334 3340 Doing so has the potential for an infinite recursion if there are
3335 3341 exceptions thrown in the process. This fixes a strange crash
3336 3342 reported by Philippe MULLER <muller-AT-irit.fr>.
3337 3343
3338 3344 2004-12-09 Fernando Perez <fperez@colorado.edu>
3339 3345
3340 3346 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3341 3347 to reflect new names in matplotlib, which now expose the
3342 3348 matlab-compatible interface via a pylab module instead of the
3343 3349 'matlab' name. The new code is backwards compatible, so users of
3344 3350 all matplotlib versions are OK. Patch by J. Hunter.
3345 3351
3346 3352 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3347 3353 of __init__ docstrings for instances (class docstrings are already
3348 3354 automatically printed). Instances with customized docstrings
3349 3355 (indep. of the class) are also recognized and all 3 separate
3350 3356 docstrings are printed (instance, class, constructor). After some
3351 3357 comments/suggestions by J. Hunter.
3352 3358
3353 3359 2004-12-05 Fernando Perez <fperez@colorado.edu>
3354 3360
3355 3361 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3356 3362 warnings when tab-completion fails and triggers an exception.
3357 3363
3358 3364 2004-12-03 Fernando Perez <fperez@colorado.edu>
3359 3365
3360 3366 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3361 3367 be triggered when using 'run -p'. An incorrect option flag was
3362 3368 being set ('d' instead of 'D').
3363 3369 (manpage): fix missing escaped \- sign.
3364 3370
3365 3371 2004-11-30 *** Released version 0.6.5
3366 3372
3367 3373 2004-11-30 Fernando Perez <fperez@colorado.edu>
3368 3374
3369 3375 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3370 3376 setting with -d option.
3371 3377
3372 3378 * setup.py (docfiles): Fix problem where the doc glob I was using
3373 3379 was COMPLETELY BROKEN. It was giving the right files by pure
3374 3380 accident, but failed once I tried to include ipython.el. Note:
3375 3381 glob() does NOT allow you to do exclusion on multiple endings!
3376 3382
3377 3383 2004-11-29 Fernando Perez <fperez@colorado.edu>
3378 3384
3379 3385 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3380 3386 the manpage as the source. Better formatting & consistency.
3381 3387
3382 3388 * IPython/Magic.py (magic_run): Added new -d option, to run
3383 3389 scripts under the control of the python pdb debugger. Note that
3384 3390 this required changing the %prun option -d to -D, to avoid a clash
3385 3391 (since %run must pass options to %prun, and getopt is too dumb to
3386 3392 handle options with string values with embedded spaces). Thanks
3387 3393 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3388 3394 (magic_who_ls): added type matching to %who and %whos, so that one
3389 3395 can filter their output to only include variables of certain
3390 3396 types. Another suggestion by Matthew.
3391 3397 (magic_whos): Added memory summaries in kb and Mb for arrays.
3392 3398 (magic_who): Improve formatting (break lines every 9 vars).
3393 3399
3394 3400 2004-11-28 Fernando Perez <fperez@colorado.edu>
3395 3401
3396 3402 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3397 3403 cache when empty lines were present.
3398 3404
3399 3405 2004-11-24 Fernando Perez <fperez@colorado.edu>
3400 3406
3401 3407 * IPython/usage.py (__doc__): document the re-activated threading
3402 3408 options for WX and GTK.
3403 3409
3404 3410 2004-11-23 Fernando Perez <fperez@colorado.edu>
3405 3411
3406 3412 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3407 3413 the -wthread and -gthread options, along with a new -tk one to try
3408 3414 and coordinate Tk threading with wx/gtk. The tk support is very
3409 3415 platform dependent, since it seems to require Tcl and Tk to be
3410 3416 built with threads (Fedora1/2 appears NOT to have it, but in
3411 3417 Prabhu's Debian boxes it works OK). But even with some Tk
3412 3418 limitations, this is a great improvement.
3413 3419
3414 3420 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3415 3421 info in user prompts. Patch by Prabhu.
3416 3422
3417 3423 2004-11-18 Fernando Perez <fperez@colorado.edu>
3418 3424
3419 3425 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3420 3426 EOFErrors and bail, to avoid infinite loops if a non-terminating
3421 3427 file is fed into ipython. Patch submitted in issue 19 by user,
3422 3428 many thanks.
3423 3429
3424 3430 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3425 3431 autoquote/parens in continuation prompts, which can cause lots of
3426 3432 problems. Closes roundup issue 20.
3427 3433
3428 3434 2004-11-17 Fernando Perez <fperez@colorado.edu>
3429 3435
3430 3436 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3431 3437 reported as debian bug #280505. I'm not sure my local changelog
3432 3438 entry has the proper debian format (Jack?).
3433 3439
3434 3440 2004-11-08 *** Released version 0.6.4
3435 3441
3436 3442 2004-11-08 Fernando Perez <fperez@colorado.edu>
3437 3443
3438 3444 * IPython/iplib.py (init_readline): Fix exit message for Windows
3439 3445 when readline is active. Thanks to a report by Eric Jones
3440 3446 <eric-AT-enthought.com>.
3441 3447
3442 3448 2004-11-07 Fernando Perez <fperez@colorado.edu>
3443 3449
3444 3450 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3445 3451 sometimes seen by win2k/cygwin users.
3446 3452
3447 3453 2004-11-06 Fernando Perez <fperez@colorado.edu>
3448 3454
3449 3455 * IPython/iplib.py (interact): Change the handling of %Exit from
3450 3456 trying to propagate a SystemExit to an internal ipython flag.
3451 3457 This is less elegant than using Python's exception mechanism, but
3452 3458 I can't get that to work reliably with threads, so under -pylab
3453 3459 %Exit was hanging IPython. Cross-thread exception handling is
3454 3460 really a bitch. Thaks to a bug report by Stephen Walton
3455 3461 <stephen.walton-AT-csun.edu>.
3456 3462
3457 3463 2004-11-04 Fernando Perez <fperez@colorado.edu>
3458 3464
3459 3465 * IPython/iplib.py (raw_input_original): store a pointer to the
3460 3466 true raw_input to harden against code which can modify it
3461 3467 (wx.py.PyShell does this and would otherwise crash ipython).
3462 3468 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3463 3469
3464 3470 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3465 3471 Ctrl-C problem, which does not mess up the input line.
3466 3472
3467 3473 2004-11-03 Fernando Perez <fperez@colorado.edu>
3468 3474
3469 3475 * IPython/Release.py: Changed licensing to BSD, in all files.
3470 3476 (name): lowercase name for tarball/RPM release.
3471 3477
3472 3478 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3473 3479 use throughout ipython.
3474 3480
3475 3481 * IPython/Magic.py (Magic._ofind): Switch to using the new
3476 3482 OInspect.getdoc() function.
3477 3483
3478 3484 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3479 3485 of the line currently being canceled via Ctrl-C. It's extremely
3480 3486 ugly, but I don't know how to do it better (the problem is one of
3481 3487 handling cross-thread exceptions).
3482 3488
3483 3489 2004-10-28 Fernando Perez <fperez@colorado.edu>
3484 3490
3485 3491 * IPython/Shell.py (signal_handler): add signal handlers to trap
3486 3492 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3487 3493 report by Francesc Alted.
3488 3494
3489 3495 2004-10-21 Fernando Perez <fperez@colorado.edu>
3490 3496
3491 3497 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3492 3498 to % for pysh syntax extensions.
3493 3499
3494 3500 2004-10-09 Fernando Perez <fperez@colorado.edu>
3495 3501
3496 3502 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3497 3503 arrays to print a more useful summary, without calling str(arr).
3498 3504 This avoids the problem of extremely lengthy computations which
3499 3505 occur if arr is large, and appear to the user as a system lockup
3500 3506 with 100% cpu activity. After a suggestion by Kristian Sandberg
3501 3507 <Kristian.Sandberg@colorado.edu>.
3502 3508 (Magic.__init__): fix bug in global magic escapes not being
3503 3509 correctly set.
3504 3510
3505 3511 2004-10-08 Fernando Perez <fperez@colorado.edu>
3506 3512
3507 3513 * IPython/Magic.py (__license__): change to absolute imports of
3508 3514 ipython's own internal packages, to start adapting to the absolute
3509 3515 import requirement of PEP-328.
3510 3516
3511 3517 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3512 3518 files, and standardize author/license marks through the Release
3513 3519 module instead of having per/file stuff (except for files with
3514 3520 particular licenses, like the MIT/PSF-licensed codes).
3515 3521
3516 3522 * IPython/Debugger.py: remove dead code for python 2.1
3517 3523
3518 3524 2004-10-04 Fernando Perez <fperez@colorado.edu>
3519 3525
3520 3526 * IPython/iplib.py (ipmagic): New function for accessing magics
3521 3527 via a normal python function call.
3522 3528
3523 3529 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3524 3530 from '@' to '%', to accomodate the new @decorator syntax of python
3525 3531 2.4.
3526 3532
3527 3533 2004-09-29 Fernando Perez <fperez@colorado.edu>
3528 3534
3529 3535 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3530 3536 matplotlib.use to prevent running scripts which try to switch
3531 3537 interactive backends from within ipython. This will just crash
3532 3538 the python interpreter, so we can't allow it (but a detailed error
3533 3539 is given to the user).
3534 3540
3535 3541 2004-09-28 Fernando Perez <fperez@colorado.edu>
3536 3542
3537 3543 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3538 3544 matplotlib-related fixes so that using @run with non-matplotlib
3539 3545 scripts doesn't pop up spurious plot windows. This requires
3540 3546 matplotlib >= 0.63, where I had to make some changes as well.
3541 3547
3542 3548 * IPython/ipmaker.py (make_IPython): update version requirement to
3543 3549 python 2.2.
3544 3550
3545 3551 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3546 3552 banner arg for embedded customization.
3547 3553
3548 3554 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3549 3555 explicit uses of __IP as the IPython's instance name. Now things
3550 3556 are properly handled via the shell.name value. The actual code
3551 3557 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3552 3558 is much better than before. I'll clean things completely when the
3553 3559 magic stuff gets a real overhaul.
3554 3560
3555 3561 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3556 3562 minor changes to debian dir.
3557 3563
3558 3564 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3559 3565 pointer to the shell itself in the interactive namespace even when
3560 3566 a user-supplied dict is provided. This is needed for embedding
3561 3567 purposes (found by tests with Michel Sanner).
3562 3568
3563 3569 2004-09-27 Fernando Perez <fperez@colorado.edu>
3564 3570
3565 3571 * IPython/UserConfig/ipythonrc: remove []{} from
3566 3572 readline_remove_delims, so that things like [modname.<TAB> do
3567 3573 proper completion. This disables [].TAB, but that's a less common
3568 3574 case than module names in list comprehensions, for example.
3569 3575 Thanks to a report by Andrea Riciputi.
3570 3576
3571 3577 2004-09-09 Fernando Perez <fperez@colorado.edu>
3572 3578
3573 3579 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3574 3580 blocking problems in win32 and osx. Fix by John.
3575 3581
3576 3582 2004-09-08 Fernando Perez <fperez@colorado.edu>
3577 3583
3578 3584 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3579 3585 for Win32 and OSX. Fix by John Hunter.
3580 3586
3581 3587 2004-08-30 *** Released version 0.6.3
3582 3588
3583 3589 2004-08-30 Fernando Perez <fperez@colorado.edu>
3584 3590
3585 3591 * setup.py (isfile): Add manpages to list of dependent files to be
3586 3592 updated.
3587 3593
3588 3594 2004-08-27 Fernando Perez <fperez@colorado.edu>
3589 3595
3590 3596 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3591 3597 for now. They don't really work with standalone WX/GTK code
3592 3598 (though matplotlib IS working fine with both of those backends).
3593 3599 This will neeed much more testing. I disabled most things with
3594 3600 comments, so turning it back on later should be pretty easy.
3595 3601
3596 3602 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3597 3603 autocalling of expressions like r'foo', by modifying the line
3598 3604 split regexp. Closes
3599 3605 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3600 3606 Riley <ipythonbugs-AT-sabi.net>.
3601 3607 (InteractiveShell.mainloop): honor --nobanner with banner
3602 3608 extensions.
3603 3609
3604 3610 * IPython/Shell.py: Significant refactoring of all classes, so
3605 3611 that we can really support ALL matplotlib backends and threading
3606 3612 models (John spotted a bug with Tk which required this). Now we
3607 3613 should support single-threaded, WX-threads and GTK-threads, both
3608 3614 for generic code and for matplotlib.
3609 3615
3610 3616 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3611 3617 -pylab, to simplify things for users. Will also remove the pylab
3612 3618 profile, since now all of matplotlib configuration is directly
3613 3619 handled here. This also reduces startup time.
3614 3620
3615 3621 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3616 3622 shell wasn't being correctly called. Also in IPShellWX.
3617 3623
3618 3624 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3619 3625 fine-tune banner.
3620 3626
3621 3627 * IPython/numutils.py (spike): Deprecate these spike functions,
3622 3628 delete (long deprecated) gnuplot_exec handler.
3623 3629
3624 3630 2004-08-26 Fernando Perez <fperez@colorado.edu>
3625 3631
3626 3632 * ipython.1: Update for threading options, plus some others which
3627 3633 were missing.
3628 3634
3629 3635 * IPython/ipmaker.py (__call__): Added -wthread option for
3630 3636 wxpython thread handling. Make sure threading options are only
3631 3637 valid at the command line.
3632 3638
3633 3639 * scripts/ipython: moved shell selection into a factory function
3634 3640 in Shell.py, to keep the starter script to a minimum.
3635 3641
3636 3642 2004-08-25 Fernando Perez <fperez@colorado.edu>
3637 3643
3638 3644 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3639 3645 John. Along with some recent changes he made to matplotlib, the
3640 3646 next versions of both systems should work very well together.
3641 3647
3642 3648 2004-08-24 Fernando Perez <fperez@colorado.edu>
3643 3649
3644 3650 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3645 3651 tried to switch the profiling to using hotshot, but I'm getting
3646 3652 strange errors from prof.runctx() there. I may be misreading the
3647 3653 docs, but it looks weird. For now the profiling code will
3648 3654 continue to use the standard profiler.
3649 3655
3650 3656 2004-08-23 Fernando Perez <fperez@colorado.edu>
3651 3657
3652 3658 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3653 3659 threaded shell, by John Hunter. It's not quite ready yet, but
3654 3660 close.
3655 3661
3656 3662 2004-08-22 Fernando Perez <fperez@colorado.edu>
3657 3663
3658 3664 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3659 3665 in Magic and ultraTB.
3660 3666
3661 3667 * ipython.1: document threading options in manpage.
3662 3668
3663 3669 * scripts/ipython: Changed name of -thread option to -gthread,
3664 3670 since this is GTK specific. I want to leave the door open for a
3665 3671 -wthread option for WX, which will most likely be necessary. This
3666 3672 change affects usage and ipmaker as well.
3667 3673
3668 3674 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3669 3675 handle the matplotlib shell issues. Code by John Hunter
3670 3676 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3671 3677 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3672 3678 broken (and disabled for end users) for now, but it puts the
3673 3679 infrastructure in place.
3674 3680
3675 3681 2004-08-21 Fernando Perez <fperez@colorado.edu>
3676 3682
3677 3683 * ipythonrc-pylab: Add matplotlib support.
3678 3684
3679 3685 * matplotlib_config.py: new files for matplotlib support, part of
3680 3686 the pylab profile.
3681 3687
3682 3688 * IPython/usage.py (__doc__): documented the threading options.
3683 3689
3684 3690 2004-08-20 Fernando Perez <fperez@colorado.edu>
3685 3691
3686 3692 * ipython: Modified the main calling routine to handle the -thread
3687 3693 and -mpthread options. This needs to be done as a top-level hack,
3688 3694 because it determines which class to instantiate for IPython
3689 3695 itself.
3690 3696
3691 3697 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3692 3698 classes to support multithreaded GTK operation without blocking,
3693 3699 and matplotlib with all backends. This is a lot of still very
3694 3700 experimental code, and threads are tricky. So it may still have a
3695 3701 few rough edges... This code owes a lot to
3696 3702 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3697 3703 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3698 3704 to John Hunter for all the matplotlib work.
3699 3705
3700 3706 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3701 3707 options for gtk thread and matplotlib support.
3702 3708
3703 3709 2004-08-16 Fernando Perez <fperez@colorado.edu>
3704 3710
3705 3711 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3706 3712 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3707 3713 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3708 3714
3709 3715 2004-08-11 Fernando Perez <fperez@colorado.edu>
3710 3716
3711 3717 * setup.py (isfile): Fix build so documentation gets updated for
3712 3718 rpms (it was only done for .tgz builds).
3713 3719
3714 3720 2004-08-10 Fernando Perez <fperez@colorado.edu>
3715 3721
3716 3722 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3717 3723
3718 3724 * iplib.py : Silence syntax error exceptions in tab-completion.
3719 3725
3720 3726 2004-08-05 Fernando Perez <fperez@colorado.edu>
3721 3727
3722 3728 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3723 3729 'color off' mark for continuation prompts. This was causing long
3724 3730 continuation lines to mis-wrap.
3725 3731
3726 3732 2004-08-01 Fernando Perez <fperez@colorado.edu>
3727 3733
3728 3734 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3729 3735 for building ipython to be a parameter. All this is necessary
3730 3736 right now to have a multithreaded version, but this insane
3731 3737 non-design will be cleaned up soon. For now, it's a hack that
3732 3738 works.
3733 3739
3734 3740 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3735 3741 args in various places. No bugs so far, but it's a dangerous
3736 3742 practice.
3737 3743
3738 3744 2004-07-31 Fernando Perez <fperez@colorado.edu>
3739 3745
3740 3746 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3741 3747 fix completion of files with dots in their names under most
3742 3748 profiles (pysh was OK because the completion order is different).
3743 3749
3744 3750 2004-07-27 Fernando Perez <fperez@colorado.edu>
3745 3751
3746 3752 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3747 3753 keywords manually, b/c the one in keyword.py was removed in python
3748 3754 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3749 3755 This is NOT a bug under python 2.3 and earlier.
3750 3756
3751 3757 2004-07-26 Fernando Perez <fperez@colorado.edu>
3752 3758
3753 3759 * IPython/ultraTB.py (VerboseTB.text): Add another
3754 3760 linecache.checkcache() call to try to prevent inspect.py from
3755 3761 crashing under python 2.3. I think this fixes
3756 3762 http://www.scipy.net/roundup/ipython/issue17.
3757 3763
3758 3764 2004-07-26 *** Released version 0.6.2
3759 3765
3760 3766 2004-07-26 Fernando Perez <fperez@colorado.edu>
3761 3767
3762 3768 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3763 3769 fail for any number.
3764 3770 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3765 3771 empty bookmarks.
3766 3772
3767 3773 2004-07-26 *** Released version 0.6.1
3768 3774
3769 3775 2004-07-26 Fernando Perez <fperez@colorado.edu>
3770 3776
3771 3777 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3772 3778
3773 3779 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3774 3780 escaping '()[]{}' in filenames.
3775 3781
3776 3782 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3777 3783 Python 2.2 users who lack a proper shlex.split.
3778 3784
3779 3785 2004-07-19 Fernando Perez <fperez@colorado.edu>
3780 3786
3781 3787 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3782 3788 for reading readline's init file. I follow the normal chain:
3783 3789 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3784 3790 report by Mike Heeter. This closes
3785 3791 http://www.scipy.net/roundup/ipython/issue16.
3786 3792
3787 3793 2004-07-18 Fernando Perez <fperez@colorado.edu>
3788 3794
3789 3795 * IPython/iplib.py (__init__): Add better handling of '\' under
3790 3796 Win32 for filenames. After a patch by Ville.
3791 3797
3792 3798 2004-07-17 Fernando Perez <fperez@colorado.edu>
3793 3799
3794 3800 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3795 3801 autocalling would be triggered for 'foo is bar' if foo is
3796 3802 callable. I also cleaned up the autocall detection code to use a
3797 3803 regexp, which is faster. Bug reported by Alexander Schmolck.
3798 3804
3799 3805 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3800 3806 '?' in them would confuse the help system. Reported by Alex
3801 3807 Schmolck.
3802 3808
3803 3809 2004-07-16 Fernando Perez <fperez@colorado.edu>
3804 3810
3805 3811 * IPython/GnuplotInteractive.py (__all__): added plot2.
3806 3812
3807 3813 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3808 3814 plotting dictionaries, lists or tuples of 1d arrays.
3809 3815
3810 3816 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3811 3817 optimizations.
3812 3818
3813 3819 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3814 3820 the information which was there from Janko's original IPP code:
3815 3821
3816 3822 03.05.99 20:53 porto.ifm.uni-kiel.de
3817 3823 --Started changelog.
3818 3824 --make clear do what it say it does
3819 3825 --added pretty output of lines from inputcache
3820 3826 --Made Logger a mixin class, simplifies handling of switches
3821 3827 --Added own completer class. .string<TAB> expands to last history
3822 3828 line which starts with string. The new expansion is also present
3823 3829 with Ctrl-r from the readline library. But this shows, who this
3824 3830 can be done for other cases.
3825 3831 --Added convention that all shell functions should accept a
3826 3832 parameter_string This opens the door for different behaviour for
3827 3833 each function. @cd is a good example of this.
3828 3834
3829 3835 04.05.99 12:12 porto.ifm.uni-kiel.de
3830 3836 --added logfile rotation
3831 3837 --added new mainloop method which freezes first the namespace
3832 3838
3833 3839 07.05.99 21:24 porto.ifm.uni-kiel.de
3834 3840 --added the docreader classes. Now there is a help system.
3835 3841 -This is only a first try. Currently it's not easy to put new
3836 3842 stuff in the indices. But this is the way to go. Info would be
3837 3843 better, but HTML is every where and not everybody has an info
3838 3844 system installed and it's not so easy to change html-docs to info.
3839 3845 --added global logfile option
3840 3846 --there is now a hook for object inspection method pinfo needs to
3841 3847 be provided for this. Can be reached by two '??'.
3842 3848
3843 3849 08.05.99 20:51 porto.ifm.uni-kiel.de
3844 3850 --added a README
3845 3851 --bug in rc file. Something has changed so functions in the rc
3846 3852 file need to reference the shell and not self. Not clear if it's a
3847 3853 bug or feature.
3848 3854 --changed rc file for new behavior
3849 3855
3850 3856 2004-07-15 Fernando Perez <fperez@colorado.edu>
3851 3857
3852 3858 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3853 3859 cache was falling out of sync in bizarre manners when multi-line
3854 3860 input was present. Minor optimizations and cleanup.
3855 3861
3856 3862 (Logger): Remove old Changelog info for cleanup. This is the
3857 3863 information which was there from Janko's original code:
3858 3864
3859 3865 Changes to Logger: - made the default log filename a parameter
3860 3866
3861 3867 - put a check for lines beginning with !@? in log(). Needed
3862 3868 (even if the handlers properly log their lines) for mid-session
3863 3869 logging activation to work properly. Without this, lines logged
3864 3870 in mid session, which get read from the cache, would end up
3865 3871 'bare' (with !@? in the open) in the log. Now they are caught
3866 3872 and prepended with a #.
3867 3873
3868 3874 * IPython/iplib.py (InteractiveShell.init_readline): added check
3869 3875 in case MagicCompleter fails to be defined, so we don't crash.
3870 3876
3871 3877 2004-07-13 Fernando Perez <fperez@colorado.edu>
3872 3878
3873 3879 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3874 3880 of EPS if the requested filename ends in '.eps'.
3875 3881
3876 3882 2004-07-04 Fernando Perez <fperez@colorado.edu>
3877 3883
3878 3884 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3879 3885 escaping of quotes when calling the shell.
3880 3886
3881 3887 2004-07-02 Fernando Perez <fperez@colorado.edu>
3882 3888
3883 3889 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3884 3890 gettext not working because we were clobbering '_'. Fixes
3885 3891 http://www.scipy.net/roundup/ipython/issue6.
3886 3892
3887 3893 2004-07-01 Fernando Perez <fperez@colorado.edu>
3888 3894
3889 3895 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3890 3896 into @cd. Patch by Ville.
3891 3897
3892 3898 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3893 3899 new function to store things after ipmaker runs. Patch by Ville.
3894 3900 Eventually this will go away once ipmaker is removed and the class
3895 3901 gets cleaned up, but for now it's ok. Key functionality here is
3896 3902 the addition of the persistent storage mechanism, a dict for
3897 3903 keeping data across sessions (for now just bookmarks, but more can
3898 3904 be implemented later).
3899 3905
3900 3906 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3901 3907 persistent across sections. Patch by Ville, I modified it
3902 3908 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3903 3909 added a '-l' option to list all bookmarks.
3904 3910
3905 3911 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3906 3912 center for cleanup. Registered with atexit.register(). I moved
3907 3913 here the old exit_cleanup(). After a patch by Ville.
3908 3914
3909 3915 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3910 3916 characters in the hacked shlex_split for python 2.2.
3911 3917
3912 3918 * IPython/iplib.py (file_matches): more fixes to filenames with
3913 3919 whitespace in them. It's not perfect, but limitations in python's
3914 3920 readline make it impossible to go further.
3915 3921
3916 3922 2004-06-29 Fernando Perez <fperez@colorado.edu>
3917 3923
3918 3924 * IPython/iplib.py (file_matches): escape whitespace correctly in
3919 3925 filename completions. Bug reported by Ville.
3920 3926
3921 3927 2004-06-28 Fernando Perez <fperez@colorado.edu>
3922 3928
3923 3929 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3924 3930 the history file will be called 'history-PROFNAME' (or just
3925 3931 'history' if no profile is loaded). I was getting annoyed at
3926 3932 getting my Numerical work history clobbered by pysh sessions.
3927 3933
3928 3934 * IPython/iplib.py (InteractiveShell.__init__): Internal
3929 3935 getoutputerror() function so that we can honor the system_verbose
3930 3936 flag for _all_ system calls. I also added escaping of #
3931 3937 characters here to avoid confusing Itpl.
3932 3938
3933 3939 * IPython/Magic.py (shlex_split): removed call to shell in
3934 3940 parse_options and replaced it with shlex.split(). The annoying
3935 3941 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3936 3942 to backport it from 2.3, with several frail hacks (the shlex
3937 3943 module is rather limited in 2.2). Thanks to a suggestion by Ville
3938 3944 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3939 3945 problem.
3940 3946
3941 3947 (Magic.magic_system_verbose): new toggle to print the actual
3942 3948 system calls made by ipython. Mainly for debugging purposes.
3943 3949
3944 3950 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3945 3951 doesn't support persistence. Reported (and fix suggested) by
3946 3952 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3947 3953
3948 3954 2004-06-26 Fernando Perez <fperez@colorado.edu>
3949 3955
3950 3956 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3951 3957 continue prompts.
3952 3958
3953 3959 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3954 3960 function (basically a big docstring) and a few more things here to
3955 3961 speedup startup. pysh.py is now very lightweight. We want because
3956 3962 it gets execfile'd, while InterpreterExec gets imported, so
3957 3963 byte-compilation saves time.
3958 3964
3959 3965 2004-06-25 Fernando Perez <fperez@colorado.edu>
3960 3966
3961 3967 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3962 3968 -NUM', which was recently broken.
3963 3969
3964 3970 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3965 3971 in multi-line input (but not !!, which doesn't make sense there).
3966 3972
3967 3973 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3968 3974 It's just too useful, and people can turn it off in the less
3969 3975 common cases where it's a problem.
3970 3976
3971 3977 2004-06-24 Fernando Perez <fperez@colorado.edu>
3972 3978
3973 3979 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3974 3980 special syntaxes (like alias calling) is now allied in multi-line
3975 3981 input. This is still _very_ experimental, but it's necessary for
3976 3982 efficient shell usage combining python looping syntax with system
3977 3983 calls. For now it's restricted to aliases, I don't think it
3978 3984 really even makes sense to have this for magics.
3979 3985
3980 3986 2004-06-23 Fernando Perez <fperez@colorado.edu>
3981 3987
3982 3988 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3983 3989 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3984 3990
3985 3991 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3986 3992 extensions under Windows (after code sent by Gary Bishop). The
3987 3993 extensions considered 'executable' are stored in IPython's rc
3988 3994 structure as win_exec_ext.
3989 3995
3990 3996 * IPython/genutils.py (shell): new function, like system() but
3991 3997 without return value. Very useful for interactive shell work.
3992 3998
3993 3999 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3994 4000 delete aliases.
3995 4001
3996 4002 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3997 4003 sure that the alias table doesn't contain python keywords.
3998 4004
3999 4005 2004-06-21 Fernando Perez <fperez@colorado.edu>
4000 4006
4001 4007 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
4002 4008 non-existent items are found in $PATH. Reported by Thorsten.
4003 4009
4004 4010 2004-06-20 Fernando Perez <fperez@colorado.edu>
4005 4011
4006 4012 * IPython/iplib.py (complete): modified the completer so that the
4007 4013 order of priorities can be easily changed at runtime.
4008 4014
4009 4015 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
4010 4016 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4011 4017
4012 4018 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4013 4019 expand Python variables prepended with $ in all system calls. The
4014 4020 same was done to InteractiveShell.handle_shell_escape. Now all
4015 4021 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4016 4022 expansion of python variables and expressions according to the
4017 4023 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4018 4024
4019 4025 Though PEP-215 has been rejected, a similar (but simpler) one
4020 4026 seems like it will go into Python 2.4, PEP-292 -
4021 4027 http://www.python.org/peps/pep-0292.html.
4022 4028
4023 4029 I'll keep the full syntax of PEP-215, since IPython has since the
4024 4030 start used Ka-Ping Yee's reference implementation discussed there
4025 4031 (Itpl), and I actually like the powerful semantics it offers.
4026 4032
4027 4033 In order to access normal shell variables, the $ has to be escaped
4028 4034 via an extra $. For example:
4029 4035
4030 4036 In [7]: PATH='a python variable'
4031 4037
4032 4038 In [8]: !echo $PATH
4033 4039 a python variable
4034 4040
4035 4041 In [9]: !echo $$PATH
4036 4042 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4037 4043
4038 4044 (Magic.parse_options): escape $ so the shell doesn't evaluate
4039 4045 things prematurely.
4040 4046
4041 4047 * IPython/iplib.py (InteractiveShell.call_alias): added the
4042 4048 ability for aliases to expand python variables via $.
4043 4049
4044 4050 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4045 4051 system, now there's a @rehash/@rehashx pair of magics. These work
4046 4052 like the csh rehash command, and can be invoked at any time. They
4047 4053 build a table of aliases to everything in the user's $PATH
4048 4054 (@rehash uses everything, @rehashx is slower but only adds
4049 4055 executable files). With this, the pysh.py-based shell profile can
4050 4056 now simply call rehash upon startup, and full access to all
4051 4057 programs in the user's path is obtained.
4052 4058
4053 4059 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4054 4060 functionality is now fully in place. I removed the old dynamic
4055 4061 code generation based approach, in favor of a much lighter one
4056 4062 based on a simple dict. The advantage is that this allows me to
4057 4063 now have thousands of aliases with negligible cost (unthinkable
4058 4064 with the old system).
4059 4065
4060 4066 2004-06-19 Fernando Perez <fperez@colorado.edu>
4061 4067
4062 4068 * IPython/iplib.py (__init__): extended MagicCompleter class to
4063 4069 also complete (last in priority) on user aliases.
4064 4070
4065 4071 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4066 4072 call to eval.
4067 4073 (ItplNS.__init__): Added a new class which functions like Itpl,
4068 4074 but allows configuring the namespace for the evaluation to occur
4069 4075 in.
4070 4076
4071 4077 2004-06-18 Fernando Perez <fperez@colorado.edu>
4072 4078
4073 4079 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4074 4080 better message when 'exit' or 'quit' are typed (a common newbie
4075 4081 confusion).
4076 4082
4077 4083 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4078 4084 check for Windows users.
4079 4085
4080 4086 * IPython/iplib.py (InteractiveShell.user_setup): removed
4081 4087 disabling of colors for Windows. I'll test at runtime and issue a
4082 4088 warning if Gary's readline isn't found, as to nudge users to
4083 4089 download it.
4084 4090
4085 4091 2004-06-16 Fernando Perez <fperez@colorado.edu>
4086 4092
4087 4093 * IPython/genutils.py (Stream.__init__): changed to print errors
4088 4094 to sys.stderr. I had a circular dependency here. Now it's
4089 4095 possible to run ipython as IDLE's shell (consider this pre-alpha,
4090 4096 since true stdout things end up in the starting terminal instead
4091 4097 of IDLE's out).
4092 4098
4093 4099 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4094 4100 users who haven't # updated their prompt_in2 definitions. Remove
4095 4101 eventually.
4096 4102 (multiple_replace): added credit to original ASPN recipe.
4097 4103
4098 4104 2004-06-15 Fernando Perez <fperez@colorado.edu>
4099 4105
4100 4106 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4101 4107 list of auto-defined aliases.
4102 4108
4103 4109 2004-06-13 Fernando Perez <fperez@colorado.edu>
4104 4110
4105 4111 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4106 4112 install was really requested (so setup.py can be used for other
4107 4113 things under Windows).
4108 4114
4109 4115 2004-06-10 Fernando Perez <fperez@colorado.edu>
4110 4116
4111 4117 * IPython/Logger.py (Logger.create_log): Manually remove any old
4112 4118 backup, since os.remove may fail under Windows. Fixes bug
4113 4119 reported by Thorsten.
4114 4120
4115 4121 2004-06-09 Fernando Perez <fperez@colorado.edu>
4116 4122
4117 4123 * examples/example-embed.py: fixed all references to %n (replaced
4118 4124 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4119 4125 for all examples and the manual as well.
4120 4126
4121 4127 2004-06-08 Fernando Perez <fperez@colorado.edu>
4122 4128
4123 4129 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4124 4130 alignment and color management. All 3 prompt subsystems now
4125 4131 inherit from BasePrompt.
4126 4132
4127 4133 * tools/release: updates for windows installer build and tag rpms
4128 4134 with python version (since paths are fixed).
4129 4135
4130 4136 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4131 4137 which will become eventually obsolete. Also fixed the default
4132 4138 prompt_in2 to use \D, so at least new users start with the correct
4133 4139 defaults.
4134 4140 WARNING: Users with existing ipythonrc files will need to apply
4135 4141 this fix manually!
4136 4142
4137 4143 * setup.py: make windows installer (.exe). This is finally the
4138 4144 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4139 4145 which I hadn't included because it required Python 2.3 (or recent
4140 4146 distutils).
4141 4147
4142 4148 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4143 4149 usage of new '\D' escape.
4144 4150
4145 4151 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4146 4152 lacks os.getuid())
4147 4153 (CachedOutput.set_colors): Added the ability to turn coloring
4148 4154 on/off with @colors even for manually defined prompt colors. It
4149 4155 uses a nasty global, but it works safely and via the generic color
4150 4156 handling mechanism.
4151 4157 (Prompt2.__init__): Introduced new escape '\D' for continuation
4152 4158 prompts. It represents the counter ('\#') as dots.
4153 4159 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4154 4160 need to update their ipythonrc files and replace '%n' with '\D' in
4155 4161 their prompt_in2 settings everywhere. Sorry, but there's
4156 4162 otherwise no clean way to get all prompts to properly align. The
4157 4163 ipythonrc shipped with IPython has been updated.
4158 4164
4159 4165 2004-06-07 Fernando Perez <fperez@colorado.edu>
4160 4166
4161 4167 * setup.py (isfile): Pass local_icons option to latex2html, so the
4162 4168 resulting HTML file is self-contained. Thanks to
4163 4169 dryice-AT-liu.com.cn for the tip.
4164 4170
4165 4171 * pysh.py: I created a new profile 'shell', which implements a
4166 4172 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4167 4173 system shell, nor will it become one anytime soon. It's mainly
4168 4174 meant to illustrate the use of the new flexible bash-like prompts.
4169 4175 I guess it could be used by hardy souls for true shell management,
4170 4176 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4171 4177 profile. This uses the InterpreterExec extension provided by
4172 4178 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4173 4179
4174 4180 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4175 4181 auto-align itself with the length of the previous input prompt
4176 4182 (taking into account the invisible color escapes).
4177 4183 (CachedOutput.__init__): Large restructuring of this class. Now
4178 4184 all three prompts (primary1, primary2, output) are proper objects,
4179 4185 managed by the 'parent' CachedOutput class. The code is still a
4180 4186 bit hackish (all prompts share state via a pointer to the cache),
4181 4187 but it's overall far cleaner than before.
4182 4188
4183 4189 * IPython/genutils.py (getoutputerror): modified to add verbose,
4184 4190 debug and header options. This makes the interface of all getout*
4185 4191 functions uniform.
4186 4192 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4187 4193
4188 4194 * IPython/Magic.py (Magic.default_option): added a function to
4189 4195 allow registering default options for any magic command. This
4190 4196 makes it easy to have profiles which customize the magics globally
4191 4197 for a certain use. The values set through this function are
4192 4198 picked up by the parse_options() method, which all magics should
4193 4199 use to parse their options.
4194 4200
4195 4201 * IPython/genutils.py (warn): modified the warnings framework to
4196 4202 use the Term I/O class. I'm trying to slowly unify all of
4197 4203 IPython's I/O operations to pass through Term.
4198 4204
4199 4205 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4200 4206 the secondary prompt to correctly match the length of the primary
4201 4207 one for any prompt. Now multi-line code will properly line up
4202 4208 even for path dependent prompts, such as the new ones available
4203 4209 via the prompt_specials.
4204 4210
4205 4211 2004-06-06 Fernando Perez <fperez@colorado.edu>
4206 4212
4207 4213 * IPython/Prompts.py (prompt_specials): Added the ability to have
4208 4214 bash-like special sequences in the prompts, which get
4209 4215 automatically expanded. Things like hostname, current working
4210 4216 directory and username are implemented already, but it's easy to
4211 4217 add more in the future. Thanks to a patch by W.J. van der Laan
4212 4218 <gnufnork-AT-hetdigitalegat.nl>
4213 4219 (prompt_specials): Added color support for prompt strings, so
4214 4220 users can define arbitrary color setups for their prompts.
4215 4221
4216 4222 2004-06-05 Fernando Perez <fperez@colorado.edu>
4217 4223
4218 4224 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4219 4225 code to load Gary Bishop's readline and configure it
4220 4226 automatically. Thanks to Gary for help on this.
4221 4227
4222 4228 2004-06-01 Fernando Perez <fperez@colorado.edu>
4223 4229
4224 4230 * IPython/Logger.py (Logger.create_log): fix bug for logging
4225 4231 with no filename (previous fix was incomplete).
4226 4232
4227 4233 2004-05-25 Fernando Perez <fperez@colorado.edu>
4228 4234
4229 4235 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4230 4236 parens would get passed to the shell.
4231 4237
4232 4238 2004-05-20 Fernando Perez <fperez@colorado.edu>
4233 4239
4234 4240 * IPython/Magic.py (Magic.magic_prun): changed default profile
4235 4241 sort order to 'time' (the more common profiling need).
4236 4242
4237 4243 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4238 4244 so that source code shown is guaranteed in sync with the file on
4239 4245 disk (also changed in psource). Similar fix to the one for
4240 4246 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4241 4247 <yann.ledu-AT-noos.fr>.
4242 4248
4243 4249 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4244 4250 with a single option would not be correctly parsed. Closes
4245 4251 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4246 4252 introduced in 0.6.0 (on 2004-05-06).
4247 4253
4248 4254 2004-05-13 *** Released version 0.6.0
4249 4255
4250 4256 2004-05-13 Fernando Perez <fperez@colorado.edu>
4251 4257
4252 4258 * debian/: Added debian/ directory to CVS, so that debian support
4253 4259 is publicly accessible. The debian package is maintained by Jack
4254 4260 Moffit <jack-AT-xiph.org>.
4255 4261
4256 4262 * Documentation: included the notes about an ipython-based system
4257 4263 shell (the hypothetical 'pysh') into the new_design.pdf document,
4258 4264 so that these ideas get distributed to users along with the
4259 4265 official documentation.
4260 4266
4261 4267 2004-05-10 Fernando Perez <fperez@colorado.edu>
4262 4268
4263 4269 * IPython/Logger.py (Logger.create_log): fix recently introduced
4264 4270 bug (misindented line) where logstart would fail when not given an
4265 4271 explicit filename.
4266 4272
4267 4273 2004-05-09 Fernando Perez <fperez@colorado.edu>
4268 4274
4269 4275 * IPython/Magic.py (Magic.parse_options): skip system call when
4270 4276 there are no options to look for. Faster, cleaner for the common
4271 4277 case.
4272 4278
4273 4279 * Documentation: many updates to the manual: describing Windows
4274 4280 support better, Gnuplot updates, credits, misc small stuff. Also
4275 4281 updated the new_design doc a bit.
4276 4282
4277 4283 2004-05-06 *** Released version 0.6.0.rc1
4278 4284
4279 4285 2004-05-06 Fernando Perez <fperez@colorado.edu>
4280 4286
4281 4287 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4282 4288 operations to use the vastly more efficient list/''.join() method.
4283 4289 (FormattedTB.text): Fix
4284 4290 http://www.scipy.net/roundup/ipython/issue12 - exception source
4285 4291 extract not updated after reload. Thanks to Mike Salib
4286 4292 <msalib-AT-mit.edu> for pinning the source of the problem.
4287 4293 Fortunately, the solution works inside ipython and doesn't require
4288 4294 any changes to python proper.
4289 4295
4290 4296 * IPython/Magic.py (Magic.parse_options): Improved to process the
4291 4297 argument list as a true shell would (by actually using the
4292 4298 underlying system shell). This way, all @magics automatically get
4293 4299 shell expansion for variables. Thanks to a comment by Alex
4294 4300 Schmolck.
4295 4301
4296 4302 2004-04-04 Fernando Perez <fperez@colorado.edu>
4297 4303
4298 4304 * IPython/iplib.py (InteractiveShell.interact): Added a special
4299 4305 trap for a debugger quit exception, which is basically impossible
4300 4306 to handle by normal mechanisms, given what pdb does to the stack.
4301 4307 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4302 4308
4303 4309 2004-04-03 Fernando Perez <fperez@colorado.edu>
4304 4310
4305 4311 * IPython/genutils.py (Term): Standardized the names of the Term
4306 4312 class streams to cin/cout/cerr, following C++ naming conventions
4307 4313 (I can't use in/out/err because 'in' is not a valid attribute
4308 4314 name).
4309 4315
4310 4316 * IPython/iplib.py (InteractiveShell.interact): don't increment
4311 4317 the prompt if there's no user input. By Daniel 'Dang' Griffith
4312 4318 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4313 4319 Francois Pinard.
4314 4320
4315 4321 2004-04-02 Fernando Perez <fperez@colorado.edu>
4316 4322
4317 4323 * IPython/genutils.py (Stream.__init__): Modified to survive at
4318 4324 least importing in contexts where stdin/out/err aren't true file
4319 4325 objects, such as PyCrust (they lack fileno() and mode). However,
4320 4326 the recovery facilities which rely on these things existing will
4321 4327 not work.
4322 4328
4323 4329 2004-04-01 Fernando Perez <fperez@colorado.edu>
4324 4330
4325 4331 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4326 4332 use the new getoutputerror() function, so it properly
4327 4333 distinguishes stdout/err.
4328 4334
4329 4335 * IPython/genutils.py (getoutputerror): added a function to
4330 4336 capture separately the standard output and error of a command.
4331 4337 After a comment from dang on the mailing lists. This code is
4332 4338 basically a modified version of commands.getstatusoutput(), from
4333 4339 the standard library.
4334 4340
4335 4341 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4336 4342 '!!' as a special syntax (shorthand) to access @sx.
4337 4343
4338 4344 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4339 4345 command and return its output as a list split on '\n'.
4340 4346
4341 4347 2004-03-31 Fernando Perez <fperez@colorado.edu>
4342 4348
4343 4349 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4344 4350 method to dictionaries used as FakeModule instances if they lack
4345 4351 it. At least pydoc in python2.3 breaks for runtime-defined
4346 4352 functions without this hack. At some point I need to _really_
4347 4353 understand what FakeModule is doing, because it's a gross hack.
4348 4354 But it solves Arnd's problem for now...
4349 4355
4350 4356 2004-02-27 Fernando Perez <fperez@colorado.edu>
4351 4357
4352 4358 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4353 4359 mode would behave erratically. Also increased the number of
4354 4360 possible logs in rotate mod to 999. Thanks to Rod Holland
4355 4361 <rhh@StructureLABS.com> for the report and fixes.
4356 4362
4357 4363 2004-02-26 Fernando Perez <fperez@colorado.edu>
4358 4364
4359 4365 * IPython/genutils.py (page): Check that the curses module really
4360 4366 has the initscr attribute before trying to use it. For some
4361 4367 reason, the Solaris curses module is missing this. I think this
4362 4368 should be considered a Solaris python bug, but I'm not sure.
4363 4369
4364 4370 2004-01-17 Fernando Perez <fperez@colorado.edu>
4365 4371
4366 4372 * IPython/genutils.py (Stream.__init__): Changes to try to make
4367 4373 ipython robust against stdin/out/err being closed by the user.
4368 4374 This is 'user error' (and blocks a normal python session, at least
4369 4375 the stdout case). However, Ipython should be able to survive such
4370 4376 instances of abuse as gracefully as possible. To simplify the
4371 4377 coding and maintain compatibility with Gary Bishop's Term
4372 4378 contributions, I've made use of classmethods for this. I think
4373 4379 this introduces a dependency on python 2.2.
4374 4380
4375 4381 2004-01-13 Fernando Perez <fperez@colorado.edu>
4376 4382
4377 4383 * IPython/numutils.py (exp_safe): simplified the code a bit and
4378 4384 removed the need for importing the kinds module altogether.
4379 4385
4380 4386 2004-01-06 Fernando Perez <fperez@colorado.edu>
4381 4387
4382 4388 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4383 4389 a magic function instead, after some community feedback. No
4384 4390 special syntax will exist for it, but its name is deliberately
4385 4391 very short.
4386 4392
4387 4393 2003-12-20 Fernando Perez <fperez@colorado.edu>
4388 4394
4389 4395 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4390 4396 new functionality, to automagically assign the result of a shell
4391 4397 command to a variable. I'll solicit some community feedback on
4392 4398 this before making it permanent.
4393 4399
4394 4400 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4395 4401 requested about callables for which inspect couldn't obtain a
4396 4402 proper argspec. Thanks to a crash report sent by Etienne
4397 4403 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4398 4404
4399 4405 2003-12-09 Fernando Perez <fperez@colorado.edu>
4400 4406
4401 4407 * IPython/genutils.py (page): patch for the pager to work across
4402 4408 various versions of Windows. By Gary Bishop.
4403 4409
4404 4410 2003-12-04 Fernando Perez <fperez@colorado.edu>
4405 4411
4406 4412 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4407 4413 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4408 4414 While I tested this and it looks ok, there may still be corner
4409 4415 cases I've missed.
4410 4416
4411 4417 2003-12-01 Fernando Perez <fperez@colorado.edu>
4412 4418
4413 4419 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4414 4420 where a line like 'p,q=1,2' would fail because the automagic
4415 4421 system would be triggered for @p.
4416 4422
4417 4423 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4418 4424 cleanups, code unmodified.
4419 4425
4420 4426 * IPython/genutils.py (Term): added a class for IPython to handle
4421 4427 output. In most cases it will just be a proxy for stdout/err, but
4422 4428 having this allows modifications to be made for some platforms,
4423 4429 such as handling color escapes under Windows. All of this code
4424 4430 was contributed by Gary Bishop, with minor modifications by me.
4425 4431 The actual changes affect many files.
4426 4432
4427 4433 2003-11-30 Fernando Perez <fperez@colorado.edu>
4428 4434
4429 4435 * IPython/iplib.py (file_matches): new completion code, courtesy
4430 4436 of Jeff Collins. This enables filename completion again under
4431 4437 python 2.3, which disabled it at the C level.
4432 4438
4433 4439 2003-11-11 Fernando Perez <fperez@colorado.edu>
4434 4440
4435 4441 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4436 4442 for Numeric.array(map(...)), but often convenient.
4437 4443
4438 4444 2003-11-05 Fernando Perez <fperez@colorado.edu>
4439 4445
4440 4446 * IPython/numutils.py (frange): Changed a call from int() to
4441 4447 int(round()) to prevent a problem reported with arange() in the
4442 4448 numpy list.
4443 4449
4444 4450 2003-10-06 Fernando Perez <fperez@colorado.edu>
4445 4451
4446 4452 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4447 4453 prevent crashes if sys lacks an argv attribute (it happens with
4448 4454 embedded interpreters which build a bare-bones sys module).
4449 4455 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4450 4456
4451 4457 2003-09-24 Fernando Perez <fperez@colorado.edu>
4452 4458
4453 4459 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4454 4460 to protect against poorly written user objects where __getattr__
4455 4461 raises exceptions other than AttributeError. Thanks to a bug
4456 4462 report by Oliver Sander <osander-AT-gmx.de>.
4457 4463
4458 4464 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4459 4465 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4460 4466
4461 4467 2003-09-09 Fernando Perez <fperez@colorado.edu>
4462 4468
4463 4469 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4464 4470 unpacking a list whith a callable as first element would
4465 4471 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4466 4472 Collins.
4467 4473
4468 4474 2003-08-25 *** Released version 0.5.0
4469 4475
4470 4476 2003-08-22 Fernando Perez <fperez@colorado.edu>
4471 4477
4472 4478 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4473 4479 improperly defined user exceptions. Thanks to feedback from Mark
4474 4480 Russell <mrussell-AT-verio.net>.
4475 4481
4476 4482 2003-08-20 Fernando Perez <fperez@colorado.edu>
4477 4483
4478 4484 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4479 4485 printing so that it would print multi-line string forms starting
4480 4486 with a new line. This way the formatting is better respected for
4481 4487 objects which work hard to make nice string forms.
4482 4488
4483 4489 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4484 4490 autocall would overtake data access for objects with both
4485 4491 __getitem__ and __call__.
4486 4492
4487 4493 2003-08-19 *** Released version 0.5.0-rc1
4488 4494
4489 4495 2003-08-19 Fernando Perez <fperez@colorado.edu>
4490 4496
4491 4497 * IPython/deep_reload.py (load_tail): single tiny change here
4492 4498 seems to fix the long-standing bug of dreload() failing to work
4493 4499 for dotted names. But this module is pretty tricky, so I may have
4494 4500 missed some subtlety. Needs more testing!.
4495 4501
4496 4502 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4497 4503 exceptions which have badly implemented __str__ methods.
4498 4504 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4499 4505 which I've been getting reports about from Python 2.3 users. I
4500 4506 wish I had a simple test case to reproduce the problem, so I could
4501 4507 either write a cleaner workaround or file a bug report if
4502 4508 necessary.
4503 4509
4504 4510 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4505 4511 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4506 4512 a bug report by Tjabo Kloppenburg.
4507 4513
4508 4514 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4509 4515 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4510 4516 seems rather unstable. Thanks to a bug report by Tjabo
4511 4517 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4512 4518
4513 4519 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4514 4520 this out soon because of the critical fixes in the inner loop for
4515 4521 generators.
4516 4522
4517 4523 * IPython/Magic.py (Magic.getargspec): removed. This (and
4518 4524 _get_def) have been obsoleted by OInspect for a long time, I
4519 4525 hadn't noticed that they were dead code.
4520 4526 (Magic._ofind): restored _ofind functionality for a few literals
4521 4527 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4522 4528 for things like "hello".capitalize?, since that would require a
4523 4529 potentially dangerous eval() again.
4524 4530
4525 4531 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4526 4532 logic a bit more to clean up the escapes handling and minimize the
4527 4533 use of _ofind to only necessary cases. The interactive 'feel' of
4528 4534 IPython should have improved quite a bit with the changes in
4529 4535 _prefilter and _ofind (besides being far safer than before).
4530 4536
4531 4537 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4532 4538 obscure, never reported). Edit would fail to find the object to
4533 4539 edit under some circumstances.
4534 4540 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4535 4541 which were causing double-calling of generators. Those eval calls
4536 4542 were _very_ dangerous, since code with side effects could be
4537 4543 triggered. As they say, 'eval is evil'... These were the
4538 4544 nastiest evals in IPython. Besides, _ofind is now far simpler,
4539 4545 and it should also be quite a bit faster. Its use of inspect is
4540 4546 also safer, so perhaps some of the inspect-related crashes I've
4541 4547 seen lately with Python 2.3 might be taken care of. That will
4542 4548 need more testing.
4543 4549
4544 4550 2003-08-17 Fernando Perez <fperez@colorado.edu>
4545 4551
4546 4552 * IPython/iplib.py (InteractiveShell._prefilter): significant
4547 4553 simplifications to the logic for handling user escapes. Faster
4548 4554 and simpler code.
4549 4555
4550 4556 2003-08-14 Fernando Perez <fperez@colorado.edu>
4551 4557
4552 4558 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4553 4559 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4554 4560 but it should be quite a bit faster. And the recursive version
4555 4561 generated O(log N) intermediate storage for all rank>1 arrays,
4556 4562 even if they were contiguous.
4557 4563 (l1norm): Added this function.
4558 4564 (norm): Added this function for arbitrary norms (including
4559 4565 l-infinity). l1 and l2 are still special cases for convenience
4560 4566 and speed.
4561 4567
4562 4568 2003-08-03 Fernando Perez <fperez@colorado.edu>
4563 4569
4564 4570 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4565 4571 exceptions, which now raise PendingDeprecationWarnings in Python
4566 4572 2.3. There were some in Magic and some in Gnuplot2.
4567 4573
4568 4574 2003-06-30 Fernando Perez <fperez@colorado.edu>
4569 4575
4570 4576 * IPython/genutils.py (page): modified to call curses only for
4571 4577 terminals where TERM=='xterm'. After problems under many other
4572 4578 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4573 4579
4574 4580 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4575 4581 would be triggered when readline was absent. This was just an old
4576 4582 debugging statement I'd forgotten to take out.
4577 4583
4578 4584 2003-06-20 Fernando Perez <fperez@colorado.edu>
4579 4585
4580 4586 * IPython/genutils.py (clock): modified to return only user time
4581 4587 (not counting system time), after a discussion on scipy. While
4582 4588 system time may be a useful quantity occasionally, it may much
4583 4589 more easily be skewed by occasional swapping or other similar
4584 4590 activity.
4585 4591
4586 4592 2003-06-05 Fernando Perez <fperez@colorado.edu>
4587 4593
4588 4594 * IPython/numutils.py (identity): new function, for building
4589 4595 arbitrary rank Kronecker deltas (mostly backwards compatible with
4590 4596 Numeric.identity)
4591 4597
4592 4598 2003-06-03 Fernando Perez <fperez@colorado.edu>
4593 4599
4594 4600 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4595 4601 arguments passed to magics with spaces, to allow trailing '\' to
4596 4602 work normally (mainly for Windows users).
4597 4603
4598 4604 2003-05-29 Fernando Perez <fperez@colorado.edu>
4599 4605
4600 4606 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4601 4607 instead of pydoc.help. This fixes a bizarre behavior where
4602 4608 printing '%s' % locals() would trigger the help system. Now
4603 4609 ipython behaves like normal python does.
4604 4610
4605 4611 Note that if one does 'from pydoc import help', the bizarre
4606 4612 behavior returns, but this will also happen in normal python, so
4607 4613 it's not an ipython bug anymore (it has to do with how pydoc.help
4608 4614 is implemented).
4609 4615
4610 4616 2003-05-22 Fernando Perez <fperez@colorado.edu>
4611 4617
4612 4618 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4613 4619 return [] instead of None when nothing matches, also match to end
4614 4620 of line. Patch by Gary Bishop.
4615 4621
4616 4622 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4617 4623 protection as before, for files passed on the command line. This
4618 4624 prevents the CrashHandler from kicking in if user files call into
4619 4625 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4620 4626 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4621 4627
4622 4628 2003-05-20 *** Released version 0.4.0
4623 4629
4624 4630 2003-05-20 Fernando Perez <fperez@colorado.edu>
4625 4631
4626 4632 * setup.py: added support for manpages. It's a bit hackish b/c of
4627 4633 a bug in the way the bdist_rpm distutils target handles gzipped
4628 4634 manpages, but it works. After a patch by Jack.
4629 4635
4630 4636 2003-05-19 Fernando Perez <fperez@colorado.edu>
4631 4637
4632 4638 * IPython/numutils.py: added a mockup of the kinds module, since
4633 4639 it was recently removed from Numeric. This way, numutils will
4634 4640 work for all users even if they are missing kinds.
4635 4641
4636 4642 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4637 4643 failure, which can occur with SWIG-wrapped extensions. After a
4638 4644 crash report from Prabhu.
4639 4645
4640 4646 2003-05-16 Fernando Perez <fperez@colorado.edu>
4641 4647
4642 4648 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4643 4649 protect ipython from user code which may call directly
4644 4650 sys.excepthook (this looks like an ipython crash to the user, even
4645 4651 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4646 4652 This is especially important to help users of WxWindows, but may
4647 4653 also be useful in other cases.
4648 4654
4649 4655 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4650 4656 an optional tb_offset to be specified, and to preserve exception
4651 4657 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4652 4658
4653 4659 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4654 4660
4655 4661 2003-05-15 Fernando Perez <fperez@colorado.edu>
4656 4662
4657 4663 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4658 4664 installing for a new user under Windows.
4659 4665
4660 4666 2003-05-12 Fernando Perez <fperez@colorado.edu>
4661 4667
4662 4668 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4663 4669 handler for Emacs comint-based lines. Currently it doesn't do
4664 4670 much (but importantly, it doesn't update the history cache). In
4665 4671 the future it may be expanded if Alex needs more functionality
4666 4672 there.
4667 4673
4668 4674 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4669 4675 info to crash reports.
4670 4676
4671 4677 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4672 4678 just like Python's -c. Also fixed crash with invalid -color
4673 4679 option value at startup. Thanks to Will French
4674 4680 <wfrench-AT-bestweb.net> for the bug report.
4675 4681
4676 4682 2003-05-09 Fernando Perez <fperez@colorado.edu>
4677 4683
4678 4684 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4679 4685 to EvalDict (it's a mapping, after all) and simplified its code
4680 4686 quite a bit, after a nice discussion on c.l.py where Gustavo
4681 4687 Córdova <gcordova-AT-sismex.com> suggested the new version.
4682 4688
4683 4689 2003-04-30 Fernando Perez <fperez@colorado.edu>
4684 4690
4685 4691 * IPython/genutils.py (timings_out): modified it to reduce its
4686 4692 overhead in the common reps==1 case.
4687 4693
4688 4694 2003-04-29 Fernando Perez <fperez@colorado.edu>
4689 4695
4690 4696 * IPython/genutils.py (timings_out): Modified to use the resource
4691 4697 module, which avoids the wraparound problems of time.clock().
4692 4698
4693 4699 2003-04-17 *** Released version 0.2.15pre4
4694 4700
4695 4701 2003-04-17 Fernando Perez <fperez@colorado.edu>
4696 4702
4697 4703 * setup.py (scriptfiles): Split windows-specific stuff over to a
4698 4704 separate file, in an attempt to have a Windows GUI installer.
4699 4705 That didn't work, but part of the groundwork is done.
4700 4706
4701 4707 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4702 4708 indent/unindent with 4 spaces. Particularly useful in combination
4703 4709 with the new auto-indent option.
4704 4710
4705 4711 2003-04-16 Fernando Perez <fperez@colorado.edu>
4706 4712
4707 4713 * IPython/Magic.py: various replacements of self.rc for
4708 4714 self.shell.rc. A lot more remains to be done to fully disentangle
4709 4715 this class from the main Shell class.
4710 4716
4711 4717 * IPython/GnuplotRuntime.py: added checks for mouse support so
4712 4718 that we don't try to enable it if the current gnuplot doesn't
4713 4719 really support it. Also added checks so that we don't try to
4714 4720 enable persist under Windows (where Gnuplot doesn't recognize the
4715 4721 option).
4716 4722
4717 4723 * IPython/iplib.py (InteractiveShell.interact): Added optional
4718 4724 auto-indenting code, after a patch by King C. Shu
4719 4725 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4720 4726 get along well with pasting indented code. If I ever figure out
4721 4727 how to make that part go well, it will become on by default.
4722 4728
4723 4729 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4724 4730 crash ipython if there was an unmatched '%' in the user's prompt
4725 4731 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4726 4732
4727 4733 * IPython/iplib.py (InteractiveShell.interact): removed the
4728 4734 ability to ask the user whether he wants to crash or not at the
4729 4735 'last line' exception handler. Calling functions at that point
4730 4736 changes the stack, and the error reports would have incorrect
4731 4737 tracebacks.
4732 4738
4733 4739 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4734 4740 pass through a peger a pretty-printed form of any object. After a
4735 4741 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4736 4742
4737 4743 2003-04-14 Fernando Perez <fperez@colorado.edu>
4738 4744
4739 4745 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4740 4746 all files in ~ would be modified at first install (instead of
4741 4747 ~/.ipython). This could be potentially disastrous, as the
4742 4748 modification (make line-endings native) could damage binary files.
4743 4749
4744 4750 2003-04-10 Fernando Perez <fperez@colorado.edu>
4745 4751
4746 4752 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4747 4753 handle only lines which are invalid python. This now means that
4748 4754 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4749 4755 for the bug report.
4750 4756
4751 4757 2003-04-01 Fernando Perez <fperez@colorado.edu>
4752 4758
4753 4759 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4754 4760 where failing to set sys.last_traceback would crash pdb.pm().
4755 4761 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4756 4762 report.
4757 4763
4758 4764 2003-03-25 Fernando Perez <fperez@colorado.edu>
4759 4765
4760 4766 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4761 4767 before printing it (it had a lot of spurious blank lines at the
4762 4768 end).
4763 4769
4764 4770 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4765 4771 output would be sent 21 times! Obviously people don't use this
4766 4772 too often, or I would have heard about it.
4767 4773
4768 4774 2003-03-24 Fernando Perez <fperez@colorado.edu>
4769 4775
4770 4776 * setup.py (scriptfiles): renamed the data_files parameter from
4771 4777 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4772 4778 for the patch.
4773 4779
4774 4780 2003-03-20 Fernando Perez <fperez@colorado.edu>
4775 4781
4776 4782 * IPython/genutils.py (error): added error() and fatal()
4777 4783 functions.
4778 4784
4779 4785 2003-03-18 *** Released version 0.2.15pre3
4780 4786
4781 4787 2003-03-18 Fernando Perez <fperez@colorado.edu>
4782 4788
4783 4789 * setupext/install_data_ext.py
4784 4790 (install_data_ext.initialize_options): Class contributed by Jack
4785 4791 Moffit for fixing the old distutils hack. He is sending this to
4786 4792 the distutils folks so in the future we may not need it as a
4787 4793 private fix.
4788 4794
4789 4795 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4790 4796 changes for Debian packaging. See his patch for full details.
4791 4797 The old distutils hack of making the ipythonrc* files carry a
4792 4798 bogus .py extension is gone, at last. Examples were moved to a
4793 4799 separate subdir under doc/, and the separate executable scripts
4794 4800 now live in their own directory. Overall a great cleanup. The
4795 4801 manual was updated to use the new files, and setup.py has been
4796 4802 fixed for this setup.
4797 4803
4798 4804 * IPython/PyColorize.py (Parser.usage): made non-executable and
4799 4805 created a pycolor wrapper around it to be included as a script.
4800 4806
4801 4807 2003-03-12 *** Released version 0.2.15pre2
4802 4808
4803 4809 2003-03-12 Fernando Perez <fperez@colorado.edu>
4804 4810
4805 4811 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4806 4812 long-standing problem with garbage characters in some terminals.
4807 4813 The issue was really that the \001 and \002 escapes must _only_ be
4808 4814 passed to input prompts (which call readline), but _never_ to
4809 4815 normal text to be printed on screen. I changed ColorANSI to have
4810 4816 two classes: TermColors and InputTermColors, each with the
4811 4817 appropriate escapes for input prompts or normal text. The code in
4812 4818 Prompts.py got slightly more complicated, but this very old and
4813 4819 annoying bug is finally fixed.
4814 4820
4815 4821 All the credit for nailing down the real origin of this problem
4816 4822 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4817 4823 *Many* thanks to him for spending quite a bit of effort on this.
4818 4824
4819 4825 2003-03-05 *** Released version 0.2.15pre1
4820 4826
4821 4827 2003-03-03 Fernando Perez <fperez@colorado.edu>
4822 4828
4823 4829 * IPython/FakeModule.py: Moved the former _FakeModule to a
4824 4830 separate file, because it's also needed by Magic (to fix a similar
4825 4831 pickle-related issue in @run).
4826 4832
4827 4833 2003-03-02 Fernando Perez <fperez@colorado.edu>
4828 4834
4829 4835 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4830 4836 the autocall option at runtime.
4831 4837 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4832 4838 across Magic.py to start separating Magic from InteractiveShell.
4833 4839 (Magic._ofind): Fixed to return proper namespace for dotted
4834 4840 names. Before, a dotted name would always return 'not currently
4835 4841 defined', because it would find the 'parent'. s.x would be found,
4836 4842 but since 'x' isn't defined by itself, it would get confused.
4837 4843 (Magic.magic_run): Fixed pickling problems reported by Ralf
4838 4844 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4839 4845 that I'd used when Mike Heeter reported similar issues at the
4840 4846 top-level, but now for @run. It boils down to injecting the
4841 4847 namespace where code is being executed with something that looks
4842 4848 enough like a module to fool pickle.dump(). Since a pickle stores
4843 4849 a named reference to the importing module, we need this for
4844 4850 pickles to save something sensible.
4845 4851
4846 4852 * IPython/ipmaker.py (make_IPython): added an autocall option.
4847 4853
4848 4854 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4849 4855 the auto-eval code. Now autocalling is an option, and the code is
4850 4856 also vastly safer. There is no more eval() involved at all.
4851 4857
4852 4858 2003-03-01 Fernando Perez <fperez@colorado.edu>
4853 4859
4854 4860 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4855 4861 dict with named keys instead of a tuple.
4856 4862
4857 4863 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4858 4864
4859 4865 * setup.py (make_shortcut): Fixed message about directories
4860 4866 created during Windows installation (the directories were ok, just
4861 4867 the printed message was misleading). Thanks to Chris Liechti
4862 4868 <cliechti-AT-gmx.net> for the heads up.
4863 4869
4864 4870 2003-02-21 Fernando Perez <fperez@colorado.edu>
4865 4871
4866 4872 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4867 4873 of ValueError exception when checking for auto-execution. This
4868 4874 one is raised by things like Numeric arrays arr.flat when the
4869 4875 array is non-contiguous.
4870 4876
4871 4877 2003-01-31 Fernando Perez <fperez@colorado.edu>
4872 4878
4873 4879 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4874 4880 not return any value at all (even though the command would get
4875 4881 executed).
4876 4882 (xsys): Flush stdout right after printing the command to ensure
4877 4883 proper ordering of commands and command output in the total
4878 4884 output.
4879 4885 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4880 4886 system/getoutput as defaults. The old ones are kept for
4881 4887 compatibility reasons, so no code which uses this library needs
4882 4888 changing.
4883 4889
4884 4890 2003-01-27 *** Released version 0.2.14
4885 4891
4886 4892 2003-01-25 Fernando Perez <fperez@colorado.edu>
4887 4893
4888 4894 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4889 4895 functions defined in previous edit sessions could not be re-edited
4890 4896 (because the temp files were immediately removed). Now temp files
4891 4897 are removed only at IPython's exit.
4892 4898 (Magic.magic_run): Improved @run to perform shell-like expansions
4893 4899 on its arguments (~users and $VARS). With this, @run becomes more
4894 4900 like a normal command-line.
4895 4901
4896 4902 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4897 4903 bugs related to embedding and cleaned up that code. A fairly
4898 4904 important one was the impossibility to access the global namespace
4899 4905 through the embedded IPython (only local variables were visible).
4900 4906
4901 4907 2003-01-14 Fernando Perez <fperez@colorado.edu>
4902 4908
4903 4909 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4904 4910 auto-calling to be a bit more conservative. Now it doesn't get
4905 4911 triggered if any of '!=()<>' are in the rest of the input line, to
4906 4912 allow comparing callables. Thanks to Alex for the heads up.
4907 4913
4908 4914 2003-01-07 Fernando Perez <fperez@colorado.edu>
4909 4915
4910 4916 * IPython/genutils.py (page): fixed estimation of the number of
4911 4917 lines in a string to be paged to simply count newlines. This
4912 4918 prevents over-guessing due to embedded escape sequences. A better
4913 4919 long-term solution would involve stripping out the control chars
4914 4920 for the count, but it's potentially so expensive I just don't
4915 4921 think it's worth doing.
4916 4922
4917 4923 2002-12-19 *** Released version 0.2.14pre50
4918 4924
4919 4925 2002-12-19 Fernando Perez <fperez@colorado.edu>
4920 4926
4921 4927 * tools/release (version): Changed release scripts to inform
4922 4928 Andrea and build a NEWS file with a list of recent changes.
4923 4929
4924 4930 * IPython/ColorANSI.py (__all__): changed terminal detection
4925 4931 code. Seems to work better for xterms without breaking
4926 4932 konsole. Will need more testing to determine if WinXP and Mac OSX
4927 4933 also work ok.
4928 4934
4929 4935 2002-12-18 *** Released version 0.2.14pre49
4930 4936
4931 4937 2002-12-18 Fernando Perez <fperez@colorado.edu>
4932 4938
4933 4939 * Docs: added new info about Mac OSX, from Andrea.
4934 4940
4935 4941 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4936 4942 allow direct plotting of python strings whose format is the same
4937 4943 of gnuplot data files.
4938 4944
4939 4945 2002-12-16 Fernando Perez <fperez@colorado.edu>
4940 4946
4941 4947 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4942 4948 value of exit question to be acknowledged.
4943 4949
4944 4950 2002-12-03 Fernando Perez <fperez@colorado.edu>
4945 4951
4946 4952 * IPython/ipmaker.py: removed generators, which had been added
4947 4953 by mistake in an earlier debugging run. This was causing trouble
4948 4954 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4949 4955 for pointing this out.
4950 4956
4951 4957 2002-11-17 Fernando Perez <fperez@colorado.edu>
4952 4958
4953 4959 * Manual: updated the Gnuplot section.
4954 4960
4955 4961 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4956 4962 a much better split of what goes in Runtime and what goes in
4957 4963 Interactive.
4958 4964
4959 4965 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4960 4966 being imported from iplib.
4961 4967
4962 4968 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4963 4969 for command-passing. Now the global Gnuplot instance is called
4964 4970 'gp' instead of 'g', which was really a far too fragile and
4965 4971 common name.
4966 4972
4967 4973 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4968 4974 bounding boxes generated by Gnuplot for square plots.
4969 4975
4970 4976 * IPython/genutils.py (popkey): new function added. I should
4971 4977 suggest this on c.l.py as a dict method, it seems useful.
4972 4978
4973 4979 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4974 4980 to transparently handle PostScript generation. MUCH better than
4975 4981 the previous plot_eps/replot_eps (which I removed now). The code
4976 4982 is also fairly clean and well documented now (including
4977 4983 docstrings).
4978 4984
4979 4985 2002-11-13 Fernando Perez <fperez@colorado.edu>
4980 4986
4981 4987 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4982 4988 (inconsistent with options).
4983 4989
4984 4990 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4985 4991 manually disabled, I don't know why. Fixed it.
4986 4992 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4987 4993 eps output.
4988 4994
4989 4995 2002-11-12 Fernando Perez <fperez@colorado.edu>
4990 4996
4991 4997 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4992 4998 don't propagate up to caller. Fixes crash reported by François
4993 4999 Pinard.
4994 5000
4995 5001 2002-11-09 Fernando Perez <fperez@colorado.edu>
4996 5002
4997 5003 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4998 5004 history file for new users.
4999 5005 (make_IPython): fixed bug where initial install would leave the
5000 5006 user running in the .ipython dir.
5001 5007 (make_IPython): fixed bug where config dir .ipython would be
5002 5008 created regardless of the given -ipythondir option. Thanks to Cory
5003 5009 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
5004 5010
5005 5011 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
5006 5012 type confirmations. Will need to use it in all of IPython's code
5007 5013 consistently.
5008 5014
5009 5015 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
5010 5016 context to print 31 lines instead of the default 5. This will make
5011 5017 the crash reports extremely detailed in case the problem is in
5012 5018 libraries I don't have access to.
5013 5019
5014 5020 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5015 5021 line of defense' code to still crash, but giving users fair
5016 5022 warning. I don't want internal errors to go unreported: if there's
5017 5023 an internal problem, IPython should crash and generate a full
5018 5024 report.
5019 5025
5020 5026 2002-11-08 Fernando Perez <fperez@colorado.edu>
5021 5027
5022 5028 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5023 5029 otherwise uncaught exceptions which can appear if people set
5024 5030 sys.stdout to something badly broken. Thanks to a crash report
5025 5031 from henni-AT-mail.brainbot.com.
5026 5032
5027 5033 2002-11-04 Fernando Perez <fperez@colorado.edu>
5028 5034
5029 5035 * IPython/iplib.py (InteractiveShell.interact): added
5030 5036 __IPYTHON__active to the builtins. It's a flag which goes on when
5031 5037 the interaction starts and goes off again when it stops. This
5032 5038 allows embedding code to detect being inside IPython. Before this
5033 5039 was done via __IPYTHON__, but that only shows that an IPython
5034 5040 instance has been created.
5035 5041
5036 5042 * IPython/Magic.py (Magic.magic_env): I realized that in a
5037 5043 UserDict, instance.data holds the data as a normal dict. So I
5038 5044 modified @env to return os.environ.data instead of rebuilding a
5039 5045 dict by hand.
5040 5046
5041 5047 2002-11-02 Fernando Perez <fperez@colorado.edu>
5042 5048
5043 5049 * IPython/genutils.py (warn): changed so that level 1 prints no
5044 5050 header. Level 2 is now the default (with 'WARNING' header, as
5045 5051 before). I think I tracked all places where changes were needed in
5046 5052 IPython, but outside code using the old level numbering may have
5047 5053 broken.
5048 5054
5049 5055 * IPython/iplib.py (InteractiveShell.runcode): added this to
5050 5056 handle the tracebacks in SystemExit traps correctly. The previous
5051 5057 code (through interact) was printing more of the stack than
5052 5058 necessary, showing IPython internal code to the user.
5053 5059
5054 5060 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5055 5061 default. Now that the default at the confirmation prompt is yes,
5056 5062 it's not so intrusive. François' argument that ipython sessions
5057 5063 tend to be complex enough not to lose them from an accidental C-d,
5058 5064 is a valid one.
5059 5065
5060 5066 * IPython/iplib.py (InteractiveShell.interact): added a
5061 5067 showtraceback() call to the SystemExit trap, and modified the exit
5062 5068 confirmation to have yes as the default.
5063 5069
5064 5070 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5065 5071 this file. It's been gone from the code for a long time, this was
5066 5072 simply leftover junk.
5067 5073
5068 5074 2002-11-01 Fernando Perez <fperez@colorado.edu>
5069 5075
5070 5076 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5071 5077 added. If set, IPython now traps EOF and asks for
5072 5078 confirmation. After a request by François Pinard.
5073 5079
5074 5080 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5075 5081 of @abort, and with a new (better) mechanism for handling the
5076 5082 exceptions.
5077 5083
5078 5084 2002-10-27 Fernando Perez <fperez@colorado.edu>
5079 5085
5080 5086 * IPython/usage.py (__doc__): updated the --help information and
5081 5087 the ipythonrc file to indicate that -log generates
5082 5088 ./ipython.log. Also fixed the corresponding info in @logstart.
5083 5089 This and several other fixes in the manuals thanks to reports by
5084 5090 François Pinard <pinard-AT-iro.umontreal.ca>.
5085 5091
5086 5092 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5087 5093 refer to @logstart (instead of @log, which doesn't exist).
5088 5094
5089 5095 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5090 5096 AttributeError crash. Thanks to Christopher Armstrong
5091 5097 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5092 5098 introduced recently (in 0.2.14pre37) with the fix to the eval
5093 5099 problem mentioned below.
5094 5100
5095 5101 2002-10-17 Fernando Perez <fperez@colorado.edu>
5096 5102
5097 5103 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5098 5104 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5099 5105
5100 5106 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5101 5107 this function to fix a problem reported by Alex Schmolck. He saw
5102 5108 it with list comprehensions and generators, which were getting
5103 5109 called twice. The real problem was an 'eval' call in testing for
5104 5110 automagic which was evaluating the input line silently.
5105 5111
5106 5112 This is a potentially very nasty bug, if the input has side
5107 5113 effects which must not be repeated. The code is much cleaner now,
5108 5114 without any blanket 'except' left and with a regexp test for
5109 5115 actual function names.
5110 5116
5111 5117 But an eval remains, which I'm not fully comfortable with. I just
5112 5118 don't know how to find out if an expression could be a callable in
5113 5119 the user's namespace without doing an eval on the string. However
5114 5120 that string is now much more strictly checked so that no code
5115 5121 slips by, so the eval should only happen for things that can
5116 5122 really be only function/method names.
5117 5123
5118 5124 2002-10-15 Fernando Perez <fperez@colorado.edu>
5119 5125
5120 5126 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5121 5127 OSX information to main manual, removed README_Mac_OSX file from
5122 5128 distribution. Also updated credits for recent additions.
5123 5129
5124 5130 2002-10-10 Fernando Perez <fperez@colorado.edu>
5125 5131
5126 5132 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5127 5133 terminal-related issues. Many thanks to Andrea Riciputi
5128 5134 <andrea.riciputi-AT-libero.it> for writing it.
5129 5135
5130 5136 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5131 5137 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5132 5138
5133 5139 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5134 5140 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5135 5141 <syver-en-AT-online.no> who both submitted patches for this problem.
5136 5142
5137 5143 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5138 5144 global embedding to make sure that things don't overwrite user
5139 5145 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5140 5146
5141 5147 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5142 5148 compatibility. Thanks to Hayden Callow
5143 5149 <h.callow-AT-elec.canterbury.ac.nz>
5144 5150
5145 5151 2002-10-04 Fernando Perez <fperez@colorado.edu>
5146 5152
5147 5153 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5148 5154 Gnuplot.File objects.
5149 5155
5150 5156 2002-07-23 Fernando Perez <fperez@colorado.edu>
5151 5157
5152 5158 * IPython/genutils.py (timing): Added timings() and timing() for
5153 5159 quick access to the most commonly needed data, the execution
5154 5160 times. Old timing() renamed to timings_out().
5155 5161
5156 5162 2002-07-18 Fernando Perez <fperez@colorado.edu>
5157 5163
5158 5164 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5159 5165 bug with nested instances disrupting the parent's tab completion.
5160 5166
5161 5167 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5162 5168 all_completions code to begin the emacs integration.
5163 5169
5164 5170 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5165 5171 argument to allow titling individual arrays when plotting.
5166 5172
5167 5173 2002-07-15 Fernando Perez <fperez@colorado.edu>
5168 5174
5169 5175 * setup.py (make_shortcut): changed to retrieve the value of
5170 5176 'Program Files' directory from the registry (this value changes in
5171 5177 non-english versions of Windows). Thanks to Thomas Fanslau
5172 5178 <tfanslau-AT-gmx.de> for the report.
5173 5179
5174 5180 2002-07-10 Fernando Perez <fperez@colorado.edu>
5175 5181
5176 5182 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5177 5183 a bug in pdb, which crashes if a line with only whitespace is
5178 5184 entered. Bug report submitted to sourceforge.
5179 5185
5180 5186 2002-07-09 Fernando Perez <fperez@colorado.edu>
5181 5187
5182 5188 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5183 5189 reporting exceptions (it's a bug in inspect.py, I just set a
5184 5190 workaround).
5185 5191
5186 5192 2002-07-08 Fernando Perez <fperez@colorado.edu>
5187 5193
5188 5194 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5189 5195 __IPYTHON__ in __builtins__ to show up in user_ns.
5190 5196
5191 5197 2002-07-03 Fernando Perez <fperez@colorado.edu>
5192 5198
5193 5199 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5194 5200 name from @gp_set_instance to @gp_set_default.
5195 5201
5196 5202 * IPython/ipmaker.py (make_IPython): default editor value set to
5197 5203 '0' (a string), to match the rc file. Otherwise will crash when
5198 5204 .strip() is called on it.
5199 5205
5200 5206
5201 5207 2002-06-28 Fernando Perez <fperez@colorado.edu>
5202 5208
5203 5209 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5204 5210 of files in current directory when a file is executed via
5205 5211 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5206 5212
5207 5213 * setup.py (manfiles): fix for rpm builds, submitted by RA
5208 5214 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5209 5215
5210 5216 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5211 5217 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5212 5218 string!). A. Schmolck caught this one.
5213 5219
5214 5220 2002-06-27 Fernando Perez <fperez@colorado.edu>
5215 5221
5216 5222 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5217 5223 defined files at the cmd line. __name__ wasn't being set to
5218 5224 __main__.
5219 5225
5220 5226 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5221 5227 regular lists and tuples besides Numeric arrays.
5222 5228
5223 5229 * IPython/Prompts.py (CachedOutput.__call__): Added output
5224 5230 supression for input ending with ';'. Similar to Mathematica and
5225 5231 Matlab. The _* vars and Out[] list are still updated, just like
5226 5232 Mathematica behaves.
5227 5233
5228 5234 2002-06-25 Fernando Perez <fperez@colorado.edu>
5229 5235
5230 5236 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5231 5237 .ini extensions for profiels under Windows.
5232 5238
5233 5239 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5234 5240 string form. Fix contributed by Alexander Schmolck
5235 5241 <a.schmolck-AT-gmx.net>
5236 5242
5237 5243 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5238 5244 pre-configured Gnuplot instance.
5239 5245
5240 5246 2002-06-21 Fernando Perez <fperez@colorado.edu>
5241 5247
5242 5248 * IPython/numutils.py (exp_safe): new function, works around the
5243 5249 underflow problems in Numeric.
5244 5250 (log2): New fn. Safe log in base 2: returns exact integer answer
5245 5251 for exact integer powers of 2.
5246 5252
5247 5253 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5248 5254 properly.
5249 5255
5250 5256 2002-06-20 Fernando Perez <fperez@colorado.edu>
5251 5257
5252 5258 * IPython/genutils.py (timing): new function like
5253 5259 Mathematica's. Similar to time_test, but returns more info.
5254 5260
5255 5261 2002-06-18 Fernando Perez <fperez@colorado.edu>
5256 5262
5257 5263 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5258 5264 according to Mike Heeter's suggestions.
5259 5265
5260 5266 2002-06-16 Fernando Perez <fperez@colorado.edu>
5261 5267
5262 5268 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5263 5269 system. GnuplotMagic is gone as a user-directory option. New files
5264 5270 make it easier to use all the gnuplot stuff both from external
5265 5271 programs as well as from IPython. Had to rewrite part of
5266 5272 hardcopy() b/c of a strange bug: often the ps files simply don't
5267 5273 get created, and require a repeat of the command (often several
5268 5274 times).
5269 5275
5270 5276 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5271 5277 resolve output channel at call time, so that if sys.stderr has
5272 5278 been redirected by user this gets honored.
5273 5279
5274 5280 2002-06-13 Fernando Perez <fperez@colorado.edu>
5275 5281
5276 5282 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5277 5283 IPShell. Kept a copy with the old names to avoid breaking people's
5278 5284 embedded code.
5279 5285
5280 5286 * IPython/ipython: simplified it to the bare minimum after
5281 5287 Holger's suggestions. Added info about how to use it in
5282 5288 PYTHONSTARTUP.
5283 5289
5284 5290 * IPython/Shell.py (IPythonShell): changed the options passing
5285 5291 from a string with funky %s replacements to a straight list. Maybe
5286 5292 a bit more typing, but it follows sys.argv conventions, so there's
5287 5293 less special-casing to remember.
5288 5294
5289 5295 2002-06-12 Fernando Perez <fperez@colorado.edu>
5290 5296
5291 5297 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5292 5298 command. Thanks to a suggestion by Mike Heeter.
5293 5299 (Magic.magic_pfile): added behavior to look at filenames if given
5294 5300 arg is not a defined object.
5295 5301 (Magic.magic_save): New @save function to save code snippets. Also
5296 5302 a Mike Heeter idea.
5297 5303
5298 5304 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5299 5305 plot() and replot(). Much more convenient now, especially for
5300 5306 interactive use.
5301 5307
5302 5308 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5303 5309 filenames.
5304 5310
5305 5311 2002-06-02 Fernando Perez <fperez@colorado.edu>
5306 5312
5307 5313 * IPython/Struct.py (Struct.__init__): modified to admit
5308 5314 initialization via another struct.
5309 5315
5310 5316 * IPython/genutils.py (SystemExec.__init__): New stateful
5311 5317 interface to xsys and bq. Useful for writing system scripts.
5312 5318
5313 5319 2002-05-30 Fernando Perez <fperez@colorado.edu>
5314 5320
5315 5321 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5316 5322 documents. This will make the user download smaller (it's getting
5317 5323 too big).
5318 5324
5319 5325 2002-05-29 Fernando Perez <fperez@colorado.edu>
5320 5326
5321 5327 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5322 5328 fix problems with shelve and pickle. Seems to work, but I don't
5323 5329 know if corner cases break it. Thanks to Mike Heeter
5324 5330 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5325 5331
5326 5332 2002-05-24 Fernando Perez <fperez@colorado.edu>
5327 5333
5328 5334 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5329 5335 macros having broken.
5330 5336
5331 5337 2002-05-21 Fernando Perez <fperez@colorado.edu>
5332 5338
5333 5339 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5334 5340 introduced logging bug: all history before logging started was
5335 5341 being written one character per line! This came from the redesign
5336 5342 of the input history as a special list which slices to strings,
5337 5343 not to lists.
5338 5344
5339 5345 2002-05-20 Fernando Perez <fperez@colorado.edu>
5340 5346
5341 5347 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5342 5348 be an attribute of all classes in this module. The design of these
5343 5349 classes needs some serious overhauling.
5344 5350
5345 5351 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5346 5352 which was ignoring '_' in option names.
5347 5353
5348 5354 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5349 5355 'Verbose_novars' to 'Context' and made it the new default. It's a
5350 5356 bit more readable and also safer than verbose.
5351 5357
5352 5358 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5353 5359 triple-quoted strings.
5354 5360
5355 5361 * IPython/OInspect.py (__all__): new module exposing the object
5356 5362 introspection facilities. Now the corresponding magics are dummy
5357 5363 wrappers around this. Having this module will make it much easier
5358 5364 to put these functions into our modified pdb.
5359 5365 This new object inspector system uses the new colorizing module,
5360 5366 so source code and other things are nicely syntax highlighted.
5361 5367
5362 5368 2002-05-18 Fernando Perez <fperez@colorado.edu>
5363 5369
5364 5370 * IPython/ColorANSI.py: Split the coloring tools into a separate
5365 5371 module so I can use them in other code easier (they were part of
5366 5372 ultraTB).
5367 5373
5368 5374 2002-05-17 Fernando Perez <fperez@colorado.edu>
5369 5375
5370 5376 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5371 5377 fixed it to set the global 'g' also to the called instance, as
5372 5378 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5373 5379 user's 'g' variables).
5374 5380
5375 5381 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5376 5382 global variables (aliases to _ih,_oh) so that users which expect
5377 5383 In[5] or Out[7] to work aren't unpleasantly surprised.
5378 5384 (InputList.__getslice__): new class to allow executing slices of
5379 5385 input history directly. Very simple class, complements the use of
5380 5386 macros.
5381 5387
5382 5388 2002-05-16 Fernando Perez <fperez@colorado.edu>
5383 5389
5384 5390 * setup.py (docdirbase): make doc directory be just doc/IPython
5385 5391 without version numbers, it will reduce clutter for users.
5386 5392
5387 5393 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5388 5394 execfile call to prevent possible memory leak. See for details:
5389 5395 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5390 5396
5391 5397 2002-05-15 Fernando Perez <fperez@colorado.edu>
5392 5398
5393 5399 * IPython/Magic.py (Magic.magic_psource): made the object
5394 5400 introspection names be more standard: pdoc, pdef, pfile and
5395 5401 psource. They all print/page their output, and it makes
5396 5402 remembering them easier. Kept old names for compatibility as
5397 5403 aliases.
5398 5404
5399 5405 2002-05-14 Fernando Perez <fperez@colorado.edu>
5400 5406
5401 5407 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5402 5408 what the mouse problem was. The trick is to use gnuplot with temp
5403 5409 files and NOT with pipes (for data communication), because having
5404 5410 both pipes and the mouse on is bad news.
5405 5411
5406 5412 2002-05-13 Fernando Perez <fperez@colorado.edu>
5407 5413
5408 5414 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5409 5415 bug. Information would be reported about builtins even when
5410 5416 user-defined functions overrode them.
5411 5417
5412 5418 2002-05-11 Fernando Perez <fperez@colorado.edu>
5413 5419
5414 5420 * IPython/__init__.py (__all__): removed FlexCompleter from
5415 5421 __all__ so that things don't fail in platforms without readline.
5416 5422
5417 5423 2002-05-10 Fernando Perez <fperez@colorado.edu>
5418 5424
5419 5425 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5420 5426 it requires Numeric, effectively making Numeric a dependency for
5421 5427 IPython.
5422 5428
5423 5429 * Released 0.2.13
5424 5430
5425 5431 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5426 5432 profiler interface. Now all the major options from the profiler
5427 5433 module are directly supported in IPython, both for single
5428 5434 expressions (@prun) and for full programs (@run -p).
5429 5435
5430 5436 2002-05-09 Fernando Perez <fperez@colorado.edu>
5431 5437
5432 5438 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5433 5439 magic properly formatted for screen.
5434 5440
5435 5441 * setup.py (make_shortcut): Changed things to put pdf version in
5436 5442 doc/ instead of doc/manual (had to change lyxport a bit).
5437 5443
5438 5444 * IPython/Magic.py (Profile.string_stats): made profile runs go
5439 5445 through pager (they are long and a pager allows searching, saving,
5440 5446 etc.)
5441 5447
5442 5448 2002-05-08 Fernando Perez <fperez@colorado.edu>
5443 5449
5444 5450 * Released 0.2.12
5445 5451
5446 5452 2002-05-06 Fernando Perez <fperez@colorado.edu>
5447 5453
5448 5454 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5449 5455 introduced); 'hist n1 n2' was broken.
5450 5456 (Magic.magic_pdb): added optional on/off arguments to @pdb
5451 5457 (Magic.magic_run): added option -i to @run, which executes code in
5452 5458 the IPython namespace instead of a clean one. Also added @irun as
5453 5459 an alias to @run -i.
5454 5460
5455 5461 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5456 5462 fixed (it didn't really do anything, the namespaces were wrong).
5457 5463
5458 5464 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5459 5465
5460 5466 * IPython/__init__.py (__all__): Fixed package namespace, now
5461 5467 'import IPython' does give access to IPython.<all> as
5462 5468 expected. Also renamed __release__ to Release.
5463 5469
5464 5470 * IPython/Debugger.py (__license__): created new Pdb class which
5465 5471 functions like a drop-in for the normal pdb.Pdb but does NOT
5466 5472 import readline by default. This way it doesn't muck up IPython's
5467 5473 readline handling, and now tab-completion finally works in the
5468 5474 debugger -- sort of. It completes things globally visible, but the
5469 5475 completer doesn't track the stack as pdb walks it. That's a bit
5470 5476 tricky, and I'll have to implement it later.
5471 5477
5472 5478 2002-05-05 Fernando Perez <fperez@colorado.edu>
5473 5479
5474 5480 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5475 5481 magic docstrings when printed via ? (explicit \'s were being
5476 5482 printed).
5477 5483
5478 5484 * IPython/ipmaker.py (make_IPython): fixed namespace
5479 5485 identification bug. Now variables loaded via logs or command-line
5480 5486 files are recognized in the interactive namespace by @who.
5481 5487
5482 5488 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5483 5489 log replay system stemming from the string form of Structs.
5484 5490
5485 5491 * IPython/Magic.py (Macro.__init__): improved macros to properly
5486 5492 handle magic commands in them.
5487 5493 (Magic.magic_logstart): usernames are now expanded so 'logstart
5488 5494 ~/mylog' now works.
5489 5495
5490 5496 * IPython/iplib.py (complete): fixed bug where paths starting with
5491 5497 '/' would be completed as magic names.
5492 5498
5493 5499 2002-05-04 Fernando Perez <fperez@colorado.edu>
5494 5500
5495 5501 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5496 5502 allow running full programs under the profiler's control.
5497 5503
5498 5504 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5499 5505 mode to report exceptions verbosely but without formatting
5500 5506 variables. This addresses the issue of ipython 'freezing' (it's
5501 5507 not frozen, but caught in an expensive formatting loop) when huge
5502 5508 variables are in the context of an exception.
5503 5509 (VerboseTB.text): Added '--->' markers at line where exception was
5504 5510 triggered. Much clearer to read, especially in NoColor modes.
5505 5511
5506 5512 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5507 5513 implemented in reverse when changing to the new parse_options().
5508 5514
5509 5515 2002-05-03 Fernando Perez <fperez@colorado.edu>
5510 5516
5511 5517 * IPython/Magic.py (Magic.parse_options): new function so that
5512 5518 magics can parse options easier.
5513 5519 (Magic.magic_prun): new function similar to profile.run(),
5514 5520 suggested by Chris Hart.
5515 5521 (Magic.magic_cd): fixed behavior so that it only changes if
5516 5522 directory actually is in history.
5517 5523
5518 5524 * IPython/usage.py (__doc__): added information about potential
5519 5525 slowness of Verbose exception mode when there are huge data
5520 5526 structures to be formatted (thanks to Archie Paulson).
5521 5527
5522 5528 * IPython/ipmaker.py (make_IPython): Changed default logging
5523 5529 (when simply called with -log) to use curr_dir/ipython.log in
5524 5530 rotate mode. Fixed crash which was occuring with -log before
5525 5531 (thanks to Jim Boyle).
5526 5532
5527 5533 2002-05-01 Fernando Perez <fperez@colorado.edu>
5528 5534
5529 5535 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5530 5536 was nasty -- though somewhat of a corner case).
5531 5537
5532 5538 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5533 5539 text (was a bug).
5534 5540
5535 5541 2002-04-30 Fernando Perez <fperez@colorado.edu>
5536 5542
5537 5543 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5538 5544 a print after ^D or ^C from the user so that the In[] prompt
5539 5545 doesn't over-run the gnuplot one.
5540 5546
5541 5547 2002-04-29 Fernando Perez <fperez@colorado.edu>
5542 5548
5543 5549 * Released 0.2.10
5544 5550
5545 5551 * IPython/__release__.py (version): get date dynamically.
5546 5552
5547 5553 * Misc. documentation updates thanks to Arnd's comments. Also ran
5548 5554 a full spellcheck on the manual (hadn't been done in a while).
5549 5555
5550 5556 2002-04-27 Fernando Perez <fperez@colorado.edu>
5551 5557
5552 5558 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5553 5559 starting a log in mid-session would reset the input history list.
5554 5560
5555 5561 2002-04-26 Fernando Perez <fperez@colorado.edu>
5556 5562
5557 5563 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5558 5564 all files were being included in an update. Now anything in
5559 5565 UserConfig that matches [A-Za-z]*.py will go (this excludes
5560 5566 __init__.py)
5561 5567
5562 5568 2002-04-25 Fernando Perez <fperez@colorado.edu>
5563 5569
5564 5570 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5565 5571 to __builtins__ so that any form of embedded or imported code can
5566 5572 test for being inside IPython.
5567 5573
5568 5574 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5569 5575 changed to GnuplotMagic because it's now an importable module,
5570 5576 this makes the name follow that of the standard Gnuplot module.
5571 5577 GnuplotMagic can now be loaded at any time in mid-session.
5572 5578
5573 5579 2002-04-24 Fernando Perez <fperez@colorado.edu>
5574 5580
5575 5581 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5576 5582 the globals (IPython has its own namespace) and the
5577 5583 PhysicalQuantity stuff is much better anyway.
5578 5584
5579 5585 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5580 5586 embedding example to standard user directory for
5581 5587 distribution. Also put it in the manual.
5582 5588
5583 5589 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5584 5590 instance as first argument (so it doesn't rely on some obscure
5585 5591 hidden global).
5586 5592
5587 5593 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5588 5594 delimiters. While it prevents ().TAB from working, it allows
5589 5595 completions in open (... expressions. This is by far a more common
5590 5596 case.
5591 5597
5592 5598 2002-04-23 Fernando Perez <fperez@colorado.edu>
5593 5599
5594 5600 * IPython/Extensions/InterpreterPasteInput.py: new
5595 5601 syntax-processing module for pasting lines with >>> or ... at the
5596 5602 start.
5597 5603
5598 5604 * IPython/Extensions/PhysicalQ_Interactive.py
5599 5605 (PhysicalQuantityInteractive.__int__): fixed to work with either
5600 5606 Numeric or math.
5601 5607
5602 5608 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5603 5609 provided profiles. Now we have:
5604 5610 -math -> math module as * and cmath with its own namespace.
5605 5611 -numeric -> Numeric as *, plus gnuplot & grace
5606 5612 -physics -> same as before
5607 5613
5608 5614 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5609 5615 user-defined magics wouldn't be found by @magic if they were
5610 5616 defined as class methods. Also cleaned up the namespace search
5611 5617 logic and the string building (to use %s instead of many repeated
5612 5618 string adds).
5613 5619
5614 5620 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5615 5621 of user-defined magics to operate with class methods (cleaner, in
5616 5622 line with the gnuplot code).
5617 5623
5618 5624 2002-04-22 Fernando Perez <fperez@colorado.edu>
5619 5625
5620 5626 * setup.py: updated dependency list so that manual is updated when
5621 5627 all included files change.
5622 5628
5623 5629 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5624 5630 the delimiter removal option (the fix is ugly right now).
5625 5631
5626 5632 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5627 5633 all of the math profile (quicker loading, no conflict between
5628 5634 g-9.8 and g-gnuplot).
5629 5635
5630 5636 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5631 5637 name of post-mortem files to IPython_crash_report.txt.
5632 5638
5633 5639 * Cleanup/update of the docs. Added all the new readline info and
5634 5640 formatted all lists as 'real lists'.
5635 5641
5636 5642 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5637 5643 tab-completion options, since the full readline parse_and_bind is
5638 5644 now accessible.
5639 5645
5640 5646 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5641 5647 handling of readline options. Now users can specify any string to
5642 5648 be passed to parse_and_bind(), as well as the delimiters to be
5643 5649 removed.
5644 5650 (InteractiveShell.__init__): Added __name__ to the global
5645 5651 namespace so that things like Itpl which rely on its existence
5646 5652 don't crash.
5647 5653 (InteractiveShell._prefilter): Defined the default with a _ so
5648 5654 that prefilter() is easier to override, while the default one
5649 5655 remains available.
5650 5656
5651 5657 2002-04-18 Fernando Perez <fperez@colorado.edu>
5652 5658
5653 5659 * Added information about pdb in the docs.
5654 5660
5655 5661 2002-04-17 Fernando Perez <fperez@colorado.edu>
5656 5662
5657 5663 * IPython/ipmaker.py (make_IPython): added rc_override option to
5658 5664 allow passing config options at creation time which may override
5659 5665 anything set in the config files or command line. This is
5660 5666 particularly useful for configuring embedded instances.
5661 5667
5662 5668 2002-04-15 Fernando Perez <fperez@colorado.edu>
5663 5669
5664 5670 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5665 5671 crash embedded instances because of the input cache falling out of
5666 5672 sync with the output counter.
5667 5673
5668 5674 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5669 5675 mode which calls pdb after an uncaught exception in IPython itself.
5670 5676
5671 5677 2002-04-14 Fernando Perez <fperez@colorado.edu>
5672 5678
5673 5679 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5674 5680 readline, fix it back after each call.
5675 5681
5676 5682 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5677 5683 method to force all access via __call__(), which guarantees that
5678 5684 traceback references are properly deleted.
5679 5685
5680 5686 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5681 5687 improve printing when pprint is in use.
5682 5688
5683 5689 2002-04-13 Fernando Perez <fperez@colorado.edu>
5684 5690
5685 5691 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5686 5692 exceptions aren't caught anymore. If the user triggers one, he
5687 5693 should know why he's doing it and it should go all the way up,
5688 5694 just like any other exception. So now @abort will fully kill the
5689 5695 embedded interpreter and the embedding code (unless that happens
5690 5696 to catch SystemExit).
5691 5697
5692 5698 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5693 5699 and a debugger() method to invoke the interactive pdb debugger
5694 5700 after printing exception information. Also added the corresponding
5695 5701 -pdb option and @pdb magic to control this feature, and updated
5696 5702 the docs. After a suggestion from Christopher Hart
5697 5703 (hart-AT-caltech.edu).
5698 5704
5699 5705 2002-04-12 Fernando Perez <fperez@colorado.edu>
5700 5706
5701 5707 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5702 5708 the exception handlers defined by the user (not the CrashHandler)
5703 5709 so that user exceptions don't trigger an ipython bug report.
5704 5710
5705 5711 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5706 5712 configurable (it should have always been so).
5707 5713
5708 5714 2002-03-26 Fernando Perez <fperez@colorado.edu>
5709 5715
5710 5716 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5711 5717 and there to fix embedding namespace issues. This should all be
5712 5718 done in a more elegant way.
5713 5719
5714 5720 2002-03-25 Fernando Perez <fperez@colorado.edu>
5715 5721
5716 5722 * IPython/genutils.py (get_home_dir): Try to make it work under
5717 5723 win9x also.
5718 5724
5719 5725 2002-03-20 Fernando Perez <fperez@colorado.edu>
5720 5726
5721 5727 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5722 5728 sys.displayhook untouched upon __init__.
5723 5729
5724 5730 2002-03-19 Fernando Perez <fperez@colorado.edu>
5725 5731
5726 5732 * Released 0.2.9 (for embedding bug, basically).
5727 5733
5728 5734 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5729 5735 exceptions so that enclosing shell's state can be restored.
5730 5736
5731 5737 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5732 5738 naming conventions in the .ipython/ dir.
5733 5739
5734 5740 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5735 5741 from delimiters list so filenames with - in them get expanded.
5736 5742
5737 5743 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5738 5744 sys.displayhook not being properly restored after an embedded call.
5739 5745
5740 5746 2002-03-18 Fernando Perez <fperez@colorado.edu>
5741 5747
5742 5748 * Released 0.2.8
5743 5749
5744 5750 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5745 5751 some files weren't being included in a -upgrade.
5746 5752 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5747 5753 on' so that the first tab completes.
5748 5754 (InteractiveShell.handle_magic): fixed bug with spaces around
5749 5755 quotes breaking many magic commands.
5750 5756
5751 5757 * setup.py: added note about ignoring the syntax error messages at
5752 5758 installation.
5753 5759
5754 5760 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5755 5761 streamlining the gnuplot interface, now there's only one magic @gp.
5756 5762
5757 5763 2002-03-17 Fernando Perez <fperez@colorado.edu>
5758 5764
5759 5765 * IPython/UserConfig/magic_gnuplot.py: new name for the
5760 5766 example-magic_pm.py file. Much enhanced system, now with a shell
5761 5767 for communicating directly with gnuplot, one command at a time.
5762 5768
5763 5769 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5764 5770 setting __name__=='__main__'.
5765 5771
5766 5772 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5767 5773 mini-shell for accessing gnuplot from inside ipython. Should
5768 5774 extend it later for grace access too. Inspired by Arnd's
5769 5775 suggestion.
5770 5776
5771 5777 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5772 5778 calling magic functions with () in their arguments. Thanks to Arnd
5773 5779 Baecker for pointing this to me.
5774 5780
5775 5781 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5776 5782 infinitely for integer or complex arrays (only worked with floats).
5777 5783
5778 5784 2002-03-16 Fernando Perez <fperez@colorado.edu>
5779 5785
5780 5786 * setup.py: Merged setup and setup_windows into a single script
5781 5787 which properly handles things for windows users.
5782 5788
5783 5789 2002-03-15 Fernando Perez <fperez@colorado.edu>
5784 5790
5785 5791 * Big change to the manual: now the magics are all automatically
5786 5792 documented. This information is generated from their docstrings
5787 5793 and put in a latex file included by the manual lyx file. This way
5788 5794 we get always up to date information for the magics. The manual
5789 5795 now also has proper version information, also auto-synced.
5790 5796
5791 5797 For this to work, an undocumented --magic_docstrings option was added.
5792 5798
5793 5799 2002-03-13 Fernando Perez <fperez@colorado.edu>
5794 5800
5795 5801 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5796 5802 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5797 5803
5798 5804 2002-03-12 Fernando Perez <fperez@colorado.edu>
5799 5805
5800 5806 * IPython/ultraTB.py (TermColors): changed color escapes again to
5801 5807 fix the (old, reintroduced) line-wrapping bug. Basically, if
5802 5808 \001..\002 aren't given in the color escapes, lines get wrapped
5803 5809 weirdly. But giving those screws up old xterms and emacs terms. So
5804 5810 I added some logic for emacs terms to be ok, but I can't identify old
5805 5811 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5806 5812
5807 5813 2002-03-10 Fernando Perez <fperez@colorado.edu>
5808 5814
5809 5815 * IPython/usage.py (__doc__): Various documentation cleanups and
5810 5816 updates, both in usage docstrings and in the manual.
5811 5817
5812 5818 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5813 5819 handling of caching. Set minimum acceptabe value for having a
5814 5820 cache at 20 values.
5815 5821
5816 5822 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5817 5823 install_first_time function to a method, renamed it and added an
5818 5824 'upgrade' mode. Now people can update their config directory with
5819 5825 a simple command line switch (-upgrade, also new).
5820 5826
5821 5827 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5822 5828 @file (convenient for automagic users under Python >= 2.2).
5823 5829 Removed @files (it seemed more like a plural than an abbrev. of
5824 5830 'file show').
5825 5831
5826 5832 * IPython/iplib.py (install_first_time): Fixed crash if there were
5827 5833 backup files ('~') in .ipython/ install directory.
5828 5834
5829 5835 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5830 5836 system. Things look fine, but these changes are fairly
5831 5837 intrusive. Test them for a few days.
5832 5838
5833 5839 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5834 5840 the prompts system. Now all in/out prompt strings are user
5835 5841 controllable. This is particularly useful for embedding, as one
5836 5842 can tag embedded instances with particular prompts.
5837 5843
5838 5844 Also removed global use of sys.ps1/2, which now allows nested
5839 5845 embeddings without any problems. Added command-line options for
5840 5846 the prompt strings.
5841 5847
5842 5848 2002-03-08 Fernando Perez <fperez@colorado.edu>
5843 5849
5844 5850 * IPython/UserConfig/example-embed-short.py (ipshell): added
5845 5851 example file with the bare minimum code for embedding.
5846 5852
5847 5853 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5848 5854 functionality for the embeddable shell to be activated/deactivated
5849 5855 either globally or at each call.
5850 5856
5851 5857 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5852 5858 rewriting the prompt with '--->' for auto-inputs with proper
5853 5859 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5854 5860 this is handled by the prompts class itself, as it should.
5855 5861
5856 5862 2002-03-05 Fernando Perez <fperez@colorado.edu>
5857 5863
5858 5864 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5859 5865 @logstart to avoid name clashes with the math log function.
5860 5866
5861 5867 * Big updates to X/Emacs section of the manual.
5862 5868
5863 5869 * Removed ipython_emacs. Milan explained to me how to pass
5864 5870 arguments to ipython through Emacs. Some day I'm going to end up
5865 5871 learning some lisp...
5866 5872
5867 5873 2002-03-04 Fernando Perez <fperez@colorado.edu>
5868 5874
5869 5875 * IPython/ipython_emacs: Created script to be used as the
5870 5876 py-python-command Emacs variable so we can pass IPython
5871 5877 parameters. I can't figure out how to tell Emacs directly to pass
5872 5878 parameters to IPython, so a dummy shell script will do it.
5873 5879
5874 5880 Other enhancements made for things to work better under Emacs'
5875 5881 various types of terminals. Many thanks to Milan Zamazal
5876 5882 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5877 5883
5878 5884 2002-03-01 Fernando Perez <fperez@colorado.edu>
5879 5885
5880 5886 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5881 5887 that loading of readline is now optional. This gives better
5882 5888 control to emacs users.
5883 5889
5884 5890 * IPython/ultraTB.py (__date__): Modified color escape sequences
5885 5891 and now things work fine under xterm and in Emacs' term buffers
5886 5892 (though not shell ones). Well, in emacs you get colors, but all
5887 5893 seem to be 'light' colors (no difference between dark and light
5888 5894 ones). But the garbage chars are gone, and also in xterms. It
5889 5895 seems that now I'm using 'cleaner' ansi sequences.
5890 5896
5891 5897 2002-02-21 Fernando Perez <fperez@colorado.edu>
5892 5898
5893 5899 * Released 0.2.7 (mainly to publish the scoping fix).
5894 5900
5895 5901 * IPython/Logger.py (Logger.logstate): added. A corresponding
5896 5902 @logstate magic was created.
5897 5903
5898 5904 * IPython/Magic.py: fixed nested scoping problem under Python
5899 5905 2.1.x (automagic wasn't working).
5900 5906
5901 5907 2002-02-20 Fernando Perez <fperez@colorado.edu>
5902 5908
5903 5909 * Released 0.2.6.
5904 5910
5905 5911 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5906 5912 option so that logs can come out without any headers at all.
5907 5913
5908 5914 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5909 5915 SciPy.
5910 5916
5911 5917 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5912 5918 that embedded IPython calls don't require vars() to be explicitly
5913 5919 passed. Now they are extracted from the caller's frame (code
5914 5920 snatched from Eric Jones' weave). Added better documentation to
5915 5921 the section on embedding and the example file.
5916 5922
5917 5923 * IPython/genutils.py (page): Changed so that under emacs, it just
5918 5924 prints the string. You can then page up and down in the emacs
5919 5925 buffer itself. This is how the builtin help() works.
5920 5926
5921 5927 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5922 5928 macro scoping: macros need to be executed in the user's namespace
5923 5929 to work as if they had been typed by the user.
5924 5930
5925 5931 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5926 5932 execute automatically (no need to type 'exec...'). They then
5927 5933 behave like 'true macros'. The printing system was also modified
5928 5934 for this to work.
5929 5935
5930 5936 2002-02-19 Fernando Perez <fperez@colorado.edu>
5931 5937
5932 5938 * IPython/genutils.py (page_file): new function for paging files
5933 5939 in an OS-independent way. Also necessary for file viewing to work
5934 5940 well inside Emacs buffers.
5935 5941 (page): Added checks for being in an emacs buffer.
5936 5942 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5937 5943 same bug in iplib.
5938 5944
5939 5945 2002-02-18 Fernando Perez <fperez@colorado.edu>
5940 5946
5941 5947 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5942 5948 of readline so that IPython can work inside an Emacs buffer.
5943 5949
5944 5950 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5945 5951 method signatures (they weren't really bugs, but it looks cleaner
5946 5952 and keeps PyChecker happy).
5947 5953
5948 5954 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5949 5955 for implementing various user-defined hooks. Currently only
5950 5956 display is done.
5951 5957
5952 5958 * IPython/Prompts.py (CachedOutput._display): changed display
5953 5959 functions so that they can be dynamically changed by users easily.
5954 5960
5955 5961 * IPython/Extensions/numeric_formats.py (num_display): added an
5956 5962 extension for printing NumPy arrays in flexible manners. It
5957 5963 doesn't do anything yet, but all the structure is in
5958 5964 place. Ultimately the plan is to implement output format control
5959 5965 like in Octave.
5960 5966
5961 5967 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5962 5968 methods are found at run-time by all the automatic machinery.
5963 5969
5964 5970 2002-02-17 Fernando Perez <fperez@colorado.edu>
5965 5971
5966 5972 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5967 5973 whole file a little.
5968 5974
5969 5975 * ToDo: closed this document. Now there's a new_design.lyx
5970 5976 document for all new ideas. Added making a pdf of it for the
5971 5977 end-user distro.
5972 5978
5973 5979 * IPython/Logger.py (Logger.switch_log): Created this to replace
5974 5980 logon() and logoff(). It also fixes a nasty crash reported by
5975 5981 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5976 5982
5977 5983 * IPython/iplib.py (complete): got auto-completion to work with
5978 5984 automagic (I had wanted this for a long time).
5979 5985
5980 5986 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5981 5987 to @file, since file() is now a builtin and clashes with automagic
5982 5988 for @file.
5983 5989
5984 5990 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5985 5991 of this was previously in iplib, which had grown to more than 2000
5986 5992 lines, way too long. No new functionality, but it makes managing
5987 5993 the code a bit easier.
5988 5994
5989 5995 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5990 5996 information to crash reports.
5991 5997
5992 5998 2002-02-12 Fernando Perez <fperez@colorado.edu>
5993 5999
5994 6000 * Released 0.2.5.
5995 6001
5996 6002 2002-02-11 Fernando Perez <fperez@colorado.edu>
5997 6003
5998 6004 * Wrote a relatively complete Windows installer. It puts
5999 6005 everything in place, creates Start Menu entries and fixes the
6000 6006 color issues. Nothing fancy, but it works.
6001 6007
6002 6008 2002-02-10 Fernando Perez <fperez@colorado.edu>
6003 6009
6004 6010 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
6005 6011 os.path.expanduser() call so that we can type @run ~/myfile.py and
6006 6012 have thigs work as expected.
6007 6013
6008 6014 * IPython/genutils.py (page): fixed exception handling so things
6009 6015 work both in Unix and Windows correctly. Quitting a pager triggers
6010 6016 an IOError/broken pipe in Unix, and in windows not finding a pager
6011 6017 is also an IOError, so I had to actually look at the return value
6012 6018 of the exception, not just the exception itself. Should be ok now.
6013 6019
6014 6020 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6015 6021 modified to allow case-insensitive color scheme changes.
6016 6022
6017 6023 2002-02-09 Fernando Perez <fperez@colorado.edu>
6018 6024
6019 6025 * IPython/genutils.py (native_line_ends): new function to leave
6020 6026 user config files with os-native line-endings.
6021 6027
6022 6028 * README and manual updates.
6023 6029
6024 6030 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6025 6031 instead of StringType to catch Unicode strings.
6026 6032
6027 6033 * IPython/genutils.py (filefind): fixed bug for paths with
6028 6034 embedded spaces (very common in Windows).
6029 6035
6030 6036 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6031 6037 files under Windows, so that they get automatically associated
6032 6038 with a text editor. Windows makes it a pain to handle
6033 6039 extension-less files.
6034 6040
6035 6041 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6036 6042 warning about readline only occur for Posix. In Windows there's no
6037 6043 way to get readline, so why bother with the warning.
6038 6044
6039 6045 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6040 6046 for __str__ instead of dir(self), since dir() changed in 2.2.
6041 6047
6042 6048 * Ported to Windows! Tested on XP, I suspect it should work fine
6043 6049 on NT/2000, but I don't think it will work on 98 et al. That
6044 6050 series of Windows is such a piece of junk anyway that I won't try
6045 6051 porting it there. The XP port was straightforward, showed a few
6046 6052 bugs here and there (fixed all), in particular some string
6047 6053 handling stuff which required considering Unicode strings (which
6048 6054 Windows uses). This is good, but hasn't been too tested :) No
6049 6055 fancy installer yet, I'll put a note in the manual so people at
6050 6056 least make manually a shortcut.
6051 6057
6052 6058 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6053 6059 into a single one, "colors". This now controls both prompt and
6054 6060 exception color schemes, and can be changed both at startup
6055 6061 (either via command-line switches or via ipythonrc files) and at
6056 6062 runtime, with @colors.
6057 6063 (Magic.magic_run): renamed @prun to @run and removed the old
6058 6064 @run. The two were too similar to warrant keeping both.
6059 6065
6060 6066 2002-02-03 Fernando Perez <fperez@colorado.edu>
6061 6067
6062 6068 * IPython/iplib.py (install_first_time): Added comment on how to
6063 6069 configure the color options for first-time users. Put a <return>
6064 6070 request at the end so that small-terminal users get a chance to
6065 6071 read the startup info.
6066 6072
6067 6073 2002-01-23 Fernando Perez <fperez@colorado.edu>
6068 6074
6069 6075 * IPython/iplib.py (CachedOutput.update): Changed output memory
6070 6076 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6071 6077 input history we still use _i. Did this b/c these variable are
6072 6078 very commonly used in interactive work, so the less we need to
6073 6079 type the better off we are.
6074 6080 (Magic.magic_prun): updated @prun to better handle the namespaces
6075 6081 the file will run in, including a fix for __name__ not being set
6076 6082 before.
6077 6083
6078 6084 2002-01-20 Fernando Perez <fperez@colorado.edu>
6079 6085
6080 6086 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6081 6087 extra garbage for Python 2.2. Need to look more carefully into
6082 6088 this later.
6083 6089
6084 6090 2002-01-19 Fernando Perez <fperez@colorado.edu>
6085 6091
6086 6092 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6087 6093 display SyntaxError exceptions properly formatted when they occur
6088 6094 (they can be triggered by imported code).
6089 6095
6090 6096 2002-01-18 Fernando Perez <fperez@colorado.edu>
6091 6097
6092 6098 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6093 6099 SyntaxError exceptions are reported nicely formatted, instead of
6094 6100 spitting out only offset information as before.
6095 6101 (Magic.magic_prun): Added the @prun function for executing
6096 6102 programs with command line args inside IPython.
6097 6103
6098 6104 2002-01-16 Fernando Perez <fperez@colorado.edu>
6099 6105
6100 6106 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6101 6107 to *not* include the last item given in a range. This brings their
6102 6108 behavior in line with Python's slicing:
6103 6109 a[n1:n2] -> a[n1]...a[n2-1]
6104 6110 It may be a bit less convenient, but I prefer to stick to Python's
6105 6111 conventions *everywhere*, so users never have to wonder.
6106 6112 (Magic.magic_macro): Added @macro function to ease the creation of
6107 6113 macros.
6108 6114
6109 6115 2002-01-05 Fernando Perez <fperez@colorado.edu>
6110 6116
6111 6117 * Released 0.2.4.
6112 6118
6113 6119 * IPython/iplib.py (Magic.magic_pdef):
6114 6120 (InteractiveShell.safe_execfile): report magic lines and error
6115 6121 lines without line numbers so one can easily copy/paste them for
6116 6122 re-execution.
6117 6123
6118 6124 * Updated manual with recent changes.
6119 6125
6120 6126 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6121 6127 docstring printing when class? is called. Very handy for knowing
6122 6128 how to create class instances (as long as __init__ is well
6123 6129 documented, of course :)
6124 6130 (Magic.magic_doc): print both class and constructor docstrings.
6125 6131 (Magic.magic_pdef): give constructor info if passed a class and
6126 6132 __call__ info for callable object instances.
6127 6133
6128 6134 2002-01-04 Fernando Perez <fperez@colorado.edu>
6129 6135
6130 6136 * Made deep_reload() off by default. It doesn't always work
6131 6137 exactly as intended, so it's probably safer to have it off. It's
6132 6138 still available as dreload() anyway, so nothing is lost.
6133 6139
6134 6140 2002-01-02 Fernando Perez <fperez@colorado.edu>
6135 6141
6136 6142 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6137 6143 so I wanted an updated release).
6138 6144
6139 6145 2001-12-27 Fernando Perez <fperez@colorado.edu>
6140 6146
6141 6147 * IPython/iplib.py (InteractiveShell.interact): Added the original
6142 6148 code from 'code.py' for this module in order to change the
6143 6149 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6144 6150 the history cache would break when the user hit Ctrl-C, and
6145 6151 interact() offers no way to add any hooks to it.
6146 6152
6147 6153 2001-12-23 Fernando Perez <fperez@colorado.edu>
6148 6154
6149 6155 * setup.py: added check for 'MANIFEST' before trying to remove
6150 6156 it. Thanks to Sean Reifschneider.
6151 6157
6152 6158 2001-12-22 Fernando Perez <fperez@colorado.edu>
6153 6159
6154 6160 * Released 0.2.2.
6155 6161
6156 6162 * Finished (reasonably) writing the manual. Later will add the
6157 6163 python-standard navigation stylesheets, but for the time being
6158 6164 it's fairly complete. Distribution will include html and pdf
6159 6165 versions.
6160 6166
6161 6167 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6162 6168 (MayaVi author).
6163 6169
6164 6170 2001-12-21 Fernando Perez <fperez@colorado.edu>
6165 6171
6166 6172 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6167 6173 good public release, I think (with the manual and the distutils
6168 6174 installer). The manual can use some work, but that can go
6169 6175 slowly. Otherwise I think it's quite nice for end users. Next
6170 6176 summer, rewrite the guts of it...
6171 6177
6172 6178 * Changed format of ipythonrc files to use whitespace as the
6173 6179 separator instead of an explicit '='. Cleaner.
6174 6180
6175 6181 2001-12-20 Fernando Perez <fperez@colorado.edu>
6176 6182
6177 6183 * Started a manual in LyX. For now it's just a quick merge of the
6178 6184 various internal docstrings and READMEs. Later it may grow into a
6179 6185 nice, full-blown manual.
6180 6186
6181 6187 * Set up a distutils based installer. Installation should now be
6182 6188 trivially simple for end-users.
6183 6189
6184 6190 2001-12-11 Fernando Perez <fperez@colorado.edu>
6185 6191
6186 6192 * Released 0.2.0. First public release, announced it at
6187 6193 comp.lang.python. From now on, just bugfixes...
6188 6194
6189 6195 * Went through all the files, set copyright/license notices and
6190 6196 cleaned up things. Ready for release.
6191 6197
6192 6198 2001-12-10 Fernando Perez <fperez@colorado.edu>
6193 6199
6194 6200 * Changed the first-time installer not to use tarfiles. It's more
6195 6201 robust now and less unix-dependent. Also makes it easier for
6196 6202 people to later upgrade versions.
6197 6203
6198 6204 * Changed @exit to @abort to reflect the fact that it's pretty
6199 6205 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6200 6206 becomes significant only when IPyhton is embedded: in that case,
6201 6207 C-D closes IPython only, but @abort kills the enclosing program
6202 6208 too (unless it had called IPython inside a try catching
6203 6209 SystemExit).
6204 6210
6205 6211 * Created Shell module which exposes the actuall IPython Shell
6206 6212 classes, currently the normal and the embeddable one. This at
6207 6213 least offers a stable interface we won't need to change when
6208 6214 (later) the internals are rewritten. That rewrite will be confined
6209 6215 to iplib and ipmaker, but the Shell interface should remain as is.
6210 6216
6211 6217 * Added embed module which offers an embeddable IPShell object,
6212 6218 useful to fire up IPython *inside* a running program. Great for
6213 6219 debugging or dynamical data analysis.
6214 6220
6215 6221 2001-12-08 Fernando Perez <fperez@colorado.edu>
6216 6222
6217 6223 * Fixed small bug preventing seeing info from methods of defined
6218 6224 objects (incorrect namespace in _ofind()).
6219 6225
6220 6226 * Documentation cleanup. Moved the main usage docstrings to a
6221 6227 separate file, usage.py (cleaner to maintain, and hopefully in the
6222 6228 future some perlpod-like way of producing interactive, man and
6223 6229 html docs out of it will be found).
6224 6230
6225 6231 * Added @profile to see your profile at any time.
6226 6232
6227 6233 * Added @p as an alias for 'print'. It's especially convenient if
6228 6234 using automagic ('p x' prints x).
6229 6235
6230 6236 * Small cleanups and fixes after a pychecker run.
6231 6237
6232 6238 * Changed the @cd command to handle @cd - and @cd -<n> for
6233 6239 visiting any directory in _dh.
6234 6240
6235 6241 * Introduced _dh, a history of visited directories. @dhist prints
6236 6242 it out with numbers.
6237 6243
6238 6244 2001-12-07 Fernando Perez <fperez@colorado.edu>
6239 6245
6240 6246 * Released 0.1.22
6241 6247
6242 6248 * Made initialization a bit more robust against invalid color
6243 6249 options in user input (exit, not traceback-crash).
6244 6250
6245 6251 * Changed the bug crash reporter to write the report only in the
6246 6252 user's .ipython directory. That way IPython won't litter people's
6247 6253 hard disks with crash files all over the place. Also print on
6248 6254 screen the necessary mail command.
6249 6255
6250 6256 * With the new ultraTB, implemented LightBG color scheme for light
6251 6257 background terminals. A lot of people like white backgrounds, so I
6252 6258 guess we should at least give them something readable.
6253 6259
6254 6260 2001-12-06 Fernando Perez <fperez@colorado.edu>
6255 6261
6256 6262 * Modified the structure of ultraTB. Now there's a proper class
6257 6263 for tables of color schemes which allow adding schemes easily and
6258 6264 switching the active scheme without creating a new instance every
6259 6265 time (which was ridiculous). The syntax for creating new schemes
6260 6266 is also cleaner. I think ultraTB is finally done, with a clean
6261 6267 class structure. Names are also much cleaner (now there's proper
6262 6268 color tables, no need for every variable to also have 'color' in
6263 6269 its name).
6264 6270
6265 6271 * Broke down genutils into separate files. Now genutils only
6266 6272 contains utility functions, and classes have been moved to their
6267 6273 own files (they had enough independent functionality to warrant
6268 6274 it): ConfigLoader, OutputTrap, Struct.
6269 6275
6270 6276 2001-12-05 Fernando Perez <fperez@colorado.edu>
6271 6277
6272 6278 * IPython turns 21! Released version 0.1.21, as a candidate for
6273 6279 public consumption. If all goes well, release in a few days.
6274 6280
6275 6281 * Fixed path bug (files in Extensions/ directory wouldn't be found
6276 6282 unless IPython/ was explicitly in sys.path).
6277 6283
6278 6284 * Extended the FlexCompleter class as MagicCompleter to allow
6279 6285 completion of @-starting lines.
6280 6286
6281 6287 * Created __release__.py file as a central repository for release
6282 6288 info that other files can read from.
6283 6289
6284 6290 * Fixed small bug in logging: when logging was turned on in
6285 6291 mid-session, old lines with special meanings (!@?) were being
6286 6292 logged without the prepended comment, which is necessary since
6287 6293 they are not truly valid python syntax. This should make session
6288 6294 restores produce less errors.
6289 6295
6290 6296 * The namespace cleanup forced me to make a FlexCompleter class
6291 6297 which is nothing but a ripoff of rlcompleter, but with selectable
6292 6298 namespace (rlcompleter only works in __main__.__dict__). I'll try
6293 6299 to submit a note to the authors to see if this change can be
6294 6300 incorporated in future rlcompleter releases (Dec.6: done)
6295 6301
6296 6302 * More fixes to namespace handling. It was a mess! Now all
6297 6303 explicit references to __main__.__dict__ are gone (except when
6298 6304 really needed) and everything is handled through the namespace
6299 6305 dicts in the IPython instance. We seem to be getting somewhere
6300 6306 with this, finally...
6301 6307
6302 6308 * Small documentation updates.
6303 6309
6304 6310 * Created the Extensions directory under IPython (with an
6305 6311 __init__.py). Put the PhysicalQ stuff there. This directory should
6306 6312 be used for all special-purpose extensions.
6307 6313
6308 6314 * File renaming:
6309 6315 ipythonlib --> ipmaker
6310 6316 ipplib --> iplib
6311 6317 This makes a bit more sense in terms of what these files actually do.
6312 6318
6313 6319 * Moved all the classes and functions in ipythonlib to ipplib, so
6314 6320 now ipythonlib only has make_IPython(). This will ease up its
6315 6321 splitting in smaller functional chunks later.
6316 6322
6317 6323 * Cleaned up (done, I think) output of @whos. Better column
6318 6324 formatting, and now shows str(var) for as much as it can, which is
6319 6325 typically what one gets with a 'print var'.
6320 6326
6321 6327 2001-12-04 Fernando Perez <fperez@colorado.edu>
6322 6328
6323 6329 * Fixed namespace problems. Now builtin/IPyhton/user names get
6324 6330 properly reported in their namespace. Internal namespace handling
6325 6331 is finally getting decent (not perfect yet, but much better than
6326 6332 the ad-hoc mess we had).
6327 6333
6328 6334 * Removed -exit option. If people just want to run a python
6329 6335 script, that's what the normal interpreter is for. Less
6330 6336 unnecessary options, less chances for bugs.
6331 6337
6332 6338 * Added a crash handler which generates a complete post-mortem if
6333 6339 IPython crashes. This will help a lot in tracking bugs down the
6334 6340 road.
6335 6341
6336 6342 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6337 6343 which were boud to functions being reassigned would bypass the
6338 6344 logger, breaking the sync of _il with the prompt counter. This
6339 6345 would then crash IPython later when a new line was logged.
6340 6346
6341 6347 2001-12-02 Fernando Perez <fperez@colorado.edu>
6342 6348
6343 6349 * Made IPython a package. This means people don't have to clutter
6344 6350 their sys.path with yet another directory. Changed the INSTALL
6345 6351 file accordingly.
6346 6352
6347 6353 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6348 6354 sorts its output (so @who shows it sorted) and @whos formats the
6349 6355 table according to the width of the first column. Nicer, easier to
6350 6356 read. Todo: write a generic table_format() which takes a list of
6351 6357 lists and prints it nicely formatted, with optional row/column
6352 6358 separators and proper padding and justification.
6353 6359
6354 6360 * Released 0.1.20
6355 6361
6356 6362 * Fixed bug in @log which would reverse the inputcache list (a
6357 6363 copy operation was missing).
6358 6364
6359 6365 * Code cleanup. @config was changed to use page(). Better, since
6360 6366 its output is always quite long.
6361 6367
6362 6368 * Itpl is back as a dependency. I was having too many problems
6363 6369 getting the parametric aliases to work reliably, and it's just
6364 6370 easier to code weird string operations with it than playing %()s
6365 6371 games. It's only ~6k, so I don't think it's too big a deal.
6366 6372
6367 6373 * Found (and fixed) a very nasty bug with history. !lines weren't
6368 6374 getting cached, and the out of sync caches would crash
6369 6375 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6370 6376 division of labor a bit better. Bug fixed, cleaner structure.
6371 6377
6372 6378 2001-12-01 Fernando Perez <fperez@colorado.edu>
6373 6379
6374 6380 * Released 0.1.19
6375 6381
6376 6382 * Added option -n to @hist to prevent line number printing. Much
6377 6383 easier to copy/paste code this way.
6378 6384
6379 6385 * Created global _il to hold the input list. Allows easy
6380 6386 re-execution of blocks of code by slicing it (inspired by Janko's
6381 6387 comment on 'macros').
6382 6388
6383 6389 * Small fixes and doc updates.
6384 6390
6385 6391 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6386 6392 much too fragile with automagic. Handles properly multi-line
6387 6393 statements and takes parameters.
6388 6394
6389 6395 2001-11-30 Fernando Perez <fperez@colorado.edu>
6390 6396
6391 6397 * Version 0.1.18 released.
6392 6398
6393 6399 * Fixed nasty namespace bug in initial module imports.
6394 6400
6395 6401 * Added copyright/license notes to all code files (except
6396 6402 DPyGetOpt). For the time being, LGPL. That could change.
6397 6403
6398 6404 * Rewrote a much nicer README, updated INSTALL, cleaned up
6399 6405 ipythonrc-* samples.
6400 6406
6401 6407 * Overall code/documentation cleanup. Basically ready for
6402 6408 release. Only remaining thing: licence decision (LGPL?).
6403 6409
6404 6410 * Converted load_config to a class, ConfigLoader. Now recursion
6405 6411 control is better organized. Doesn't include the same file twice.
6406 6412
6407 6413 2001-11-29 Fernando Perez <fperez@colorado.edu>
6408 6414
6409 6415 * Got input history working. Changed output history variables from
6410 6416 _p to _o so that _i is for input and _o for output. Just cleaner
6411 6417 convention.
6412 6418
6413 6419 * Implemented parametric aliases. This pretty much allows the
6414 6420 alias system to offer full-blown shell convenience, I think.
6415 6421
6416 6422 * Version 0.1.17 released, 0.1.18 opened.
6417 6423
6418 6424 * dot_ipython/ipythonrc (alias): added documentation.
6419 6425 (xcolor): Fixed small bug (xcolors -> xcolor)
6420 6426
6421 6427 * Changed the alias system. Now alias is a magic command to define
6422 6428 aliases just like the shell. Rationale: the builtin magics should
6423 6429 be there for things deeply connected to IPython's
6424 6430 architecture. And this is a much lighter system for what I think
6425 6431 is the really important feature: allowing users to define quickly
6426 6432 magics that will do shell things for them, so they can customize
6427 6433 IPython easily to match their work habits. If someone is really
6428 6434 desperate to have another name for a builtin alias, they can
6429 6435 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6430 6436 works.
6431 6437
6432 6438 2001-11-28 Fernando Perez <fperez@colorado.edu>
6433 6439
6434 6440 * Changed @file so that it opens the source file at the proper
6435 6441 line. Since it uses less, if your EDITOR environment is
6436 6442 configured, typing v will immediately open your editor of choice
6437 6443 right at the line where the object is defined. Not as quick as
6438 6444 having a direct @edit command, but for all intents and purposes it
6439 6445 works. And I don't have to worry about writing @edit to deal with
6440 6446 all the editors, less does that.
6441 6447
6442 6448 * Version 0.1.16 released, 0.1.17 opened.
6443 6449
6444 6450 * Fixed some nasty bugs in the page/page_dumb combo that could
6445 6451 crash IPython.
6446 6452
6447 6453 2001-11-27 Fernando Perez <fperez@colorado.edu>
6448 6454
6449 6455 * Version 0.1.15 released, 0.1.16 opened.
6450 6456
6451 6457 * Finally got ? and ?? to work for undefined things: now it's
6452 6458 possible to type {}.get? and get information about the get method
6453 6459 of dicts, or os.path? even if only os is defined (so technically
6454 6460 os.path isn't). Works at any level. For example, after import os,
6455 6461 os?, os.path?, os.path.abspath? all work. This is great, took some
6456 6462 work in _ofind.
6457 6463
6458 6464 * Fixed more bugs with logging. The sanest way to do it was to add
6459 6465 to @log a 'mode' parameter. Killed two in one shot (this mode
6460 6466 option was a request of Janko's). I think it's finally clean
6461 6467 (famous last words).
6462 6468
6463 6469 * Added a page_dumb() pager which does a decent job of paging on
6464 6470 screen, if better things (like less) aren't available. One less
6465 6471 unix dependency (someday maybe somebody will port this to
6466 6472 windows).
6467 6473
6468 6474 * Fixed problem in magic_log: would lock of logging out if log
6469 6475 creation failed (because it would still think it had succeeded).
6470 6476
6471 6477 * Improved the page() function using curses to auto-detect screen
6472 6478 size. Now it can make a much better decision on whether to print
6473 6479 or page a string. Option screen_length was modified: a value 0
6474 6480 means auto-detect, and that's the default now.
6475 6481
6476 6482 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6477 6483 go out. I'll test it for a few days, then talk to Janko about
6478 6484 licences and announce it.
6479 6485
6480 6486 * Fixed the length of the auto-generated ---> prompt which appears
6481 6487 for auto-parens and auto-quotes. Getting this right isn't trivial,
6482 6488 with all the color escapes, different prompt types and optional
6483 6489 separators. But it seems to be working in all the combinations.
6484 6490
6485 6491 2001-11-26 Fernando Perez <fperez@colorado.edu>
6486 6492
6487 6493 * Wrote a regexp filter to get option types from the option names
6488 6494 string. This eliminates the need to manually keep two duplicate
6489 6495 lists.
6490 6496
6491 6497 * Removed the unneeded check_option_names. Now options are handled
6492 6498 in a much saner manner and it's easy to visually check that things
6493 6499 are ok.
6494 6500
6495 6501 * Updated version numbers on all files I modified to carry a
6496 6502 notice so Janko and Nathan have clear version markers.
6497 6503
6498 6504 * Updated docstring for ultraTB with my changes. I should send
6499 6505 this to Nathan.
6500 6506
6501 6507 * Lots of small fixes. Ran everything through pychecker again.
6502 6508
6503 6509 * Made loading of deep_reload an cmd line option. If it's not too
6504 6510 kosher, now people can just disable it. With -nodeep_reload it's
6505 6511 still available as dreload(), it just won't overwrite reload().
6506 6512
6507 6513 * Moved many options to the no| form (-opt and -noopt
6508 6514 accepted). Cleaner.
6509 6515
6510 6516 * Changed magic_log so that if called with no parameters, it uses
6511 6517 'rotate' mode. That way auto-generated logs aren't automatically
6512 6518 over-written. For normal logs, now a backup is made if it exists
6513 6519 (only 1 level of backups). A new 'backup' mode was added to the
6514 6520 Logger class to support this. This was a request by Janko.
6515 6521
6516 6522 * Added @logoff/@logon to stop/restart an active log.
6517 6523
6518 6524 * Fixed a lot of bugs in log saving/replay. It was pretty
6519 6525 broken. Now special lines (!@,/) appear properly in the command
6520 6526 history after a log replay.
6521 6527
6522 6528 * Tried and failed to implement full session saving via pickle. My
6523 6529 idea was to pickle __main__.__dict__, but modules can't be
6524 6530 pickled. This would be a better alternative to replaying logs, but
6525 6531 seems quite tricky to get to work. Changed -session to be called
6526 6532 -logplay, which more accurately reflects what it does. And if we
6527 6533 ever get real session saving working, -session is now available.
6528 6534
6529 6535 * Implemented color schemes for prompts also. As for tracebacks,
6530 6536 currently only NoColor and Linux are supported. But now the
6531 6537 infrastructure is in place, based on a generic ColorScheme
6532 6538 class. So writing and activating new schemes both for the prompts
6533 6539 and the tracebacks should be straightforward.
6534 6540
6535 6541 * Version 0.1.13 released, 0.1.14 opened.
6536 6542
6537 6543 * Changed handling of options for output cache. Now counter is
6538 6544 hardwired starting at 1 and one specifies the maximum number of
6539 6545 entries *in the outcache* (not the max prompt counter). This is
6540 6546 much better, since many statements won't increase the cache
6541 6547 count. It also eliminated some confusing options, now there's only
6542 6548 one: cache_size.
6543 6549
6544 6550 * Added 'alias' magic function and magic_alias option in the
6545 6551 ipythonrc file. Now the user can easily define whatever names he
6546 6552 wants for the magic functions without having to play weird
6547 6553 namespace games. This gives IPython a real shell-like feel.
6548 6554
6549 6555 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6550 6556 @ or not).
6551 6557
6552 6558 This was one of the last remaining 'visible' bugs (that I know
6553 6559 of). I think if I can clean up the session loading so it works
6554 6560 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6555 6561 about licensing).
6556 6562
6557 6563 2001-11-25 Fernando Perez <fperez@colorado.edu>
6558 6564
6559 6565 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6560 6566 there's a cleaner distinction between what ? and ?? show.
6561 6567
6562 6568 * Added screen_length option. Now the user can define his own
6563 6569 screen size for page() operations.
6564 6570
6565 6571 * Implemented magic shell-like functions with automatic code
6566 6572 generation. Now adding another function is just a matter of adding
6567 6573 an entry to a dict, and the function is dynamically generated at
6568 6574 run-time. Python has some really cool features!
6569 6575
6570 6576 * Renamed many options to cleanup conventions a little. Now all
6571 6577 are lowercase, and only underscores where needed. Also in the code
6572 6578 option name tables are clearer.
6573 6579
6574 6580 * Changed prompts a little. Now input is 'In [n]:' instead of
6575 6581 'In[n]:='. This allows it the numbers to be aligned with the
6576 6582 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6577 6583 Python (it was a Mathematica thing). The '...' continuation prompt
6578 6584 was also changed a little to align better.
6579 6585
6580 6586 * Fixed bug when flushing output cache. Not all _p<n> variables
6581 6587 exist, so their deletion needs to be wrapped in a try:
6582 6588
6583 6589 * Figured out how to properly use inspect.formatargspec() (it
6584 6590 requires the args preceded by *). So I removed all the code from
6585 6591 _get_pdef in Magic, which was just replicating that.
6586 6592
6587 6593 * Added test to prefilter to allow redefining magic function names
6588 6594 as variables. This is ok, since the @ form is always available,
6589 6595 but whe should allow the user to define a variable called 'ls' if
6590 6596 he needs it.
6591 6597
6592 6598 * Moved the ToDo information from README into a separate ToDo.
6593 6599
6594 6600 * General code cleanup and small bugfixes. I think it's close to a
6595 6601 state where it can be released, obviously with a big 'beta'
6596 6602 warning on it.
6597 6603
6598 6604 * Got the magic function split to work. Now all magics are defined
6599 6605 in a separate class. It just organizes things a bit, and now
6600 6606 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6601 6607 was too long).
6602 6608
6603 6609 * Changed @clear to @reset to avoid potential confusions with
6604 6610 the shell command clear. Also renamed @cl to @clear, which does
6605 6611 exactly what people expect it to from their shell experience.
6606 6612
6607 6613 Added a check to the @reset command (since it's so
6608 6614 destructive, it's probably a good idea to ask for confirmation).
6609 6615 But now reset only works for full namespace resetting. Since the
6610 6616 del keyword is already there for deleting a few specific
6611 6617 variables, I don't see the point of having a redundant magic
6612 6618 function for the same task.
6613 6619
6614 6620 2001-11-24 Fernando Perez <fperez@colorado.edu>
6615 6621
6616 6622 * Updated the builtin docs (esp. the ? ones).
6617 6623
6618 6624 * Ran all the code through pychecker. Not terribly impressed with
6619 6625 it: lots of spurious warnings and didn't really find anything of
6620 6626 substance (just a few modules being imported and not used).
6621 6627
6622 6628 * Implemented the new ultraTB functionality into IPython. New
6623 6629 option: xcolors. This chooses color scheme. xmode now only selects
6624 6630 between Plain and Verbose. Better orthogonality.
6625 6631
6626 6632 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6627 6633 mode and color scheme for the exception handlers. Now it's
6628 6634 possible to have the verbose traceback with no coloring.
6629 6635
6630 6636 2001-11-23 Fernando Perez <fperez@colorado.edu>
6631 6637
6632 6638 * Version 0.1.12 released, 0.1.13 opened.
6633 6639
6634 6640 * Removed option to set auto-quote and auto-paren escapes by
6635 6641 user. The chances of breaking valid syntax are just too high. If
6636 6642 someone *really* wants, they can always dig into the code.
6637 6643
6638 6644 * Made prompt separators configurable.
6639 6645
6640 6646 2001-11-22 Fernando Perez <fperez@colorado.edu>
6641 6647
6642 6648 * Small bugfixes in many places.
6643 6649
6644 6650 * Removed the MyCompleter class from ipplib. It seemed redundant
6645 6651 with the C-p,C-n history search functionality. Less code to
6646 6652 maintain.
6647 6653
6648 6654 * Moved all the original ipython.py code into ipythonlib.py. Right
6649 6655 now it's just one big dump into a function called make_IPython, so
6650 6656 no real modularity has been gained. But at least it makes the
6651 6657 wrapper script tiny, and since ipythonlib is a module, it gets
6652 6658 compiled and startup is much faster.
6653 6659
6654 6660 This is a reasobably 'deep' change, so we should test it for a
6655 6661 while without messing too much more with the code.
6656 6662
6657 6663 2001-11-21 Fernando Perez <fperez@colorado.edu>
6658 6664
6659 6665 * Version 0.1.11 released, 0.1.12 opened for further work.
6660 6666
6661 6667 * Removed dependency on Itpl. It was only needed in one place. It
6662 6668 would be nice if this became part of python, though. It makes life
6663 6669 *a lot* easier in some cases.
6664 6670
6665 6671 * Simplified the prefilter code a bit. Now all handlers are
6666 6672 expected to explicitly return a value (at least a blank string).
6667 6673
6668 6674 * Heavy edits in ipplib. Removed the help system altogether. Now
6669 6675 obj?/?? is used for inspecting objects, a magic @doc prints
6670 6676 docstrings, and full-blown Python help is accessed via the 'help'
6671 6677 keyword. This cleans up a lot of code (less to maintain) and does
6672 6678 the job. Since 'help' is now a standard Python component, might as
6673 6679 well use it and remove duplicate functionality.
6674 6680
6675 6681 Also removed the option to use ipplib as a standalone program. By
6676 6682 now it's too dependent on other parts of IPython to function alone.
6677 6683
6678 6684 * Fixed bug in genutils.pager. It would crash if the pager was
6679 6685 exited immediately after opening (broken pipe).
6680 6686
6681 6687 * Trimmed down the VerboseTB reporting a little. The header is
6682 6688 much shorter now and the repeated exception arguments at the end
6683 6689 have been removed. For interactive use the old header seemed a bit
6684 6690 excessive.
6685 6691
6686 6692 * Fixed small bug in output of @whos for variables with multi-word
6687 6693 types (only first word was displayed).
6688 6694
6689 6695 2001-11-17 Fernando Perez <fperez@colorado.edu>
6690 6696
6691 6697 * Version 0.1.10 released, 0.1.11 opened for further work.
6692 6698
6693 6699 * Modified dirs and friends. dirs now *returns* the stack (not
6694 6700 prints), so one can manipulate it as a variable. Convenient to
6695 6701 travel along many directories.
6696 6702
6697 6703 * Fixed bug in magic_pdef: would only work with functions with
6698 6704 arguments with default values.
6699 6705
6700 6706 2001-11-14 Fernando Perez <fperez@colorado.edu>
6701 6707
6702 6708 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6703 6709 example with IPython. Various other minor fixes and cleanups.
6704 6710
6705 6711 * Version 0.1.9 released, 0.1.10 opened for further work.
6706 6712
6707 6713 * Added sys.path to the list of directories searched in the
6708 6714 execfile= option. It used to be the current directory and the
6709 6715 user's IPYTHONDIR only.
6710 6716
6711 6717 2001-11-13 Fernando Perez <fperez@colorado.edu>
6712 6718
6713 6719 * Reinstated the raw_input/prefilter separation that Janko had
6714 6720 initially. This gives a more convenient setup for extending the
6715 6721 pre-processor from the outside: raw_input always gets a string,
6716 6722 and prefilter has to process it. We can then redefine prefilter
6717 6723 from the outside and implement extensions for special
6718 6724 purposes.
6719 6725
6720 6726 Today I got one for inputting PhysicalQuantity objects
6721 6727 (from Scientific) without needing any function calls at
6722 6728 all. Extremely convenient, and it's all done as a user-level
6723 6729 extension (no IPython code was touched). Now instead of:
6724 6730 a = PhysicalQuantity(4.2,'m/s**2')
6725 6731 one can simply say
6726 6732 a = 4.2 m/s**2
6727 6733 or even
6728 6734 a = 4.2 m/s^2
6729 6735
6730 6736 I use this, but it's also a proof of concept: IPython really is
6731 6737 fully user-extensible, even at the level of the parsing of the
6732 6738 command line. It's not trivial, but it's perfectly doable.
6733 6739
6734 6740 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6735 6741 the problem of modules being loaded in the inverse order in which
6736 6742 they were defined in
6737 6743
6738 6744 * Version 0.1.8 released, 0.1.9 opened for further work.
6739 6745
6740 6746 * Added magics pdef, source and file. They respectively show the
6741 6747 definition line ('prototype' in C), source code and full python
6742 6748 file for any callable object. The object inspector oinfo uses
6743 6749 these to show the same information.
6744 6750
6745 6751 * Version 0.1.7 released, 0.1.8 opened for further work.
6746 6752
6747 6753 * Separated all the magic functions into a class called Magic. The
6748 6754 InteractiveShell class was becoming too big for Xemacs to handle
6749 6755 (de-indenting a line would lock it up for 10 seconds while it
6750 6756 backtracked on the whole class!)
6751 6757
6752 6758 FIXME: didn't work. It can be done, but right now namespaces are
6753 6759 all messed up. Do it later (reverted it for now, so at least
6754 6760 everything works as before).
6755 6761
6756 6762 * Got the object introspection system (magic_oinfo) working! I
6757 6763 think this is pretty much ready for release to Janko, so he can
6758 6764 test it for a while and then announce it. Pretty much 100% of what
6759 6765 I wanted for the 'phase 1' release is ready. Happy, tired.
6760 6766
6761 6767 2001-11-12 Fernando Perez <fperez@colorado.edu>
6762 6768
6763 6769 * Version 0.1.6 released, 0.1.7 opened for further work.
6764 6770
6765 6771 * Fixed bug in printing: it used to test for truth before
6766 6772 printing, so 0 wouldn't print. Now checks for None.
6767 6773
6768 6774 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6769 6775 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6770 6776 reaches by hand into the outputcache. Think of a better way to do
6771 6777 this later.
6772 6778
6773 6779 * Various small fixes thanks to Nathan's comments.
6774 6780
6775 6781 * Changed magic_pprint to magic_Pprint. This way it doesn't
6776 6782 collide with pprint() and the name is consistent with the command
6777 6783 line option.
6778 6784
6779 6785 * Changed prompt counter behavior to be fully like
6780 6786 Mathematica's. That is, even input that doesn't return a result
6781 6787 raises the prompt counter. The old behavior was kind of confusing
6782 6788 (getting the same prompt number several times if the operation
6783 6789 didn't return a result).
6784 6790
6785 6791 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6786 6792
6787 6793 * Fixed -Classic mode (wasn't working anymore).
6788 6794
6789 6795 * Added colored prompts using Nathan's new code. Colors are
6790 6796 currently hardwired, they can be user-configurable. For
6791 6797 developers, they can be chosen in file ipythonlib.py, at the
6792 6798 beginning of the CachedOutput class def.
6793 6799
6794 6800 2001-11-11 Fernando Perez <fperez@colorado.edu>
6795 6801
6796 6802 * Version 0.1.5 released, 0.1.6 opened for further work.
6797 6803
6798 6804 * Changed magic_env to *return* the environment as a dict (not to
6799 6805 print it). This way it prints, but it can also be processed.
6800 6806
6801 6807 * Added Verbose exception reporting to interactive
6802 6808 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6803 6809 traceback. Had to make some changes to the ultraTB file. This is
6804 6810 probably the last 'big' thing in my mental todo list. This ties
6805 6811 in with the next entry:
6806 6812
6807 6813 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6808 6814 has to specify is Plain, Color or Verbose for all exception
6809 6815 handling.
6810 6816
6811 6817 * Removed ShellServices option. All this can really be done via
6812 6818 the magic system. It's easier to extend, cleaner and has automatic
6813 6819 namespace protection and documentation.
6814 6820
6815 6821 2001-11-09 Fernando Perez <fperez@colorado.edu>
6816 6822
6817 6823 * Fixed bug in output cache flushing (missing parameter to
6818 6824 __init__). Other small bugs fixed (found using pychecker).
6819 6825
6820 6826 * Version 0.1.4 opened for bugfixing.
6821 6827
6822 6828 2001-11-07 Fernando Perez <fperez@colorado.edu>
6823 6829
6824 6830 * Version 0.1.3 released, mainly because of the raw_input bug.
6825 6831
6826 6832 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6827 6833 and when testing for whether things were callable, a call could
6828 6834 actually be made to certain functions. They would get called again
6829 6835 once 'really' executed, with a resulting double call. A disaster
6830 6836 in many cases (list.reverse() would never work!).
6831 6837
6832 6838 * Removed prefilter() function, moved its code to raw_input (which
6833 6839 after all was just a near-empty caller for prefilter). This saves
6834 6840 a function call on every prompt, and simplifies the class a tiny bit.
6835 6841
6836 6842 * Fix _ip to __ip name in magic example file.
6837 6843
6838 6844 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6839 6845 work with non-gnu versions of tar.
6840 6846
6841 6847 2001-11-06 Fernando Perez <fperez@colorado.edu>
6842 6848
6843 6849 * Version 0.1.2. Just to keep track of the recent changes.
6844 6850
6845 6851 * Fixed nasty bug in output prompt routine. It used to check 'if
6846 6852 arg != None...'. Problem is, this fails if arg implements a
6847 6853 special comparison (__cmp__) which disallows comparing to
6848 6854 None. Found it when trying to use the PhysicalQuantity module from
6849 6855 ScientificPython.
6850 6856
6851 6857 2001-11-05 Fernando Perez <fperez@colorado.edu>
6852 6858
6853 6859 * Also added dirs. Now the pushd/popd/dirs family functions
6854 6860 basically like the shell, with the added convenience of going home
6855 6861 when called with no args.
6856 6862
6857 6863 * pushd/popd slightly modified to mimic shell behavior more
6858 6864 closely.
6859 6865
6860 6866 * Added env,pushd,popd from ShellServices as magic functions. I
6861 6867 think the cleanest will be to port all desired functions from
6862 6868 ShellServices as magics and remove ShellServices altogether. This
6863 6869 will provide a single, clean way of adding functionality
6864 6870 (shell-type or otherwise) to IP.
6865 6871
6866 6872 2001-11-04 Fernando Perez <fperez@colorado.edu>
6867 6873
6868 6874 * Added .ipython/ directory to sys.path. This way users can keep
6869 6875 customizations there and access them via import.
6870 6876
6871 6877 2001-11-03 Fernando Perez <fperez@colorado.edu>
6872 6878
6873 6879 * Opened version 0.1.1 for new changes.
6874 6880
6875 6881 * Changed version number to 0.1.0: first 'public' release, sent to
6876 6882 Nathan and Janko.
6877 6883
6878 6884 * Lots of small fixes and tweaks.
6879 6885
6880 6886 * Minor changes to whos format. Now strings are shown, snipped if
6881 6887 too long.
6882 6888
6883 6889 * Changed ShellServices to work on __main__ so they show up in @who
6884 6890
6885 6891 * Help also works with ? at the end of a line:
6886 6892 ?sin and sin?
6887 6893 both produce the same effect. This is nice, as often I use the
6888 6894 tab-complete to find the name of a method, but I used to then have
6889 6895 to go to the beginning of the line to put a ? if I wanted more
6890 6896 info. Now I can just add the ? and hit return. Convenient.
6891 6897
6892 6898 2001-11-02 Fernando Perez <fperez@colorado.edu>
6893 6899
6894 6900 * Python version check (>=2.1) added.
6895 6901
6896 6902 * Added LazyPython documentation. At this point the docs are quite
6897 6903 a mess. A cleanup is in order.
6898 6904
6899 6905 * Auto-installer created. For some bizarre reason, the zipfiles
6900 6906 module isn't working on my system. So I made a tar version
6901 6907 (hopefully the command line options in various systems won't kill
6902 6908 me).
6903 6909
6904 6910 * Fixes to Struct in genutils. Now all dictionary-like methods are
6905 6911 protected (reasonably).
6906 6912
6907 6913 * Added pager function to genutils and changed ? to print usage
6908 6914 note through it (it was too long).
6909 6915
6910 6916 * Added the LazyPython functionality. Works great! I changed the
6911 6917 auto-quote escape to ';', it's on home row and next to '. But
6912 6918 both auto-quote and auto-paren (still /) escapes are command-line
6913 6919 parameters.
6914 6920
6915 6921
6916 6922 2001-11-01 Fernando Perez <fperez@colorado.edu>
6917 6923
6918 6924 * Version changed to 0.0.7. Fairly large change: configuration now
6919 6925 is all stored in a directory, by default .ipython. There, all
6920 6926 config files have normal looking names (not .names)
6921 6927
6922 6928 * Version 0.0.6 Released first to Lucas and Archie as a test
6923 6929 run. Since it's the first 'semi-public' release, change version to
6924 6930 > 0.0.6 for any changes now.
6925 6931
6926 6932 * Stuff I had put in the ipplib.py changelog:
6927 6933
6928 6934 Changes to InteractiveShell:
6929 6935
6930 6936 - Made the usage message a parameter.
6931 6937
6932 6938 - Require the name of the shell variable to be given. It's a bit
6933 6939 of a hack, but allows the name 'shell' not to be hardwired in the
6934 6940 magic (@) handler, which is problematic b/c it requires
6935 6941 polluting the global namespace with 'shell'. This in turn is
6936 6942 fragile: if a user redefines a variable called shell, things
6937 6943 break.
6938 6944
6939 6945 - magic @: all functions available through @ need to be defined
6940 6946 as magic_<name>, even though they can be called simply as
6941 6947 @<name>. This allows the special command @magic to gather
6942 6948 information automatically about all existing magic functions,
6943 6949 even if they are run-time user extensions, by parsing the shell
6944 6950 instance __dict__ looking for special magic_ names.
6945 6951
6946 6952 - mainloop: added *two* local namespace parameters. This allows
6947 6953 the class to differentiate between parameters which were there
6948 6954 before and after command line initialization was processed. This
6949 6955 way, later @who can show things loaded at startup by the
6950 6956 user. This trick was necessary to make session saving/reloading
6951 6957 really work: ideally after saving/exiting/reloading a session,
6952 6958 *everything* should look the same, including the output of @who. I
6953 6959 was only able to make this work with this double namespace
6954 6960 trick.
6955 6961
6956 6962 - added a header to the logfile which allows (almost) full
6957 6963 session restoring.
6958 6964
6959 6965 - prepend lines beginning with @ or !, with a and log
6960 6966 them. Why? !lines: may be useful to know what you did @lines:
6961 6967 they may affect session state. So when restoring a session, at
6962 6968 least inform the user of their presence. I couldn't quite get
6963 6969 them to properly re-execute, but at least the user is warned.
6964 6970
6965 6971 * Started ChangeLog.
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now