##// END OF EJS Templates
Fix for unicode support, python identifiers can only be ascii so we need to...
fperez -
Show More
@@ -1,3096 +1,3101 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 2153 2007-03-18 22:53:18Z fperez $"""
4 $Id: Magic.py 2187 2007-03-30 04:56:40Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 #****************************************************************************
15 15 # Modules and globals
16 16
17 17 from IPython import Release
18 18 __author__ = '%s <%s>\n%s <%s>' % \
19 19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 20 __license__ = Release.license
21 21
22 22 # Python standard modules
23 23 import __builtin__
24 24 import bdb
25 25 import inspect
26 26 import os
27 27 import pdb
28 28 import pydoc
29 29 import sys
30 30 import re
31 31 import tempfile
32 32 import time
33 33 import cPickle as pickle
34 34 import textwrap
35 35 from cStringIO import StringIO
36 36 from getopt import getopt,GetoptError
37 37 from pprint import pprint, pformat
38 38
39 39 # cProfile was added in Python2.5
40 40 try:
41 41 import cProfile as profile
42 42 import pstats
43 43 except ImportError:
44 44 # profile isn't bundled by default in Debian for license reasons
45 45 try:
46 46 import profile,pstats
47 47 except ImportError:
48 48 profile = pstats = None
49 49
50 50 # Homebrewed
51 51 import IPython
52 52 from IPython import Debugger, OInspect, wildcard
53 53 from IPython.FakeModule import FakeModule
54 54 from IPython.Itpl import Itpl, itpl, printpl,itplns
55 55 from IPython.PyColorize import Parser
56 56 from IPython.ipstruct import Struct
57 57 from IPython.macro import Macro
58 58 from IPython.genutils import *
59 59 from IPython import platutils
60 60
61 61 #***************************************************************************
62 62 # Utility functions
63 63 def on_off(tag):
64 64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
65 65 return ['OFF','ON'][tag]
66 66
67 67 class Bunch: pass
68 68
69 69 #***************************************************************************
70 70 # Main class implementing Magic functionality
71 71 class Magic:
72 72 """Magic functions for InteractiveShell.
73 73
74 74 Shell functions which can be reached as %function_name. All magic
75 75 functions should accept a string, which they can parse for their own
76 76 needs. This can make some functions easier to type, eg `%cd ../`
77 77 vs. `%cd("../")`
78 78
79 79 ALL definitions MUST begin with the prefix magic_. The user won't need it
80 80 at the command line, but it is is needed in the definition. """
81 81
82 82 # class globals
83 83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
84 84 'Automagic is ON, % prefix NOT needed for magic functions.']
85 85
86 86 #......................................................................
87 87 # some utility functions
88 88
89 89 def __init__(self,shell):
90 90
91 91 self.options_table = {}
92 92 if profile is None:
93 93 self.magic_prun = self.profile_missing_notice
94 94 self.shell = shell
95 95
96 96 # namespace for holding state we may need
97 97 self._magic_state = Bunch()
98 98
99 99 def profile_missing_notice(self, *args, **kwargs):
100 100 error("""\
101 101 The profile module could not be found. If you are a Debian user,
102 102 it has been removed from the standard Debian package because of its non-free
103 103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
104 104
105 105 def default_option(self,fn,optstr):
106 106 """Make an entry in the options_table for fn, with value optstr"""
107 107
108 108 if fn not in self.lsmagic():
109 109 error("%s is not a magic function" % fn)
110 110 self.options_table[fn] = optstr
111 111
112 112 def lsmagic(self):
113 113 """Return a list of currently available magic functions.
114 114
115 115 Gives a list of the bare names after mangling (['ls','cd', ...], not
116 116 ['magic_ls','magic_cd',...]"""
117 117
118 118 # FIXME. This needs a cleanup, in the way the magics list is built.
119 119
120 120 # magics in class definition
121 121 class_magic = lambda fn: fn.startswith('magic_') and \
122 122 callable(Magic.__dict__[fn])
123 123 # in instance namespace (run-time user additions)
124 124 inst_magic = lambda fn: fn.startswith('magic_') and \
125 125 callable(self.__dict__[fn])
126 126 # and bound magics by user (so they can access self):
127 127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
128 128 callable(self.__class__.__dict__[fn])
129 129 magics = filter(class_magic,Magic.__dict__.keys()) + \
130 130 filter(inst_magic,self.__dict__.keys()) + \
131 131 filter(inst_bound_magic,self.__class__.__dict__.keys())
132 132 out = []
133 133 for fn in magics:
134 134 out.append(fn.replace('magic_','',1))
135 135 out.sort()
136 136 return out
137 137
138 138 def extract_input_slices(self,slices,raw=False):
139 139 """Return as a string a set of input history slices.
140 140
141 141 Inputs:
142 142
143 143 - slices: the set of slices is given as a list of strings (like
144 144 ['1','4:8','9'], since this function is for use by magic functions
145 145 which get their arguments as strings.
146 146
147 147 Optional inputs:
148 148
149 149 - raw(False): by default, the processed input is used. If this is
150 150 true, the raw input history is used instead.
151 151
152 152 Note that slices can be called with two notations:
153 153
154 154 N:M -> standard python form, means including items N...(M-1).
155 155
156 156 N-M -> include items N..M (closed endpoint)."""
157 157
158 158 if raw:
159 159 hist = self.shell.input_hist_raw
160 160 else:
161 161 hist = self.shell.input_hist
162 162
163 163 cmds = []
164 164 for chunk in slices:
165 165 if ':' in chunk:
166 166 ini,fin = map(int,chunk.split(':'))
167 167 elif '-' in chunk:
168 168 ini,fin = map(int,chunk.split('-'))
169 169 fin += 1
170 170 else:
171 171 ini = int(chunk)
172 172 fin = ini+1
173 173 cmds.append(hist[ini:fin])
174 174 return cmds
175 175
176 176 def _ofind(self, oname, namespaces=None):
177 177 """Find an object in the available namespaces.
178 178
179 179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
180 180
181 181 Has special code to detect magic functions.
182 182 """
183 183
184 184 oname = oname.strip()
185 185
186 186 alias_ns = None
187 187 if namespaces is None:
188 188 # Namespaces to search in:
189 189 # Put them in a list. The order is important so that we
190 190 # find things in the same order that Python finds them.
191 191 namespaces = [ ('Interactive', self.shell.user_ns),
192 192 ('IPython internal', self.shell.internal_ns),
193 193 ('Python builtin', __builtin__.__dict__),
194 194 ('Alias', self.shell.alias_table),
195 195 ]
196 196 alias_ns = self.shell.alias_table
197 197
198 198 # initialize results to 'null'
199 199 found = 0; obj = None; ospace = None; ds = None;
200 200 ismagic = 0; isalias = 0; parent = None
201 201
202 202 # Look for the given name by splitting it in parts. If the head is
203 203 # found, then we look for all the remaining parts as members, and only
204 204 # declare success if we can find them all.
205 205 oname_parts = oname.split('.')
206 206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
207 207 for nsname,ns in namespaces:
208 208 try:
209 209 obj = ns[oname_head]
210 210 except KeyError:
211 211 continue
212 212 else:
213 213 #print 'oname_rest:', oname_rest # dbg
214 214 for part in oname_rest:
215 215 try:
216 216 parent = obj
217 217 obj = getattr(obj,part)
218 218 except:
219 219 # Blanket except b/c some badly implemented objects
220 220 # allow __getattr__ to raise exceptions other than
221 221 # AttributeError, which then crashes IPython.
222 222 break
223 223 else:
224 224 # If we finish the for loop (no break), we got all members
225 225 found = 1
226 226 ospace = nsname
227 227 if ns == alias_ns:
228 228 isalias = 1
229 229 break # namespace loop
230 230
231 231 # Try to see if it's magic
232 232 if not found:
233 233 if oname.startswith(self.shell.ESC_MAGIC):
234 234 oname = oname[1:]
235 235 obj = getattr(self,'magic_'+oname,None)
236 236 if obj is not None:
237 237 found = 1
238 238 ospace = 'IPython internal'
239 239 ismagic = 1
240 240
241 241 # Last try: special-case some literals like '', [], {}, etc:
242 242 if not found and oname_head in ["''",'""','[]','{}','()']:
243 243 obj = eval(oname_head)
244 244 found = 1
245 245 ospace = 'Interactive'
246 246
247 247 return {'found':found, 'obj':obj, 'namespace':ospace,
248 248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
249 249
250 250 def arg_err(self,func):
251 251 """Print docstring if incorrect arguments were passed"""
252 252 print 'Error in arguments:'
253 253 print OInspect.getdoc(func)
254 254
255 255 def format_latex(self,strng):
256 256 """Format a string for latex inclusion."""
257 257
258 258 # Characters that need to be escaped for latex:
259 259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
260 260 # Magic command names as headers:
261 261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
262 262 re.MULTILINE)
263 263 # Magic commands
264 264 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
265 265 re.MULTILINE)
266 266 # Paragraph continue
267 267 par_re = re.compile(r'\\$',re.MULTILINE)
268 268
269 269 # The "\n" symbol
270 270 newline_re = re.compile(r'\\n')
271 271
272 272 # Now build the string for output:
273 273 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
274 274 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
275 275 strng)
276 276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
277 277 strng = par_re.sub(r'\\\\',strng)
278 278 strng = escape_re.sub(r'\\\1',strng)
279 279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
280 280 return strng
281 281
282 282 def format_screen(self,strng):
283 283 """Format a string for screen printing.
284 284
285 285 This removes some latex-type format codes."""
286 286 # Paragraph continue
287 287 par_re = re.compile(r'\\$',re.MULTILINE)
288 288 strng = par_re.sub('',strng)
289 289 return strng
290 290
291 291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
292 292 """Parse options passed to an argument string.
293 293
294 294 The interface is similar to that of getopt(), but it returns back a
295 295 Struct with the options as keys and the stripped argument string still
296 296 as a string.
297 297
298 298 arg_str is quoted as a true sys.argv vector by using shlex.split.
299 299 This allows us to easily expand variables, glob files, quote
300 300 arguments, etc.
301 301
302 302 Options:
303 303 -mode: default 'string'. If given as 'list', the argument string is
304 304 returned as a list (split on whitespace) instead of a string.
305 305
306 306 -list_all: put all option values in lists. Normally only options
307 307 appearing more than once are put in a list.
308 308
309 309 -posix (True): whether to split the input line in POSIX mode or not,
310 310 as per the conventions outlined in the shlex module from the
311 311 standard library."""
312 312
313 313 # inject default options at the beginning of the input line
314 314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
315 315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
316 316
317 317 mode = kw.get('mode','string')
318 318 if mode not in ['string','list']:
319 319 raise ValueError,'incorrect mode given: %s' % mode
320 320 # Get options
321 321 list_all = kw.get('list_all',0)
322 322 posix = kw.get('posix',True)
323 323
324 324 # Check if we have more than one argument to warrant extra processing:
325 325 odict = {} # Dictionary with options
326 326 args = arg_str.split()
327 327 if len(args) >= 1:
328 328 # If the list of inputs only has 0 or 1 thing in it, there's no
329 329 # need to look for options
330 330 argv = arg_split(arg_str,posix)
331 331 # Do regular option processing
332 332 try:
333 333 opts,args = getopt(argv,opt_str,*long_opts)
334 334 except GetoptError,e:
335 335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
336 336 " ".join(long_opts)))
337 337 for o,a in opts:
338 338 if o.startswith('--'):
339 339 o = o[2:]
340 340 else:
341 341 o = o[1:]
342 342 try:
343 343 odict[o].append(a)
344 344 except AttributeError:
345 345 odict[o] = [odict[o],a]
346 346 except KeyError:
347 347 if list_all:
348 348 odict[o] = [a]
349 349 else:
350 350 odict[o] = a
351 351
352 352 # Prepare opts,args for return
353 353 opts = Struct(odict)
354 354 if mode == 'string':
355 355 args = ' '.join(args)
356 356
357 357 return opts,args
358 358
359 359 #......................................................................
360 360 # And now the actual magic functions
361 361
362 362 # Functions for IPython shell work (vars,funcs, config, etc)
363 363 def magic_lsmagic(self, parameter_s = ''):
364 364 """List currently available magic functions."""
365 365 mesc = self.shell.ESC_MAGIC
366 366 print 'Available magic functions:\n'+mesc+\
367 367 (' '+mesc).join(self.lsmagic())
368 368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
369 369 return None
370 370
371 371 def magic_magic(self, parameter_s = ''):
372 372 """Print information about the magic function system."""
373 373
374 374 mode = ''
375 375 try:
376 376 if parameter_s.split()[0] == '-latex':
377 377 mode = 'latex'
378 378 if parameter_s.split()[0] == '-brief':
379 379 mode = 'brief'
380 380 except:
381 381 pass
382 382
383 383 magic_docs = []
384 384 for fname in self.lsmagic():
385 385 mname = 'magic_' + fname
386 386 for space in (Magic,self,self.__class__):
387 387 try:
388 388 fn = space.__dict__[mname]
389 389 except KeyError:
390 390 pass
391 391 else:
392 392 break
393 393 if mode == 'brief':
394 394 # only first line
395 395 fndoc = fn.__doc__.split('\n',1)[0]
396 396 else:
397 397 fndoc = fn.__doc__
398 398
399 399 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
400 400 fname,fndoc))
401 401 magic_docs = ''.join(magic_docs)
402 402
403 403 if mode == 'latex':
404 404 print self.format_latex(magic_docs)
405 405 return
406 406 else:
407 407 magic_docs = self.format_screen(magic_docs)
408 408 if mode == 'brief':
409 409 return magic_docs
410 410
411 411 outmsg = """
412 412 IPython's 'magic' functions
413 413 ===========================
414 414
415 415 The magic function system provides a series of functions which allow you to
416 416 control the behavior of IPython itself, plus a lot of system-type
417 417 features. All these functions are prefixed with a % character, but parameters
418 418 are given without parentheses or quotes.
419 419
420 420 NOTE: If you have 'automagic' enabled (via the command line option or with the
421 421 %automagic function), you don't need to type in the % explicitly. By default,
422 422 IPython ships with automagic on, so you should only rarely need the % escape.
423 423
424 424 Example: typing '%cd mydir' (without the quotes) changes you working directory
425 425 to 'mydir', if it exists.
426 426
427 427 You can define your own magic functions to extend the system. See the supplied
428 428 ipythonrc and example-magic.py files for details (in your ipython
429 429 configuration directory, typically $HOME/.ipython/).
430 430
431 431 You can also define your own aliased names for magic functions. In your
432 432 ipythonrc file, placing a line like:
433 433
434 434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
435 435
436 436 will define %pf as a new name for %profile.
437 437
438 438 You can also call magics in code using the ipmagic() function, which IPython
439 439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
440 440
441 441 For a list of the available magic functions, use %lsmagic. For a description
442 442 of any of them, type %magic_name?, e.g. '%cd?'.
443 443
444 444 Currently the magic system has the following functions:\n"""
445 445
446 446 mesc = self.shell.ESC_MAGIC
447 447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
448 448 "\n\n%s%s\n\n%s" % (outmsg,
449 449 magic_docs,mesc,mesc,
450 450 (' '+mesc).join(self.lsmagic()),
451 451 Magic.auto_status[self.shell.rc.automagic] ) )
452 452
453 453 page(outmsg,screen_lines=self.shell.rc.screen_length)
454 454
455 455 def magic_automagic(self, parameter_s = ''):
456 456 """Make magic functions callable without having to type the initial %.
457 457
458 458 Without argumentsl toggles on/off (when off, you must call it as
459 459 %automagic, of course). With arguments it sets the value, and you can
460 460 use any of (case insensitive):
461 461
462 462 - on,1,True: to activate
463 463
464 464 - off,0,False: to deactivate.
465 465
466 466 Note that magic functions have lowest priority, so if there's a
467 467 variable whose name collides with that of a magic fn, automagic won't
468 468 work for that function (you get the variable instead). However, if you
469 469 delete the variable (del var), the previously shadowed magic function
470 470 becomes visible to automagic again."""
471 471
472 472 rc = self.shell.rc
473 473 arg = parameter_s.lower()
474 474 if parameter_s in ('on','1','true'):
475 475 rc.automagic = True
476 476 elif parameter_s in ('off','0','false'):
477 477 rc.automagic = False
478 478 else:
479 479 rc.automagic = not rc.automagic
480 480 print '\n' + Magic.auto_status[rc.automagic]
481 481
482 482 def magic_autocall(self, parameter_s = ''):
483 483 """Make functions callable without having to type parentheses.
484 484
485 485 Usage:
486 486
487 487 %autocall [mode]
488 488
489 489 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
490 490 value is toggled on and off (remembering the previous state)."""
491 491
492 492 rc = self.shell.rc
493 493
494 494 if parameter_s:
495 495 arg = int(parameter_s)
496 496 else:
497 497 arg = 'toggle'
498 498
499 499 if not arg in (0,1,2,'toggle'):
500 500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
501 501 return
502 502
503 503 if arg in (0,1,2):
504 504 rc.autocall = arg
505 505 else: # toggle
506 506 if rc.autocall:
507 507 self._magic_state.autocall_save = rc.autocall
508 508 rc.autocall = 0
509 509 else:
510 510 try:
511 511 rc.autocall = self._magic_state.autocall_save
512 512 except AttributeError:
513 513 rc.autocall = self._magic_state.autocall_save = 1
514 514
515 515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
516 516
517 517 def magic_autoindent(self, parameter_s = ''):
518 518 """Toggle autoindent on/off (if available)."""
519 519
520 520 self.shell.set_autoindent()
521 521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
522 522
523 523 def magic_system_verbose(self, parameter_s = ''):
524 524 """Set verbose printing of system calls.
525 525
526 526 If called without an argument, act as a toggle"""
527 527
528 528 if parameter_s:
529 529 val = bool(eval(parameter_s))
530 530 else:
531 531 val = None
532 532
533 533 self.shell.rc_set_toggle('system_verbose',val)
534 534 print "System verbose printing is:",\
535 535 ['OFF','ON'][self.shell.rc.system_verbose]
536 536
537 537 def magic_history(self, parameter_s = ''):
538 538 """Print input history (_i<n> variables), with most recent last.
539 539
540 540 %history -> print at most 40 inputs (some may be multi-line)\\
541 541 %history n -> print at most n inputs\\
542 542 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
543 543
544 544 Each input's number <n> is shown, and is accessible as the
545 545 automatically generated variable _i<n>. Multi-line statements are
546 546 printed starting at a new line for easy copy/paste.
547 547
548 548
549 549 Options:
550 550
551 551 -n: do NOT print line numbers. This is useful if you want to get a
552 552 printout of many lines which can be directly pasted into a text
553 553 editor.
554 554
555 555 This feature is only available if numbered prompts are in use.
556 556
557 557 -r: print the 'raw' history. IPython filters your input and
558 558 converts it all into valid Python source before executing it (things
559 559 like magics or aliases are turned into function calls, for
560 560 example). With this option, you'll see the unfiltered history
561 561 instead of the filtered version: '%cd /' will be seen as '%cd /'
562 562 instead of '_ip.magic("%cd /")'.
563 563 """
564 564
565 565 shell = self.shell
566 566 if not shell.outputcache.do_full_cache:
567 567 print 'This feature is only available if numbered prompts are in use.'
568 568 return
569 569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
570 570
571 571 if opts.has_key('r'):
572 572 input_hist = shell.input_hist_raw
573 573 else:
574 574 input_hist = shell.input_hist
575 575
576 576 default_length = 40
577 577 if len(args) == 0:
578 578 final = len(input_hist)
579 579 init = max(1,final-default_length)
580 580 elif len(args) == 1:
581 581 final = len(input_hist)
582 582 init = max(1,final-int(args[0]))
583 583 elif len(args) == 2:
584 584 init,final = map(int,args)
585 585 else:
586 586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
587 587 print self.magic_hist.__doc__
588 588 return
589 589 width = len(str(final))
590 590 line_sep = ['','\n']
591 591 print_nums = not opts.has_key('n')
592 592 for in_num in range(init,final):
593 593 inline = input_hist[in_num]
594 594 multiline = int(inline.count('\n') > 1)
595 595 if print_nums:
596 596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
597 597 print inline,
598 598
599 599 def magic_hist(self, parameter_s=''):
600 600 """Alternate name for %history."""
601 601 return self.magic_history(parameter_s)
602 602
603 603 def magic_p(self, parameter_s=''):
604 604 """Just a short alias for Python's 'print'."""
605 605 exec 'print ' + parameter_s in self.shell.user_ns
606 606
607 607 def magic_r(self, parameter_s=''):
608 608 """Repeat previous input.
609 609
610 610 If given an argument, repeats the previous command which starts with
611 611 the same string, otherwise it just repeats the previous input.
612 612
613 613 Shell escaped commands (with ! as first character) are not recognized
614 614 by this system, only pure python code and magic commands.
615 615 """
616 616
617 617 start = parameter_s.strip()
618 618 esc_magic = self.shell.ESC_MAGIC
619 619 # Identify magic commands even if automagic is on (which means
620 620 # the in-memory version is different from that typed by the user).
621 621 if self.shell.rc.automagic:
622 622 start_magic = esc_magic+start
623 623 else:
624 624 start_magic = start
625 625 # Look through the input history in reverse
626 626 for n in range(len(self.shell.input_hist)-2,0,-1):
627 627 input = self.shell.input_hist[n]
628 628 # skip plain 'r' lines so we don't recurse to infinity
629 629 if input != '_ip.magic("r")\n' and \
630 630 (input.startswith(start) or input.startswith(start_magic)):
631 631 #print 'match',`input` # dbg
632 632 print 'Executing:',input,
633 633 self.shell.runlines(input)
634 634 return
635 635 print 'No previous input matching `%s` found.' % start
636 636
637 637 def magic_page(self, parameter_s=''):
638 638 """Pretty print the object and display it through a pager.
639 639
640 640 %page [options] OBJECT
641 641
642 642 If no object is given, use _ (last output).
643 643
644 644 Options:
645 645
646 646 -r: page str(object), don't pretty-print it."""
647 647
648 648 # After a function contributed by Olivier Aubert, slightly modified.
649 649
650 650 # Process options/args
651 651 opts,args = self.parse_options(parameter_s,'r')
652 652 raw = 'r' in opts
653 653
654 654 oname = args and args or '_'
655 655 info = self._ofind(oname)
656 656 if info['found']:
657 657 txt = (raw and str or pformat)( info['obj'] )
658 658 page(txt)
659 659 else:
660 660 print 'Object `%s` not found' % oname
661 661
662 662 def magic_profile(self, parameter_s=''):
663 663 """Print your currently active IPyhton profile."""
664 664 if self.shell.rc.profile:
665 665 printpl('Current IPython profile: $self.shell.rc.profile.')
666 666 else:
667 667 print 'No profile active.'
668 668
669 669 def _inspect(self,meth,oname,namespaces=None,**kw):
670 670 """Generic interface to the inspector system.
671 671
672 672 This function is meant to be called by pdef, pdoc & friends."""
673
674 oname = oname.strip()
673
674 try:
675 oname = oname.strip().encode('ascii')
676 except UnicodeEncodeError:
677 print 'Python identifiers can only contain ascii characters.'
678 return 'not found'
679
675 680 info = Struct(self._ofind(oname, namespaces))
676 681
677 682 if info.found:
678 683 # Get the docstring of the class property if it exists.
679 684 path = oname.split('.')
680 685 root = '.'.join(path[:-1])
681 686 if info.parent is not None:
682 687 try:
683 688 target = getattr(info.parent, '__class__')
684 689 # The object belongs to a class instance.
685 690 try:
686 691 target = getattr(target, path[-1])
687 692 # The class defines the object.
688 693 if isinstance(target, property):
689 694 oname = root + '.__class__.' + path[-1]
690 695 info = Struct(self._ofind(oname))
691 696 except AttributeError: pass
692 697 except AttributeError: pass
693 698
694 699 pmethod = getattr(self.shell.inspector,meth)
695 700 formatter = info.ismagic and self.format_screen or None
696 701 if meth == 'pdoc':
697 702 pmethod(info.obj,oname,formatter)
698 703 elif meth == 'pinfo':
699 704 pmethod(info.obj,oname,formatter,info,**kw)
700 705 else:
701 706 pmethod(info.obj,oname)
702 707 else:
703 708 print 'Object `%s` not found.' % oname
704 709 return 'not found' # so callers can take other action
705 710
706 711 def magic_pdef(self, parameter_s='', namespaces=None):
707 712 """Print the definition header for any callable object.
708 713
709 714 If the object is a class, print the constructor information."""
710 715 self._inspect('pdef',parameter_s, namespaces)
711 716
712 717 def magic_pdoc(self, parameter_s='', namespaces=None):
713 718 """Print the docstring for an object.
714 719
715 720 If the given object is a class, it will print both the class and the
716 721 constructor docstrings."""
717 722 self._inspect('pdoc',parameter_s, namespaces)
718 723
719 724 def magic_psource(self, parameter_s='', namespaces=None):
720 725 """Print (or run through pager) the source code for an object."""
721 726 self._inspect('psource',parameter_s, namespaces)
722 727
723 728 def magic_pfile(self, parameter_s=''):
724 729 """Print (or run through pager) the file where an object is defined.
725 730
726 731 The file opens at the line where the object definition begins. IPython
727 732 will honor the environment variable PAGER if set, and otherwise will
728 733 do its best to print the file in a convenient form.
729 734
730 735 If the given argument is not an object currently defined, IPython will
731 736 try to interpret it as a filename (automatically adding a .py extension
732 737 if needed). You can thus use %pfile as a syntax highlighting code
733 738 viewer."""
734 739
735 740 # first interpret argument as an object name
736 741 out = self._inspect('pfile',parameter_s)
737 742 # if not, try the input as a filename
738 743 if out == 'not found':
739 744 try:
740 745 filename = get_py_filename(parameter_s)
741 746 except IOError,msg:
742 747 print msg
743 748 return
744 749 page(self.shell.inspector.format(file(filename).read()))
745 750
746 751 def magic_pinfo(self, parameter_s='', namespaces=None):
747 752 """Provide detailed information about an object.
748 753
749 754 '%pinfo object' is just a synonym for object? or ?object."""
750 755
751 756 #print 'pinfo par: <%s>' % parameter_s # dbg
752 757
753 758 # detail_level: 0 -> obj? , 1 -> obj??
754 759 detail_level = 0
755 760 # We need to detect if we got called as 'pinfo pinfo foo', which can
756 761 # happen if the user types 'pinfo foo?' at the cmd line.
757 762 pinfo,qmark1,oname,qmark2 = \
758 763 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
759 764 if pinfo or qmark1 or qmark2:
760 765 detail_level = 1
761 766 if "*" in oname:
762 767 self.magic_psearch(oname)
763 768 else:
764 769 self._inspect('pinfo', oname, detail_level=detail_level,
765 770 namespaces=namespaces)
766 771
767 772 def magic_psearch(self, parameter_s=''):
768 773 """Search for object in namespaces by wildcard.
769 774
770 775 %psearch [options] PATTERN [OBJECT TYPE]
771 776
772 777 Note: ? can be used as a synonym for %psearch, at the beginning or at
773 778 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
774 779 rest of the command line must be unchanged (options come first), so
775 780 for example the following forms are equivalent
776 781
777 782 %psearch -i a* function
778 783 -i a* function?
779 784 ?-i a* function
780 785
781 786 Arguments:
782 787
783 788 PATTERN
784 789
785 790 where PATTERN is a string containing * as a wildcard similar to its
786 791 use in a shell. The pattern is matched in all namespaces on the
787 792 search path. By default objects starting with a single _ are not
788 793 matched, many IPython generated objects have a single
789 794 underscore. The default is case insensitive matching. Matching is
790 795 also done on the attributes of objects and not only on the objects
791 796 in a module.
792 797
793 798 [OBJECT TYPE]
794 799
795 800 Is the name of a python type from the types module. The name is
796 801 given in lowercase without the ending type, ex. StringType is
797 802 written string. By adding a type here only objects matching the
798 803 given type are matched. Using all here makes the pattern match all
799 804 types (this is the default).
800 805
801 806 Options:
802 807
803 808 -a: makes the pattern match even objects whose names start with a
804 809 single underscore. These names are normally ommitted from the
805 810 search.
806 811
807 812 -i/-c: make the pattern case insensitive/sensitive. If neither of
808 813 these options is given, the default is read from your ipythonrc
809 814 file. The option name which sets this value is
810 815 'wildcards_case_sensitive'. If this option is not specified in your
811 816 ipythonrc file, IPython's internal default is to do a case sensitive
812 817 search.
813 818
814 819 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
815 820 specifiy can be searched in any of the following namespaces:
816 821 'builtin', 'user', 'user_global','internal', 'alias', where
817 822 'builtin' and 'user' are the search defaults. Note that you should
818 823 not use quotes when specifying namespaces.
819 824
820 825 'Builtin' contains the python module builtin, 'user' contains all
821 826 user data, 'alias' only contain the shell aliases and no python
822 827 objects, 'internal' contains objects used by IPython. The
823 828 'user_global' namespace is only used by embedded IPython instances,
824 829 and it contains module-level globals. You can add namespaces to the
825 830 search with -s or exclude them with -e (these options can be given
826 831 more than once).
827 832
828 833 Examples:
829 834
830 835 %psearch a* -> objects beginning with an a
831 836 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
832 837 %psearch a* function -> all functions beginning with an a
833 838 %psearch re.e* -> objects beginning with an e in module re
834 839 %psearch r*.e* -> objects that start with e in modules starting in r
835 840 %psearch r*.* string -> all strings in modules beginning with r
836 841
837 842 Case sensitve search:
838 843
839 844 %psearch -c a* list all object beginning with lower case a
840 845
841 846 Show objects beginning with a single _:
842 847
843 848 %psearch -a _* list objects beginning with a single underscore"""
844 849
845 850 # default namespaces to be searched
846 851 def_search = ['user','builtin']
847 852
848 853 # Process options/args
849 854 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
850 855 opt = opts.get
851 856 shell = self.shell
852 857 psearch = shell.inspector.psearch
853 858
854 859 # select case options
855 860 if opts.has_key('i'):
856 861 ignore_case = True
857 862 elif opts.has_key('c'):
858 863 ignore_case = False
859 864 else:
860 865 ignore_case = not shell.rc.wildcards_case_sensitive
861 866
862 867 # Build list of namespaces to search from user options
863 868 def_search.extend(opt('s',[]))
864 869 ns_exclude = ns_exclude=opt('e',[])
865 870 ns_search = [nm for nm in def_search if nm not in ns_exclude]
866 871
867 872 # Call the actual search
868 873 try:
869 874 psearch(args,shell.ns_table,ns_search,
870 875 show_all=opt('a'),ignore_case=ignore_case)
871 876 except:
872 877 shell.showtraceback()
873 878
874 879 def magic_who_ls(self, parameter_s=''):
875 880 """Return a sorted list of all interactive variables.
876 881
877 882 If arguments are given, only variables of types matching these
878 883 arguments are returned."""
879 884
880 885 user_ns = self.shell.user_ns
881 886 internal_ns = self.shell.internal_ns
882 887 user_config_ns = self.shell.user_config_ns
883 888 out = []
884 889 typelist = parameter_s.split()
885 890
886 891 for i in user_ns:
887 892 if not (i.startswith('_') or i.startswith('_i')) \
888 893 and not (i in internal_ns or i in user_config_ns):
889 894 if typelist:
890 895 if type(user_ns[i]).__name__ in typelist:
891 896 out.append(i)
892 897 else:
893 898 out.append(i)
894 899 out.sort()
895 900 return out
896 901
897 902 def magic_who(self, parameter_s=''):
898 903 """Print all interactive variables, with some minimal formatting.
899 904
900 905 If any arguments are given, only variables whose type matches one of
901 906 these are printed. For example:
902 907
903 908 %who function str
904 909
905 910 will only list functions and strings, excluding all other types of
906 911 variables. To find the proper type names, simply use type(var) at a
907 912 command line to see how python prints type names. For example:
908 913
909 914 In [1]: type('hello')\\
910 915 Out[1]: <type 'str'>
911 916
912 917 indicates that the type name for strings is 'str'.
913 918
914 919 %who always excludes executed names loaded through your configuration
915 920 file and things which are internal to IPython.
916 921
917 922 This is deliberate, as typically you may load many modules and the
918 923 purpose of %who is to show you only what you've manually defined."""
919 924
920 925 varlist = self.magic_who_ls(parameter_s)
921 926 if not varlist:
922 927 print 'Interactive namespace is empty.'
923 928 return
924 929
925 930 # if we have variables, move on...
926 931
927 932 # stupid flushing problem: when prompts have no separators, stdout is
928 933 # getting lost. I'm starting to think this is a python bug. I'm having
929 934 # to force a flush with a print because even a sys.stdout.flush
930 935 # doesn't seem to do anything!
931 936
932 937 count = 0
933 938 for i in varlist:
934 939 print i+'\t',
935 940 count += 1
936 941 if count > 8:
937 942 count = 0
938 943 print
939 944 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
940 945
941 946 print # well, this does force a flush at the expense of an extra \n
942 947
943 948 def magic_whos(self, parameter_s=''):
944 949 """Like %who, but gives some extra information about each variable.
945 950
946 951 The same type filtering of %who can be applied here.
947 952
948 953 For all variables, the type is printed. Additionally it prints:
949 954
950 955 - For {},[],(): their length.
951 956
952 957 - For Numeric arrays, a summary with shape, number of elements,
953 958 typecode and size in memory.
954 959
955 960 - Everything else: a string representation, snipping their middle if
956 961 too long."""
957 962
958 963 varnames = self.magic_who_ls(parameter_s)
959 964 if not varnames:
960 965 print 'Interactive namespace is empty.'
961 966 return
962 967
963 968 # if we have variables, move on...
964 969
965 970 # for these types, show len() instead of data:
966 971 seq_types = [types.DictType,types.ListType,types.TupleType]
967 972
968 973 # for Numeric arrays, display summary info
969 974 try:
970 975 import Numeric
971 976 except ImportError:
972 977 array_type = None
973 978 else:
974 979 array_type = Numeric.ArrayType.__name__
975 980
976 981 # Find all variable names and types so we can figure out column sizes
977 982
978 983 def get_vars(i):
979 984 return self.shell.user_ns[i]
980 985
981 986 # some types are well known and can be shorter
982 987 abbrevs = {'IPython.macro.Macro' : 'Macro'}
983 988 def type_name(v):
984 989 tn = type(v).__name__
985 990 return abbrevs.get(tn,tn)
986 991
987 992 varlist = map(get_vars,varnames)
988 993
989 994 typelist = []
990 995 for vv in varlist:
991 996 tt = type_name(vv)
992 997
993 998 if tt=='instance':
994 999 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
995 1000 else:
996 1001 typelist.append(tt)
997 1002
998 1003 # column labels and # of spaces as separator
999 1004 varlabel = 'Variable'
1000 1005 typelabel = 'Type'
1001 1006 datalabel = 'Data/Info'
1002 1007 colsep = 3
1003 1008 # variable format strings
1004 1009 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1005 1010 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1006 1011 aformat = "%s: %s elems, type `%s`, %s bytes"
1007 1012 # find the size of the columns to format the output nicely
1008 1013 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1009 1014 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1010 1015 # table header
1011 1016 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1012 1017 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1013 1018 # and the table itself
1014 1019 kb = 1024
1015 1020 Mb = 1048576 # kb**2
1016 1021 for vname,var,vtype in zip(varnames,varlist,typelist):
1017 1022 print itpl(vformat),
1018 1023 if vtype in seq_types:
1019 1024 print len(var)
1020 1025 elif vtype==array_type:
1021 1026 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1022 1027 vsize = Numeric.size(var)
1023 1028 vbytes = vsize*var.itemsize()
1024 1029 if vbytes < 100000:
1025 1030 print aformat % (vshape,vsize,var.typecode(),vbytes)
1026 1031 else:
1027 1032 print aformat % (vshape,vsize,var.typecode(),vbytes),
1028 1033 if vbytes < Mb:
1029 1034 print '(%s kb)' % (vbytes/kb,)
1030 1035 else:
1031 1036 print '(%s Mb)' % (vbytes/Mb,)
1032 1037 else:
1033 1038 vstr = str(var).replace('\n','\\n')
1034 1039 if len(vstr) < 50:
1035 1040 print vstr
1036 1041 else:
1037 1042 printpl(vfmt_short)
1038 1043
1039 1044 def magic_reset(self, parameter_s=''):
1040 1045 """Resets the namespace by removing all names defined by the user.
1041 1046
1042 1047 Input/Output history are left around in case you need them."""
1043 1048
1044 1049 ans = self.shell.ask_yes_no(
1045 1050 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1046 1051 if not ans:
1047 1052 print 'Nothing done.'
1048 1053 return
1049 1054 user_ns = self.shell.user_ns
1050 1055 for i in self.magic_who_ls():
1051 1056 del(user_ns[i])
1052 1057
1053 1058 def magic_logstart(self,parameter_s=''):
1054 1059 """Start logging anywhere in a session.
1055 1060
1056 1061 %logstart [-o|-r|-t] [log_name [log_mode]]
1057 1062
1058 1063 If no name is given, it defaults to a file named 'ipython_log.py' in your
1059 1064 current directory, in 'rotate' mode (see below).
1060 1065
1061 1066 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1062 1067 history up to that point and then continues logging.
1063 1068
1064 1069 %logstart takes a second optional parameter: logging mode. This can be one
1065 1070 of (note that the modes are given unquoted):\\
1066 1071 append: well, that says it.\\
1067 1072 backup: rename (if exists) to name~ and start name.\\
1068 1073 global: single logfile in your home dir, appended to.\\
1069 1074 over : overwrite existing log.\\
1070 1075 rotate: create rotating logs name.1~, name.2~, etc.
1071 1076
1072 1077 Options:
1073 1078
1074 1079 -o: log also IPython's output. In this mode, all commands which
1075 1080 generate an Out[NN] prompt are recorded to the logfile, right after
1076 1081 their corresponding input line. The output lines are always
1077 1082 prepended with a '#[Out]# ' marker, so that the log remains valid
1078 1083 Python code.
1079 1084
1080 1085 Since this marker is always the same, filtering only the output from
1081 1086 a log is very easy, using for example a simple awk call:
1082 1087
1083 1088 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1084 1089
1085 1090 -r: log 'raw' input. Normally, IPython's logs contain the processed
1086 1091 input, so that user lines are logged in their final form, converted
1087 1092 into valid Python. For example, %Exit is logged as
1088 1093 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1089 1094 exactly as typed, with no transformations applied.
1090 1095
1091 1096 -t: put timestamps before each input line logged (these are put in
1092 1097 comments)."""
1093 1098
1094 1099 opts,par = self.parse_options(parameter_s,'ort')
1095 1100 log_output = 'o' in opts
1096 1101 log_raw_input = 'r' in opts
1097 1102 timestamp = 't' in opts
1098 1103
1099 1104 rc = self.shell.rc
1100 1105 logger = self.shell.logger
1101 1106
1102 1107 # if no args are given, the defaults set in the logger constructor by
1103 1108 # ipytohn remain valid
1104 1109 if par:
1105 1110 try:
1106 1111 logfname,logmode = par.split()
1107 1112 except:
1108 1113 logfname = par
1109 1114 logmode = 'backup'
1110 1115 else:
1111 1116 logfname = logger.logfname
1112 1117 logmode = logger.logmode
1113 1118 # put logfname into rc struct as if it had been called on the command
1114 1119 # line, so it ends up saved in the log header Save it in case we need
1115 1120 # to restore it...
1116 1121 old_logfile = rc.opts.get('logfile','')
1117 1122 if logfname:
1118 1123 logfname = os.path.expanduser(logfname)
1119 1124 rc.opts.logfile = logfname
1120 1125 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1121 1126 try:
1122 1127 started = logger.logstart(logfname,loghead,logmode,
1123 1128 log_output,timestamp,log_raw_input)
1124 1129 except:
1125 1130 rc.opts.logfile = old_logfile
1126 1131 warn("Couldn't start log: %s" % sys.exc_info()[1])
1127 1132 else:
1128 1133 # log input history up to this point, optionally interleaving
1129 1134 # output if requested
1130 1135
1131 1136 if timestamp:
1132 1137 # disable timestamping for the previous history, since we've
1133 1138 # lost those already (no time machine here).
1134 1139 logger.timestamp = False
1135 1140
1136 1141 if log_raw_input:
1137 1142 input_hist = self.shell.input_hist_raw
1138 1143 else:
1139 1144 input_hist = self.shell.input_hist
1140 1145
1141 1146 if log_output:
1142 1147 log_write = logger.log_write
1143 1148 output_hist = self.shell.output_hist
1144 1149 for n in range(1,len(input_hist)-1):
1145 1150 log_write(input_hist[n].rstrip())
1146 1151 if n in output_hist:
1147 1152 log_write(repr(output_hist[n]),'output')
1148 1153 else:
1149 1154 logger.log_write(input_hist[1:])
1150 1155 if timestamp:
1151 1156 # re-enable timestamping
1152 1157 logger.timestamp = True
1153 1158
1154 1159 print ('Activating auto-logging. '
1155 1160 'Current session state plus future input saved.')
1156 1161 logger.logstate()
1157 1162
1158 1163 def magic_logoff(self,parameter_s=''):
1159 1164 """Temporarily stop logging.
1160 1165
1161 1166 You must have previously started logging."""
1162 1167 self.shell.logger.switch_log(0)
1163 1168
1164 1169 def magic_logon(self,parameter_s=''):
1165 1170 """Restart logging.
1166 1171
1167 1172 This function is for restarting logging which you've temporarily
1168 1173 stopped with %logoff. For starting logging for the first time, you
1169 1174 must use the %logstart function, which allows you to specify an
1170 1175 optional log filename."""
1171 1176
1172 1177 self.shell.logger.switch_log(1)
1173 1178
1174 1179 def magic_logstate(self,parameter_s=''):
1175 1180 """Print the status of the logging system."""
1176 1181
1177 1182 self.shell.logger.logstate()
1178 1183
1179 1184 def magic_pdb(self, parameter_s=''):
1180 1185 """Control the automatic calling of the pdb interactive debugger.
1181 1186
1182 1187 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1183 1188 argument it works as a toggle.
1184 1189
1185 1190 When an exception is triggered, IPython can optionally call the
1186 1191 interactive pdb debugger after the traceback printout. %pdb toggles
1187 1192 this feature on and off.
1188 1193
1189 1194 The initial state of this feature is set in your ipythonrc
1190 1195 configuration file (the variable is called 'pdb').
1191 1196
1192 1197 If you want to just activate the debugger AFTER an exception has fired,
1193 1198 without having to type '%pdb on' and rerunning your code, you can use
1194 1199 the %debug magic."""
1195 1200
1196 1201 par = parameter_s.strip().lower()
1197 1202
1198 1203 if par:
1199 1204 try:
1200 1205 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1201 1206 except KeyError:
1202 1207 print ('Incorrect argument. Use on/1, off/0, '
1203 1208 'or nothing for a toggle.')
1204 1209 return
1205 1210 else:
1206 1211 # toggle
1207 1212 new_pdb = not self.shell.call_pdb
1208 1213
1209 1214 # set on the shell
1210 1215 self.shell.call_pdb = new_pdb
1211 1216 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1212 1217
1213 1218 def magic_debug(self, parameter_s=''):
1214 1219 """Activate the interactive debugger in post-mortem mode.
1215 1220
1216 1221 If an exception has just occurred, this lets you inspect its stack
1217 1222 frames interactively. Note that this will always work only on the last
1218 1223 traceback that occurred, so you must call this quickly after an
1219 1224 exception that you wish to inspect has fired, because if another one
1220 1225 occurs, it clobbers the previous one.
1221 1226
1222 1227 If you want IPython to automatically do this on every exception, see
1223 1228 the %pdb magic for more details.
1224 1229 """
1225 1230
1226 1231 self.shell.debugger(force=True)
1227 1232
1228 1233 def magic_prun(self, parameter_s ='',user_mode=1,
1229 1234 opts=None,arg_lst=None,prog_ns=None):
1230 1235
1231 1236 """Run a statement through the python code profiler.
1232 1237
1233 1238 Usage:\\
1234 1239 %prun [options] statement
1235 1240
1236 1241 The given statement (which doesn't require quote marks) is run via the
1237 1242 python profiler in a manner similar to the profile.run() function.
1238 1243 Namespaces are internally managed to work correctly; profile.run
1239 1244 cannot be used in IPython because it makes certain assumptions about
1240 1245 namespaces which do not hold under IPython.
1241 1246
1242 1247 Options:
1243 1248
1244 1249 -l <limit>: you can place restrictions on what or how much of the
1245 1250 profile gets printed. The limit value can be:
1246 1251
1247 1252 * A string: only information for function names containing this string
1248 1253 is printed.
1249 1254
1250 1255 * An integer: only these many lines are printed.
1251 1256
1252 1257 * A float (between 0 and 1): this fraction of the report is printed
1253 1258 (for example, use a limit of 0.4 to see the topmost 40% only).
1254 1259
1255 1260 You can combine several limits with repeated use of the option. For
1256 1261 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1257 1262 information about class constructors.
1258 1263
1259 1264 -r: return the pstats.Stats object generated by the profiling. This
1260 1265 object has all the information about the profile in it, and you can
1261 1266 later use it for further analysis or in other functions.
1262 1267
1263 1268 -s <key>: sort profile by given key. You can provide more than one key
1264 1269 by using the option several times: '-s key1 -s key2 -s key3...'. The
1265 1270 default sorting key is 'time'.
1266 1271
1267 1272 The following is copied verbatim from the profile documentation
1268 1273 referenced below:
1269 1274
1270 1275 When more than one key is provided, additional keys are used as
1271 1276 secondary criteria when the there is equality in all keys selected
1272 1277 before them.
1273 1278
1274 1279 Abbreviations can be used for any key names, as long as the
1275 1280 abbreviation is unambiguous. The following are the keys currently
1276 1281 defined:
1277 1282
1278 1283 Valid Arg Meaning\\
1279 1284 "calls" call count\\
1280 1285 "cumulative" cumulative time\\
1281 1286 "file" file name\\
1282 1287 "module" file name\\
1283 1288 "pcalls" primitive call count\\
1284 1289 "line" line number\\
1285 1290 "name" function name\\
1286 1291 "nfl" name/file/line\\
1287 1292 "stdname" standard name\\
1288 1293 "time" internal time
1289 1294
1290 1295 Note that all sorts on statistics are in descending order (placing
1291 1296 most time consuming items first), where as name, file, and line number
1292 1297 searches are in ascending order (i.e., alphabetical). The subtle
1293 1298 distinction between "nfl" and "stdname" is that the standard name is a
1294 1299 sort of the name as printed, which means that the embedded line
1295 1300 numbers get compared in an odd way. For example, lines 3, 20, and 40
1296 1301 would (if the file names were the same) appear in the string order
1297 1302 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1298 1303 line numbers. In fact, sort_stats("nfl") is the same as
1299 1304 sort_stats("name", "file", "line").
1300 1305
1301 1306 -T <filename>: save profile results as shown on screen to a text
1302 1307 file. The profile is still shown on screen.
1303 1308
1304 1309 -D <filename>: save (via dump_stats) profile statistics to given
1305 1310 filename. This data is in a format understod by the pstats module, and
1306 1311 is generated by a call to the dump_stats() method of profile
1307 1312 objects. The profile is still shown on screen.
1308 1313
1309 1314 If you want to run complete programs under the profiler's control, use
1310 1315 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1311 1316 contains profiler specific options as described here.
1312 1317
1313 1318 You can read the complete documentation for the profile module with:\\
1314 1319 In [1]: import profile; profile.help() """
1315 1320
1316 1321 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1317 1322 # protect user quote marks
1318 1323 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1319 1324
1320 1325 if user_mode: # regular user call
1321 1326 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1322 1327 list_all=1)
1323 1328 namespace = self.shell.user_ns
1324 1329 else: # called to run a program by %run -p
1325 1330 try:
1326 1331 filename = get_py_filename(arg_lst[0])
1327 1332 except IOError,msg:
1328 1333 error(msg)
1329 1334 return
1330 1335
1331 1336 arg_str = 'execfile(filename,prog_ns)'
1332 1337 namespace = locals()
1333 1338
1334 1339 opts.merge(opts_def)
1335 1340
1336 1341 prof = profile.Profile()
1337 1342 try:
1338 1343 prof = prof.runctx(arg_str,namespace,namespace)
1339 1344 sys_exit = ''
1340 1345 except SystemExit:
1341 1346 sys_exit = """*** SystemExit exception caught in code being profiled."""
1342 1347
1343 1348 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1344 1349
1345 1350 lims = opts.l
1346 1351 if lims:
1347 1352 lims = [] # rebuild lims with ints/floats/strings
1348 1353 for lim in opts.l:
1349 1354 try:
1350 1355 lims.append(int(lim))
1351 1356 except ValueError:
1352 1357 try:
1353 1358 lims.append(float(lim))
1354 1359 except ValueError:
1355 1360 lims.append(lim)
1356 1361
1357 1362 # Trap output.
1358 1363 stdout_trap = StringIO()
1359 1364
1360 1365 if hasattr(stats,'stream'):
1361 1366 # In newer versions of python, the stats object has a 'stream'
1362 1367 # attribute to write into.
1363 1368 stats.stream = stdout_trap
1364 1369 stats.print_stats(*lims)
1365 1370 else:
1366 1371 # For older versions, we manually redirect stdout during printing
1367 1372 sys_stdout = sys.stdout
1368 1373 try:
1369 1374 sys.stdout = stdout_trap
1370 1375 stats.print_stats(*lims)
1371 1376 finally:
1372 1377 sys.stdout = sys_stdout
1373 1378
1374 1379 output = stdout_trap.getvalue()
1375 1380 output = output.rstrip()
1376 1381
1377 1382 page(output,screen_lines=self.shell.rc.screen_length)
1378 1383 print sys_exit,
1379 1384
1380 1385 dump_file = opts.D[0]
1381 1386 text_file = opts.T[0]
1382 1387 if dump_file:
1383 1388 prof.dump_stats(dump_file)
1384 1389 print '\n*** Profile stats marshalled to file',\
1385 1390 `dump_file`+'.',sys_exit
1386 1391 if text_file:
1387 1392 pfile = file(text_file,'w')
1388 1393 pfile.write(output)
1389 1394 pfile.close()
1390 1395 print '\n*** Profile printout saved to text file',\
1391 1396 `text_file`+'.',sys_exit
1392 1397
1393 1398 if opts.has_key('r'):
1394 1399 return stats
1395 1400 else:
1396 1401 return None
1397 1402
1398 1403 def magic_run(self, parameter_s ='',runner=None):
1399 1404 """Run the named file inside IPython as a program.
1400 1405
1401 1406 Usage:\\
1402 1407 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1403 1408
1404 1409 Parameters after the filename are passed as command-line arguments to
1405 1410 the program (put in sys.argv). Then, control returns to IPython's
1406 1411 prompt.
1407 1412
1408 1413 This is similar to running at a system prompt:\\
1409 1414 $ python file args\\
1410 1415 but with the advantage of giving you IPython's tracebacks, and of
1411 1416 loading all variables into your interactive namespace for further use
1412 1417 (unless -p is used, see below).
1413 1418
1414 1419 The file is executed in a namespace initially consisting only of
1415 1420 __name__=='__main__' and sys.argv constructed as indicated. It thus
1416 1421 sees its environment as if it were being run as a stand-alone
1417 1422 program. But after execution, the IPython interactive namespace gets
1418 1423 updated with all variables defined in the program (except for __name__
1419 1424 and sys.argv). This allows for very convenient loading of code for
1420 1425 interactive work, while giving each program a 'clean sheet' to run in.
1421 1426
1422 1427 Options:
1423 1428
1424 1429 -n: __name__ is NOT set to '__main__', but to the running file's name
1425 1430 without extension (as python does under import). This allows running
1426 1431 scripts and reloading the definitions in them without calling code
1427 1432 protected by an ' if __name__ == "__main__" ' clause.
1428 1433
1429 1434 -i: run the file in IPython's namespace instead of an empty one. This
1430 1435 is useful if you are experimenting with code written in a text editor
1431 1436 which depends on variables defined interactively.
1432 1437
1433 1438 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1434 1439 being run. This is particularly useful if IPython is being used to
1435 1440 run unittests, which always exit with a sys.exit() call. In such
1436 1441 cases you are interested in the output of the test results, not in
1437 1442 seeing a traceback of the unittest module.
1438 1443
1439 1444 -t: print timing information at the end of the run. IPython will give
1440 1445 you an estimated CPU time consumption for your script, which under
1441 1446 Unix uses the resource module to avoid the wraparound problems of
1442 1447 time.clock(). Under Unix, an estimate of time spent on system tasks
1443 1448 is also given (for Windows platforms this is reported as 0.0).
1444 1449
1445 1450 If -t is given, an additional -N<N> option can be given, where <N>
1446 1451 must be an integer indicating how many times you want the script to
1447 1452 run. The final timing report will include total and per run results.
1448 1453
1449 1454 For example (testing the script uniq_stable.py):
1450 1455
1451 1456 In [1]: run -t uniq_stable
1452 1457
1453 1458 IPython CPU timings (estimated):\\
1454 1459 User : 0.19597 s.\\
1455 1460 System: 0.0 s.\\
1456 1461
1457 1462 In [2]: run -t -N5 uniq_stable
1458 1463
1459 1464 IPython CPU timings (estimated):\\
1460 1465 Total runs performed: 5\\
1461 1466 Times : Total Per run\\
1462 1467 User : 0.910862 s, 0.1821724 s.\\
1463 1468 System: 0.0 s, 0.0 s.
1464 1469
1465 1470 -d: run your program under the control of pdb, the Python debugger.
1466 1471 This allows you to execute your program step by step, watch variables,
1467 1472 etc. Internally, what IPython does is similar to calling:
1468 1473
1469 1474 pdb.run('execfile("YOURFILENAME")')
1470 1475
1471 1476 with a breakpoint set on line 1 of your file. You can change the line
1472 1477 number for this automatic breakpoint to be <N> by using the -bN option
1473 1478 (where N must be an integer). For example:
1474 1479
1475 1480 %run -d -b40 myscript
1476 1481
1477 1482 will set the first breakpoint at line 40 in myscript.py. Note that
1478 1483 the first breakpoint must be set on a line which actually does
1479 1484 something (not a comment or docstring) for it to stop execution.
1480 1485
1481 1486 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1482 1487 first enter 'c' (without qoutes) to start execution up to the first
1483 1488 breakpoint.
1484 1489
1485 1490 Entering 'help' gives information about the use of the debugger. You
1486 1491 can easily see pdb's full documentation with "import pdb;pdb.help()"
1487 1492 at a prompt.
1488 1493
1489 1494 -p: run program under the control of the Python profiler module (which
1490 1495 prints a detailed report of execution times, function calls, etc).
1491 1496
1492 1497 You can pass other options after -p which affect the behavior of the
1493 1498 profiler itself. See the docs for %prun for details.
1494 1499
1495 1500 In this mode, the program's variables do NOT propagate back to the
1496 1501 IPython interactive namespace (because they remain in the namespace
1497 1502 where the profiler executes them).
1498 1503
1499 1504 Internally this triggers a call to %prun, see its documentation for
1500 1505 details on the options available specifically for profiling.
1501 1506
1502 1507 There is one special usage for which the text above doesn't apply:
1503 1508 if the filename ends with .ipy, the file is run as ipython script,
1504 1509 just as if the commands were written on IPython prompt.
1505 1510 """
1506 1511
1507 1512 # get arguments and set sys.argv for program to be run.
1508 1513 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1509 1514 mode='list',list_all=1)
1510 1515
1511 1516 try:
1512 1517 filename = get_py_filename(arg_lst[0])
1513 1518 except IndexError:
1514 1519 warn('you must provide at least a filename.')
1515 1520 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1516 1521 return
1517 1522 except IOError,msg:
1518 1523 error(msg)
1519 1524 return
1520 1525
1521 1526 if filename.lower().endswith('.ipy'):
1522 1527 self.api.runlines(open(filename).read())
1523 1528 return
1524 1529
1525 1530 # Control the response to exit() calls made by the script being run
1526 1531 exit_ignore = opts.has_key('e')
1527 1532
1528 1533 # Make sure that the running script gets a proper sys.argv as if it
1529 1534 # were run from a system shell.
1530 1535 save_argv = sys.argv # save it for later restoring
1531 1536 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1532 1537
1533 1538 if opts.has_key('i'):
1534 1539 prog_ns = self.shell.user_ns
1535 1540 __name__save = self.shell.user_ns['__name__']
1536 1541 prog_ns['__name__'] = '__main__'
1537 1542 else:
1538 1543 if opts.has_key('n'):
1539 1544 name = os.path.splitext(os.path.basename(filename))[0]
1540 1545 else:
1541 1546 name = '__main__'
1542 1547 prog_ns = {'__name__':name}
1543 1548
1544 1549 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1545 1550 # set the __file__ global in the script's namespace
1546 1551 prog_ns['__file__'] = filename
1547 1552
1548 1553 # pickle fix. See iplib for an explanation. But we need to make sure
1549 1554 # that, if we overwrite __main__, we replace it at the end
1550 1555 if prog_ns['__name__'] == '__main__':
1551 1556 restore_main = sys.modules['__main__']
1552 1557 else:
1553 1558 restore_main = False
1554 1559
1555 1560 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1556 1561
1557 1562 stats = None
1558 1563 try:
1559 1564 if self.shell.has_readline:
1560 1565 self.shell.savehist()
1561 1566
1562 1567 if opts.has_key('p'):
1563 1568 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1564 1569 else:
1565 1570 if opts.has_key('d'):
1566 1571 deb = Debugger.Pdb(self.shell.rc.colors)
1567 1572 # reset Breakpoint state, which is moronically kept
1568 1573 # in a class
1569 1574 bdb.Breakpoint.next = 1
1570 1575 bdb.Breakpoint.bplist = {}
1571 1576 bdb.Breakpoint.bpbynumber = [None]
1572 1577 # Set an initial breakpoint to stop execution
1573 1578 maxtries = 10
1574 1579 bp = int(opts.get('b',[1])[0])
1575 1580 checkline = deb.checkline(filename,bp)
1576 1581 if not checkline:
1577 1582 for bp in range(bp+1,bp+maxtries+1):
1578 1583 if deb.checkline(filename,bp):
1579 1584 break
1580 1585 else:
1581 1586 msg = ("\nI failed to find a valid line to set "
1582 1587 "a breakpoint\n"
1583 1588 "after trying up to line: %s.\n"
1584 1589 "Please set a valid breakpoint manually "
1585 1590 "with the -b option." % bp)
1586 1591 error(msg)
1587 1592 return
1588 1593 # if we find a good linenumber, set the breakpoint
1589 1594 deb.do_break('%s:%s' % (filename,bp))
1590 1595 # Start file run
1591 1596 print "NOTE: Enter 'c' at the",
1592 1597 print "%s prompt to start your script." % deb.prompt
1593 1598 try:
1594 1599 deb.run('execfile("%s")' % filename,prog_ns)
1595 1600
1596 1601 except:
1597 1602 etype, value, tb = sys.exc_info()
1598 1603 # Skip three frames in the traceback: the %run one,
1599 1604 # one inside bdb.py, and the command-line typed by the
1600 1605 # user (run by exec in pdb itself).
1601 1606 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1602 1607 else:
1603 1608 if runner is None:
1604 1609 runner = self.shell.safe_execfile
1605 1610 if opts.has_key('t'):
1606 1611 try:
1607 1612 nruns = int(opts['N'][0])
1608 1613 if nruns < 1:
1609 1614 error('Number of runs must be >=1')
1610 1615 return
1611 1616 except (KeyError):
1612 1617 nruns = 1
1613 1618 if nruns == 1:
1614 1619 t0 = clock2()
1615 1620 runner(filename,prog_ns,prog_ns,
1616 1621 exit_ignore=exit_ignore)
1617 1622 t1 = clock2()
1618 1623 t_usr = t1[0]-t0[0]
1619 1624 t_sys = t1[1]-t1[1]
1620 1625 print "\nIPython CPU timings (estimated):"
1621 1626 print " User : %10s s." % t_usr
1622 1627 print " System: %10s s." % t_sys
1623 1628 else:
1624 1629 runs = range(nruns)
1625 1630 t0 = clock2()
1626 1631 for nr in runs:
1627 1632 runner(filename,prog_ns,prog_ns,
1628 1633 exit_ignore=exit_ignore)
1629 1634 t1 = clock2()
1630 1635 t_usr = t1[0]-t0[0]
1631 1636 t_sys = t1[1]-t1[1]
1632 1637 print "\nIPython CPU timings (estimated):"
1633 1638 print "Total runs performed:",nruns
1634 1639 print " Times : %10s %10s" % ('Total','Per run')
1635 1640 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1636 1641 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1637 1642
1638 1643 else:
1639 1644 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1640 1645 if opts.has_key('i'):
1641 1646 self.shell.user_ns['__name__'] = __name__save
1642 1647 else:
1643 1648 # update IPython interactive namespace
1644 1649 del prog_ns['__name__']
1645 1650 self.shell.user_ns.update(prog_ns)
1646 1651 finally:
1647 1652 sys.argv = save_argv
1648 1653 if restore_main:
1649 1654 sys.modules['__main__'] = restore_main
1650 1655 if self.shell.has_readline:
1651 1656 self.shell.readline.read_history_file(self.shell.histfile)
1652 1657
1653 1658 return stats
1654 1659
1655 1660 def magic_runlog(self, parameter_s =''):
1656 1661 """Run files as logs.
1657 1662
1658 1663 Usage:\\
1659 1664 %runlog file1 file2 ...
1660 1665
1661 1666 Run the named files (treating them as log files) in sequence inside
1662 1667 the interpreter, and return to the prompt. This is much slower than
1663 1668 %run because each line is executed in a try/except block, but it
1664 1669 allows running files with syntax errors in them.
1665 1670
1666 1671 Normally IPython will guess when a file is one of its own logfiles, so
1667 1672 you can typically use %run even for logs. This shorthand allows you to
1668 1673 force any file to be treated as a log file."""
1669 1674
1670 1675 for f in parameter_s.split():
1671 1676 self.shell.safe_execfile(f,self.shell.user_ns,
1672 1677 self.shell.user_ns,islog=1)
1673 1678
1674 1679 def magic_timeit(self, parameter_s =''):
1675 1680 """Time execution of a Python statement or expression
1676 1681
1677 1682 Usage:\\
1678 1683 %timeit [-n<N> -r<R> [-t|-c]] statement
1679 1684
1680 1685 Time execution of a Python statement or expression using the timeit
1681 1686 module.
1682 1687
1683 1688 Options:
1684 1689 -n<N>: execute the given statement <N> times in a loop. If this value
1685 1690 is not given, a fitting value is chosen.
1686 1691
1687 1692 -r<R>: repeat the loop iteration <R> times and take the best result.
1688 1693 Default: 3
1689 1694
1690 1695 -t: use time.time to measure the time, which is the default on Unix.
1691 1696 This function measures wall time.
1692 1697
1693 1698 -c: use time.clock to measure the time, which is the default on
1694 1699 Windows and measures wall time. On Unix, resource.getrusage is used
1695 1700 instead and returns the CPU user time.
1696 1701
1697 1702 -p<P>: use a precision of <P> digits to display the timing result.
1698 1703 Default: 3
1699 1704
1700 1705
1701 1706 Examples:\\
1702 1707 In [1]: %timeit pass
1703 1708 10000000 loops, best of 3: 53.3 ns per loop
1704 1709
1705 1710 In [2]: u = None
1706 1711
1707 1712 In [3]: %timeit u is None
1708 1713 10000000 loops, best of 3: 184 ns per loop
1709 1714
1710 1715 In [4]: %timeit -r 4 u == None
1711 1716 1000000 loops, best of 4: 242 ns per loop
1712 1717
1713 1718 In [5]: import time
1714 1719
1715 1720 In [6]: %timeit -n1 time.sleep(2)
1716 1721 1 loops, best of 3: 2 s per loop
1717 1722
1718 1723
1719 1724 The times reported by %timeit will be slightly higher than those
1720 1725 reported by the timeit.py script when variables are accessed. This is
1721 1726 due to the fact that %timeit executes the statement in the namespace
1722 1727 of the shell, compared with timeit.py, which uses a single setup
1723 1728 statement to import function or create variables. Generally, the bias
1724 1729 does not matter as long as results from timeit.py are not mixed with
1725 1730 those from %timeit."""
1726 1731
1727 1732 import timeit
1728 1733 import math
1729 1734
1730 1735 units = ["s", "ms", "\xc2\xb5s", "ns"]
1731 1736 scaling = [1, 1e3, 1e6, 1e9]
1732 1737
1733 1738 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1734 1739 posix=False)
1735 1740 if stmt == "":
1736 1741 return
1737 1742 timefunc = timeit.default_timer
1738 1743 number = int(getattr(opts, "n", 0))
1739 1744 repeat = int(getattr(opts, "r", timeit.default_repeat))
1740 1745 precision = int(getattr(opts, "p", 3))
1741 1746 if hasattr(opts, "t"):
1742 1747 timefunc = time.time
1743 1748 if hasattr(opts, "c"):
1744 1749 timefunc = clock
1745 1750
1746 1751 timer = timeit.Timer(timer=timefunc)
1747 1752 # this code has tight coupling to the inner workings of timeit.Timer,
1748 1753 # but is there a better way to achieve that the code stmt has access
1749 1754 # to the shell namespace?
1750 1755
1751 1756 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1752 1757 'setup': "pass"}
1753 1758 code = compile(src, "<magic-timeit>", "exec")
1754 1759 ns = {}
1755 1760 exec code in self.shell.user_ns, ns
1756 1761 timer.inner = ns["inner"]
1757 1762
1758 1763 if number == 0:
1759 1764 # determine number so that 0.2 <= total time < 2.0
1760 1765 number = 1
1761 1766 for i in range(1, 10):
1762 1767 number *= 10
1763 1768 if timer.timeit(number) >= 0.2:
1764 1769 break
1765 1770
1766 1771 best = min(timer.repeat(repeat, number)) / number
1767 1772
1768 1773 if best > 0.0:
1769 1774 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1770 1775 else:
1771 1776 order = 3
1772 1777 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1773 1778 precision,
1774 1779 best * scaling[order],
1775 1780 units[order])
1776 1781
1777 1782 def magic_time(self,parameter_s = ''):
1778 1783 """Time execution of a Python statement or expression.
1779 1784
1780 1785 The CPU and wall clock times are printed, and the value of the
1781 1786 expression (if any) is returned. Note that under Win32, system time
1782 1787 is always reported as 0, since it can not be measured.
1783 1788
1784 1789 This function provides very basic timing functionality. In Python
1785 1790 2.3, the timeit module offers more control and sophistication, so this
1786 1791 could be rewritten to use it (patches welcome).
1787 1792
1788 1793 Some examples:
1789 1794
1790 1795 In [1]: time 2**128
1791 1796 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1792 1797 Wall time: 0.00
1793 1798 Out[1]: 340282366920938463463374607431768211456L
1794 1799
1795 1800 In [2]: n = 1000000
1796 1801
1797 1802 In [3]: time sum(range(n))
1798 1803 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1799 1804 Wall time: 1.37
1800 1805 Out[3]: 499999500000L
1801 1806
1802 1807 In [4]: time print 'hello world'
1803 1808 hello world
1804 1809 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1805 1810 Wall time: 0.00
1806 1811 """
1807 1812
1808 1813 # fail immediately if the given expression can't be compiled
1809 1814 try:
1810 1815 mode = 'eval'
1811 1816 code = compile(parameter_s,'<timed eval>',mode)
1812 1817 except SyntaxError:
1813 1818 mode = 'exec'
1814 1819 code = compile(parameter_s,'<timed exec>',mode)
1815 1820 # skew measurement as little as possible
1816 1821 glob = self.shell.user_ns
1817 1822 clk = clock2
1818 1823 wtime = time.time
1819 1824 # time execution
1820 1825 wall_st = wtime()
1821 1826 if mode=='eval':
1822 1827 st = clk()
1823 1828 out = eval(code,glob)
1824 1829 end = clk()
1825 1830 else:
1826 1831 st = clk()
1827 1832 exec code in glob
1828 1833 end = clk()
1829 1834 out = None
1830 1835 wall_end = wtime()
1831 1836 # Compute actual times and report
1832 1837 wall_time = wall_end-wall_st
1833 1838 cpu_user = end[0]-st[0]
1834 1839 cpu_sys = end[1]-st[1]
1835 1840 cpu_tot = cpu_user+cpu_sys
1836 1841 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1837 1842 (cpu_user,cpu_sys,cpu_tot)
1838 1843 print "Wall time: %.2f" % wall_time
1839 1844 return out
1840 1845
1841 1846 def magic_macro(self,parameter_s = ''):
1842 1847 """Define a set of input lines as a macro for future re-execution.
1843 1848
1844 1849 Usage:\\
1845 1850 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1846 1851
1847 1852 Options:
1848 1853
1849 1854 -r: use 'raw' input. By default, the 'processed' history is used,
1850 1855 so that magics are loaded in their transformed version to valid
1851 1856 Python. If this option is given, the raw input as typed as the
1852 1857 command line is used instead.
1853 1858
1854 1859 This will define a global variable called `name` which is a string
1855 1860 made of joining the slices and lines you specify (n1,n2,... numbers
1856 1861 above) from your input history into a single string. This variable
1857 1862 acts like an automatic function which re-executes those lines as if
1858 1863 you had typed them. You just type 'name' at the prompt and the code
1859 1864 executes.
1860 1865
1861 1866 The notation for indicating number ranges is: n1-n2 means 'use line
1862 1867 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1863 1868 using the lines numbered 5,6 and 7.
1864 1869
1865 1870 Note: as a 'hidden' feature, you can also use traditional python slice
1866 1871 notation, where N:M means numbers N through M-1.
1867 1872
1868 1873 For example, if your history contains (%hist prints it):
1869 1874
1870 1875 44: x=1\\
1871 1876 45: y=3\\
1872 1877 46: z=x+y\\
1873 1878 47: print x\\
1874 1879 48: a=5\\
1875 1880 49: print 'x',x,'y',y\\
1876 1881
1877 1882 you can create a macro with lines 44 through 47 (included) and line 49
1878 1883 called my_macro with:
1879 1884
1880 1885 In [51]: %macro my_macro 44-47 49
1881 1886
1882 1887 Now, typing `my_macro` (without quotes) will re-execute all this code
1883 1888 in one pass.
1884 1889
1885 1890 You don't need to give the line-numbers in order, and any given line
1886 1891 number can appear multiple times. You can assemble macros with any
1887 1892 lines from your input history in any order.
1888 1893
1889 1894 The macro is a simple object which holds its value in an attribute,
1890 1895 but IPython's display system checks for macros and executes them as
1891 1896 code instead of printing them when you type their name.
1892 1897
1893 1898 You can view a macro's contents by explicitly printing it with:
1894 1899
1895 1900 'print macro_name'.
1896 1901
1897 1902 For one-off cases which DON'T contain magic function calls in them you
1898 1903 can obtain similar results by explicitly executing slices from your
1899 1904 input history with:
1900 1905
1901 1906 In [60]: exec In[44:48]+In[49]"""
1902 1907
1903 1908 opts,args = self.parse_options(parameter_s,'r',mode='list')
1904 1909 name,ranges = args[0], args[1:]
1905 1910 #print 'rng',ranges # dbg
1906 1911 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1907 1912 macro = Macro(lines)
1908 1913 self.shell.user_ns.update({name:macro})
1909 1914 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1910 1915 print 'Macro contents:'
1911 1916 print macro,
1912 1917
1913 1918 def magic_save(self,parameter_s = ''):
1914 1919 """Save a set of lines to a given filename.
1915 1920
1916 1921 Usage:\\
1917 1922 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1918 1923
1919 1924 Options:
1920 1925
1921 1926 -r: use 'raw' input. By default, the 'processed' history is used,
1922 1927 so that magics are loaded in their transformed version to valid
1923 1928 Python. If this option is given, the raw input as typed as the
1924 1929 command line is used instead.
1925 1930
1926 1931 This function uses the same syntax as %macro for line extraction, but
1927 1932 instead of creating a macro it saves the resulting string to the
1928 1933 filename you specify.
1929 1934
1930 1935 It adds a '.py' extension to the file if you don't do so yourself, and
1931 1936 it asks for confirmation before overwriting existing files."""
1932 1937
1933 1938 opts,args = self.parse_options(parameter_s,'r',mode='list')
1934 1939 fname,ranges = args[0], args[1:]
1935 1940 if not fname.endswith('.py'):
1936 1941 fname += '.py'
1937 1942 if os.path.isfile(fname):
1938 1943 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1939 1944 if ans.lower() not in ['y','yes']:
1940 1945 print 'Operation cancelled.'
1941 1946 return
1942 1947 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1943 1948 f = file(fname,'w')
1944 1949 f.write(cmds)
1945 1950 f.close()
1946 1951 print 'The following commands were written to file `%s`:' % fname
1947 1952 print cmds
1948 1953
1949 1954 def _edit_macro(self,mname,macro):
1950 1955 """open an editor with the macro data in a file"""
1951 1956 filename = self.shell.mktempfile(macro.value)
1952 1957 self.shell.hooks.editor(filename)
1953 1958
1954 1959 # and make a new macro object, to replace the old one
1955 1960 mfile = open(filename)
1956 1961 mvalue = mfile.read()
1957 1962 mfile.close()
1958 1963 self.shell.user_ns[mname] = Macro(mvalue)
1959 1964
1960 1965 def magic_ed(self,parameter_s=''):
1961 1966 """Alias to %edit."""
1962 1967 return self.magic_edit(parameter_s)
1963 1968
1964 1969 def magic_edit(self,parameter_s='',last_call=['','']):
1965 1970 """Bring up an editor and execute the resulting code.
1966 1971
1967 1972 Usage:
1968 1973 %edit [options] [args]
1969 1974
1970 1975 %edit runs IPython's editor hook. The default version of this hook is
1971 1976 set to call the __IPYTHON__.rc.editor command. This is read from your
1972 1977 environment variable $EDITOR. If this isn't found, it will default to
1973 1978 vi under Linux/Unix and to notepad under Windows. See the end of this
1974 1979 docstring for how to change the editor hook.
1975 1980
1976 1981 You can also set the value of this editor via the command line option
1977 1982 '-editor' or in your ipythonrc file. This is useful if you wish to use
1978 1983 specifically for IPython an editor different from your typical default
1979 1984 (and for Windows users who typically don't set environment variables).
1980 1985
1981 1986 This command allows you to conveniently edit multi-line code right in
1982 1987 your IPython session.
1983 1988
1984 1989 If called without arguments, %edit opens up an empty editor with a
1985 1990 temporary file and will execute the contents of this file when you
1986 1991 close it (don't forget to save it!).
1987 1992
1988 1993
1989 1994 Options:
1990 1995
1991 1996 -n <number>: open the editor at a specified line number. By default,
1992 1997 the IPython editor hook uses the unix syntax 'editor +N filename', but
1993 1998 you can configure this by providing your own modified hook if your
1994 1999 favorite editor supports line-number specifications with a different
1995 2000 syntax.
1996 2001
1997 2002 -p: this will call the editor with the same data as the previous time
1998 2003 it was used, regardless of how long ago (in your current session) it
1999 2004 was.
2000 2005
2001 2006 -r: use 'raw' input. This option only applies to input taken from the
2002 2007 user's history. By default, the 'processed' history is used, so that
2003 2008 magics are loaded in their transformed version to valid Python. If
2004 2009 this option is given, the raw input as typed as the command line is
2005 2010 used instead. When you exit the editor, it will be executed by
2006 2011 IPython's own processor.
2007 2012
2008 2013 -x: do not execute the edited code immediately upon exit. This is
2009 2014 mainly useful if you are editing programs which need to be called with
2010 2015 command line arguments, which you can then do using %run.
2011 2016
2012 2017
2013 2018 Arguments:
2014 2019
2015 2020 If arguments are given, the following possibilites exist:
2016 2021
2017 2022 - The arguments are numbers or pairs of colon-separated numbers (like
2018 2023 1 4:8 9). These are interpreted as lines of previous input to be
2019 2024 loaded into the editor. The syntax is the same of the %macro command.
2020 2025
2021 2026 - If the argument doesn't start with a number, it is evaluated as a
2022 2027 variable and its contents loaded into the editor. You can thus edit
2023 2028 any string which contains python code (including the result of
2024 2029 previous edits).
2025 2030
2026 2031 - If the argument is the name of an object (other than a string),
2027 2032 IPython will try to locate the file where it was defined and open the
2028 2033 editor at the point where it is defined. You can use `%edit function`
2029 2034 to load an editor exactly at the point where 'function' is defined,
2030 2035 edit it and have the file be executed automatically.
2031 2036
2032 2037 If the object is a macro (see %macro for details), this opens up your
2033 2038 specified editor with a temporary file containing the macro's data.
2034 2039 Upon exit, the macro is reloaded with the contents of the file.
2035 2040
2036 2041 Note: opening at an exact line is only supported under Unix, and some
2037 2042 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2038 2043 '+NUMBER' parameter necessary for this feature. Good editors like
2039 2044 (X)Emacs, vi, jed, pico and joe all do.
2040 2045
2041 2046 - If the argument is not found as a variable, IPython will look for a
2042 2047 file with that name (adding .py if necessary) and load it into the
2043 2048 editor. It will execute its contents with execfile() when you exit,
2044 2049 loading any code in the file into your interactive namespace.
2045 2050
2046 2051 After executing your code, %edit will return as output the code you
2047 2052 typed in the editor (except when it was an existing file). This way
2048 2053 you can reload the code in further invocations of %edit as a variable,
2049 2054 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2050 2055 the output.
2051 2056
2052 2057 Note that %edit is also available through the alias %ed.
2053 2058
2054 2059 This is an example of creating a simple function inside the editor and
2055 2060 then modifying it. First, start up the editor:
2056 2061
2057 2062 In [1]: ed\\
2058 2063 Editing... done. Executing edited code...\\
2059 2064 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2060 2065
2061 2066 We can then call the function foo():
2062 2067
2063 2068 In [2]: foo()\\
2064 2069 foo() was defined in an editing session
2065 2070
2066 2071 Now we edit foo. IPython automatically loads the editor with the
2067 2072 (temporary) file where foo() was previously defined:
2068 2073
2069 2074 In [3]: ed foo\\
2070 2075 Editing... done. Executing edited code...
2071 2076
2072 2077 And if we call foo() again we get the modified version:
2073 2078
2074 2079 In [4]: foo()\\
2075 2080 foo() has now been changed!
2076 2081
2077 2082 Here is an example of how to edit a code snippet successive
2078 2083 times. First we call the editor:
2079 2084
2080 2085 In [8]: ed\\
2081 2086 Editing... done. Executing edited code...\\
2082 2087 hello\\
2083 2088 Out[8]: "print 'hello'\\n"
2084 2089
2085 2090 Now we call it again with the previous output (stored in _):
2086 2091
2087 2092 In [9]: ed _\\
2088 2093 Editing... done. Executing edited code...\\
2089 2094 hello world\\
2090 2095 Out[9]: "print 'hello world'\\n"
2091 2096
2092 2097 Now we call it with the output #8 (stored in _8, also as Out[8]):
2093 2098
2094 2099 In [10]: ed _8\\
2095 2100 Editing... done. Executing edited code...\\
2096 2101 hello again\\
2097 2102 Out[10]: "print 'hello again'\\n"
2098 2103
2099 2104
2100 2105 Changing the default editor hook:
2101 2106
2102 2107 If you wish to write your own editor hook, you can put it in a
2103 2108 configuration file which you load at startup time. The default hook
2104 2109 is defined in the IPython.hooks module, and you can use that as a
2105 2110 starting example for further modifications. That file also has
2106 2111 general instructions on how to set a new hook for use once you've
2107 2112 defined it."""
2108 2113
2109 2114 # FIXME: This function has become a convoluted mess. It needs a
2110 2115 # ground-up rewrite with clean, simple logic.
2111 2116
2112 2117 def make_filename(arg):
2113 2118 "Make a filename from the given args"
2114 2119 try:
2115 2120 filename = get_py_filename(arg)
2116 2121 except IOError:
2117 2122 if args.endswith('.py'):
2118 2123 filename = arg
2119 2124 else:
2120 2125 filename = None
2121 2126 return filename
2122 2127
2123 2128 # custom exceptions
2124 2129 class DataIsObject(Exception): pass
2125 2130
2126 2131 opts,args = self.parse_options(parameter_s,'prxn:')
2127 2132 # Set a few locals from the options for convenience:
2128 2133 opts_p = opts.has_key('p')
2129 2134 opts_r = opts.has_key('r')
2130 2135
2131 2136 # Default line number value
2132 2137 lineno = opts.get('n',None)
2133 2138
2134 2139 if opts_p:
2135 2140 args = '_%s' % last_call[0]
2136 2141 if not self.shell.user_ns.has_key(args):
2137 2142 args = last_call[1]
2138 2143
2139 2144 # use last_call to remember the state of the previous call, but don't
2140 2145 # let it be clobbered by successive '-p' calls.
2141 2146 try:
2142 2147 last_call[0] = self.shell.outputcache.prompt_count
2143 2148 if not opts_p:
2144 2149 last_call[1] = parameter_s
2145 2150 except:
2146 2151 pass
2147 2152
2148 2153 # by default this is done with temp files, except when the given
2149 2154 # arg is a filename
2150 2155 use_temp = 1
2151 2156
2152 2157 if re.match(r'\d',args):
2153 2158 # Mode where user specifies ranges of lines, like in %macro.
2154 2159 # This means that you can't edit files whose names begin with
2155 2160 # numbers this way. Tough.
2156 2161 ranges = args.split()
2157 2162 data = ''.join(self.extract_input_slices(ranges,opts_r))
2158 2163 elif args.endswith('.py'):
2159 2164 filename = make_filename(args)
2160 2165 data = ''
2161 2166 use_temp = 0
2162 2167 elif args:
2163 2168 try:
2164 2169 # Load the parameter given as a variable. If not a string,
2165 2170 # process it as an object instead (below)
2166 2171
2167 2172 #print '*** args',args,'type',type(args) # dbg
2168 2173 data = eval(args,self.shell.user_ns)
2169 2174 if not type(data) in StringTypes:
2170 2175 raise DataIsObject
2171 2176
2172 2177 except (NameError,SyntaxError):
2173 2178 # given argument is not a variable, try as a filename
2174 2179 filename = make_filename(args)
2175 2180 if filename is None:
2176 2181 warn("Argument given (%s) can't be found as a variable "
2177 2182 "or as a filename." % args)
2178 2183 return
2179 2184
2180 2185 data = ''
2181 2186 use_temp = 0
2182 2187 except DataIsObject:
2183 2188
2184 2189 # macros have a special edit function
2185 2190 if isinstance(data,Macro):
2186 2191 self._edit_macro(args,data)
2187 2192 return
2188 2193
2189 2194 # For objects, try to edit the file where they are defined
2190 2195 try:
2191 2196 filename = inspect.getabsfile(data)
2192 2197 datafile = 1
2193 2198 except TypeError:
2194 2199 filename = make_filename(args)
2195 2200 datafile = 1
2196 2201 warn('Could not find file where `%s` is defined.\n'
2197 2202 'Opening a file named `%s`' % (args,filename))
2198 2203 # Now, make sure we can actually read the source (if it was in
2199 2204 # a temp file it's gone by now).
2200 2205 if datafile:
2201 2206 try:
2202 2207 if lineno is None:
2203 2208 lineno = inspect.getsourcelines(data)[1]
2204 2209 except IOError:
2205 2210 filename = make_filename(args)
2206 2211 if filename is None:
2207 2212 warn('The file `%s` where `%s` was defined cannot '
2208 2213 'be read.' % (filename,data))
2209 2214 return
2210 2215 use_temp = 0
2211 2216 else:
2212 2217 data = ''
2213 2218
2214 2219 if use_temp:
2215 2220 filename = self.shell.mktempfile(data)
2216 2221 print 'IPython will make a temporary file named:',filename
2217 2222
2218 2223 # do actual editing here
2219 2224 print 'Editing...',
2220 2225 sys.stdout.flush()
2221 2226 self.shell.hooks.editor(filename,lineno)
2222 2227 if opts.has_key('x'): # -x prevents actual execution
2223 2228 print
2224 2229 else:
2225 2230 print 'done. Executing edited code...'
2226 2231 if opts_r:
2227 2232 self.shell.runlines(file_read(filename))
2228 2233 else:
2229 2234 self.shell.safe_execfile(filename,self.shell.user_ns)
2230 2235 if use_temp:
2231 2236 try:
2232 2237 return open(filename).read()
2233 2238 except IOError,msg:
2234 2239 if msg.filename == filename:
2235 2240 warn('File not found. Did you forget to save?')
2236 2241 return
2237 2242 else:
2238 2243 self.shell.showtraceback()
2239 2244
2240 2245 def magic_xmode(self,parameter_s = ''):
2241 2246 """Switch modes for the exception handlers.
2242 2247
2243 2248 Valid modes: Plain, Context and Verbose.
2244 2249
2245 2250 If called without arguments, acts as a toggle."""
2246 2251
2247 2252 def xmode_switch_err(name):
2248 2253 warn('Error changing %s exception modes.\n%s' %
2249 2254 (name,sys.exc_info()[1]))
2250 2255
2251 2256 shell = self.shell
2252 2257 new_mode = parameter_s.strip().capitalize()
2253 2258 try:
2254 2259 shell.InteractiveTB.set_mode(mode=new_mode)
2255 2260 print 'Exception reporting mode:',shell.InteractiveTB.mode
2256 2261 except:
2257 2262 xmode_switch_err('user')
2258 2263
2259 2264 # threaded shells use a special handler in sys.excepthook
2260 2265 if shell.isthreaded:
2261 2266 try:
2262 2267 shell.sys_excepthook.set_mode(mode=new_mode)
2263 2268 except:
2264 2269 xmode_switch_err('threaded')
2265 2270
2266 2271 def magic_colors(self,parameter_s = ''):
2267 2272 """Switch color scheme for prompts, info system and exception handlers.
2268 2273
2269 2274 Currently implemented schemes: NoColor, Linux, LightBG.
2270 2275
2271 2276 Color scheme names are not case-sensitive."""
2272 2277
2273 2278 def color_switch_err(name):
2274 2279 warn('Error changing %s color schemes.\n%s' %
2275 2280 (name,sys.exc_info()[1]))
2276 2281
2277 2282
2278 2283 new_scheme = parameter_s.strip()
2279 2284 if not new_scheme:
2280 2285 print 'You must specify a color scheme.'
2281 2286 return
2282 2287 import IPython.rlineimpl as readline
2283 2288 if not readline.have_readline:
2284 2289 msg = """\
2285 2290 Proper color support under MS Windows requires the pyreadline library.
2286 2291 You can find it at:
2287 2292 http://ipython.scipy.org/moin/PyReadline/Intro
2288 2293 Gary's readline needs the ctypes module, from:
2289 2294 http://starship.python.net/crew/theller/ctypes
2290 2295 (Note that ctypes is already part of Python versions 2.5 and newer).
2291 2296
2292 2297 Defaulting color scheme to 'NoColor'"""
2293 2298 new_scheme = 'NoColor'
2294 2299 warn(msg)
2295 2300 # local shortcut
2296 2301 shell = self.shell
2297 2302
2298 2303 # Set prompt colors
2299 2304 try:
2300 2305 shell.outputcache.set_colors(new_scheme)
2301 2306 except:
2302 2307 color_switch_err('prompt')
2303 2308 else:
2304 2309 shell.rc.colors = \
2305 2310 shell.outputcache.color_table.active_scheme_name
2306 2311 # Set exception colors
2307 2312 try:
2308 2313 shell.InteractiveTB.set_colors(scheme = new_scheme)
2309 2314 shell.SyntaxTB.set_colors(scheme = new_scheme)
2310 2315 except:
2311 2316 color_switch_err('exception')
2312 2317
2313 2318 # threaded shells use a verbose traceback in sys.excepthook
2314 2319 if shell.isthreaded:
2315 2320 try:
2316 2321 shell.sys_excepthook.set_colors(scheme=new_scheme)
2317 2322 except:
2318 2323 color_switch_err('system exception handler')
2319 2324
2320 2325 # Set info (for 'object?') colors
2321 2326 if shell.rc.color_info:
2322 2327 try:
2323 2328 shell.inspector.set_active_scheme(new_scheme)
2324 2329 except:
2325 2330 color_switch_err('object inspector')
2326 2331 else:
2327 2332 shell.inspector.set_active_scheme('NoColor')
2328 2333
2329 2334 def magic_color_info(self,parameter_s = ''):
2330 2335 """Toggle color_info.
2331 2336
2332 2337 The color_info configuration parameter controls whether colors are
2333 2338 used for displaying object details (by things like %psource, %pfile or
2334 2339 the '?' system). This function toggles this value with each call.
2335 2340
2336 2341 Note that unless you have a fairly recent pager (less works better
2337 2342 than more) in your system, using colored object information displays
2338 2343 will not work properly. Test it and see."""
2339 2344
2340 2345 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2341 2346 self.magic_colors(self.shell.rc.colors)
2342 2347 print 'Object introspection functions have now coloring:',
2343 2348 print ['OFF','ON'][self.shell.rc.color_info]
2344 2349
2345 2350 def magic_Pprint(self, parameter_s=''):
2346 2351 """Toggle pretty printing on/off."""
2347 2352
2348 2353 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2349 2354 print 'Pretty printing has been turned', \
2350 2355 ['OFF','ON'][self.shell.rc.pprint]
2351 2356
2352 2357 def magic_exit(self, parameter_s=''):
2353 2358 """Exit IPython, confirming if configured to do so.
2354 2359
2355 2360 You can configure whether IPython asks for confirmation upon exit by
2356 2361 setting the confirm_exit flag in the ipythonrc file."""
2357 2362
2358 2363 self.shell.exit()
2359 2364
2360 2365 def magic_quit(self, parameter_s=''):
2361 2366 """Exit IPython, confirming if configured to do so (like %exit)"""
2362 2367
2363 2368 self.shell.exit()
2364 2369
2365 2370 def magic_Exit(self, parameter_s=''):
2366 2371 """Exit IPython without confirmation."""
2367 2372
2368 2373 self.shell.exit_now = True
2369 2374
2370 2375 def magic_Quit(self, parameter_s=''):
2371 2376 """Exit IPython without confirmation (like %Exit)."""
2372 2377
2373 2378 self.shell.exit_now = True
2374 2379
2375 2380 #......................................................................
2376 2381 # Functions to implement unix shell-type things
2377 2382
2378 2383 def magic_alias(self, parameter_s = ''):
2379 2384 """Define an alias for a system command.
2380 2385
2381 2386 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2382 2387
2383 2388 Then, typing 'alias_name params' will execute the system command 'cmd
2384 2389 params' (from your underlying operating system).
2385 2390
2386 2391 Aliases have lower precedence than magic functions and Python normal
2387 2392 variables, so if 'foo' is both a Python variable and an alias, the
2388 2393 alias can not be executed until 'del foo' removes the Python variable.
2389 2394
2390 2395 You can use the %l specifier in an alias definition to represent the
2391 2396 whole line when the alias is called. For example:
2392 2397
2393 2398 In [2]: alias all echo "Input in brackets: <%l>"\\
2394 2399 In [3]: all hello world\\
2395 2400 Input in brackets: <hello world>
2396 2401
2397 2402 You can also define aliases with parameters using %s specifiers (one
2398 2403 per parameter):
2399 2404
2400 2405 In [1]: alias parts echo first %s second %s\\
2401 2406 In [2]: %parts A B\\
2402 2407 first A second B\\
2403 2408 In [3]: %parts A\\
2404 2409 Incorrect number of arguments: 2 expected.\\
2405 2410 parts is an alias to: 'echo first %s second %s'
2406 2411
2407 2412 Note that %l and %s are mutually exclusive. You can only use one or
2408 2413 the other in your aliases.
2409 2414
2410 2415 Aliases expand Python variables just like system calls using ! or !!
2411 2416 do: all expressions prefixed with '$' get expanded. For details of
2412 2417 the semantic rules, see PEP-215:
2413 2418 http://www.python.org/peps/pep-0215.html. This is the library used by
2414 2419 IPython for variable expansion. If you want to access a true shell
2415 2420 variable, an extra $ is necessary to prevent its expansion by IPython:
2416 2421
2417 2422 In [6]: alias show echo\\
2418 2423 In [7]: PATH='A Python string'\\
2419 2424 In [8]: show $PATH\\
2420 2425 A Python string\\
2421 2426 In [9]: show $$PATH\\
2422 2427 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2423 2428
2424 2429 You can use the alias facility to acess all of $PATH. See the %rehash
2425 2430 and %rehashx functions, which automatically create aliases for the
2426 2431 contents of your $PATH.
2427 2432
2428 2433 If called with no parameters, %alias prints the current alias table."""
2429 2434
2430 2435 par = parameter_s.strip()
2431 2436 if not par:
2432 2437 stored = self.db.get('stored_aliases', {} )
2433 2438 atab = self.shell.alias_table
2434 2439 aliases = atab.keys()
2435 2440 aliases.sort()
2436 2441 res = []
2437 2442 showlast = []
2438 2443 for alias in aliases:
2439 2444 tgt = atab[alias][1]
2440 2445 # 'interesting' aliases
2441 2446 if (alias in stored or
2442 2447 alias != os.path.splitext(tgt)[0] or
2443 2448 ' ' in tgt):
2444 2449 showlast.append((alias, tgt))
2445 2450 else:
2446 2451 res.append((alias, tgt ))
2447 2452
2448 2453 # show most interesting aliases last
2449 2454 res.extend(showlast)
2450 2455 print "Total number of aliases:",len(aliases)
2451 2456 return res
2452 2457 try:
2453 2458 alias,cmd = par.split(None,1)
2454 2459 except:
2455 2460 print OInspect.getdoc(self.magic_alias)
2456 2461 else:
2457 2462 nargs = cmd.count('%s')
2458 2463 if nargs>0 and cmd.find('%l')>=0:
2459 2464 error('The %s and %l specifiers are mutually exclusive '
2460 2465 'in alias definitions.')
2461 2466 else: # all looks OK
2462 2467 self.shell.alias_table[alias] = (nargs,cmd)
2463 2468 self.shell.alias_table_validate(verbose=0)
2464 2469 # end magic_alias
2465 2470
2466 2471 def magic_unalias(self, parameter_s = ''):
2467 2472 """Remove an alias"""
2468 2473
2469 2474 aname = parameter_s.strip()
2470 2475 if aname in self.shell.alias_table:
2471 2476 del self.shell.alias_table[aname]
2472 2477 stored = self.db.get('stored_aliases', {} )
2473 2478 if aname in stored:
2474 2479 print "Removing %stored alias",aname
2475 2480 del stored[aname]
2476 2481 self.db['stored_aliases'] = stored
2477 2482
2478 2483 def magic_rehash(self, parameter_s = ''):
2479 2484 """Update the alias table with all entries in $PATH.
2480 2485
2481 2486 This version does no checks on execute permissions or whether the
2482 2487 contents of $PATH are truly files (instead of directories or something
2483 2488 else). For such a safer (but slower) version, use %rehashx."""
2484 2489
2485 2490 # This function (and rehashx) manipulate the alias_table directly
2486 2491 # rather than calling magic_alias, for speed reasons. A rehash on a
2487 2492 # typical Linux box involves several thousand entries, so efficiency
2488 2493 # here is a top concern.
2489 2494
2490 2495 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2491 2496 alias_table = self.shell.alias_table
2492 2497 for pdir in path:
2493 2498 for ff in os.listdir(pdir):
2494 2499 # each entry in the alias table must be (N,name), where
2495 2500 # N is the number of positional arguments of the alias.
2496 2501 alias_table[ff] = (0,ff)
2497 2502 # Make sure the alias table doesn't contain keywords or builtins
2498 2503 self.shell.alias_table_validate()
2499 2504 # Call again init_auto_alias() so we get 'rm -i' and other modified
2500 2505 # aliases since %rehash will probably clobber them
2501 2506 self.shell.init_auto_alias()
2502 2507
2503 2508 def magic_rehashx(self, parameter_s = ''):
2504 2509 """Update the alias table with all executable files in $PATH.
2505 2510
2506 2511 This version explicitly checks that every entry in $PATH is a file
2507 2512 with execute access (os.X_OK), so it is much slower than %rehash.
2508 2513
2509 2514 Under Windows, it checks executability as a match agains a
2510 2515 '|'-separated string of extensions, stored in the IPython config
2511 2516 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2512 2517
2513 2518 path = [os.path.abspath(os.path.expanduser(p)) for p in
2514 2519 os.environ['PATH'].split(os.pathsep)]
2515 2520 path = filter(os.path.isdir,path)
2516 2521
2517 2522 alias_table = self.shell.alias_table
2518 2523 syscmdlist = []
2519 2524 if os.name == 'posix':
2520 2525 isexec = lambda fname:os.path.isfile(fname) and \
2521 2526 os.access(fname,os.X_OK)
2522 2527 else:
2523 2528
2524 2529 try:
2525 2530 winext = os.environ['pathext'].replace(';','|').replace('.','')
2526 2531 except KeyError:
2527 2532 winext = 'exe|com|bat|py'
2528 2533 if 'py' not in winext:
2529 2534 winext += '|py'
2530 2535 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2531 2536 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2532 2537 savedir = os.getcwd()
2533 2538 try:
2534 2539 # write the whole loop for posix/Windows so we don't have an if in
2535 2540 # the innermost part
2536 2541 if os.name == 'posix':
2537 2542 for pdir in path:
2538 2543 os.chdir(pdir)
2539 2544 for ff in os.listdir(pdir):
2540 2545 if isexec(ff) and ff not in self.shell.no_alias:
2541 2546 # each entry in the alias table must be (N,name),
2542 2547 # where N is the number of positional arguments of the
2543 2548 # alias.
2544 2549 alias_table[ff] = (0,ff)
2545 2550 syscmdlist.append(ff)
2546 2551 else:
2547 2552 for pdir in path:
2548 2553 os.chdir(pdir)
2549 2554 for ff in os.listdir(pdir):
2550 2555 base, ext = os.path.splitext(ff)
2551 2556 if isexec(ff) and base not in self.shell.no_alias:
2552 2557 if ext.lower() == '.exe':
2553 2558 ff = base
2554 2559 alias_table[base] = (0,ff)
2555 2560 syscmdlist.append(ff)
2556 2561 # Make sure the alias table doesn't contain keywords or builtins
2557 2562 self.shell.alias_table_validate()
2558 2563 # Call again init_auto_alias() so we get 'rm -i' and other
2559 2564 # modified aliases since %rehashx will probably clobber them
2560 2565 self.shell.init_auto_alias()
2561 2566 db = self.getapi().db
2562 2567 db['syscmdlist'] = syscmdlist
2563 2568 finally:
2564 2569 os.chdir(savedir)
2565 2570
2566 2571 def magic_pwd(self, parameter_s = ''):
2567 2572 """Return the current working directory path."""
2568 2573 return os.getcwd()
2569 2574
2570 2575 def magic_cd(self, parameter_s=''):
2571 2576 """Change the current working directory.
2572 2577
2573 2578 This command automatically maintains an internal list of directories
2574 2579 you visit during your IPython session, in the variable _dh. The
2575 2580 command %dhist shows this history nicely formatted. You can also
2576 2581 do 'cd -<tab>' to see directory history conveniently.
2577 2582
2578 2583 Usage:
2579 2584
2580 2585 cd 'dir': changes to directory 'dir'.
2581 2586
2582 2587 cd -: changes to the last visited directory.
2583 2588
2584 2589 cd -<n>: changes to the n-th directory in the directory history.
2585 2590
2586 2591 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2587 2592 (note: cd <bookmark_name> is enough if there is no
2588 2593 directory <bookmark_name>, but a bookmark with the name exists.)
2589 2594 'cd -b <tab>' allows you to tab-complete bookmark names.
2590 2595
2591 2596 Options:
2592 2597
2593 2598 -q: quiet. Do not print the working directory after the cd command is
2594 2599 executed. By default IPython's cd command does print this directory,
2595 2600 since the default prompts do not display path information.
2596 2601
2597 2602 Note that !cd doesn't work for this purpose because the shell where
2598 2603 !command runs is immediately discarded after executing 'command'."""
2599 2604
2600 2605 parameter_s = parameter_s.strip()
2601 2606 #bkms = self.shell.persist.get("bookmarks",{})
2602 2607
2603 2608 numcd = re.match(r'(-)(\d+)$',parameter_s)
2604 2609 # jump in directory history by number
2605 2610 if numcd:
2606 2611 nn = int(numcd.group(2))
2607 2612 try:
2608 2613 ps = self.shell.user_ns['_dh'][nn]
2609 2614 except IndexError:
2610 2615 print 'The requested directory does not exist in history.'
2611 2616 return
2612 2617 else:
2613 2618 opts = {}
2614 2619 else:
2615 2620 #turn all non-space-escaping backslashes to slashes,
2616 2621 # for c:\windows\directory\names\
2617 2622 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2618 2623 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2619 2624 # jump to previous
2620 2625 if ps == '-':
2621 2626 try:
2622 2627 ps = self.shell.user_ns['_dh'][-2]
2623 2628 except IndexError:
2624 2629 print 'No previous directory to change to.'
2625 2630 return
2626 2631 # jump to bookmark if needed
2627 2632 else:
2628 2633 if not os.path.isdir(ps) or opts.has_key('b'):
2629 2634 bkms = self.db.get('bookmarks', {})
2630 2635
2631 2636 if bkms.has_key(ps):
2632 2637 target = bkms[ps]
2633 2638 print '(bookmark:%s) -> %s' % (ps,target)
2634 2639 ps = target
2635 2640 else:
2636 2641 if opts.has_key('b'):
2637 2642 error("Bookmark '%s' not found. "
2638 2643 "Use '%%bookmark -l' to see your bookmarks." % ps)
2639 2644 return
2640 2645
2641 2646 # at this point ps should point to the target dir
2642 2647 if ps:
2643 2648 try:
2644 2649 os.chdir(os.path.expanduser(ps))
2645 2650 if self.shell.rc.term_title:
2646 2651 #print 'set term title:',self.shell.rc.term_title # dbg
2647 2652 ttitle = ("IPy:" + (
2648 2653 os.getcwd() == '/' and '/' or \
2649 2654 os.path.basename(os.getcwd())))
2650 2655 platutils.set_term_title(ttitle)
2651 2656 except OSError:
2652 2657 print sys.exc_info()[1]
2653 2658 else:
2654 2659 self.shell.user_ns['_dh'].append(os.getcwd())
2655 2660 else:
2656 2661 os.chdir(self.shell.home_dir)
2657 2662 if self.shell.rc.term_title:
2658 2663 platutils.set_term_title("IPy:~")
2659 2664 self.shell.user_ns['_dh'].append(os.getcwd())
2660 2665 if not 'q' in opts:
2661 2666 print self.shell.user_ns['_dh'][-1]
2662 2667
2663 2668 def magic_dhist(self, parameter_s=''):
2664 2669 """Print your history of visited directories.
2665 2670
2666 2671 %dhist -> print full history\\
2667 2672 %dhist n -> print last n entries only\\
2668 2673 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2669 2674
2670 2675 This history is automatically maintained by the %cd command, and
2671 2676 always available as the global list variable _dh. You can use %cd -<n>
2672 2677 to go to directory number <n>."""
2673 2678
2674 2679 dh = self.shell.user_ns['_dh']
2675 2680 if parameter_s:
2676 2681 try:
2677 2682 args = map(int,parameter_s.split())
2678 2683 except:
2679 2684 self.arg_err(Magic.magic_dhist)
2680 2685 return
2681 2686 if len(args) == 1:
2682 2687 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2683 2688 elif len(args) == 2:
2684 2689 ini,fin = args
2685 2690 else:
2686 2691 self.arg_err(Magic.magic_dhist)
2687 2692 return
2688 2693 else:
2689 2694 ini,fin = 0,len(dh)
2690 2695 nlprint(dh,
2691 2696 header = 'Directory history (kept in _dh)',
2692 2697 start=ini,stop=fin)
2693 2698
2694 2699 def magic_env(self, parameter_s=''):
2695 2700 """List environment variables."""
2696 2701
2697 2702 return os.environ.data
2698 2703
2699 2704 def magic_pushd(self, parameter_s=''):
2700 2705 """Place the current dir on stack and change directory.
2701 2706
2702 2707 Usage:\\
2703 2708 %pushd ['dirname']
2704 2709
2705 2710 %pushd with no arguments does a %pushd to your home directory.
2706 2711 """
2707 2712 if parameter_s == '': parameter_s = '~'
2708 2713 dir_s = self.shell.dir_stack
2709 2714 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2710 2715 os.path.expanduser(self.shell.dir_stack[0]):
2711 2716 try:
2712 2717 self.magic_cd(parameter_s)
2713 2718 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2714 2719 self.magic_dirs()
2715 2720 except:
2716 2721 print 'Invalid directory'
2717 2722 else:
2718 2723 print 'You are already there!'
2719 2724
2720 2725 def magic_popd(self, parameter_s=''):
2721 2726 """Change to directory popped off the top of the stack.
2722 2727 """
2723 2728 if len (self.shell.dir_stack) > 1:
2724 2729 self.shell.dir_stack.pop(0)
2725 2730 self.magic_cd(self.shell.dir_stack[0])
2726 2731 print self.shell.dir_stack[0]
2727 2732 else:
2728 2733 print "You can't remove the starting directory from the stack:",\
2729 2734 self.shell.dir_stack
2730 2735
2731 2736 def magic_dirs(self, parameter_s=''):
2732 2737 """Return the current directory stack."""
2733 2738
2734 2739 return self.shell.dir_stack[:]
2735 2740
2736 2741 def magic_sc(self, parameter_s=''):
2737 2742 """Shell capture - execute a shell command and capture its output.
2738 2743
2739 2744 DEPRECATED. Suboptimal, retained for backwards compatibility.
2740 2745
2741 2746 You should use the form 'var = !command' instead. Example:
2742 2747
2743 2748 "%sc -l myfiles = ls ~" should now be written as
2744 2749
2745 2750 "myfiles = !ls ~"
2746 2751
2747 2752 myfiles.s, myfiles.l and myfiles.n still apply as documented
2748 2753 below.
2749 2754
2750 2755 --
2751 2756 %sc [options] varname=command
2752 2757
2753 2758 IPython will run the given command using commands.getoutput(), and
2754 2759 will then update the user's interactive namespace with a variable
2755 2760 called varname, containing the value of the call. Your command can
2756 2761 contain shell wildcards, pipes, etc.
2757 2762
2758 2763 The '=' sign in the syntax is mandatory, and the variable name you
2759 2764 supply must follow Python's standard conventions for valid names.
2760 2765
2761 2766 (A special format without variable name exists for internal use)
2762 2767
2763 2768 Options:
2764 2769
2765 2770 -l: list output. Split the output on newlines into a list before
2766 2771 assigning it to the given variable. By default the output is stored
2767 2772 as a single string.
2768 2773
2769 2774 -v: verbose. Print the contents of the variable.
2770 2775
2771 2776 In most cases you should not need to split as a list, because the
2772 2777 returned value is a special type of string which can automatically
2773 2778 provide its contents either as a list (split on newlines) or as a
2774 2779 space-separated string. These are convenient, respectively, either
2775 2780 for sequential processing or to be passed to a shell command.
2776 2781
2777 2782 For example:
2778 2783
2779 2784 # Capture into variable a
2780 2785 In [9]: sc a=ls *py
2781 2786
2782 2787 # a is a string with embedded newlines
2783 2788 In [10]: a
2784 2789 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2785 2790
2786 2791 # which can be seen as a list:
2787 2792 In [11]: a.l
2788 2793 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2789 2794
2790 2795 # or as a whitespace-separated string:
2791 2796 In [12]: a.s
2792 2797 Out[12]: 'setup.py win32_manual_post_install.py'
2793 2798
2794 2799 # a.s is useful to pass as a single command line:
2795 2800 In [13]: !wc -l $a.s
2796 2801 146 setup.py
2797 2802 130 win32_manual_post_install.py
2798 2803 276 total
2799 2804
2800 2805 # while the list form is useful to loop over:
2801 2806 In [14]: for f in a.l:
2802 2807 ....: !wc -l $f
2803 2808 ....:
2804 2809 146 setup.py
2805 2810 130 win32_manual_post_install.py
2806 2811
2807 2812 Similiarly, the lists returned by the -l option are also special, in
2808 2813 the sense that you can equally invoke the .s attribute on them to
2809 2814 automatically get a whitespace-separated string from their contents:
2810 2815
2811 2816 In [1]: sc -l b=ls *py
2812 2817
2813 2818 In [2]: b
2814 2819 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2815 2820
2816 2821 In [3]: b.s
2817 2822 Out[3]: 'setup.py win32_manual_post_install.py'
2818 2823
2819 2824 In summary, both the lists and strings used for ouptut capture have
2820 2825 the following special attributes:
2821 2826
2822 2827 .l (or .list) : value as list.
2823 2828 .n (or .nlstr): value as newline-separated string.
2824 2829 .s (or .spstr): value as space-separated string.
2825 2830 """
2826 2831
2827 2832 opts,args = self.parse_options(parameter_s,'lv')
2828 2833 # Try to get a variable name and command to run
2829 2834 try:
2830 2835 # the variable name must be obtained from the parse_options
2831 2836 # output, which uses shlex.split to strip options out.
2832 2837 var,_ = args.split('=',1)
2833 2838 var = var.strip()
2834 2839 # But the the command has to be extracted from the original input
2835 2840 # parameter_s, not on what parse_options returns, to avoid the
2836 2841 # quote stripping which shlex.split performs on it.
2837 2842 _,cmd = parameter_s.split('=',1)
2838 2843 except ValueError:
2839 2844 var,cmd = '',''
2840 2845 # If all looks ok, proceed
2841 2846 out,err = self.shell.getoutputerror(cmd)
2842 2847 if err:
2843 2848 print >> Term.cerr,err
2844 2849 if opts.has_key('l'):
2845 2850 out = SList(out.split('\n'))
2846 2851 else:
2847 2852 out = LSString(out)
2848 2853 if opts.has_key('v'):
2849 2854 print '%s ==\n%s' % (var,pformat(out))
2850 2855 if var:
2851 2856 self.shell.user_ns.update({var:out})
2852 2857 else:
2853 2858 return out
2854 2859
2855 2860 def magic_sx(self, parameter_s=''):
2856 2861 """Shell execute - run a shell command and capture its output.
2857 2862
2858 2863 %sx command
2859 2864
2860 2865 IPython will run the given command using commands.getoutput(), and
2861 2866 return the result formatted as a list (split on '\\n'). Since the
2862 2867 output is _returned_, it will be stored in ipython's regular output
2863 2868 cache Out[N] and in the '_N' automatic variables.
2864 2869
2865 2870 Notes:
2866 2871
2867 2872 1) If an input line begins with '!!', then %sx is automatically
2868 2873 invoked. That is, while:
2869 2874 !ls
2870 2875 causes ipython to simply issue system('ls'), typing
2871 2876 !!ls
2872 2877 is a shorthand equivalent to:
2873 2878 %sx ls
2874 2879
2875 2880 2) %sx differs from %sc in that %sx automatically splits into a list,
2876 2881 like '%sc -l'. The reason for this is to make it as easy as possible
2877 2882 to process line-oriented shell output via further python commands.
2878 2883 %sc is meant to provide much finer control, but requires more
2879 2884 typing.
2880 2885
2881 2886 3) Just like %sc -l, this is a list with special attributes:
2882 2887
2883 2888 .l (or .list) : value as list.
2884 2889 .n (or .nlstr): value as newline-separated string.
2885 2890 .s (or .spstr): value as whitespace-separated string.
2886 2891
2887 2892 This is very useful when trying to use such lists as arguments to
2888 2893 system commands."""
2889 2894
2890 2895 if parameter_s:
2891 2896 out,err = self.shell.getoutputerror(parameter_s)
2892 2897 if err:
2893 2898 print >> Term.cerr,err
2894 2899 return SList(out.split('\n'))
2895 2900
2896 2901 def magic_bg(self, parameter_s=''):
2897 2902 """Run a job in the background, in a separate thread.
2898 2903
2899 2904 For example,
2900 2905
2901 2906 %bg myfunc(x,y,z=1)
2902 2907
2903 2908 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2904 2909 execution starts, a message will be printed indicating the job
2905 2910 number. If your job number is 5, you can use
2906 2911
2907 2912 myvar = jobs.result(5) or myvar = jobs[5].result
2908 2913
2909 2914 to assign this result to variable 'myvar'.
2910 2915
2911 2916 IPython has a job manager, accessible via the 'jobs' object. You can
2912 2917 type jobs? to get more information about it, and use jobs.<TAB> to see
2913 2918 its attributes. All attributes not starting with an underscore are
2914 2919 meant for public use.
2915 2920
2916 2921 In particular, look at the jobs.new() method, which is used to create
2917 2922 new jobs. This magic %bg function is just a convenience wrapper
2918 2923 around jobs.new(), for expression-based jobs. If you want to create a
2919 2924 new job with an explicit function object and arguments, you must call
2920 2925 jobs.new() directly.
2921 2926
2922 2927 The jobs.new docstring also describes in detail several important
2923 2928 caveats associated with a thread-based model for background job
2924 2929 execution. Type jobs.new? for details.
2925 2930
2926 2931 You can check the status of all jobs with jobs.status().
2927 2932
2928 2933 The jobs variable is set by IPython into the Python builtin namespace.
2929 2934 If you ever declare a variable named 'jobs', you will shadow this
2930 2935 name. You can either delete your global jobs variable to regain
2931 2936 access to the job manager, or make a new name and assign it manually
2932 2937 to the manager (stored in IPython's namespace). For example, to
2933 2938 assign the job manager to the Jobs name, use:
2934 2939
2935 2940 Jobs = __builtins__.jobs"""
2936 2941
2937 2942 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2938 2943
2939 2944
2940 2945 def magic_bookmark(self, parameter_s=''):
2941 2946 """Manage IPython's bookmark system.
2942 2947
2943 2948 %bookmark <name> - set bookmark to current dir
2944 2949 %bookmark <name> <dir> - set bookmark to <dir>
2945 2950 %bookmark -l - list all bookmarks
2946 2951 %bookmark -d <name> - remove bookmark
2947 2952 %bookmark -r - remove all bookmarks
2948 2953
2949 2954 You can later on access a bookmarked folder with:
2950 2955 %cd -b <name>
2951 2956 or simply '%cd <name>' if there is no directory called <name> AND
2952 2957 there is such a bookmark defined.
2953 2958
2954 2959 Your bookmarks persist through IPython sessions, but they are
2955 2960 associated with each profile."""
2956 2961
2957 2962 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2958 2963 if len(args) > 2:
2959 2964 error('You can only give at most two arguments')
2960 2965 return
2961 2966
2962 2967 bkms = self.db.get('bookmarks',{})
2963 2968
2964 2969 if opts.has_key('d'):
2965 2970 try:
2966 2971 todel = args[0]
2967 2972 except IndexError:
2968 2973 error('You must provide a bookmark to delete')
2969 2974 else:
2970 2975 try:
2971 2976 del bkms[todel]
2972 2977 except:
2973 2978 error("Can't delete bookmark '%s'" % todel)
2974 2979 elif opts.has_key('r'):
2975 2980 bkms = {}
2976 2981 elif opts.has_key('l'):
2977 2982 bks = bkms.keys()
2978 2983 bks.sort()
2979 2984 if bks:
2980 2985 size = max(map(len,bks))
2981 2986 else:
2982 2987 size = 0
2983 2988 fmt = '%-'+str(size)+'s -> %s'
2984 2989 print 'Current bookmarks:'
2985 2990 for bk in bks:
2986 2991 print fmt % (bk,bkms[bk])
2987 2992 else:
2988 2993 if not args:
2989 2994 error("You must specify the bookmark name")
2990 2995 elif len(args)==1:
2991 2996 bkms[args[0]] = os.getcwd()
2992 2997 elif len(args)==2:
2993 2998 bkms[args[0]] = args[1]
2994 2999 self.db['bookmarks'] = bkms
2995 3000
2996 3001 def magic_pycat(self, parameter_s=''):
2997 3002 """Show a syntax-highlighted file through a pager.
2998 3003
2999 3004 This magic is similar to the cat utility, but it will assume the file
3000 3005 to be Python source and will show it with syntax highlighting. """
3001 3006
3002 3007 try:
3003 3008 filename = get_py_filename(parameter_s)
3004 3009 cont = file_read(filename)
3005 3010 except IOError:
3006 3011 try:
3007 3012 cont = eval(parameter_s,self.user_ns)
3008 3013 except NameError:
3009 3014 cont = None
3010 3015 if cont is None:
3011 3016 print "Error: no such file or variable"
3012 3017 return
3013 3018
3014 3019 page(self.shell.pycolorize(cont),
3015 3020 screen_lines=self.shell.rc.screen_length)
3016 3021
3017 3022 def magic_cpaste(self, parameter_s=''):
3018 3023 """Allows you to paste & execute a pre-formatted code block from clipboard
3019 3024
3020 3025 You must terminate the block with '--' (two minus-signs) alone on the
3021 3026 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3022 3027 is the new sentinel for this operation)
3023 3028
3024 3029 The block is dedented prior to execution to enable execution of
3025 3030 method definitions. '>' characters at the beginning of a line is
3026 3031 ignored, to allow pasting directly from e-mails. The executed block
3027 3032 is also assigned to variable named 'pasted_block' for later editing
3028 3033 with '%edit pasted_block'.
3029 3034
3030 3035 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3031 3036 This assigns the pasted block to variable 'foo' as string, without
3032 3037 dedenting or executing it.
3033 3038
3034 3039 Do not be alarmed by garbled output on Windows (it's a readline bug).
3035 3040 Just press enter and type -- (and press enter again) and the block
3036 3041 will be what was just pasted.
3037 3042
3038 3043 IPython statements (magics, shell escapes) are not supported (yet).
3039 3044 """
3040 3045 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3041 3046 par = args.strip()
3042 3047 sentinel = opts.get('s','--')
3043 3048
3044 3049 from IPython import iplib
3045 3050 lines = []
3046 3051 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3047 3052 while 1:
3048 3053 l = iplib.raw_input_original(':')
3049 3054 if l ==sentinel:
3050 3055 break
3051 3056 lines.append(l.lstrip('>'))
3052 3057 block = "\n".join(lines) + '\n'
3053 3058 #print "block:\n",block
3054 3059 if not par:
3055 3060 b = textwrap.dedent(block)
3056 3061 exec b in self.user_ns
3057 3062 self.user_ns['pasted_block'] = b
3058 3063 else:
3059 3064 self.user_ns[par] = block
3060 3065 print "Block assigned to '%s'" % par
3061 3066
3062 3067 def magic_quickref(self,arg):
3063 3068 """ Show a quick reference sheet """
3064 3069 import IPython.usage
3065 3070 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3066 3071
3067 3072 page(qr)
3068 3073
3069 3074 def magic_upgrade(self,arg):
3070 3075 """ Upgrade your IPython installation
3071 3076
3072 3077 This will copy the config files that don't yet exist in your
3073 3078 ipython dir from the system config dir. Use this after upgrading
3074 3079 IPython if you don't wish to delete your .ipython dir.
3075 3080
3076 3081 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3077 3082 new users)
3078 3083
3079 3084 """
3080 3085 ip = self.getapi()
3081 3086 ipinstallation = path(IPython.__file__).dirname()
3082 3087 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3083 3088 src_config = ipinstallation / 'UserConfig'
3084 3089 userdir = path(ip.options.ipythondir)
3085 3090 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3086 3091 print ">",cmd
3087 3092 shell(cmd)
3088 3093 if arg == '-nolegacy':
3089 3094 legacy = userdir.files('ipythonrc*')
3090 3095 print "Nuking legacy files:",legacy
3091 3096
3092 3097 [p.remove() for p in legacy]
3093 3098 suffix = (sys.platform == 'win32' and '.ini' or '')
3094 3099 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3095 3100
3096 3101 # end Magic
@@ -1,2578 +1,2579 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 2173 2007-03-23 14:26:16Z vivainio $
9 $Id: iplib.py 2187 2007-03-30 04:56:40Z fperez $
10 10 """
11 11
12 12 #*****************************************************************************
13 13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 15 #
16 16 # Distributed under the terms of the BSD License. The full license is in
17 17 # the file COPYING, distributed as part of this software.
18 18 #
19 19 # Note: this code originally subclassed code.InteractiveConsole from the
20 20 # Python standard library. Over time, all of that class has been copied
21 21 # verbatim here for modifications which could not be accomplished by
22 22 # subclassing. At this point, there are no dependencies at all on the code
23 23 # module anymore (it is not even imported). The Python License (sec. 2)
24 24 # allows for this, but it's always nice to acknowledge credit where credit is
25 25 # due.
26 26 #*****************************************************************************
27 27
28 28 #****************************************************************************
29 29 # Modules and globals
30 30
31 31 from IPython import Release
32 32 __author__ = '%s <%s>\n%s <%s>' % \
33 33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 34 __license__ = Release.license
35 35 __version__ = Release.version
36 36
37 37 # Python standard modules
38 38 import __main__
39 39 import __builtin__
40 40 import StringIO
41 41 import bdb
42 42 import cPickle as pickle
43 43 import codeop
44 44 import exceptions
45 45 import glob
46 46 import inspect
47 47 import keyword
48 48 import new
49 49 import os
50 50 import pydoc
51 51 import re
52 52 import shutil
53 53 import string
54 54 import sys
55 55 import tempfile
56 56 import traceback
57 57 import types
58 58 import pickleshare
59 59 from sets import Set
60 60 from pprint import pprint, pformat
61 61
62 62 # IPython's own modules
63 63 import IPython
64 64 from IPython import OInspect,PyColorize,ultraTB
65 65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 66 from IPython.FakeModule import FakeModule
67 67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 68 from IPython.Logger import Logger
69 69 from IPython.Magic import Magic
70 70 from IPython.Prompts import CachedOutput
71 71 from IPython.ipstruct import Struct
72 72 from IPython.background_jobs import BackgroundJobManager
73 73 from IPython.usage import cmd_line_usage,interactive_usage
74 74 from IPython.genutils import *
75 75 from IPython.strdispatch import StrDispatch
76 76 import IPython.ipapi
77 77
78 78 # Globals
79 79
80 80 # store the builtin raw_input globally, and use this always, in case user code
81 81 # overwrites it (like wx.py.PyShell does)
82 82 raw_input_original = raw_input
83 83
84 84 # compiled regexps for autoindent management
85 85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86 86
87 87
88 88 #****************************************************************************
89 89 # Some utility function definitions
90 90
91 91 ini_spaces_re = re.compile(r'^(\s+)')
92 92
93 93 def num_ini_spaces(strng):
94 94 """Return the number of initial spaces in a string"""
95 95
96 96 ini_spaces = ini_spaces_re.match(strng)
97 97 if ini_spaces:
98 98 return ini_spaces.end()
99 99 else:
100 100 return 0
101 101
102 102 def softspace(file, newvalue):
103 103 """Copied from code.py, to remove the dependency"""
104 104
105 105 oldvalue = 0
106 106 try:
107 107 oldvalue = file.softspace
108 108 except AttributeError:
109 109 pass
110 110 try:
111 111 file.softspace = newvalue
112 112 except (AttributeError, TypeError):
113 113 # "attribute-less object" or "read-only attributes"
114 114 pass
115 115 return oldvalue
116 116
117 117
118 118 #****************************************************************************
119 119 # Local use exceptions
120 120 class SpaceInInput(exceptions.Exception): pass
121 121
122 122
123 123 #****************************************************************************
124 124 # Local use classes
125 125 class Bunch: pass
126 126
127 127 class Undefined: pass
128 128
129 129 class Quitter(object):
130 130 """Simple class to handle exit, similar to Python 2.5's.
131 131
132 132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
133 133 doesn't do (obviously, since it doesn't know about ipython)."""
134 134
135 135 def __init__(self,shell,name):
136 136 self.shell = shell
137 137 self.name = name
138 138
139 139 def __repr__(self):
140 140 return 'Type %s() to exit.' % self.name
141 141 __str__ = __repr__
142 142
143 143 def __call__(self):
144 144 self.shell.exit()
145 145
146 146 class InputList(list):
147 147 """Class to store user input.
148 148
149 149 It's basically a list, but slices return a string instead of a list, thus
150 150 allowing things like (assuming 'In' is an instance):
151 151
152 152 exec In[4:7]
153 153
154 154 or
155 155
156 156 exec In[5:9] + In[14] + In[21:25]"""
157 157
158 158 def __getslice__(self,i,j):
159 159 return ''.join(list.__getslice__(self,i,j))
160 160
161 161 class SyntaxTB(ultraTB.ListTB):
162 162 """Extension which holds some state: the last exception value"""
163 163
164 164 def __init__(self,color_scheme = 'NoColor'):
165 165 ultraTB.ListTB.__init__(self,color_scheme)
166 166 self.last_syntax_error = None
167 167
168 168 def __call__(self, etype, value, elist):
169 169 self.last_syntax_error = value
170 170 ultraTB.ListTB.__call__(self,etype,value,elist)
171 171
172 172 def clear_err_state(self):
173 173 """Return the current error state and clear it"""
174 174 e = self.last_syntax_error
175 175 self.last_syntax_error = None
176 176 return e
177 177
178 178 #****************************************************************************
179 179 # Main IPython class
180 180
181 181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
182 182 # until a full rewrite is made. I've cleaned all cross-class uses of
183 183 # attributes and methods, but too much user code out there relies on the
184 184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
185 185 #
186 186 # But at least now, all the pieces have been separated and we could, in
187 187 # principle, stop using the mixin. This will ease the transition to the
188 188 # chainsaw branch.
189 189
190 190 # For reference, the following is the list of 'self.foo' uses in the Magic
191 191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
192 192 # class, to prevent clashes.
193 193
194 194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
195 195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
196 196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
197 197 # 'self.value']
198 198
199 199 class InteractiveShell(object,Magic):
200 200 """An enhanced console for Python."""
201 201
202 202 # class attribute to indicate whether the class supports threads or not.
203 203 # Subclasses with thread support should override this as needed.
204 204 isthreaded = False
205 205
206 206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
207 207 user_ns = None,user_global_ns=None,banner2='',
208 208 custom_exceptions=((),None),embedded=False):
209 209
210 210 # log system
211 211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
212 212
213 213 # some minimal strict typechecks. For some core data structures, I
214 214 # want actual basic python types, not just anything that looks like
215 215 # one. This is especially true for namespaces.
216 216 for ns in (user_ns,user_global_ns):
217 217 if ns is not None and type(ns) != types.DictType:
218 218 raise TypeError,'namespace must be a dictionary'
219 219
220 220 # Job manager (for jobs run as background threads)
221 221 self.jobs = BackgroundJobManager()
222 222
223 223 # Store the actual shell's name
224 224 self.name = name
225 225
226 226 # We need to know whether the instance is meant for embedding, since
227 227 # global/local namespaces need to be handled differently in that case
228 228 self.embedded = embedded
229 229
230 230 # command compiler
231 231 self.compile = codeop.CommandCompiler()
232 232
233 233 # User input buffer
234 234 self.buffer = []
235 235
236 236 # Default name given in compilation of code
237 237 self.filename = '<ipython console>'
238 238
239 239 # Install our own quitter instead of the builtins. For python2.3-2.4,
240 240 # this brings in behavior like 2.5, and for 2.5 it's identical.
241 241 __builtin__.exit = Quitter(self,'exit')
242 242 __builtin__.quit = Quitter(self,'quit')
243 243
244 244 # Make an empty namespace, which extension writers can rely on both
245 245 # existing and NEVER being used by ipython itself. This gives them a
246 246 # convenient location for storing additional information and state
247 247 # their extensions may require, without fear of collisions with other
248 248 # ipython names that may develop later.
249 249 self.meta = Struct()
250 250
251 251 # Create the namespace where the user will operate. user_ns is
252 252 # normally the only one used, and it is passed to the exec calls as
253 253 # the locals argument. But we do carry a user_global_ns namespace
254 254 # given as the exec 'globals' argument, This is useful in embedding
255 255 # situations where the ipython shell opens in a context where the
256 256 # distinction between locals and globals is meaningful.
257 257
258 258 # FIXME. For some strange reason, __builtins__ is showing up at user
259 259 # level as a dict instead of a module. This is a manual fix, but I
260 260 # should really track down where the problem is coming from. Alex
261 261 # Schmolck reported this problem first.
262 262
263 263 # A useful post by Alex Martelli on this topic:
264 264 # Re: inconsistent value from __builtins__
265 265 # Von: Alex Martelli <aleaxit@yahoo.com>
266 266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
267 267 # Gruppen: comp.lang.python
268 268
269 269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
270 270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
271 271 # > <type 'dict'>
272 272 # > >>> print type(__builtins__)
273 273 # > <type 'module'>
274 274 # > Is this difference in return value intentional?
275 275
276 276 # Well, it's documented that '__builtins__' can be either a dictionary
277 277 # or a module, and it's been that way for a long time. Whether it's
278 278 # intentional (or sensible), I don't know. In any case, the idea is
279 279 # that if you need to access the built-in namespace directly, you
280 280 # should start with "import __builtin__" (note, no 's') which will
281 281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
282 282
283 283 # These routines return properly built dicts as needed by the rest of
284 284 # the code, and can also be used by extension writers to generate
285 285 # properly initialized namespaces.
286 286 user_ns = IPython.ipapi.make_user_ns(user_ns)
287 287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
288 288
289 289 # Assign namespaces
290 290 # This is the namespace where all normal user variables live
291 291 self.user_ns = user_ns
292 292 # Embedded instances require a separate namespace for globals.
293 293 # Normally this one is unused by non-embedded instances.
294 294 self.user_global_ns = user_global_ns
295 295 # A namespace to keep track of internal data structures to prevent
296 296 # them from cluttering user-visible stuff. Will be updated later
297 297 self.internal_ns = {}
298 298
299 299 # Namespace of system aliases. Each entry in the alias
300 300 # table must be a 2-tuple of the form (N,name), where N is the number
301 301 # of positional arguments of the alias.
302 302 self.alias_table = {}
303 303
304 304 # A table holding all the namespaces IPython deals with, so that
305 305 # introspection facilities can search easily.
306 306 self.ns_table = {'user':user_ns,
307 307 'user_global':user_global_ns,
308 308 'alias':self.alias_table,
309 309 'internal':self.internal_ns,
310 310 'builtin':__builtin__.__dict__
311 311 }
312 312
313 313 # The user namespace MUST have a pointer to the shell itself.
314 314 self.user_ns[name] = self
315 315
316 316 # We need to insert into sys.modules something that looks like a
317 317 # module but which accesses the IPython namespace, for shelve and
318 318 # pickle to work interactively. Normally they rely on getting
319 319 # everything out of __main__, but for embedding purposes each IPython
320 320 # instance has its own private namespace, so we can't go shoving
321 321 # everything into __main__.
322 322
323 323 # note, however, that we should only do this for non-embedded
324 324 # ipythons, which really mimic the __main__.__dict__ with their own
325 325 # namespace. Embedded instances, on the other hand, should not do
326 326 # this because they need to manage the user local/global namespaces
327 327 # only, but they live within a 'normal' __main__ (meaning, they
328 328 # shouldn't overtake the execution environment of the script they're
329 329 # embedded in).
330 330
331 331 if not embedded:
332 332 try:
333 333 main_name = self.user_ns['__name__']
334 334 except KeyError:
335 335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 336 else:
337 337 #print "pickle hack in place" # dbg
338 338 #print 'main_name:',main_name # dbg
339 339 sys.modules[main_name] = FakeModule(self.user_ns)
340 340
341 341 # List of input with multi-line handling.
342 342 # Fill its zero entry, user counter starts at 1
343 343 self.input_hist = InputList(['\n'])
344 344 # This one will hold the 'raw' input history, without any
345 345 # pre-processing. This will allow users to retrieve the input just as
346 346 # it was exactly typed in by the user, with %hist -r.
347 347 self.input_hist_raw = InputList(['\n'])
348 348
349 349 # list of visited directories
350 350 try:
351 351 self.dir_hist = [os.getcwd()]
352 352 except IOError, e:
353 353 self.dir_hist = []
354 354
355 355 # dict of output history
356 356 self.output_hist = {}
357 357
358 358 # dict of things NOT to alias (keywords, builtins and some magics)
359 359 no_alias = {}
360 360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 361 for key in keyword.kwlist + no_alias_magics:
362 362 no_alias[key] = 1
363 363 no_alias.update(__builtin__.__dict__)
364 364 self.no_alias = no_alias
365 365
366 366 # make global variables for user access to these
367 367 self.user_ns['_ih'] = self.input_hist
368 368 self.user_ns['_oh'] = self.output_hist
369 369 self.user_ns['_dh'] = self.dir_hist
370 370
371 371 # user aliases to input and output histories
372 372 self.user_ns['In'] = self.input_hist
373 373 self.user_ns['Out'] = self.output_hist
374 374
375 375 # Object variable to store code object waiting execution. This is
376 376 # used mainly by the multithreaded shells, but it can come in handy in
377 377 # other situations. No need to use a Queue here, since it's a single
378 378 # item which gets cleared once run.
379 379 self.code_to_run = None
380 380
381 381 # escapes for automatic behavior on the command line
382 382 self.ESC_SHELL = '!'
383 383 self.ESC_HELP = '?'
384 384 self.ESC_MAGIC = '%'
385 385 self.ESC_QUOTE = ','
386 386 self.ESC_QUOTE2 = ';'
387 387 self.ESC_PAREN = '/'
388 388
389 389 # And their associated handlers
390 390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 391 self.ESC_QUOTE : self.handle_auto,
392 392 self.ESC_QUOTE2 : self.handle_auto,
393 393 self.ESC_MAGIC : self.handle_magic,
394 394 self.ESC_HELP : self.handle_help,
395 395 self.ESC_SHELL : self.handle_shell_escape,
396 396 }
397 397
398 398 # class initializations
399 399 Magic.__init__(self,self)
400 400
401 401 # Python source parser/formatter for syntax highlighting
402 402 pyformat = PyColorize.Parser().format
403 403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404 404
405 405 # hooks holds pointers used for user-side customizations
406 406 self.hooks = Struct()
407 407
408 408 self.strdispatchers = {}
409 409
410 410 # Set all default hooks, defined in the IPython.hooks module.
411 411 hooks = IPython.hooks
412 412 for hook_name in hooks.__all__:
413 413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
414 414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 415 #print "bound hook",hook_name
416 416
417 417 # Flag to mark unconditional exit
418 418 self.exit_now = False
419 419
420 420 self.usage_min = """\
421 421 An enhanced console for Python.
422 422 Some of its features are:
423 423 - Readline support if the readline library is present.
424 424 - Tab completion in the local namespace.
425 425 - Logging of input, see command-line options.
426 426 - System shell escape via ! , eg !ls.
427 427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 428 - Keeps track of locally defined variables via %who, %whos.
429 429 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 430 """
431 431 if usage: self.usage = usage
432 432 else: self.usage = self.usage_min
433 433
434 434 # Storage
435 435 self.rc = rc # This will hold all configuration information
436 436 self.pager = 'less'
437 437 # temporary files used for various purposes. Deleted at exit.
438 438 self.tempfiles = []
439 439
440 440 # Keep track of readline usage (later set by init_readline)
441 441 self.has_readline = False
442 442
443 443 # template for logfile headers. It gets resolved at runtime by the
444 444 # logstart method.
445 445 self.loghead_tpl = \
446 446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 448 #log# opts = %s
449 449 #log# args = %s
450 450 #log# It is safe to make manual edits below here.
451 451 #log#-----------------------------------------------------------------------
452 452 """
453 453 # for pushd/popd management
454 454 try:
455 455 self.home_dir = get_home_dir()
456 456 except HomeDirError,msg:
457 457 fatal(msg)
458 458
459 459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460 460
461 461 # Functions to call the underlying shell.
462 462
463 463 # The first is similar to os.system, but it doesn't return a value,
464 464 # and it allows interpolation of variables in the user's namespace.
465 465 self.system = lambda cmd: \
466 466 shell(self.var_expand(cmd,depth=2),
467 467 header=self.rc.system_header,
468 468 verbose=self.rc.system_verbose)
469 469
470 470 # These are for getoutput and getoutputerror:
471 471 self.getoutput = lambda cmd: \
472 472 getoutput(self.var_expand(cmd,depth=2),
473 473 header=self.rc.system_header,
474 474 verbose=self.rc.system_verbose)
475 475
476 476 self.getoutputerror = lambda cmd: \
477 477 getoutputerror(self.var_expand(cmd,depth=2),
478 478 header=self.rc.system_header,
479 479 verbose=self.rc.system_verbose)
480 480
481 481 # RegExp for splitting line contents into pre-char//first
482 482 # word-method//rest. For clarity, each group in on one line.
483 483
484 484 # WARNING: update the regexp if the above escapes are changed, as they
485 485 # are hardwired in.
486 486
487 487 # Don't get carried away with trying to make the autocalling catch too
488 488 # much: it's better to be conservative rather than to trigger hidden
489 489 # evals() somewhere and end up causing side effects.
490 490 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
491 491 r'([\?\w\.]+\w*\s*)'
492 492 r'(\(?.*$)')
493 493
494 494 self.shell_line_split = re.compile(r'^(\s*)'
495 495 r'(\S*\s*)'
496 496 r'(\(?.*$)')
497 497
498 498
499 499 # A simpler regexp used as a fallback if the above doesn't work. This
500 500 # one is more conservative in how it partitions the input. This code
501 501 # can probably be cleaned up to do everything with just one regexp, but
502 502 # I'm afraid of breaking something; do it once the unit tests are in
503 503 # place.
504 504 self.line_split_fallback = re.compile(r'^(\s*)'
505 505 r'([%\!\?\w\.]*)'
506 506 r'(.*)')
507 507
508 508 # Original re, keep around for a while in case changes break something
509 509 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
510 510 # r'(\s*[\?\w\.]+\w*\s*)'
511 511 # r'(\(?.*$)')
512 512
513 513 # RegExp to identify potential function names
514 514 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
515 515
516 516 # RegExp to exclude strings with this start from autocalling. In
517 517 # particular, all binary operators should be excluded, so that if foo
518 518 # is callable, foo OP bar doesn't become foo(OP bar), which is
519 519 # invalid. The characters '!=()' don't need to be checked for, as the
520 520 # _prefilter routine explicitely does so, to catch direct calls and
521 521 # rebindings of existing names.
522 522
523 523 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
524 524 # it affects the rest of the group in square brackets.
525 525 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
526 526 '|^is |^not |^in |^and |^or ')
527 527
528 528 # try to catch also methods for stuff in lists/tuples/dicts: off
529 529 # (experimental). For this to work, the line_split regexp would need
530 530 # to be modified so it wouldn't break things at '['. That line is
531 531 # nasty enough that I shouldn't change it until I can test it _well_.
532 532 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
533 533
534 534 # keep track of where we started running (mainly for crash post-mortem)
535 535 self.starting_dir = os.getcwd()
536 536
537 537 # Various switches which can be set
538 538 self.CACHELENGTH = 5000 # this is cheap, it's just text
539 539 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
540 540 self.banner2 = banner2
541 541
542 542 # TraceBack handlers:
543 543
544 544 # Syntax error handler.
545 545 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
546 546
547 547 # The interactive one is initialized with an offset, meaning we always
548 548 # want to remove the topmost item in the traceback, which is our own
549 549 # internal code. Valid modes: ['Plain','Context','Verbose']
550 550 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
551 551 color_scheme='NoColor',
552 552 tb_offset = 1)
553 553
554 554 # IPython itself shouldn't crash. This will produce a detailed
555 555 # post-mortem if it does. But we only install the crash handler for
556 556 # non-threaded shells, the threaded ones use a normal verbose reporter
557 557 # and lose the crash handler. This is because exceptions in the main
558 558 # thread (such as in GUI code) propagate directly to sys.excepthook,
559 559 # and there's no point in printing crash dumps for every user exception.
560 560 if self.isthreaded:
561 561 ipCrashHandler = ultraTB.FormattedTB()
562 562 else:
563 563 from IPython import CrashHandler
564 564 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
565 565 self.set_crash_handler(ipCrashHandler)
566 566
567 567 # and add any custom exception handlers the user may have specified
568 568 self.set_custom_exc(*custom_exceptions)
569 569
570 570 # indentation management
571 571 self.autoindent = False
572 572 self.indent_current_nsp = 0
573 573
574 574 # Make some aliases automatically
575 575 # Prepare list of shell aliases to auto-define
576 576 if os.name == 'posix':
577 577 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
578 578 'mv mv -i','rm rm -i','cp cp -i',
579 579 'cat cat','less less','clear clear',
580 580 # a better ls
581 581 'ls ls -F',
582 582 # long ls
583 583 'll ls -lF')
584 584 # Extra ls aliases with color, which need special treatment on BSD
585 585 # variants
586 586 ls_extra = ( # color ls
587 587 'lc ls -F -o --color',
588 588 # ls normal files only
589 589 'lf ls -F -o --color %l | grep ^-',
590 590 # ls symbolic links
591 591 'lk ls -F -o --color %l | grep ^l',
592 592 # directories or links to directories,
593 593 'ldir ls -F -o --color %l | grep /$',
594 594 # things which are executable
595 595 'lx ls -F -o --color %l | grep ^-..x',
596 596 )
597 597 # The BSDs don't ship GNU ls, so they don't understand the
598 598 # --color switch out of the box
599 599 if 'bsd' in sys.platform:
600 600 ls_extra = ( # ls normal files only
601 601 'lf ls -lF | grep ^-',
602 602 # ls symbolic links
603 603 'lk ls -lF | grep ^l',
604 604 # directories or links to directories,
605 605 'ldir ls -lF | grep /$',
606 606 # things which are executable
607 607 'lx ls -lF | grep ^-..x',
608 608 )
609 609 auto_alias = auto_alias + ls_extra
610 610 elif os.name in ['nt','dos']:
611 611 auto_alias = ('dir dir /on', 'ls dir /on',
612 612 'ddir dir /ad /on', 'ldir dir /ad /on',
613 613 'mkdir mkdir','rmdir rmdir','echo echo',
614 614 'ren ren','cls cls','copy copy')
615 615 else:
616 616 auto_alias = ()
617 617 self.auto_alias = [s.split(None,1) for s in auto_alias]
618 618 # Call the actual (public) initializer
619 619 self.init_auto_alias()
620 620
621 621 # Produce a public API instance
622 622 self.api = IPython.ipapi.IPApi(self)
623 623
624 624 # track which builtins we add, so we can clean up later
625 625 self.builtins_added = {}
626 626 # This method will add the necessary builtins for operation, but
627 627 # tracking what it did via the builtins_added dict.
628 628 self.add_builtins()
629 629
630 630 # end __init__
631 631
632 632 def var_expand(self,cmd,depth=0):
633 633 """Expand python variables in a string.
634 634
635 635 The depth argument indicates how many frames above the caller should
636 636 be walked to look for the local namespace where to expand variables.
637 637
638 638 The global namespace for expansion is always the user's interactive
639 639 namespace.
640 640 """
641 641
642 642 return str(ItplNS(cmd.replace('#','\#'),
643 643 self.user_ns, # globals
644 644 # Skip our own frame in searching for locals:
645 645 sys._getframe(depth+1).f_locals # locals
646 646 ))
647 647
648 648 def pre_config_initialization(self):
649 649 """Pre-configuration init method
650 650
651 651 This is called before the configuration files are processed to
652 652 prepare the services the config files might need.
653 653
654 654 self.rc already has reasonable default values at this point.
655 655 """
656 656 rc = self.rc
657 657
658 658 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
659 659
660 660 def post_config_initialization(self):
661 661 """Post configuration init method
662 662
663 663 This is called after the configuration files have been processed to
664 664 'finalize' the initialization."""
665 665
666 666 rc = self.rc
667 667
668 668 # Object inspector
669 669 self.inspector = OInspect.Inspector(OInspect.InspectColors,
670 670 PyColorize.ANSICodeColors,
671 671 'NoColor',
672 672 rc.object_info_string_level)
673 673
674 674 # Load readline proper
675 675 if rc.readline:
676 676 self.init_readline()
677 677
678 678 # local shortcut, this is used a LOT
679 679 self.log = self.logger.log
680 680
681 681 # Initialize cache, set in/out prompts and printing system
682 682 self.outputcache = CachedOutput(self,
683 683 rc.cache_size,
684 684 rc.pprint,
685 685 input_sep = rc.separate_in,
686 686 output_sep = rc.separate_out,
687 687 output_sep2 = rc.separate_out2,
688 688 ps1 = rc.prompt_in1,
689 689 ps2 = rc.prompt_in2,
690 690 ps_out = rc.prompt_out,
691 691 pad_left = rc.prompts_pad_left)
692 692
693 693 # user may have over-ridden the default print hook:
694 694 try:
695 695 self.outputcache.__class__.display = self.hooks.display
696 696 except AttributeError:
697 697 pass
698 698
699 699 # I don't like assigning globally to sys, because it means when
700 700 # embedding instances, each embedded instance overrides the previous
701 701 # choice. But sys.displayhook seems to be called internally by exec,
702 702 # so I don't see a way around it. We first save the original and then
703 703 # overwrite it.
704 704 self.sys_displayhook = sys.displayhook
705 705 sys.displayhook = self.outputcache
706 706
707 707 # Set user colors (don't do it in the constructor above so that it
708 708 # doesn't crash if colors option is invalid)
709 709 self.magic_colors(rc.colors)
710 710
711 711 # Set calling of pdb on exceptions
712 712 self.call_pdb = rc.pdb
713 713
714 714 # Load user aliases
715 715 for alias in rc.alias:
716 716 self.magic_alias(alias)
717 717 self.hooks.late_startup_hook()
718 718
719 719 batchrun = False
720 720 for batchfile in [path(arg) for arg in self.rc.args
721 721 if arg.lower().endswith('.ipy')]:
722 722 if not batchfile.isfile():
723 723 print "No such batch file:", batchfile
724 724 continue
725 725 self.api.runlines(batchfile.text())
726 726 batchrun = True
727 727 if batchrun:
728 728 self.exit_now = True
729 729
730 730 def add_builtins(self):
731 731 """Store ipython references into the builtin namespace.
732 732
733 733 Some parts of ipython operate via builtins injected here, which hold a
734 734 reference to IPython itself."""
735 735
736 736 # TODO: deprecate all except _ip; 'jobs' should be installed
737 737 # by an extension and the rest are under _ip, ipalias is redundant
738 738 builtins_new = dict(__IPYTHON__ = self,
739 739 ip_set_hook = self.set_hook,
740 740 jobs = self.jobs,
741 741 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
742 742 ipalias = wrap_deprecated(self.ipalias),
743 743 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
744 744 _ip = self.api
745 745 )
746 746 for biname,bival in builtins_new.items():
747 747 try:
748 748 # store the orignal value so we can restore it
749 749 self.builtins_added[biname] = __builtin__.__dict__[biname]
750 750 except KeyError:
751 751 # or mark that it wasn't defined, and we'll just delete it at
752 752 # cleanup
753 753 self.builtins_added[biname] = Undefined
754 754 __builtin__.__dict__[biname] = bival
755 755
756 756 # Keep in the builtins a flag for when IPython is active. We set it
757 757 # with setdefault so that multiple nested IPythons don't clobber one
758 758 # another. Each will increase its value by one upon being activated,
759 759 # which also gives us a way to determine the nesting level.
760 760 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
761 761
762 762 def clean_builtins(self):
763 763 """Remove any builtins which might have been added by add_builtins, or
764 764 restore overwritten ones to their previous values."""
765 765 for biname,bival in self.builtins_added.items():
766 766 if bival is Undefined:
767 767 del __builtin__.__dict__[biname]
768 768 else:
769 769 __builtin__.__dict__[biname] = bival
770 770 self.builtins_added.clear()
771 771
772 772 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
773 773 """set_hook(name,hook) -> sets an internal IPython hook.
774 774
775 775 IPython exposes some of its internal API as user-modifiable hooks. By
776 776 adding your function to one of these hooks, you can modify IPython's
777 777 behavior to call at runtime your own routines."""
778 778
779 779 # At some point in the future, this should validate the hook before it
780 780 # accepts it. Probably at least check that the hook takes the number
781 781 # of args it's supposed to.
782 782
783 783 f = new.instancemethod(hook,self,self.__class__)
784 784
785 785 # check if the hook is for strdispatcher first
786 786 if str_key is not None:
787 787 sdp = self.strdispatchers.get(name, StrDispatch())
788 788 sdp.add_s(str_key, f, priority )
789 789 self.strdispatchers[name] = sdp
790 790 return
791 791 if re_key is not None:
792 792 sdp = self.strdispatchers.get(name, StrDispatch())
793 793 sdp.add_re(re.compile(re_key), f, priority )
794 794 self.strdispatchers[name] = sdp
795 795 return
796 796
797 797 dp = getattr(self.hooks, name, None)
798 798 if name not in IPython.hooks.__all__:
799 799 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
800 800 if not dp:
801 801 dp = IPython.hooks.CommandChainDispatcher()
802 802
803 803 try:
804 804 dp.add(f,priority)
805 805 except AttributeError:
806 806 # it was not commandchain, plain old func - replace
807 807 dp = f
808 808
809 809 setattr(self.hooks,name, dp)
810 810
811 811
812 812 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
813 813
814 814 def set_crash_handler(self,crashHandler):
815 815 """Set the IPython crash handler.
816 816
817 817 This must be a callable with a signature suitable for use as
818 818 sys.excepthook."""
819 819
820 820 # Install the given crash handler as the Python exception hook
821 821 sys.excepthook = crashHandler
822 822
823 823 # The instance will store a pointer to this, so that runtime code
824 824 # (such as magics) can access it. This is because during the
825 825 # read-eval loop, it gets temporarily overwritten (to deal with GUI
826 826 # frameworks).
827 827 self.sys_excepthook = sys.excepthook
828 828
829 829
830 830 def set_custom_exc(self,exc_tuple,handler):
831 831 """set_custom_exc(exc_tuple,handler)
832 832
833 833 Set a custom exception handler, which will be called if any of the
834 834 exceptions in exc_tuple occur in the mainloop (specifically, in the
835 835 runcode() method.
836 836
837 837 Inputs:
838 838
839 839 - exc_tuple: a *tuple* of valid exceptions to call the defined
840 840 handler for. It is very important that you use a tuple, and NOT A
841 841 LIST here, because of the way Python's except statement works. If
842 842 you only want to trap a single exception, use a singleton tuple:
843 843
844 844 exc_tuple == (MyCustomException,)
845 845
846 846 - handler: this must be defined as a function with the following
847 847 basic interface: def my_handler(self,etype,value,tb).
848 848
849 849 This will be made into an instance method (via new.instancemethod)
850 850 of IPython itself, and it will be called if any of the exceptions
851 851 listed in the exc_tuple are caught. If the handler is None, an
852 852 internal basic one is used, which just prints basic info.
853 853
854 854 WARNING: by putting in your own exception handler into IPython's main
855 855 execution loop, you run a very good chance of nasty crashes. This
856 856 facility should only be used if you really know what you are doing."""
857 857
858 858 assert type(exc_tuple)==type(()) , \
859 859 "The custom exceptions must be given AS A TUPLE."
860 860
861 861 def dummy_handler(self,etype,value,tb):
862 862 print '*** Simple custom exception handler ***'
863 863 print 'Exception type :',etype
864 864 print 'Exception value:',value
865 865 print 'Traceback :',tb
866 866 print 'Source code :','\n'.join(self.buffer)
867 867
868 868 if handler is None: handler = dummy_handler
869 869
870 870 self.CustomTB = new.instancemethod(handler,self,self.__class__)
871 871 self.custom_exceptions = exc_tuple
872 872
873 873 def set_custom_completer(self,completer,pos=0):
874 874 """set_custom_completer(completer,pos=0)
875 875
876 876 Adds a new custom completer function.
877 877
878 878 The position argument (defaults to 0) is the index in the completers
879 879 list where you want the completer to be inserted."""
880 880
881 881 newcomp = new.instancemethod(completer,self.Completer,
882 882 self.Completer.__class__)
883 883 self.Completer.matchers.insert(pos,newcomp)
884 884
885 885 def _get_call_pdb(self):
886 886 return self._call_pdb
887 887
888 888 def _set_call_pdb(self,val):
889 889
890 890 if val not in (0,1,False,True):
891 891 raise ValueError,'new call_pdb value must be boolean'
892 892
893 893 # store value in instance
894 894 self._call_pdb = val
895 895
896 896 # notify the actual exception handlers
897 897 self.InteractiveTB.call_pdb = val
898 898 if self.isthreaded:
899 899 try:
900 900 self.sys_excepthook.call_pdb = val
901 901 except:
902 902 warn('Failed to activate pdb for threaded exception handler')
903 903
904 904 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
905 905 'Control auto-activation of pdb at exceptions')
906 906
907 907
908 908 # These special functions get installed in the builtin namespace, to
909 909 # provide programmatic (pure python) access to magics, aliases and system
910 910 # calls. This is important for logging, user scripting, and more.
911 911
912 912 # We are basically exposing, via normal python functions, the three
913 913 # mechanisms in which ipython offers special call modes (magics for
914 914 # internal control, aliases for direct system access via pre-selected
915 915 # names, and !cmd for calling arbitrary system commands).
916 916
917 917 def ipmagic(self,arg_s):
918 918 """Call a magic function by name.
919 919
920 920 Input: a string containing the name of the magic function to call and any
921 921 additional arguments to be passed to the magic.
922 922
923 923 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
924 924 prompt:
925 925
926 926 In[1]: %name -opt foo bar
927 927
928 928 To call a magic without arguments, simply use ipmagic('name').
929 929
930 930 This provides a proper Python function to call IPython's magics in any
931 931 valid Python code you can type at the interpreter, including loops and
932 932 compound statements. It is added by IPython to the Python builtin
933 933 namespace upon initialization."""
934 934
935 935 args = arg_s.split(' ',1)
936 936 magic_name = args[0]
937 937 magic_name = magic_name.lstrip(self.ESC_MAGIC)
938 938
939 939 try:
940 940 magic_args = args[1]
941 941 except IndexError:
942 942 magic_args = ''
943 943 fn = getattr(self,'magic_'+magic_name,None)
944 944 if fn is None:
945 945 error("Magic function `%s` not found." % magic_name)
946 946 else:
947 947 magic_args = self.var_expand(magic_args,1)
948 948 return fn(magic_args)
949 949
950 950 def ipalias(self,arg_s):
951 951 """Call an alias by name.
952 952
953 953 Input: a string containing the name of the alias to call and any
954 954 additional arguments to be passed to the magic.
955 955
956 956 ipalias('name -opt foo bar') is equivalent to typing at the ipython
957 957 prompt:
958 958
959 959 In[1]: name -opt foo bar
960 960
961 961 To call an alias without arguments, simply use ipalias('name').
962 962
963 963 This provides a proper Python function to call IPython's aliases in any
964 964 valid Python code you can type at the interpreter, including loops and
965 965 compound statements. It is added by IPython to the Python builtin
966 966 namespace upon initialization."""
967 967
968 968 args = arg_s.split(' ',1)
969 969 alias_name = args[0]
970 970 try:
971 971 alias_args = args[1]
972 972 except IndexError:
973 973 alias_args = ''
974 974 if alias_name in self.alias_table:
975 975 self.call_alias(alias_name,alias_args)
976 976 else:
977 977 error("Alias `%s` not found." % alias_name)
978 978
979 979 def ipsystem(self,arg_s):
980 980 """Make a system call, using IPython."""
981 981
982 982 self.system(arg_s)
983 983
984 984 def complete(self,text):
985 985 """Return a sorted list of all possible completions on text.
986 986
987 987 Inputs:
988 988
989 989 - text: a string of text to be completed on.
990 990
991 991 This is a wrapper around the completion mechanism, similar to what
992 992 readline does at the command line when the TAB key is hit. By
993 993 exposing it as a method, it can be used by other non-readline
994 994 environments (such as GUIs) for text completion.
995 995
996 996 Simple usage example:
997 997
998 998 In [1]: x = 'hello'
999 999
1000 1000 In [2]: __IP.complete('x.l')
1001 1001 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1002 1002
1003 1003 complete = self.Completer.complete
1004 1004 state = 0
1005 1005 # use a dict so we get unique keys, since ipyhton's multiple
1006 1006 # completers can return duplicates.
1007 1007 comps = {}
1008 1008 while True:
1009 1009 newcomp = complete(text,state)
1010 1010 if newcomp is None:
1011 1011 break
1012 1012 comps[newcomp] = 1
1013 1013 state += 1
1014 1014 outcomps = comps.keys()
1015 1015 outcomps.sort()
1016 1016 return outcomps
1017 1017
1018 1018 def set_completer_frame(self, frame=None):
1019 1019 if frame:
1020 1020 self.Completer.namespace = frame.f_locals
1021 1021 self.Completer.global_namespace = frame.f_globals
1022 1022 else:
1023 1023 self.Completer.namespace = self.user_ns
1024 1024 self.Completer.global_namespace = self.user_global_ns
1025 1025
1026 1026 def init_auto_alias(self):
1027 1027 """Define some aliases automatically.
1028 1028
1029 1029 These are ALL parameter-less aliases"""
1030 1030
1031 1031 for alias,cmd in self.auto_alias:
1032 1032 self.alias_table[alias] = (0,cmd)
1033 1033
1034 1034 def alias_table_validate(self,verbose=0):
1035 1035 """Update information about the alias table.
1036 1036
1037 1037 In particular, make sure no Python keywords/builtins are in it."""
1038 1038
1039 1039 no_alias = self.no_alias
1040 1040 for k in self.alias_table.keys():
1041 1041 if k in no_alias:
1042 1042 del self.alias_table[k]
1043 1043 if verbose:
1044 1044 print ("Deleting alias <%s>, it's a Python "
1045 1045 "keyword or builtin." % k)
1046 1046
1047 1047 def set_autoindent(self,value=None):
1048 1048 """Set the autoindent flag, checking for readline support.
1049 1049
1050 1050 If called with no arguments, it acts as a toggle."""
1051 1051
1052 1052 if not self.has_readline:
1053 1053 if os.name == 'posix':
1054 1054 warn("The auto-indent feature requires the readline library")
1055 1055 self.autoindent = 0
1056 1056 return
1057 1057 if value is None:
1058 1058 self.autoindent = not self.autoindent
1059 1059 else:
1060 1060 self.autoindent = value
1061 1061
1062 1062 def rc_set_toggle(self,rc_field,value=None):
1063 1063 """Set or toggle a field in IPython's rc config. structure.
1064 1064
1065 1065 If called with no arguments, it acts as a toggle.
1066 1066
1067 1067 If called with a non-existent field, the resulting AttributeError
1068 1068 exception will propagate out."""
1069 1069
1070 1070 rc_val = getattr(self.rc,rc_field)
1071 1071 if value is None:
1072 1072 value = not rc_val
1073 1073 setattr(self.rc,rc_field,value)
1074 1074
1075 1075 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1076 1076 """Install the user configuration directory.
1077 1077
1078 1078 Can be called when running for the first time or to upgrade the user's
1079 1079 .ipython/ directory with the mode parameter. Valid modes are 'install'
1080 1080 and 'upgrade'."""
1081 1081
1082 1082 def wait():
1083 1083 try:
1084 1084 raw_input("Please press <RETURN> to start IPython.")
1085 1085 except EOFError:
1086 1086 print >> Term.cout
1087 1087 print '*'*70
1088 1088
1089 1089 cwd = os.getcwd() # remember where we started
1090 1090 glb = glob.glob
1091 1091 print '*'*70
1092 1092 if mode == 'install':
1093 1093 print \
1094 1094 """Welcome to IPython. I will try to create a personal configuration directory
1095 1095 where you can customize many aspects of IPython's functionality in:\n"""
1096 1096 else:
1097 1097 print 'I am going to upgrade your configuration in:'
1098 1098
1099 1099 print ipythondir
1100 1100
1101 1101 rcdirend = os.path.join('IPython','UserConfig')
1102 1102 cfg = lambda d: os.path.join(d,rcdirend)
1103 1103 try:
1104 1104 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1105 1105 except IOError:
1106 1106 warning = """
1107 1107 Installation error. IPython's directory was not found.
1108 1108
1109 1109 Check the following:
1110 1110
1111 1111 The ipython/IPython directory should be in a directory belonging to your
1112 1112 PYTHONPATH environment variable (that is, it should be in a directory
1113 1113 belonging to sys.path). You can copy it explicitly there or just link to it.
1114 1114
1115 1115 IPython will proceed with builtin defaults.
1116 1116 """
1117 1117 warn(warning)
1118 1118 wait()
1119 1119 return
1120 1120
1121 1121 if mode == 'install':
1122 1122 try:
1123 1123 shutil.copytree(rcdir,ipythondir)
1124 1124 os.chdir(ipythondir)
1125 1125 rc_files = glb("ipythonrc*")
1126 1126 for rc_file in rc_files:
1127 1127 os.rename(rc_file,rc_file+rc_suffix)
1128 1128 except:
1129 1129 warning = """
1130 1130
1131 1131 There was a problem with the installation:
1132 1132 %s
1133 1133 Try to correct it or contact the developers if you think it's a bug.
1134 1134 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1135 1135 warn(warning)
1136 1136 wait()
1137 1137 return
1138 1138
1139 1139 elif mode == 'upgrade':
1140 1140 try:
1141 1141 os.chdir(ipythondir)
1142 1142 except:
1143 1143 print """
1144 1144 Can not upgrade: changing to directory %s failed. Details:
1145 1145 %s
1146 1146 """ % (ipythondir,sys.exc_info()[1])
1147 1147 wait()
1148 1148 return
1149 1149 else:
1150 1150 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1151 1151 for new_full_path in sources:
1152 1152 new_filename = os.path.basename(new_full_path)
1153 1153 if new_filename.startswith('ipythonrc'):
1154 1154 new_filename = new_filename + rc_suffix
1155 1155 # The config directory should only contain files, skip any
1156 1156 # directories which may be there (like CVS)
1157 1157 if os.path.isdir(new_full_path):
1158 1158 continue
1159 1159 if os.path.exists(new_filename):
1160 1160 old_file = new_filename+'.old'
1161 1161 if os.path.exists(old_file):
1162 1162 os.remove(old_file)
1163 1163 os.rename(new_filename,old_file)
1164 1164 shutil.copy(new_full_path,new_filename)
1165 1165 else:
1166 1166 raise ValueError,'unrecognized mode for install:',`mode`
1167 1167
1168 1168 # Fix line-endings to those native to each platform in the config
1169 1169 # directory.
1170 1170 try:
1171 1171 os.chdir(ipythondir)
1172 1172 except:
1173 1173 print """
1174 1174 Problem: changing to directory %s failed.
1175 1175 Details:
1176 1176 %s
1177 1177
1178 1178 Some configuration files may have incorrect line endings. This should not
1179 1179 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1180 1180 wait()
1181 1181 else:
1182 1182 for fname in glb('ipythonrc*'):
1183 1183 try:
1184 1184 native_line_ends(fname,backup=0)
1185 1185 except IOError:
1186 1186 pass
1187 1187
1188 1188 if mode == 'install':
1189 1189 print """
1190 1190 Successful installation!
1191 1191
1192 1192 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1193 1193 IPython manual (there are both HTML and PDF versions supplied with the
1194 1194 distribution) to make sure that your system environment is properly configured
1195 1195 to take advantage of IPython's features.
1196 1196
1197 1197 Important note: the configuration system has changed! The old system is
1198 1198 still in place, but its setting may be partly overridden by the settings in
1199 1199 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1200 1200 if some of the new settings bother you.
1201 1201
1202 1202 """
1203 1203 else:
1204 1204 print """
1205 1205 Successful upgrade!
1206 1206
1207 1207 All files in your directory:
1208 1208 %(ipythondir)s
1209 1209 which would have been overwritten by the upgrade were backed up with a .old
1210 1210 extension. If you had made particular customizations in those files you may
1211 1211 want to merge them back into the new files.""" % locals()
1212 1212 wait()
1213 1213 os.chdir(cwd)
1214 1214 # end user_setup()
1215 1215
1216 1216 def atexit_operations(self):
1217 1217 """This will be executed at the time of exit.
1218 1218
1219 1219 Saving of persistent data should be performed here. """
1220 1220
1221 1221 #print '*** IPython exit cleanup ***' # dbg
1222 1222 # input history
1223 1223 self.savehist()
1224 1224
1225 1225 # Cleanup all tempfiles left around
1226 1226 for tfile in self.tempfiles:
1227 1227 try:
1228 1228 os.unlink(tfile)
1229 1229 except OSError:
1230 1230 pass
1231 1231
1232 1232 # save the "persistent data" catch-all dictionary
1233 1233 self.hooks.shutdown_hook()
1234 1234
1235 1235 def savehist(self):
1236 1236 """Save input history to a file (via readline library)."""
1237 1237 try:
1238 1238 self.readline.write_history_file(self.histfile)
1239 1239 except:
1240 1240 print 'Unable to save IPython command history to file: ' + \
1241 1241 `self.histfile`
1242 1242
1243 1243 def history_saving_wrapper(self, func):
1244 1244 """ Wrap func for readline history saving
1245 1245
1246 1246 Convert func into callable that saves & restores
1247 1247 history around the call """
1248 1248
1249 1249 if not self.has_readline:
1250 1250 return func
1251 1251
1252 1252 def wrapper():
1253 1253 self.savehist()
1254 1254 try:
1255 1255 func()
1256 1256 finally:
1257 1257 readline.read_history_file(self.histfile)
1258 1258 return wrapper
1259 1259
1260 1260
1261 1261 def pre_readline(self):
1262 1262 """readline hook to be used at the start of each line.
1263 1263
1264 1264 Currently it handles auto-indent only."""
1265 1265
1266 1266 #debugx('self.indent_current_nsp','pre_readline:')
1267 1267 self.readline.insert_text(self.indent_current_str())
1268 1268
1269 1269 def init_readline(self):
1270 1270 """Command history completion/saving/reloading."""
1271 1271
1272 1272 import IPython.rlineimpl as readline
1273 1273 if not readline.have_readline:
1274 1274 self.has_readline = 0
1275 1275 self.readline = None
1276 1276 # no point in bugging windows users with this every time:
1277 1277 warn('Readline services not available on this platform.')
1278 1278 else:
1279 1279 sys.modules['readline'] = readline
1280 1280 import atexit
1281 1281 from IPython.completer import IPCompleter
1282 1282 self.Completer = IPCompleter(self,
1283 1283 self.user_ns,
1284 1284 self.user_global_ns,
1285 1285 self.rc.readline_omit__names,
1286 1286 self.alias_table)
1287 1287 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1288 1288 self.strdispatchers['complete_command'] = sdisp
1289 1289 self.Completer.custom_completers = sdisp
1290 1290 # Platform-specific configuration
1291 1291 if os.name == 'nt':
1292 1292 self.readline_startup_hook = readline.set_pre_input_hook
1293 1293 else:
1294 1294 self.readline_startup_hook = readline.set_startup_hook
1295 1295
1296 1296 # Load user's initrc file (readline config)
1297 1297 inputrc_name = os.environ.get('INPUTRC')
1298 1298 if inputrc_name is None:
1299 1299 home_dir = get_home_dir()
1300 1300 if home_dir is not None:
1301 1301 inputrc_name = os.path.join(home_dir,'.inputrc')
1302 1302 if os.path.isfile(inputrc_name):
1303 1303 try:
1304 1304 readline.read_init_file(inputrc_name)
1305 1305 except:
1306 1306 warn('Problems reading readline initialization file <%s>'
1307 1307 % inputrc_name)
1308 1308
1309 1309 self.has_readline = 1
1310 1310 self.readline = readline
1311 1311 # save this in sys so embedded copies can restore it properly
1312 1312 sys.ipcompleter = self.Completer.complete
1313 1313 readline.set_completer(self.Completer.complete)
1314 1314
1315 1315 # Configure readline according to user's prefs
1316 1316 for rlcommand in self.rc.readline_parse_and_bind:
1317 1317 readline.parse_and_bind(rlcommand)
1318 1318
1319 1319 # remove some chars from the delimiters list
1320 1320 delims = readline.get_completer_delims()
1321 1321 delims = delims.translate(string._idmap,
1322 1322 self.rc.readline_remove_delims)
1323 1323 readline.set_completer_delims(delims)
1324 1324 # otherwise we end up with a monster history after a while:
1325 1325 readline.set_history_length(1000)
1326 1326 try:
1327 1327 #print '*** Reading readline history' # dbg
1328 1328 readline.read_history_file(self.histfile)
1329 1329 except IOError:
1330 1330 pass # It doesn't exist yet.
1331 1331
1332 1332 atexit.register(self.atexit_operations)
1333 1333 del atexit
1334 1334
1335 1335 # Configure auto-indent for all platforms
1336 1336 self.set_autoindent(self.rc.autoindent)
1337 1337
1338 1338 def ask_yes_no(self,prompt,default=True):
1339 1339 if self.rc.quiet:
1340 1340 return True
1341 1341 return ask_yes_no(prompt,default)
1342 1342
1343 1343 def _should_recompile(self,e):
1344 1344 """Utility routine for edit_syntax_error"""
1345 1345
1346 1346 if e.filename in ('<ipython console>','<input>','<string>',
1347 1347 '<console>','<BackgroundJob compilation>',
1348 1348 None):
1349 1349
1350 1350 return False
1351 1351 try:
1352 1352 if (self.rc.autoedit_syntax and
1353 1353 not self.ask_yes_no('Return to editor to correct syntax error? '
1354 1354 '[Y/n] ','y')):
1355 1355 return False
1356 1356 except EOFError:
1357 1357 return False
1358 1358
1359 1359 def int0(x):
1360 1360 try:
1361 1361 return int(x)
1362 1362 except TypeError:
1363 1363 return 0
1364 1364 # always pass integer line and offset values to editor hook
1365 1365 self.hooks.fix_error_editor(e.filename,
1366 1366 int0(e.lineno),int0(e.offset),e.msg)
1367 1367 return True
1368 1368
1369 1369 def edit_syntax_error(self):
1370 1370 """The bottom half of the syntax error handler called in the main loop.
1371 1371
1372 1372 Loop until syntax error is fixed or user cancels.
1373 1373 """
1374 1374
1375 1375 while self.SyntaxTB.last_syntax_error:
1376 1376 # copy and clear last_syntax_error
1377 1377 err = self.SyntaxTB.clear_err_state()
1378 1378 if not self._should_recompile(err):
1379 1379 return
1380 1380 try:
1381 1381 # may set last_syntax_error again if a SyntaxError is raised
1382 1382 self.safe_execfile(err.filename,self.user_ns)
1383 1383 except:
1384 1384 self.showtraceback()
1385 1385 else:
1386 1386 try:
1387 1387 f = file(err.filename)
1388 1388 try:
1389 1389 sys.displayhook(f.read())
1390 1390 finally:
1391 1391 f.close()
1392 1392 except:
1393 1393 self.showtraceback()
1394 1394
1395 1395 def showsyntaxerror(self, filename=None):
1396 1396 """Display the syntax error that just occurred.
1397 1397
1398 1398 This doesn't display a stack trace because there isn't one.
1399 1399
1400 1400 If a filename is given, it is stuffed in the exception instead
1401 1401 of what was there before (because Python's parser always uses
1402 1402 "<string>" when reading from a string).
1403 1403 """
1404 1404 etype, value, last_traceback = sys.exc_info()
1405 1405
1406 1406 # See note about these variables in showtraceback() below
1407 1407 sys.last_type = etype
1408 1408 sys.last_value = value
1409 1409 sys.last_traceback = last_traceback
1410 1410
1411 1411 if filename and etype is SyntaxError:
1412 1412 # Work hard to stuff the correct filename in the exception
1413 1413 try:
1414 1414 msg, (dummy_filename, lineno, offset, line) = value
1415 1415 except:
1416 1416 # Not the format we expect; leave it alone
1417 1417 pass
1418 1418 else:
1419 1419 # Stuff in the right filename
1420 1420 try:
1421 1421 # Assume SyntaxError is a class exception
1422 1422 value = SyntaxError(msg, (filename, lineno, offset, line))
1423 1423 except:
1424 1424 # If that failed, assume SyntaxError is a string
1425 1425 value = msg, (filename, lineno, offset, line)
1426 1426 self.SyntaxTB(etype,value,[])
1427 1427
1428 1428 def debugger(self,force=False):
1429 1429 """Call the pydb/pdb debugger.
1430 1430
1431 1431 Keywords:
1432 1432
1433 1433 - force(False): by default, this routine checks the instance call_pdb
1434 1434 flag and does not actually invoke the debugger if the flag is false.
1435 1435 The 'force' option forces the debugger to activate even if the flag
1436 1436 is false.
1437 1437 """
1438 1438
1439 1439 if not (force or self.call_pdb):
1440 1440 return
1441 1441
1442 1442 if not hasattr(sys,'last_traceback'):
1443 1443 error('No traceback has been produced, nothing to debug.')
1444 1444 return
1445 1445
1446 1446 have_pydb = False
1447 1447 # use pydb if available
1448 1448 try:
1449 1449 from pydb import pm
1450 1450 have_pydb = True
1451 1451 except ImportError:
1452 1452 pass
1453 1453 if not have_pydb:
1454 1454 # fallback to our internal debugger
1455 1455 pm = lambda : self.InteractiveTB.debugger(force=True)
1456 1456 self.history_saving_wrapper(pm)()
1457 1457
1458 1458 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1459 1459 """Display the exception that just occurred.
1460 1460
1461 1461 If nothing is known about the exception, this is the method which
1462 1462 should be used throughout the code for presenting user tracebacks,
1463 1463 rather than directly invoking the InteractiveTB object.
1464 1464
1465 1465 A specific showsyntaxerror() also exists, but this method can take
1466 1466 care of calling it if needed, so unless you are explicitly catching a
1467 1467 SyntaxError exception, don't try to analyze the stack manually and
1468 1468 simply call this method."""
1469 1469
1470 1470 # Though this won't be called by syntax errors in the input line,
1471 1471 # there may be SyntaxError cases whith imported code.
1472 1472 if exc_tuple is None:
1473 1473 etype, value, tb = sys.exc_info()
1474 1474 else:
1475 1475 etype, value, tb = exc_tuple
1476 1476
1477 1477 if etype is SyntaxError:
1478 1478 self.showsyntaxerror(filename)
1479 1479 else:
1480 1480 # WARNING: these variables are somewhat deprecated and not
1481 1481 # necessarily safe to use in a threaded environment, but tools
1482 1482 # like pdb depend on their existence, so let's set them. If we
1483 1483 # find problems in the field, we'll need to revisit their use.
1484 1484 sys.last_type = etype
1485 1485 sys.last_value = value
1486 1486 sys.last_traceback = tb
1487 1487
1488 1488 if etype in self.custom_exceptions:
1489 1489 self.CustomTB(etype,value,tb)
1490 1490 else:
1491 1491 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1492 1492 if self.InteractiveTB.call_pdb and self.has_readline:
1493 1493 # pdb mucks up readline, fix it back
1494 1494 self.readline.set_completer(self.Completer.complete)
1495 1495
1496 1496 def mainloop(self,banner=None):
1497 1497 """Creates the local namespace and starts the mainloop.
1498 1498
1499 1499 If an optional banner argument is given, it will override the
1500 1500 internally created default banner."""
1501 1501
1502 1502 if self.rc.c: # Emulate Python's -c option
1503 1503 self.exec_init_cmd()
1504 1504 if banner is None:
1505 1505 if not self.rc.banner:
1506 1506 banner = ''
1507 1507 # banner is string? Use it directly!
1508 1508 elif isinstance(self.rc.banner,basestring):
1509 1509 banner = self.rc.banner
1510 1510 else:
1511 1511 banner = self.BANNER+self.banner2
1512 1512
1513 1513 self.interact(banner)
1514 1514
1515 1515 def exec_init_cmd(self):
1516 1516 """Execute a command given at the command line.
1517 1517
1518 1518 This emulates Python's -c option."""
1519 1519
1520 1520 #sys.argv = ['-c']
1521 1521 self.push(self.rc.c)
1522 1522
1523 1523 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1524 1524 """Embeds IPython into a running python program.
1525 1525
1526 1526 Input:
1527 1527
1528 1528 - header: An optional header message can be specified.
1529 1529
1530 1530 - local_ns, global_ns: working namespaces. If given as None, the
1531 1531 IPython-initialized one is updated with __main__.__dict__, so that
1532 1532 program variables become visible but user-specific configuration
1533 1533 remains possible.
1534 1534
1535 1535 - stack_depth: specifies how many levels in the stack to go to
1536 1536 looking for namespaces (when local_ns and global_ns are None). This
1537 1537 allows an intermediate caller to make sure that this function gets
1538 1538 the namespace from the intended level in the stack. By default (0)
1539 1539 it will get its locals and globals from the immediate caller.
1540 1540
1541 1541 Warning: it's possible to use this in a program which is being run by
1542 1542 IPython itself (via %run), but some funny things will happen (a few
1543 1543 globals get overwritten). In the future this will be cleaned up, as
1544 1544 there is no fundamental reason why it can't work perfectly."""
1545 1545
1546 1546 # Get locals and globals from caller
1547 1547 if local_ns is None or global_ns is None:
1548 1548 call_frame = sys._getframe(stack_depth).f_back
1549 1549
1550 1550 if local_ns is None:
1551 1551 local_ns = call_frame.f_locals
1552 1552 if global_ns is None:
1553 1553 global_ns = call_frame.f_globals
1554 1554
1555 1555 # Update namespaces and fire up interpreter
1556 1556
1557 1557 # The global one is easy, we can just throw it in
1558 1558 self.user_global_ns = global_ns
1559 1559
1560 1560 # but the user/local one is tricky: ipython needs it to store internal
1561 1561 # data, but we also need the locals. We'll copy locals in the user
1562 1562 # one, but will track what got copied so we can delete them at exit.
1563 1563 # This is so that a later embedded call doesn't see locals from a
1564 1564 # previous call (which most likely existed in a separate scope).
1565 1565 local_varnames = local_ns.keys()
1566 1566 self.user_ns.update(local_ns)
1567 1567
1568 1568 # Patch for global embedding to make sure that things don't overwrite
1569 1569 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1570 1570 # FIXME. Test this a bit more carefully (the if.. is new)
1571 1571 if local_ns is None and global_ns is None:
1572 1572 self.user_global_ns.update(__main__.__dict__)
1573 1573
1574 1574 # make sure the tab-completer has the correct frame information, so it
1575 1575 # actually completes using the frame's locals/globals
1576 1576 self.set_completer_frame()
1577 1577
1578 1578 # before activating the interactive mode, we need to make sure that
1579 1579 # all names in the builtin namespace needed by ipython point to
1580 1580 # ourselves, and not to other instances.
1581 1581 self.add_builtins()
1582 1582
1583 1583 self.interact(header)
1584 1584
1585 1585 # now, purge out the user namespace from anything we might have added
1586 1586 # from the caller's local namespace
1587 1587 delvar = self.user_ns.pop
1588 1588 for var in local_varnames:
1589 1589 delvar(var,None)
1590 1590 # and clean builtins we may have overridden
1591 1591 self.clean_builtins()
1592 1592
1593 1593 def interact(self, banner=None):
1594 1594 """Closely emulate the interactive Python console.
1595 1595
1596 1596 The optional banner argument specify the banner to print
1597 1597 before the first interaction; by default it prints a banner
1598 1598 similar to the one printed by the real Python interpreter,
1599 1599 followed by the current class name in parentheses (so as not
1600 1600 to confuse this with the real interpreter -- since it's so
1601 1601 close!).
1602 1602
1603 1603 """
1604 1604
1605 1605 if self.exit_now:
1606 1606 # batch run -> do not interact
1607 1607 return
1608 1608 cprt = 'Type "copyright", "credits" or "license" for more information.'
1609 1609 if banner is None:
1610 1610 self.write("Python %s on %s\n%s\n(%s)\n" %
1611 1611 (sys.version, sys.platform, cprt,
1612 1612 self.__class__.__name__))
1613 1613 else:
1614 1614 self.write(banner)
1615 1615
1616 1616 more = 0
1617 1617
1618 1618 # Mark activity in the builtins
1619 1619 __builtin__.__dict__['__IPYTHON__active'] += 1
1620 1620
1621 1621 # exit_now is set by a call to %Exit or %Quit
1622 1622 while not self.exit_now:
1623 1623 if more:
1624 1624 prompt = self.hooks.generate_prompt(True)
1625 1625 if self.autoindent:
1626 1626 self.readline_startup_hook(self.pre_readline)
1627 1627 else:
1628 1628 prompt = self.hooks.generate_prompt(False)
1629 1629 try:
1630 1630 line = self.raw_input(prompt,more)
1631 1631 if self.exit_now:
1632 1632 # quick exit on sys.std[in|out] close
1633 1633 break
1634 1634 if self.autoindent:
1635 1635 self.readline_startup_hook(None)
1636 1636 except KeyboardInterrupt:
1637 1637 self.write('\nKeyboardInterrupt\n')
1638 1638 self.resetbuffer()
1639 1639 # keep cache in sync with the prompt counter:
1640 1640 self.outputcache.prompt_count -= 1
1641 1641
1642 1642 if self.autoindent:
1643 1643 self.indent_current_nsp = 0
1644 1644 more = 0
1645 1645 except EOFError:
1646 1646 if self.autoindent:
1647 1647 self.readline_startup_hook(None)
1648 1648 self.write('\n')
1649 1649 self.exit()
1650 1650 except bdb.BdbQuit:
1651 1651 warn('The Python debugger has exited with a BdbQuit exception.\n'
1652 1652 'Because of how pdb handles the stack, it is impossible\n'
1653 1653 'for IPython to properly format this particular exception.\n'
1654 1654 'IPython will resume normal operation.')
1655 1655 except:
1656 1656 # exceptions here are VERY RARE, but they can be triggered
1657 1657 # asynchronously by signal handlers, for example.
1658 1658 self.showtraceback()
1659 1659 else:
1660 1660 more = self.push(line)
1661 1661 if (self.SyntaxTB.last_syntax_error and
1662 1662 self.rc.autoedit_syntax):
1663 1663 self.edit_syntax_error()
1664 1664
1665 1665 # We are off again...
1666 1666 __builtin__.__dict__['__IPYTHON__active'] -= 1
1667 1667
1668 1668 def excepthook(self, etype, value, tb):
1669 1669 """One more defense for GUI apps that call sys.excepthook.
1670 1670
1671 1671 GUI frameworks like wxPython trap exceptions and call
1672 1672 sys.excepthook themselves. I guess this is a feature that
1673 1673 enables them to keep running after exceptions that would
1674 1674 otherwise kill their mainloop. This is a bother for IPython
1675 1675 which excepts to catch all of the program exceptions with a try:
1676 1676 except: statement.
1677 1677
1678 1678 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1679 1679 any app directly invokes sys.excepthook, it will look to the user like
1680 1680 IPython crashed. In order to work around this, we can disable the
1681 1681 CrashHandler and replace it with this excepthook instead, which prints a
1682 1682 regular traceback using our InteractiveTB. In this fashion, apps which
1683 1683 call sys.excepthook will generate a regular-looking exception from
1684 1684 IPython, and the CrashHandler will only be triggered by real IPython
1685 1685 crashes.
1686 1686
1687 1687 This hook should be used sparingly, only in places which are not likely
1688 1688 to be true IPython errors.
1689 1689 """
1690 1690 self.showtraceback((etype,value,tb),tb_offset=0)
1691 1691
1692 1692 def expand_aliases(self,fn,rest):
1693 1693 """ Expand multiple levels of aliases:
1694 1694
1695 1695 if:
1696 1696
1697 1697 alias foo bar /tmp
1698 1698 alias baz foo
1699 1699
1700 1700 then:
1701 1701
1702 1702 baz huhhahhei -> bar /tmp huhhahhei
1703 1703
1704 1704 """
1705 1705 line = fn + " " + rest
1706 1706
1707 1707 done = Set()
1708 1708 while 1:
1709 1709 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1710 1710 # print "!",fn,"!",rest # dbg
1711 1711 if fn in self.alias_table:
1712 1712 if fn in done:
1713 1713 warn("Cyclic alias definition, repeated '%s'" % fn)
1714 1714 return ""
1715 1715 done.add(fn)
1716 1716
1717 1717 l2 = self.transform_alias(fn,rest)
1718 1718 # dir -> dir
1719 1719 # print "alias",line, "->",l2 #dbg
1720 1720 if l2 == line:
1721 1721 break
1722 1722 # ls -> ls -F should not recurse forever
1723 1723 if l2.split(None,1)[0] == line.split(None,1)[0]:
1724 1724 line = l2
1725 1725 break
1726 1726
1727 1727 line=l2
1728 1728
1729 1729
1730 1730 # print "al expand to",line #dbg
1731 1731 else:
1732 1732 break
1733 1733
1734 1734 return line
1735 1735
1736 1736 def transform_alias(self, alias,rest=''):
1737 1737 """ Transform alias to system command string.
1738 1738 """
1739 1739 nargs,cmd = self.alias_table[alias]
1740 1740 if ' ' in cmd and os.path.isfile(cmd):
1741 1741 cmd = '"%s"' % cmd
1742 1742
1743 1743 # Expand the %l special to be the user's input line
1744 1744 if cmd.find('%l') >= 0:
1745 1745 cmd = cmd.replace('%l',rest)
1746 1746 rest = ''
1747 1747 if nargs==0:
1748 1748 # Simple, argument-less aliases
1749 1749 cmd = '%s %s' % (cmd,rest)
1750 1750 else:
1751 1751 # Handle aliases with positional arguments
1752 1752 args = rest.split(None,nargs)
1753 1753 if len(args)< nargs:
1754 1754 error('Alias <%s> requires %s arguments, %s given.' %
1755 1755 (alias,nargs,len(args)))
1756 1756 return None
1757 1757 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1758 1758 # Now call the macro, evaluating in the user's namespace
1759 1759 #print 'new command: <%r>' % cmd # dbg
1760 1760 return cmd
1761 1761
1762 1762 def call_alias(self,alias,rest=''):
1763 1763 """Call an alias given its name and the rest of the line.
1764 1764
1765 1765 This is only used to provide backwards compatibility for users of
1766 1766 ipalias(), use of which is not recommended for anymore."""
1767 1767
1768 1768 # Now call the macro, evaluating in the user's namespace
1769 1769 cmd = self.transform_alias(alias, rest)
1770 1770 try:
1771 1771 self.system(cmd)
1772 1772 except:
1773 1773 self.showtraceback()
1774 1774
1775 1775 def indent_current_str(self):
1776 1776 """return the current level of indentation as a string"""
1777 1777 return self.indent_current_nsp * ' '
1778 1778
1779 1779 def autoindent_update(self,line):
1780 1780 """Keep track of the indent level."""
1781 1781
1782 1782 #debugx('line')
1783 1783 #debugx('self.indent_current_nsp')
1784 1784 if self.autoindent:
1785 1785 if line:
1786 1786 inisp = num_ini_spaces(line)
1787 1787 if inisp < self.indent_current_nsp:
1788 1788 self.indent_current_nsp = inisp
1789 1789
1790 1790 if line[-1] == ':':
1791 1791 self.indent_current_nsp += 4
1792 1792 elif dedent_re.match(line):
1793 1793 self.indent_current_nsp -= 4
1794 1794 else:
1795 1795 self.indent_current_nsp = 0
1796 1796
1797 1797 def runlines(self,lines):
1798 1798 """Run a string of one or more lines of source.
1799 1799
1800 1800 This method is capable of running a string containing multiple source
1801 1801 lines, as if they had been entered at the IPython prompt. Since it
1802 1802 exposes IPython's processing machinery, the given strings can contain
1803 1803 magic calls (%magic), special shell access (!cmd), etc."""
1804 1804
1805 1805 # We must start with a clean buffer, in case this is run from an
1806 1806 # interactive IPython session (via a magic, for example).
1807 1807 self.resetbuffer()
1808 1808 lines = lines.split('\n')
1809 1809 more = 0
1810 1810 for line in lines:
1811 1811 # skip blank lines so we don't mess up the prompt counter, but do
1812 1812 # NOT skip even a blank line if we are in a code block (more is
1813 1813 # true)
1814 1814 if line or more:
1815 1815 more = self.push(self.prefilter(line,more))
1816 1816 # IPython's runsource returns None if there was an error
1817 1817 # compiling the code. This allows us to stop processing right
1818 1818 # away, so the user gets the error message at the right place.
1819 1819 if more is None:
1820 1820 break
1821 1821 # final newline in case the input didn't have it, so that the code
1822 1822 # actually does get executed
1823 1823 if more:
1824 1824 self.push('\n')
1825 1825
1826 1826 def runsource(self, source, filename='<input>', symbol='single'):
1827 1827 """Compile and run some source in the interpreter.
1828 1828
1829 1829 Arguments are as for compile_command().
1830 1830
1831 1831 One several things can happen:
1832 1832
1833 1833 1) The input is incorrect; compile_command() raised an
1834 1834 exception (SyntaxError or OverflowError). A syntax traceback
1835 1835 will be printed by calling the showsyntaxerror() method.
1836 1836
1837 1837 2) The input is incomplete, and more input is required;
1838 1838 compile_command() returned None. Nothing happens.
1839 1839
1840 1840 3) The input is complete; compile_command() returned a code
1841 1841 object. The code is executed by calling self.runcode() (which
1842 1842 also handles run-time exceptions, except for SystemExit).
1843 1843
1844 1844 The return value is:
1845 1845
1846 1846 - True in case 2
1847 1847
1848 1848 - False in the other cases, unless an exception is raised, where
1849 1849 None is returned instead. This can be used by external callers to
1850 1850 know whether to continue feeding input or not.
1851 1851
1852 1852 The return value can be used to decide whether to use sys.ps1 or
1853 1853 sys.ps2 to prompt the next line."""
1854 1854
1855 1855 # if the source code has leading blanks, add 'if 1:\n' to it
1856 1856 # this allows execution of indented pasted code. It is tempting
1857 1857 # to add '\n' at the end of source to run commands like ' a=1'
1858 1858 # directly, but this fails for more complicated scenarios
1859 1859 if source[:1] in [' ', '\t']:
1860 1860 source = 'if 1:\n%s' % source
1861 1861
1862 1862 try:
1863 1863 code = self.compile(source,filename,symbol)
1864 1864 except (OverflowError, SyntaxError, ValueError):
1865 1865 # Case 1
1866 1866 self.showsyntaxerror(filename)
1867 1867 return None
1868 1868
1869 1869 if code is None:
1870 1870 # Case 2
1871 1871 return True
1872 1872
1873 1873 # Case 3
1874 1874 # We store the code object so that threaded shells and
1875 1875 # custom exception handlers can access all this info if needed.
1876 1876 # The source corresponding to this can be obtained from the
1877 1877 # buffer attribute as '\n'.join(self.buffer).
1878 1878 self.code_to_run = code
1879 1879 # now actually execute the code object
1880 1880 if self.runcode(code) == 0:
1881 1881 return False
1882 1882 else:
1883 1883 return None
1884 1884
1885 1885 def runcode(self,code_obj):
1886 1886 """Execute a code object.
1887 1887
1888 1888 When an exception occurs, self.showtraceback() is called to display a
1889 1889 traceback.
1890 1890
1891 1891 Return value: a flag indicating whether the code to be run completed
1892 1892 successfully:
1893 1893
1894 1894 - 0: successful execution.
1895 1895 - 1: an error occurred.
1896 1896 """
1897 1897
1898 1898 # Set our own excepthook in case the user code tries to call it
1899 1899 # directly, so that the IPython crash handler doesn't get triggered
1900 1900 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1901 1901
1902 1902 # we save the original sys.excepthook in the instance, in case config
1903 1903 # code (such as magics) needs access to it.
1904 1904 self.sys_excepthook = old_excepthook
1905 1905 outflag = 1 # happens in more places, so it's easier as default
1906 1906 try:
1907 1907 try:
1908 1908 # Embedded instances require separate global/local namespaces
1909 1909 # so they can see both the surrounding (local) namespace and
1910 1910 # the module-level globals when called inside another function.
1911 1911 if self.embedded:
1912 1912 exec code_obj in self.user_global_ns, self.user_ns
1913 1913 # Normal (non-embedded) instances should only have a single
1914 1914 # namespace for user code execution, otherwise functions won't
1915 1915 # see interactive top-level globals.
1916 1916 else:
1917 1917 exec code_obj in self.user_ns
1918 1918 finally:
1919 1919 # Reset our crash handler in place
1920 1920 sys.excepthook = old_excepthook
1921 1921 except SystemExit:
1922 1922 self.resetbuffer()
1923 1923 self.showtraceback()
1924 1924 warn("Type %exit or %quit to exit IPython "
1925 1925 "(%Exit or %Quit do so unconditionally).",level=1)
1926 1926 except self.custom_exceptions:
1927 1927 etype,value,tb = sys.exc_info()
1928 1928 self.CustomTB(etype,value,tb)
1929 1929 except:
1930 1930 self.showtraceback()
1931 1931 else:
1932 1932 outflag = 0
1933 1933 if softspace(sys.stdout, 0):
1934 1934 print
1935 1935 # Flush out code object which has been run (and source)
1936 1936 self.code_to_run = None
1937 1937 return outflag
1938 1938
1939 1939 def push(self, line):
1940 1940 """Push a line to the interpreter.
1941 1941
1942 1942 The line should not have a trailing newline; it may have
1943 1943 internal newlines. The line is appended to a buffer and the
1944 1944 interpreter's runsource() method is called with the
1945 1945 concatenated contents of the buffer as source. If this
1946 1946 indicates that the command was executed or invalid, the buffer
1947 1947 is reset; otherwise, the command is incomplete, and the buffer
1948 1948 is left as it was after the line was appended. The return
1949 1949 value is 1 if more input is required, 0 if the line was dealt
1950 1950 with in some way (this is the same as runsource()).
1951 1951 """
1952 1952
1953 1953 # autoindent management should be done here, and not in the
1954 1954 # interactive loop, since that one is only seen by keyboard input. We
1955 1955 # need this done correctly even for code run via runlines (which uses
1956 1956 # push).
1957 1957
1958 1958 #print 'push line: <%s>' % line # dbg
1959 1959 for subline in line.splitlines():
1960 1960 self.autoindent_update(subline)
1961 1961 self.buffer.append(line)
1962 1962 more = self.runsource('\n'.join(self.buffer), self.filename)
1963 1963 if not more:
1964 1964 self.resetbuffer()
1965 1965 return more
1966 1966
1967 1967 def resetbuffer(self):
1968 1968 """Reset the input buffer."""
1969 1969 self.buffer[:] = []
1970 1970
1971 1971 def raw_input(self,prompt='',continue_prompt=False):
1972 1972 """Write a prompt and read a line.
1973 1973
1974 1974 The returned line does not include the trailing newline.
1975 1975 When the user enters the EOF key sequence, EOFError is raised.
1976 1976
1977 1977 Optional inputs:
1978 1978
1979 1979 - prompt(''): a string to be printed to prompt the user.
1980 1980
1981 1981 - continue_prompt(False): whether this line is the first one or a
1982 1982 continuation in a sequence of inputs.
1983 1983 """
1984 1984
1985 1985 try:
1986 1986 line = raw_input_original(prompt).decode(sys.stdin.encoding)
1987 1987 except ValueError:
1988 1988 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1989 1989 self.exit_now = True
1990 1990 return ""
1991 1991
1992 1992
1993 1993 # Try to be reasonably smart about not re-indenting pasted input more
1994 1994 # than necessary. We do this by trimming out the auto-indent initial
1995 1995 # spaces, if the user's actual input started itself with whitespace.
1996 1996 #debugx('self.buffer[-1]')
1997 1997
1998 1998 if self.autoindent:
1999 1999 if num_ini_spaces(line) > self.indent_current_nsp:
2000 2000 line = line[self.indent_current_nsp:]
2001 2001 self.indent_current_nsp = 0
2002 2002
2003 2003 # store the unfiltered input before the user has any chance to modify
2004 2004 # it.
2005 2005 if line.strip():
2006 2006 if continue_prompt:
2007 2007 self.input_hist_raw[-1] += '%s\n' % line
2008 2008 if self.has_readline: # and some config option is set?
2009 2009 try:
2010 2010 histlen = self.readline.get_current_history_length()
2011 2011 newhist = self.input_hist_raw[-1].rstrip()
2012 2012 self.readline.remove_history_item(histlen-1)
2013 2013 self.readline.replace_history_item(histlen-2,newhist)
2014 2014 except AttributeError:
2015 2015 pass # re{move,place}_history_item are new in 2.4.
2016 2016 else:
2017 2017 self.input_hist_raw.append('%s\n' % line)
2018 2018
2019 2019 try:
2020 2020 lineout = self.prefilter(line,continue_prompt)
2021 2021 except:
2022 2022 # blanket except, in case a user-defined prefilter crashes, so it
2023 2023 # can't take all of ipython with it.
2024 2024 self.showtraceback()
2025 2025 return ''
2026 2026 else:
2027 2027 return lineout
2028 2028
2029 2029 def split_user_input(self,line, pattern = None):
2030 2030 """Split user input into pre-char, function part and rest."""
2031 2031
2032 2032 if pattern is None:
2033 2033 pattern = self.line_split
2034 2034
2035 2035 lsplit = pattern.match(line)
2036 2036 if lsplit is None: # no regexp match returns None
2037 2037 #print "match failed for line '%s'" % line # dbg
2038 2038 try:
2039 2039 iFun,theRest = line.split(None,1)
2040 2040 except ValueError:
2041 2041 #print "split failed for line '%s'" % line # dbg
2042 2042 iFun,theRest = line,''
2043 2043 pre = re.match('^(\s*)(.*)',line).groups()[0]
2044 2044 else:
2045 2045 pre,iFun,theRest = lsplit.groups()
2046 2046
2047 2047 #print 'line:<%s>' % line # dbg
2048 2048 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2049 2049 return pre,iFun.strip(),theRest
2050 2050
2051 2051 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2052 2052 # accesses with a more stringent check of inputs, but it introduced other
2053 2053 # bugs. Disable it for now until I can properly fix it.
2054 2054 def split_user_inputBROKEN(self,line):
2055 2055 """Split user input into pre-char, function part and rest."""
2056 2056
2057 2057 lsplit = self.line_split.match(line)
2058 2058 if lsplit is None: # no regexp match returns None
2059 2059 lsplit = self.line_split_fallback.match(line)
2060 2060
2061 2061 #pre,iFun,theRest = lsplit.groups() # dbg
2062 2062 #print 'line:<%s>' % line # dbg
2063 2063 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2064 2064 #return pre,iFun.strip(),theRest # dbg
2065 2065
2066 2066 return lsplit.groups()
2067 2067
2068 2068 def _prefilter(self, line, continue_prompt):
2069 2069 """Calls different preprocessors, depending on the form of line."""
2070 2070
2071 2071 # All handlers *must* return a value, even if it's blank ('').
2072 2072
2073 2073 # Lines are NOT logged here. Handlers should process the line as
2074 2074 # needed, update the cache AND log it (so that the input cache array
2075 2075 # stays synced).
2076 2076
2077 2077 # This function is _very_ delicate, and since it's also the one which
2078 2078 # determines IPython's response to user input, it must be as efficient
2079 2079 # as possible. For this reason it has _many_ returns in it, trying
2080 2080 # always to exit as quickly as it can figure out what it needs to do.
2081 2081
2082 2082 # This function is the main responsible for maintaining IPython's
2083 2083 # behavior respectful of Python's semantics. So be _very_ careful if
2084 2084 # making changes to anything here.
2085 2085
2086 2086 #.....................................................................
2087 2087 # Code begins
2088 2088
2089 2089 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2090 2090
2091 2091 # save the line away in case we crash, so the post-mortem handler can
2092 2092 # record it
2093 2093 self._last_input_line = line
2094 2094
2095 2095 #print '***line: <%s>' % line # dbg
2096 2096
2097 2097 # the input history needs to track even empty lines
2098 2098 stripped = line.strip()
2099 2099
2100 2100 if not stripped:
2101 2101 if not continue_prompt:
2102 2102 self.outputcache.prompt_count -= 1
2103 2103 return self.handle_normal(line,continue_prompt)
2104 2104 #return self.handle_normal('',continue_prompt)
2105 2105
2106 2106 # print '***cont',continue_prompt # dbg
2107 2107 # special handlers are only allowed for single line statements
2108 2108 if continue_prompt and not self.rc.multi_line_specials:
2109 2109 return self.handle_normal(line,continue_prompt)
2110 2110
2111 2111
2112 2112 # For the rest, we need the structure of the input
2113 2113 pre,iFun,theRest = self.split_user_input(line)
2114 2114
2115 2115 # See whether any pre-existing handler can take care of it
2116 2116
2117 2117 rewritten = self.hooks.input_prefilter(stripped)
2118 2118 if rewritten != stripped: # ok, some prefilter did something
2119 2119 rewritten = pre + rewritten # add indentation
2120 2120 return self.handle_normal(rewritten)
2121 2121
2122 2122 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2123 2123
2124 2124 # Next, check if we can automatically execute this thing
2125 2125
2126 2126 # Allow ! in multi-line statements if multi_line_specials is on:
2127 2127 if continue_prompt and self.rc.multi_line_specials and \
2128 2128 iFun.startswith(self.ESC_SHELL):
2129 2129 return self.handle_shell_escape(line,continue_prompt,
2130 2130 pre=pre,iFun=iFun,
2131 2131 theRest=theRest)
2132 2132
2133 2133 # First check for explicit escapes in the last/first character
2134 2134 handler = None
2135 2135 if line[-1] == self.ESC_HELP:
2136 2136 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2137 2137 if handler is None:
2138 2138 # look at the first character of iFun, NOT of line, so we skip
2139 2139 # leading whitespace in multiline input
2140 2140 handler = self.esc_handlers.get(iFun[0:1])
2141 2141 if handler is not None:
2142 2142 return handler(line,continue_prompt,pre,iFun,theRest)
2143 2143 # Emacs ipython-mode tags certain input lines
2144 2144 if line.endswith('# PYTHON-MODE'):
2145 2145 return self.handle_emacs(line,continue_prompt)
2146 2146
2147 2147 # Let's try to find if the input line is a magic fn
2148 2148 oinfo = None
2149 2149 if hasattr(self,'magic_'+iFun):
2150 2150 # WARNING: _ofind uses getattr(), so it can consume generators and
2151 2151 # cause other side effects.
2152 2152 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2153 2153 if oinfo['ismagic']:
2154 2154 # Be careful not to call magics when a variable assignment is
2155 2155 # being made (ls='hi', for example)
2156 2156 if self.rc.automagic and \
2157 2157 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2158 2158 (self.rc.multi_line_specials or not continue_prompt):
2159 2159 return self.handle_magic(line,continue_prompt,
2160 2160 pre,iFun,theRest)
2161 2161 else:
2162 2162 return self.handle_normal(line,continue_prompt)
2163 2163
2164 2164 # If the rest of the line begins with an (in)equality, assginment or
2165 2165 # function call, we should not call _ofind but simply execute it.
2166 2166 # This avoids spurious geattr() accesses on objects upon assignment.
2167 2167 #
2168 2168 # It also allows users to assign to either alias or magic names true
2169 2169 # python variables (the magic/alias systems always take second seat to
2170 2170 # true python code).
2171 2171 if theRest and theRest[0] in '!=()':
2172 2172 return self.handle_normal(line,continue_prompt)
2173 2173
2174 2174 if oinfo is None:
2175 2175 # let's try to ensure that _oinfo is ONLY called when autocall is
2176 2176 # on. Since it has inevitable potential side effects, at least
2177 2177 # having autocall off should be a guarantee to the user that no
2178 2178 # weird things will happen.
2179 2179
2180 2180 if self.rc.autocall:
2181 2181 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2182 2182 else:
2183 2183 # in this case, all that's left is either an alias or
2184 2184 # processing the line normally.
2185 2185 if iFun in self.alias_table:
2186 2186 # if autocall is off, by not running _ofind we won't know
2187 2187 # whether the given name may also exist in one of the
2188 2188 # user's namespace. At this point, it's best to do a
2189 2189 # quick check just to be sure that we don't let aliases
2190 2190 # shadow variables.
2191 2191 head = iFun.split('.',1)[0]
2192 2192 if head in self.user_ns or head in self.internal_ns \
2193 2193 or head in __builtin__.__dict__:
2194 2194 return self.handle_normal(line,continue_prompt)
2195 2195 else:
2196 2196 return self.handle_alias(line,continue_prompt,
2197 2197 pre,iFun,theRest)
2198 2198
2199 2199 else:
2200 2200 return self.handle_normal(line,continue_prompt)
2201 2201
2202 2202 if not oinfo['found']:
2203 2203 return self.handle_normal(line,continue_prompt)
2204 2204 else:
2205 2205 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2206 2206 if oinfo['isalias']:
2207 2207 return self.handle_alias(line,continue_prompt,
2208 2208 pre,iFun,theRest)
2209 2209
2210 2210 if (self.rc.autocall
2211 2211 and
2212 2212 (
2213 2213 #only consider exclusion re if not "," or ";" autoquoting
2214 2214 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2215 2215 or pre == self.ESC_PAREN) or
2216 2216 (not self.re_exclude_auto.match(theRest)))
2217 2217 and
2218 2218 self.re_fun_name.match(iFun) and
2219 2219 callable(oinfo['obj'])) :
2220 2220 #print 'going auto' # dbg
2221 2221 return self.handle_auto(line,continue_prompt,
2222 2222 pre,iFun,theRest,oinfo['obj'])
2223 2223 else:
2224 2224 #print 'was callable?', callable(oinfo['obj']) # dbg
2225 2225 return self.handle_normal(line,continue_prompt)
2226 2226
2227 2227 # If we get here, we have a normal Python line. Log and return.
2228 2228 return self.handle_normal(line,continue_prompt)
2229 2229
2230 2230 def _prefilter_dumb(self, line, continue_prompt):
2231 2231 """simple prefilter function, for debugging"""
2232 2232 return self.handle_normal(line,continue_prompt)
2233 2233
2234 2234
2235 2235 def multiline_prefilter(self, line, continue_prompt):
2236 2236 """ Run _prefilter for each line of input
2237 2237
2238 2238 Covers cases where there are multiple lines in the user entry,
2239 2239 which is the case when the user goes back to a multiline history
2240 2240 entry and presses enter.
2241 2241
2242 2242 """
2243 2243 out = []
2244 2244 for l in line.rstrip('\n').split('\n'):
2245 2245 out.append(self._prefilter(l, continue_prompt))
2246 2246 return '\n'.join(out)
2247 2247
2248 2248 # Set the default prefilter() function (this can be user-overridden)
2249 2249 prefilter = multiline_prefilter
2250 2250
2251 2251 def handle_normal(self,line,continue_prompt=None,
2252 2252 pre=None,iFun=None,theRest=None):
2253 2253 """Handle normal input lines. Use as a template for handlers."""
2254 2254
2255 2255 # With autoindent on, we need some way to exit the input loop, and I
2256 2256 # don't want to force the user to have to backspace all the way to
2257 2257 # clear the line. The rule will be in this case, that either two
2258 2258 # lines of pure whitespace in a row, or a line of pure whitespace but
2259 2259 # of a size different to the indent level, will exit the input loop.
2260 2260
2261 2261 if (continue_prompt and self.autoindent and line.isspace() and
2262 2262 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2263 2263 (self.buffer[-1]).isspace() )):
2264 2264 line = ''
2265 2265
2266 2266 self.log(line,line,continue_prompt)
2267 2267 return line
2268 2268
2269 2269 def handle_alias(self,line,continue_prompt=None,
2270 2270 pre=None,iFun=None,theRest=None):
2271 2271 """Handle alias input lines. """
2272 2272
2273 2273 # pre is needed, because it carries the leading whitespace. Otherwise
2274 2274 # aliases won't work in indented sections.
2275 2275 transformed = self.expand_aliases(iFun, theRest)
2276 2276 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2277 2277 self.log(line,line_out,continue_prompt)
2278 2278 #print 'line out:',line_out # dbg
2279 2279 return line_out
2280 2280
2281 2281 def handle_shell_escape(self, line, continue_prompt=None,
2282 2282 pre=None,iFun=None,theRest=None):
2283 2283 """Execute the line in a shell, empty return value"""
2284 2284
2285 2285 #print 'line in :', `line` # dbg
2286 2286 # Example of a special handler. Others follow a similar pattern.
2287 2287 if line.lstrip().startswith('!!'):
2288 2288 # rewrite iFun/theRest to properly hold the call to %sx and
2289 2289 # the actual command to be executed, so handle_magic can work
2290 2290 # correctly
2291 2291 theRest = '%s %s' % (iFun[2:],theRest)
2292 2292 iFun = 'sx'
2293 2293 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2294 2294 line.lstrip()[2:]),
2295 2295 continue_prompt,pre,iFun,theRest)
2296 2296 else:
2297 2297 cmd=line.lstrip().lstrip('!')
2298 2298 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2299 2299 # update cache/log and return
2300 2300 self.log(line,line_out,continue_prompt)
2301 2301 return line_out
2302 2302
2303 2303 def handle_magic(self, line, continue_prompt=None,
2304 2304 pre=None,iFun=None,theRest=None):
2305 2305 """Execute magic functions."""
2306 2306
2307 2307
2308 2308 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2309 2309 self.log(line,cmd,continue_prompt)
2310 2310 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2311 2311 return cmd
2312 2312
2313 2313 def handle_auto(self, line, continue_prompt=None,
2314 2314 pre=None,iFun=None,theRest=None,obj=None):
2315 2315 """Hande lines which can be auto-executed, quoting if requested."""
2316 2316
2317 2317 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2318 2318
2319 2319 # This should only be active for single-line input!
2320 2320 if continue_prompt:
2321 2321 self.log(line,line,continue_prompt)
2322 2322 return line
2323 2323
2324 2324 auto_rewrite = True
2325 2325
2326 2326 if pre == self.ESC_QUOTE:
2327 2327 # Auto-quote splitting on whitespace
2328 2328 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2329 2329 elif pre == self.ESC_QUOTE2:
2330 2330 # Auto-quote whole string
2331 2331 newcmd = '%s("%s")' % (iFun,theRest)
2332 2332 elif pre == self.ESC_PAREN:
2333 2333 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2334 2334 else:
2335 2335 # Auto-paren.
2336 2336 # We only apply it to argument-less calls if the autocall
2337 2337 # parameter is set to 2. We only need to check that autocall is <
2338 2338 # 2, since this function isn't called unless it's at least 1.
2339 2339 if not theRest and (self.rc.autocall < 2):
2340 2340 newcmd = '%s %s' % (iFun,theRest)
2341 2341 auto_rewrite = False
2342 2342 else:
2343 2343 if theRest.startswith('['):
2344 2344 if hasattr(obj,'__getitem__'):
2345 2345 # Don't autocall in this case: item access for an object
2346 2346 # which is BOTH callable and implements __getitem__.
2347 2347 newcmd = '%s %s' % (iFun,theRest)
2348 2348 auto_rewrite = False
2349 2349 else:
2350 2350 # if the object doesn't support [] access, go ahead and
2351 2351 # autocall
2352 2352 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2353 2353 elif theRest.endswith(';'):
2354 2354 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2355 2355 else:
2356 2356 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2357 2357
2358 2358 if auto_rewrite:
2359 2359 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2360 2360 # log what is now valid Python, not the actual user input (without the
2361 2361 # final newline)
2362 2362 self.log(line,newcmd,continue_prompt)
2363 2363 return newcmd
2364 2364
2365 2365 def handle_help(self, line, continue_prompt=None,
2366 2366 pre=None,iFun=None,theRest=None):
2367 2367 """Try to get some help for the object.
2368 2368
2369 2369 obj? or ?obj -> basic information.
2370 2370 obj?? or ??obj -> more details.
2371 2371 """
2372 2372
2373 2373 # We need to make sure that we don't process lines which would be
2374 2374 # otherwise valid python, such as "x=1 # what?"
2375 2375 try:
2376 2376 codeop.compile_command(line)
2377 2377 except SyntaxError:
2378 2378 # We should only handle as help stuff which is NOT valid syntax
2379 2379 if line[0]==self.ESC_HELP:
2380 2380 line = line[1:]
2381 2381 elif line[-1]==self.ESC_HELP:
2382 2382 line = line[:-1]
2383 2383 self.log(line,'#?'+line,continue_prompt)
2384 2384 if line:
2385 #print 'line:<%r>' % line # dbg
2385 2386 self.magic_pinfo(line)
2386 2387 else:
2387 2388 page(self.usage,screen_lines=self.rc.screen_length)
2388 2389 return '' # Empty string is needed here!
2389 2390 except:
2390 2391 # Pass any other exceptions through to the normal handler
2391 2392 return self.handle_normal(line,continue_prompt)
2392 2393 else:
2393 2394 # If the code compiles ok, we should handle it normally
2394 2395 return self.handle_normal(line,continue_prompt)
2395 2396
2396 2397 def getapi(self):
2397 2398 """ Get an IPApi object for this shell instance
2398 2399
2399 2400 Getting an IPApi object is always preferable to accessing the shell
2400 2401 directly, but this holds true especially for extensions.
2401 2402
2402 2403 It should always be possible to implement an extension with IPApi
2403 2404 alone. If not, contact maintainer to request an addition.
2404 2405
2405 2406 """
2406 2407 return self.api
2407 2408
2408 2409 def handle_emacs(self,line,continue_prompt=None,
2409 2410 pre=None,iFun=None,theRest=None):
2410 2411 """Handle input lines marked by python-mode."""
2411 2412
2412 2413 # Currently, nothing is done. Later more functionality can be added
2413 2414 # here if needed.
2414 2415
2415 2416 # The input cache shouldn't be updated
2416 2417
2417 2418 return line
2418 2419
2419 2420 def mktempfile(self,data=None):
2420 2421 """Make a new tempfile and return its filename.
2421 2422
2422 2423 This makes a call to tempfile.mktemp, but it registers the created
2423 2424 filename internally so ipython cleans it up at exit time.
2424 2425
2425 2426 Optional inputs:
2426 2427
2427 2428 - data(None): if data is given, it gets written out to the temp file
2428 2429 immediately, and the file is closed again."""
2429 2430
2430 2431 filename = tempfile.mktemp('.py','ipython_edit_')
2431 2432 self.tempfiles.append(filename)
2432 2433
2433 2434 if data:
2434 2435 tmp_file = open(filename,'w')
2435 2436 tmp_file.write(data)
2436 2437 tmp_file.close()
2437 2438 return filename
2438 2439
2439 2440 def write(self,data):
2440 2441 """Write a string to the default output"""
2441 2442 Term.cout.write(data)
2442 2443
2443 2444 def write_err(self,data):
2444 2445 """Write a string to the default error output"""
2445 2446 Term.cerr.write(data)
2446 2447
2447 2448 def exit(self):
2448 2449 """Handle interactive exit.
2449 2450
2450 2451 This method sets the exit_now attribute."""
2451 2452
2452 2453 if self.rc.confirm_exit:
2453 2454 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2454 2455 self.exit_now = True
2455 2456 else:
2456 2457 self.exit_now = True
2457 2458
2458 2459 def safe_execfile(self,fname,*where,**kw):
2459 2460 """A safe version of the builtin execfile().
2460 2461
2461 2462 This version will never throw an exception, and knows how to handle
2462 2463 ipython logs as well."""
2463 2464
2464 2465 def syspath_cleanup():
2465 2466 """Internal cleanup routine for sys.path."""
2466 2467 if add_dname:
2467 2468 try:
2468 2469 sys.path.remove(dname)
2469 2470 except ValueError:
2470 2471 # For some reason the user has already removed it, ignore.
2471 2472 pass
2472 2473
2473 2474 fname = os.path.expanduser(fname)
2474 2475
2475 2476 # Find things also in current directory. This is needed to mimic the
2476 2477 # behavior of running a script from the system command line, where
2477 2478 # Python inserts the script's directory into sys.path
2478 2479 dname = os.path.dirname(os.path.abspath(fname))
2479 2480 add_dname = False
2480 2481 if dname not in sys.path:
2481 2482 sys.path.insert(0,dname)
2482 2483 add_dname = True
2483 2484
2484 2485 try:
2485 2486 xfile = open(fname)
2486 2487 except:
2487 2488 print >> Term.cerr, \
2488 2489 'Could not open file <%s> for safe execution.' % fname
2489 2490 syspath_cleanup()
2490 2491 return None
2491 2492
2492 2493 kw.setdefault('islog',0)
2493 2494 kw.setdefault('quiet',1)
2494 2495 kw.setdefault('exit_ignore',0)
2495 2496 first = xfile.readline()
2496 2497 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2497 2498 xfile.close()
2498 2499 # line by line execution
2499 2500 if first.startswith(loghead) or kw['islog']:
2500 2501 print 'Loading log file <%s> one line at a time...' % fname
2501 2502 if kw['quiet']:
2502 2503 stdout_save = sys.stdout
2503 2504 sys.stdout = StringIO.StringIO()
2504 2505 try:
2505 2506 globs,locs = where[0:2]
2506 2507 except:
2507 2508 try:
2508 2509 globs = locs = where[0]
2509 2510 except:
2510 2511 globs = locs = globals()
2511 2512 badblocks = []
2512 2513
2513 2514 # we also need to identify indented blocks of code when replaying
2514 2515 # logs and put them together before passing them to an exec
2515 2516 # statement. This takes a bit of regexp and look-ahead work in the
2516 2517 # file. It's easiest if we swallow the whole thing in memory
2517 2518 # first, and manually walk through the lines list moving the
2518 2519 # counter ourselves.
2519 2520 indent_re = re.compile('\s+\S')
2520 2521 xfile = open(fname)
2521 2522 filelines = xfile.readlines()
2522 2523 xfile.close()
2523 2524 nlines = len(filelines)
2524 2525 lnum = 0
2525 2526 while lnum < nlines:
2526 2527 line = filelines[lnum]
2527 2528 lnum += 1
2528 2529 # don't re-insert logger status info into cache
2529 2530 if line.startswith('#log#'):
2530 2531 continue
2531 2532 else:
2532 2533 # build a block of code (maybe a single line) for execution
2533 2534 block = line
2534 2535 try:
2535 2536 next = filelines[lnum] # lnum has already incremented
2536 2537 except:
2537 2538 next = None
2538 2539 while next and indent_re.match(next):
2539 2540 block += next
2540 2541 lnum += 1
2541 2542 try:
2542 2543 next = filelines[lnum]
2543 2544 except:
2544 2545 next = None
2545 2546 # now execute the block of one or more lines
2546 2547 try:
2547 2548 exec block in globs,locs
2548 2549 except SystemExit:
2549 2550 pass
2550 2551 except:
2551 2552 badblocks.append(block.rstrip())
2552 2553 if kw['quiet']: # restore stdout
2553 2554 sys.stdout.close()
2554 2555 sys.stdout = stdout_save
2555 2556 print 'Finished replaying log file <%s>' % fname
2556 2557 if badblocks:
2557 2558 print >> sys.stderr, ('\nThe following lines/blocks in file '
2558 2559 '<%s> reported errors:' % fname)
2559 2560
2560 2561 for badline in badblocks:
2561 2562 print >> sys.stderr, badline
2562 2563 else: # regular file execution
2563 2564 try:
2564 2565 execfile(fname,*where)
2565 2566 except SyntaxError:
2566 2567 self.showsyntaxerror()
2567 2568 warn('Failure executing file: <%s>' % fname)
2568 2569 except SystemExit,status:
2569 2570 if not kw['exit_ignore']:
2570 2571 self.showtraceback()
2571 2572 warn('Failure executing file: <%s>' % fname)
2572 2573 except:
2573 2574 self.showtraceback()
2574 2575 warn('Failure executing file: <%s>' % fname)
2575 2576
2576 2577 syspath_cleanup()
2577 2578
2578 2579 #************************* end of file <iplib.py> *****************************
@@ -1,6401 +1,6408 b''
1 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (_inspect): convert unicode input into ascii
4 before trying to evaluate it as a Python identifier. This fixes a
5 problem that the new unicode support had introduced when analyzing
6 long definition lines for functions.
7
1 8 2007-03-24 Walter Doerwald <walter@livinglogic.de>
2 9
3 10 * IPython/Extensions/igrid.py: Fix picking. Using
4 11 igrid with wxPython 2.6 and -wthread should work now.
5 12 igrid.display() simply tries to create a frame without
6 13 an application. Only if this fails an application is created.
7 14
8 15 2007-03-23 Walter Doerwald <walter@livinglogic.de>
9 16
10 17 * IPython/Extensions/path.py: Updated to version 2.2.
11 18
12 19 2007-03-23 Ville Vainio <vivainio@gmail.com>
13 20
14 21 * iplib.py: recursive alias expansion now works better, so that
15 22 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
16 23 doesn't trip up the process, if 'd' has been aliased to 'ls'.
17 24
18 25 * Extensions/ipy_gnuglobal.py added, provides %global magic
19 26 for users of http://www.gnu.org/software/global
20 27
21 28 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
22 29 Closes #52. Patch by Stefan van der Walt.
23 30
24 31 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
25 32
26 33 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
27 34 respect the __file__ attribute when using %run. Thanks to a bug
28 35 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
29 36
30 37 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
31 38
32 39 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
33 40 input. Patch sent by Stefan.
34 41
35 42 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
36 43 * IPython/Extensions/ipy_stock_completer.py
37 44 shlex_split, fix bug in shlex_split. len function
38 45 call was missing in if statement. Caused shlex_split to
39 46 sometimes return "" as last element.
40 47
41 48 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
42 49
43 50 * IPython/completer.py
44 51 (IPCompleter.file_matches.single_dir_expand): fix a problem
45 52 reported by Stefan, where directories containign a single subdir
46 53 would be completed too early.
47 54
48 55 * IPython/Shell.py (_load_pylab): Make the execution of 'from
49 56 pylab import *' when -pylab is given be optional. A new flag,
50 57 pylab_import_all controls this behavior, the default is True for
51 58 backwards compatibility.
52 59
53 60 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
54 61 modified) R. Bernstein's patch for fully syntax highlighted
55 62 tracebacks. The functionality is also available under ultraTB for
56 63 non-ipython users (someone using ultraTB but outside an ipython
57 64 session). They can select the color scheme by setting the
58 65 module-level global DEFAULT_SCHEME. The highlight functionality
59 66 also works when debugging.
60 67
61 68 * IPython/genutils.py (IOStream.close): small patch by
62 69 R. Bernstein for improved pydb support.
63 70
64 71 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
65 72 DaveS <davls@telus.net> to improve support of debugging under
66 73 NTEmacs, including improved pydb behavior.
67 74
68 75 * IPython/Magic.py (magic_prun): Fix saving of profile info for
69 76 Python 2.5, where the stats object API changed a little. Thanks
70 77 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
71 78
72 79 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
73 80 Pernetty's patch to improve support for (X)Emacs under Win32.
74 81
75 82 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
76 83
77 84 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
78 85 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
79 86 a report by Nik Tautenhahn.
80 87
81 88 2007-03-16 Walter Doerwald <walter@livinglogic.de>
82 89
83 90 * setup.py: Add the igrid help files to the list of data files
84 91 to be installed alongside igrid.
85 92 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
86 93 Show the input object of the igrid browser as the window tile.
87 94 Show the object the cursor is on in the statusbar.
88 95
89 96 2007-03-15 Ville Vainio <vivainio@gmail.com>
90 97
91 98 * Extensions/ipy_stock_completers.py: Fixed exception
92 99 on mismatching quotes in %run completer. Patch by
93 100 JοΏ½rgen Stenarson. Closes #127.
94 101
95 102 2007-03-14 Ville Vainio <vivainio@gmail.com>
96 103
97 104 * Extensions/ext_rehashdir.py: Do not do auto_alias
98 105 in %rehashdir, it clobbers %store'd aliases.
99 106
100 107 * UserConfig/ipy_profile_sh.py: envpersist.py extension
101 108 (beefed up %env) imported for sh profile.
102 109
103 110 2007-03-10 Walter Doerwald <walter@livinglogic.de>
104 111
105 112 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
106 113 as the default browser.
107 114 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
108 115 As igrid displays all attributes it ever encounters, fetch() (which has
109 116 been renamed to _fetch()) doesn't have to recalculate the display attributes
110 117 every time a new item is fetched. This should speed up scrolling.
111 118
112 119 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
113 120
114 121 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
115 122 Schmolck's recently reported tab-completion bug (my previous one
116 123 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
117 124
118 125 2007-03-09 Walter Doerwald <walter@livinglogic.de>
119 126
120 127 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
121 128 Close help window if exiting igrid.
122 129
123 130 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
124 131
125 132 * IPython/Extensions/ipy_defaults.py: Check if readline is available
126 133 before calling functions from readline.
127 134
128 135 2007-03-02 Walter Doerwald <walter@livinglogic.de>
129 136
130 137 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
131 138 igrid is a wxPython-based display object for ipipe. If your system has
132 139 wx installed igrid will be the default display. Without wx ipipe falls
133 140 back to ibrowse (which needs curses). If no curses is installed ipipe
134 141 falls back to idump.
135 142
136 143 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
137 144
138 145 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
139 146 my changes from yesterday, they introduced bugs. Will reactivate
140 147 once I get a correct solution, which will be much easier thanks to
141 148 Dan Milstein's new prefilter test suite.
142 149
143 150 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
144 151
145 152 * IPython/iplib.py (split_user_input): fix input splitting so we
146 153 don't attempt attribute accesses on things that can't possibly be
147 154 valid Python attributes. After a bug report by Alex Schmolck.
148 155 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
149 156 %magic with explicit % prefix.
150 157
151 158 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
152 159
153 160 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
154 161 avoid a DeprecationWarning from GTK.
155 162
156 163 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
157 164
158 165 * IPython/genutils.py (clock): I modified clock() to return total
159 166 time, user+system. This is a more commonly needed metric. I also
160 167 introduced the new clocku/clocks to get only user/system time if
161 168 one wants those instead.
162 169
163 170 ***WARNING: API CHANGE*** clock() used to return only user time,
164 171 so if you want exactly the same results as before, use clocku
165 172 instead.
166 173
167 174 2007-02-22 Ville Vainio <vivainio@gmail.com>
168 175
169 176 * IPython/Extensions/ipy_p4.py: Extension for improved
170 177 p4 (perforce version control system) experience.
171 178 Adds %p4 magic with p4 command completion and
172 179 automatic -G argument (marshall output as python dict)
173 180
174 181 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
175 182
176 183 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
177 184 stop marks.
178 185 (ClearingMixin): a simple mixin to easily make a Demo class clear
179 186 the screen in between blocks and have empty marquees. The
180 187 ClearDemo and ClearIPDemo classes that use it are included.
181 188
182 189 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
183 190
184 191 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
185 192 protect against exceptions at Python shutdown time. Patch
186 193 sumbmitted to upstream.
187 194
188 195 2007-02-14 Walter Doerwald <walter@livinglogic.de>
189 196
190 197 * IPython/Extensions/ibrowse.py: If entering the first object level
191 198 (i.e. the object for which the browser has been started) fails,
192 199 now the error is raised directly (aborting the browser) instead of
193 200 running into an empty levels list later.
194 201
195 202 2007-02-03 Walter Doerwald <walter@livinglogic.de>
196 203
197 204 * IPython/Extensions/ipipe.py: Add an xrepr implementation
198 205 for the noitem object.
199 206
200 207 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
201 208
202 209 * IPython/completer.py (Completer.attr_matches): Fix small
203 210 tab-completion bug with Enthought Traits objects with units.
204 211 Thanks to a bug report by Tom Denniston
205 212 <tom.denniston-AT-alum.dartmouth.org>.
206 213
207 214 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
208 215
209 216 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
210 217 bug where only .ipy or .py would be completed. Once the first
211 218 argument to %run has been given, all completions are valid because
212 219 they are the arguments to the script, which may well be non-python
213 220 filenames.
214 221
215 222 * IPython/irunner.py (InteractiveRunner.run_source): major updates
216 223 to irunner to allow it to correctly support real doctesting of
217 224 out-of-process ipython code.
218 225
219 226 * IPython/Magic.py (magic_cd): Make the setting of the terminal
220 227 title an option (-noterm_title) because it completely breaks
221 228 doctesting.
222 229
223 230 * IPython/demo.py: fix IPythonDemo class that was not actually working.
224 231
225 232 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
226 233
227 234 * IPython/irunner.py (main): fix small bug where extensions were
228 235 not being correctly recognized.
229 236
230 237 2007-01-23 Walter Doerwald <walter@livinglogic.de>
231 238
232 239 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
233 240 a string containing a single line yields the string itself as the
234 241 only item.
235 242
236 243 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
237 244 object if it's the same as the one on the last level (This avoids
238 245 infinite recursion for one line strings).
239 246
240 247 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
241 248
242 249 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
243 250 all output streams before printing tracebacks. This ensures that
244 251 user output doesn't end up interleaved with traceback output.
245 252
246 253 2007-01-10 Ville Vainio <vivainio@gmail.com>
247 254
248 255 * Extensions/envpersist.py: Turbocharged %env that remembers
249 256 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
250 257 "%env VISUAL=jed".
251 258
252 259 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
253 260
254 261 * IPython/iplib.py (showtraceback): ensure that we correctly call
255 262 custom handlers in all cases (some with pdb were slipping through,
256 263 but I'm not exactly sure why).
257 264
258 265 * IPython/Debugger.py (Tracer.__init__): added new class to
259 266 support set_trace-like usage of IPython's enhanced debugger.
260 267
261 268 2006-12-24 Ville Vainio <vivainio@gmail.com>
262 269
263 270 * ipmaker.py: more informative message when ipy_user_conf
264 271 import fails (suggest running %upgrade).
265 272
266 273 * tools/run_ipy_in_profiler.py: Utility to see where
267 274 the time during IPython startup is spent.
268 275
269 276 2006-12-20 Ville Vainio <vivainio@gmail.com>
270 277
271 278 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
272 279
273 280 * ipapi.py: Add new ipapi method, expand_alias.
274 281
275 282 * Release.py: Bump up version to 0.7.4.svn
276 283
277 284 2006-12-17 Ville Vainio <vivainio@gmail.com>
278 285
279 286 * Extensions/jobctrl.py: Fixed &cmd arg arg...
280 287 to work properly on posix too
281 288
282 289 * Release.py: Update revnum (version is still just 0.7.3).
283 290
284 291 2006-12-15 Ville Vainio <vivainio@gmail.com>
285 292
286 293 * scripts/ipython_win_post_install: create ipython.py in
287 294 prefix + "/scripts".
288 295
289 296 * Release.py: Update version to 0.7.3.
290 297
291 298 2006-12-14 Ville Vainio <vivainio@gmail.com>
292 299
293 300 * scripts/ipython_win_post_install: Overwrite old shortcuts
294 301 if they already exist
295 302
296 303 * Release.py: release 0.7.3rc2
297 304
298 305 2006-12-13 Ville Vainio <vivainio@gmail.com>
299 306
300 307 * Branch and update Release.py for 0.7.3rc1
301 308
302 309 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
303 310
304 311 * IPython/Shell.py (IPShellWX): update for current WX naming
305 312 conventions, to avoid a deprecation warning with current WX
306 313 versions. Thanks to a report by Danny Shevitz.
307 314
308 315 2006-12-12 Ville Vainio <vivainio@gmail.com>
309 316
310 317 * ipmaker.py: apply david cournapeau's patch to make
311 318 import_some work properly even when ipythonrc does
312 319 import_some on empty list (it was an old bug!).
313 320
314 321 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
315 322 Add deprecation note to ipythonrc and a url to wiki
316 323 in ipy_user_conf.py
317 324
318 325
319 326 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
320 327 as if it was typed on IPython command prompt, i.e.
321 328 as IPython script.
322 329
323 330 * example-magic.py, magic_grepl.py: remove outdated examples
324 331
325 332 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
326 333
327 334 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
328 335 is called before any exception has occurred.
329 336
330 337 2006-12-08 Ville Vainio <vivainio@gmail.com>
331 338
332 339 * Extensions/ipy_stock_completers.py: fix cd completer
333 340 to translate /'s to \'s again.
334 341
335 342 * completer.py: prevent traceback on file completions w/
336 343 backslash.
337 344
338 345 * Release.py: Update release number to 0.7.3b3 for release
339 346
340 347 2006-12-07 Ville Vainio <vivainio@gmail.com>
341 348
342 349 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
343 350 while executing external code. Provides more shell-like behaviour
344 351 and overall better response to ctrl + C / ctrl + break.
345 352
346 353 * tools/make_tarball.py: new script to create tarball straight from svn
347 354 (setup.py sdist doesn't work on win32).
348 355
349 356 * Extensions/ipy_stock_completers.py: fix cd completer to give up
350 357 on dirnames with spaces and use the default completer instead.
351 358
352 359 * Revision.py: Change version to 0.7.3b2 for release.
353 360
354 361 2006-12-05 Ville Vainio <vivainio@gmail.com>
355 362
356 363 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
357 364 pydb patch 4 (rm debug printing, py 2.5 checking)
358 365
359 366 2006-11-30 Walter Doerwald <walter@livinglogic.de>
360 367 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
361 368 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
362 369 "refreshfind" (mapped to "R") does the same but tries to go back to the same
363 370 object the cursor was on before the refresh. The command "markrange" is
364 371 mapped to "%" now.
365 372 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
366 373
367 374 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
368 375
369 376 * IPython/Magic.py (magic_debug): new %debug magic to activate the
370 377 interactive debugger on the last traceback, without having to call
371 378 %pdb and rerun your code. Made minor changes in various modules,
372 379 should automatically recognize pydb if available.
373 380
374 381 2006-11-28 Ville Vainio <vivainio@gmail.com>
375 382
376 383 * completer.py: If the text start with !, show file completions
377 384 properly. This helps when trying to complete command name
378 385 for shell escapes.
379 386
380 387 2006-11-27 Ville Vainio <vivainio@gmail.com>
381 388
382 389 * ipy_stock_completers.py: bzr completer submitted by Stefan van
383 390 der Walt. Clean up svn and hg completers by using a common
384 391 vcs_completer.
385 392
386 393 2006-11-26 Ville Vainio <vivainio@gmail.com>
387 394
388 395 * Remove ipconfig and %config; you should use _ip.options structure
389 396 directly instead!
390 397
391 398 * genutils.py: add wrap_deprecated function for deprecating callables
392 399
393 400 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
394 401 _ip.system instead. ipalias is redundant.
395 402
396 403 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
397 404 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
398 405 explicit.
399 406
400 407 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
401 408 completer. Try it by entering 'hg ' and pressing tab.
402 409
403 410 * macro.py: Give Macro a useful __repr__ method
404 411
405 412 * Magic.py: %whos abbreviates the typename of Macro for brevity.
406 413
407 414 2006-11-24 Walter Doerwald <walter@livinglogic.de>
408 415 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
409 416 we don't get a duplicate ipipe module, where registration of the xrepr
410 417 implementation for Text is useless.
411 418
412 419 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
413 420
414 421 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
415 422
416 423 2006-11-24 Ville Vainio <vivainio@gmail.com>
417 424
418 425 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
419 426 try to use "cProfile" instead of the slower pure python
420 427 "profile"
421 428
422 429 2006-11-23 Ville Vainio <vivainio@gmail.com>
423 430
424 431 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
425 432 Qt+IPython+Designer link in documentation.
426 433
427 434 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
428 435 correct Pdb object to %pydb.
429 436
430 437
431 438 2006-11-22 Walter Doerwald <walter@livinglogic.de>
432 439 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
433 440 generic xrepr(), otherwise the list implementation would kick in.
434 441
435 442 2006-11-21 Ville Vainio <vivainio@gmail.com>
436 443
437 444 * upgrade_dir.py: Now actually overwrites a nonmodified user file
438 445 with one from UserConfig.
439 446
440 447 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
441 448 it was missing which broke the sh profile.
442 449
443 450 * completer.py: file completer now uses explicit '/' instead
444 451 of os.path.join, expansion of 'foo' was broken on win32
445 452 if there was one directory with name 'foobar'.
446 453
447 454 * A bunch of patches from Kirill Smelkov:
448 455
449 456 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
450 457
451 458 * [patch 7/9] Implement %page -r (page in raw mode) -
452 459
453 460 * [patch 5/9] ScientificPython webpage has moved
454 461
455 462 * [patch 4/9] The manual mentions %ds, should be %dhist
456 463
457 464 * [patch 3/9] Kill old bits from %prun doc.
458 465
459 466 * [patch 1/9] Fix typos here and there.
460 467
461 468 2006-11-08 Ville Vainio <vivainio@gmail.com>
462 469
463 470 * completer.py (attr_matches): catch all exceptions raised
464 471 by eval of expr with dots.
465 472
466 473 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
467 474
468 475 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
469 476 input if it starts with whitespace. This allows you to paste
470 477 indented input from any editor without manually having to type in
471 478 the 'if 1:', which is convenient when working interactively.
472 479 Slightly modifed version of a patch by Bo Peng
473 480 <bpeng-AT-rice.edu>.
474 481
475 482 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
476 483
477 484 * IPython/irunner.py (main): modified irunner so it automatically
478 485 recognizes the right runner to use based on the extension (.py for
479 486 python, .ipy for ipython and .sage for sage).
480 487
481 488 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
482 489 visible in ipapi as ip.config(), to programatically control the
483 490 internal rc object. There's an accompanying %config magic for
484 491 interactive use, which has been enhanced to match the
485 492 funtionality in ipconfig.
486 493
487 494 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
488 495 so it's not just a toggle, it now takes an argument. Add support
489 496 for a customizable header when making system calls, as the new
490 497 system_header variable in the ipythonrc file.
491 498
492 499 2006-11-03 Walter Doerwald <walter@livinglogic.de>
493 500
494 501 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
495 502 generic functions (using Philip J. Eby's simplegeneric package).
496 503 This makes it possible to customize the display of third-party classes
497 504 without having to monkeypatch them. xiter() no longer supports a mode
498 505 argument and the XMode class has been removed. The same functionality can
499 506 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
500 507 One consequence of the switch to generic functions is that xrepr() and
501 508 xattrs() implementation must define the default value for the mode
502 509 argument themselves and xattrs() implementations must return real
503 510 descriptors.
504 511
505 512 * IPython/external: This new subpackage will contain all third-party
506 513 packages that are bundled with IPython. (The first one is simplegeneric).
507 514
508 515 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
509 516 directory which as been dropped in r1703.
510 517
511 518 * IPython/Extensions/ipipe.py (iless): Fixed.
512 519
513 520 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
514 521
515 522 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
516 523
517 524 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
518 525 handling in variable expansion so that shells and magics recognize
519 526 function local scopes correctly. Bug reported by Brian.
520 527
521 528 * scripts/ipython: remove the very first entry in sys.path which
522 529 Python auto-inserts for scripts, so that sys.path under IPython is
523 530 as similar as possible to that under plain Python.
524 531
525 532 * IPython/completer.py (IPCompleter.file_matches): Fix
526 533 tab-completion so that quotes are not closed unless the completion
527 534 is unambiguous. After a request by Stefan. Minor cleanups in
528 535 ipy_stock_completers.
529 536
530 537 2006-11-02 Ville Vainio <vivainio@gmail.com>
531 538
532 539 * ipy_stock_completers.py: Add %run and %cd completers.
533 540
534 541 * completer.py: Try running custom completer for both
535 542 "foo" and "%foo" if the command is just "foo". Ignore case
536 543 when filtering possible completions.
537 544
538 545 * UserConfig/ipy_user_conf.py: install stock completers as default
539 546
540 547 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
541 548 simplified readline history save / restore through a wrapper
542 549 function
543 550
544 551
545 552 2006-10-31 Ville Vainio <vivainio@gmail.com>
546 553
547 554 * strdispatch.py, completer.py, ipy_stock_completers.py:
548 555 Allow str_key ("command") in completer hooks. Implement
549 556 trivial completer for 'import' (stdlib modules only). Rename
550 557 ipy_linux_package_managers.py to ipy_stock_completers.py.
551 558 SVN completer.
552 559
553 560 * Extensions/ledit.py: %magic line editor for easily and
554 561 incrementally manipulating lists of strings. The magic command
555 562 name is %led.
556 563
557 564 2006-10-30 Ville Vainio <vivainio@gmail.com>
558 565
559 566 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
560 567 Bernsteins's patches for pydb integration.
561 568 http://bashdb.sourceforge.net/pydb/
562 569
563 570 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
564 571 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
565 572 custom completer hook to allow the users to implement their own
566 573 completers. See ipy_linux_package_managers.py for example. The
567 574 hook name is 'complete_command'.
568 575
569 576 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
570 577
571 578 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
572 579 Numeric leftovers.
573 580
574 581 * ipython.el (py-execute-region): apply Stefan's patch to fix
575 582 garbled results if the python shell hasn't been previously started.
576 583
577 584 * IPython/genutils.py (arg_split): moved to genutils, since it's a
578 585 pretty generic function and useful for other things.
579 586
580 587 * IPython/OInspect.py (getsource): Add customizable source
581 588 extractor. After a request/patch form W. Stein (SAGE).
582 589
583 590 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
584 591 window size to a more reasonable value from what pexpect does,
585 592 since their choice causes wrapping bugs with long input lines.
586 593
587 594 2006-10-28 Ville Vainio <vivainio@gmail.com>
588 595
589 596 * Magic.py (%run): Save and restore the readline history from
590 597 file around %run commands to prevent side effects from
591 598 %runned programs that might use readline (e.g. pydb).
592 599
593 600 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
594 601 invoking the pydb enhanced debugger.
595 602
596 603 2006-10-23 Walter Doerwald <walter@livinglogic.de>
597 604
598 605 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
599 606 call the base class method and propagate the return value to
600 607 ifile. This is now done by path itself.
601 608
602 609 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
603 610
604 611 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
605 612 api: set_crash_handler(), to expose the ability to change the
606 613 internal crash handler.
607 614
608 615 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
609 616 the various parameters of the crash handler so that apps using
610 617 IPython as their engine can customize crash handling. Ipmlemented
611 618 at the request of SAGE.
612 619
613 620 2006-10-14 Ville Vainio <vivainio@gmail.com>
614 621
615 622 * Magic.py, ipython.el: applied first "safe" part of Rocky
616 623 Bernstein's patch set for pydb integration.
617 624
618 625 * Magic.py (%unalias, %alias): %store'd aliases can now be
619 626 removed with '%unalias'. %alias w/o args now shows most
620 627 interesting (stored / manually defined) aliases last
621 628 where they catch the eye w/o scrolling.
622 629
623 630 * Magic.py (%rehashx), ext_rehashdir.py: files with
624 631 'py' extension are always considered executable, even
625 632 when not in PATHEXT environment variable.
626 633
627 634 2006-10-12 Ville Vainio <vivainio@gmail.com>
628 635
629 636 * jobctrl.py: Add new "jobctrl" extension for spawning background
630 637 processes with "&find /". 'import jobctrl' to try it out. Requires
631 638 'subprocess' module, standard in python 2.4+.
632 639
633 640 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
634 641 so if foo -> bar and bar -> baz, then foo -> baz.
635 642
636 643 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
637 644
638 645 * IPython/Magic.py (Magic.parse_options): add a new posix option
639 646 to allow parsing of input args in magics that doesn't strip quotes
640 647 (if posix=False). This also closes %timeit bug reported by
641 648 Stefan.
642 649
643 650 2006-10-03 Ville Vainio <vivainio@gmail.com>
644 651
645 652 * iplib.py (raw_input, interact): Return ValueError catching for
646 653 raw_input. Fixes infinite loop for sys.stdin.close() or
647 654 sys.stdout.close().
648 655
649 656 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
650 657
651 658 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
652 659 to help in handling doctests. irunner is now pretty useful for
653 660 running standalone scripts and simulate a full interactive session
654 661 in a format that can be then pasted as a doctest.
655 662
656 663 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
657 664 on top of the default (useless) ones. This also fixes the nasty
658 665 way in which 2.5's Quitter() exits (reverted [1785]).
659 666
660 667 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
661 668 2.5.
662 669
663 670 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
664 671 color scheme is updated as well when color scheme is changed
665 672 interactively.
666 673
667 674 2006-09-27 Ville Vainio <vivainio@gmail.com>
668 675
669 676 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
670 677 infinite loop and just exit. It's a hack, but will do for a while.
671 678
672 679 2006-08-25 Walter Doerwald <walter@livinglogic.de>
673 680
674 681 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
675 682 the constructor, this makes it possible to get a list of only directories
676 683 or only files.
677 684
678 685 2006-08-12 Ville Vainio <vivainio@gmail.com>
679 686
680 687 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
681 688 they broke unittest
682 689
683 690 2006-08-11 Ville Vainio <vivainio@gmail.com>
684 691
685 692 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
686 693 by resolving issue properly, i.e. by inheriting FakeModule
687 694 from types.ModuleType. Pickling ipython interactive data
688 695 should still work as usual (testing appreciated).
689 696
690 697 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
691 698
692 699 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
693 700 running under python 2.3 with code from 2.4 to fix a bug with
694 701 help(). Reported by the Debian maintainers, Norbert Tretkowski
695 702 <norbert-AT-tretkowski.de> and Alexandre Fayolle
696 703 <afayolle-AT-debian.org>.
697 704
698 705 2006-08-04 Walter Doerwald <walter@livinglogic.de>
699 706
700 707 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
701 708 (which was displaying "quit" twice).
702 709
703 710 2006-07-28 Walter Doerwald <walter@livinglogic.de>
704 711
705 712 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
706 713 the mode argument).
707 714
708 715 2006-07-27 Walter Doerwald <walter@livinglogic.de>
709 716
710 717 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
711 718 not running under IPython.
712 719
713 720 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
714 721 and make it iterable (iterating over the attribute itself). Add two new
715 722 magic strings for __xattrs__(): If the string starts with "-", the attribute
716 723 will not be displayed in ibrowse's detail view (but it can still be
717 724 iterated over). This makes it possible to add attributes that are large
718 725 lists or generator methods to the detail view. Replace magic attribute names
719 726 and _attrname() and _getattr() with "descriptors": For each type of magic
720 727 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
721 728 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
722 729 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
723 730 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
724 731 are still supported.
725 732
726 733 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
727 734 fails in ibrowse.fetch(), the exception object is added as the last item
728 735 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
729 736 a generator throws an exception midway through execution.
730 737
731 738 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
732 739 encoding into methods.
733 740
734 741 2006-07-26 Ville Vainio <vivainio@gmail.com>
735 742
736 743 * iplib.py: history now stores multiline input as single
737 744 history entries. Patch by Jorgen Cederlof.
738 745
739 746 2006-07-18 Walter Doerwald <walter@livinglogic.de>
740 747
741 748 * IPython/Extensions/ibrowse.py: Make cursor visible over
742 749 non existing attributes.
743 750
744 751 2006-07-14 Walter Doerwald <walter@livinglogic.de>
745 752
746 753 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
747 754 error output of the running command doesn't mess up the screen.
748 755
749 756 2006-07-13 Walter Doerwald <walter@livinglogic.de>
750 757
751 758 * IPython/Extensions/ipipe.py (isort): Make isort usable without
752 759 argument. This sorts the items themselves.
753 760
754 761 2006-07-12 Walter Doerwald <walter@livinglogic.de>
755 762
756 763 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
757 764 Compile expression strings into code objects. This should speed
758 765 up ifilter and friends somewhat.
759 766
760 767 2006-07-08 Ville Vainio <vivainio@gmail.com>
761 768
762 769 * Magic.py: %cpaste now strips > from the beginning of lines
763 770 to ease pasting quoted code from emails. Contributed by
764 771 Stefan van der Walt.
765 772
766 773 2006-06-29 Ville Vainio <vivainio@gmail.com>
767 774
768 775 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
769 776 mode, patch contributed by Darren Dale. NEEDS TESTING!
770 777
771 778 2006-06-28 Walter Doerwald <walter@livinglogic.de>
772 779
773 780 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
774 781 a blue background. Fix fetching new display rows when the browser
775 782 scrolls more than a screenful (e.g. by using the goto command).
776 783
777 784 2006-06-27 Ville Vainio <vivainio@gmail.com>
778 785
779 786 * Magic.py (_inspect, _ofind) Apply David Huard's
780 787 patch for displaying the correct docstring for 'property'
781 788 attributes.
782 789
783 790 2006-06-23 Walter Doerwald <walter@livinglogic.de>
784 791
785 792 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
786 793 commands into the methods implementing them.
787 794
788 795 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
789 796
790 797 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
791 798 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
792 799 autoindent support was authored by Jin Liu.
793 800
794 801 2006-06-22 Walter Doerwald <walter@livinglogic.de>
795 802
796 803 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
797 804 for keymaps with a custom class that simplifies handling.
798 805
799 806 2006-06-19 Walter Doerwald <walter@livinglogic.de>
800 807
801 808 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
802 809 resizing. This requires Python 2.5 to work.
803 810
804 811 2006-06-16 Walter Doerwald <walter@livinglogic.de>
805 812
806 813 * IPython/Extensions/ibrowse.py: Add two new commands to
807 814 ibrowse: "hideattr" (mapped to "h") hides the attribute under
808 815 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
809 816 attributes again. Remapped the help command to "?". Display
810 817 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
811 818 as keys for the "home" and "end" commands. Add three new commands
812 819 to the input mode for "find" and friends: "delend" (CTRL-K)
813 820 deletes to the end of line. "incsearchup" searches upwards in the
814 821 command history for an input that starts with the text before the cursor.
815 822 "incsearchdown" does the same downwards. Removed a bogus mapping of
816 823 the x key to "delete".
817 824
818 825 2006-06-15 Ville Vainio <vivainio@gmail.com>
819 826
820 827 * iplib.py, hooks.py: Added new generate_prompt hook that can be
821 828 used to create prompts dynamically, instead of the "old" way of
822 829 assigning "magic" strings to prompt_in1 and prompt_in2. The old
823 830 way still works (it's invoked by the default hook), of course.
824 831
825 832 * Prompts.py: added generate_output_prompt hook for altering output
826 833 prompt
827 834
828 835 * Release.py: Changed version string to 0.7.3.svn.
829 836
830 837 2006-06-15 Walter Doerwald <walter@livinglogic.de>
831 838
832 839 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
833 840 the call to fetch() always tries to fetch enough data for at least one
834 841 full screen. This makes it possible to simply call moveto(0,0,True) in
835 842 the constructor. Fix typos and removed the obsolete goto attribute.
836 843
837 844 2006-06-12 Ville Vainio <vivainio@gmail.com>
838 845
839 846 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
840 847 allowing $variable interpolation within multiline statements,
841 848 though so far only with "sh" profile for a testing period.
842 849 The patch also enables splitting long commands with \ but it
843 850 doesn't work properly yet.
844 851
845 852 2006-06-12 Walter Doerwald <walter@livinglogic.de>
846 853
847 854 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
848 855 input history and the position of the cursor in the input history for
849 856 the find, findbackwards and goto command.
850 857
851 858 2006-06-10 Walter Doerwald <walter@livinglogic.de>
852 859
853 860 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
854 861 implements the basic functionality of browser commands that require
855 862 input. Reimplement the goto, find and findbackwards commands as
856 863 subclasses of _CommandInput. Add an input history and keymaps to those
857 864 commands. Add "\r" as a keyboard shortcut for the enterdefault and
858 865 execute commands.
859 866
860 867 2006-06-07 Ville Vainio <vivainio@gmail.com>
861 868
862 869 * iplib.py: ipython mybatch.ipy exits ipython immediately after
863 870 running the batch files instead of leaving the session open.
864 871
865 872 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
866 873
867 874 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
868 875 the original fix was incomplete. Patch submitted by W. Maier.
869 876
870 877 2006-06-07 Ville Vainio <vivainio@gmail.com>
871 878
872 879 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
873 880 Confirmation prompts can be supressed by 'quiet' option.
874 881 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
875 882
876 883 2006-06-06 *** Released version 0.7.2
877 884
878 885 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
879 886
880 887 * IPython/Release.py (version): Made 0.7.2 final for release.
881 888 Repo tagged and release cut.
882 889
883 890 2006-06-05 Ville Vainio <vivainio@gmail.com>
884 891
885 892 * Magic.py (magic_rehashx): Honor no_alias list earlier in
886 893 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
887 894
888 895 * upgrade_dir.py: try import 'path' module a bit harder
889 896 (for %upgrade)
890 897
891 898 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
892 899
893 900 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
894 901 instead of looping 20 times.
895 902
896 903 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
897 904 correctly at initialization time. Bug reported by Krishna Mohan
898 905 Gundu <gkmohan-AT-gmail.com> on the user list.
899 906
900 907 * IPython/Release.py (version): Mark 0.7.2 version to start
901 908 testing for release on 06/06.
902 909
903 910 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
904 911
905 912 * scripts/irunner: thin script interface so users don't have to
906 913 find the module and call it as an executable, since modules rarely
907 914 live in people's PATH.
908 915
909 916 * IPython/irunner.py (InteractiveRunner.__init__): added
910 917 delaybeforesend attribute to control delays with newer versions of
911 918 pexpect. Thanks to detailed help from pexpect's author, Noah
912 919 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
913 920 correctly (it works in NoColor mode).
914 921
915 922 * IPython/iplib.py (handle_normal): fix nasty crash reported on
916 923 SAGE list, from improper log() calls.
917 924
918 925 2006-05-31 Ville Vainio <vivainio@gmail.com>
919 926
920 927 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
921 928 with args in parens to work correctly with dirs that have spaces.
922 929
923 930 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
924 931
925 932 * IPython/Logger.py (Logger.logstart): add option to log raw input
926 933 instead of the processed one. A -r flag was added to the
927 934 %logstart magic used for controlling logging.
928 935
929 936 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
930 937
931 938 * IPython/iplib.py (InteractiveShell.__init__): add check for the
932 939 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
933 940 recognize the option. After a bug report by Will Maier. This
934 941 closes #64 (will do it after confirmation from W. Maier).
935 942
936 943 * IPython/irunner.py: New module to run scripts as if manually
937 944 typed into an interactive environment, based on pexpect. After a
938 945 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
939 946 ipython-user list. Simple unittests in the tests/ directory.
940 947
941 948 * tools/release: add Will Maier, OpenBSD port maintainer, to
942 949 recepients list. We are now officially part of the OpenBSD ports:
943 950 http://www.openbsd.org/ports.html ! Many thanks to Will for the
944 951 work.
945 952
946 953 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
947 954
948 955 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
949 956 so that it doesn't break tkinter apps.
950 957
951 958 * IPython/iplib.py (_prefilter): fix bug where aliases would
952 959 shadow variables when autocall was fully off. Reported by SAGE
953 960 author William Stein.
954 961
955 962 * IPython/OInspect.py (Inspector.__init__): add a flag to control
956 963 at what detail level strings are computed when foo? is requested.
957 964 This allows users to ask for example that the string form of an
958 965 object is only computed when foo?? is called, or even never, by
959 966 setting the object_info_string_level >= 2 in the configuration
960 967 file. This new option has been added and documented. After a
961 968 request by SAGE to be able to control the printing of very large
962 969 objects more easily.
963 970
964 971 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
965 972
966 973 * IPython/ipmaker.py (make_IPython): remove the ipython call path
967 974 from sys.argv, to be 100% consistent with how Python itself works
968 975 (as seen for example with python -i file.py). After a bug report
969 976 by Jeffrey Collins.
970 977
971 978 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
972 979 nasty bug which was preventing custom namespaces with -pylab,
973 980 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
974 981 compatibility (long gone from mpl).
975 982
976 983 * IPython/ipapi.py (make_session): name change: create->make. We
977 984 use make in other places (ipmaker,...), it's shorter and easier to
978 985 type and say, etc. I'm trying to clean things before 0.7.2 so
979 986 that I can keep things stable wrt to ipapi in the chainsaw branch.
980 987
981 988 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
982 989 python-mode recognizes our debugger mode. Add support for
983 990 autoindent inside (X)emacs. After a patch sent in by Jin Liu
984 991 <m.liu.jin-AT-gmail.com> originally written by
985 992 doxgen-AT-newsmth.net (with minor modifications for xemacs
986 993 compatibility)
987 994
988 995 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
989 996 tracebacks when walking the stack so that the stack tracking system
990 997 in emacs' python-mode can identify the frames correctly.
991 998
992 999 * IPython/ipmaker.py (make_IPython): make the internal (and
993 1000 default config) autoedit_syntax value false by default. Too many
994 1001 users have complained to me (both on and off-list) about problems
995 1002 with this option being on by default, so I'm making it default to
996 1003 off. It can still be enabled by anyone via the usual mechanisms.
997 1004
998 1005 * IPython/completer.py (Completer.attr_matches): add support for
999 1006 PyCrust-style _getAttributeNames magic method. Patch contributed
1000 1007 by <mscott-AT-goldenspud.com>. Closes #50.
1001 1008
1002 1009 * IPython/iplib.py (InteractiveShell.__init__): remove the
1003 1010 deletion of exit/quit from __builtin__, which can break
1004 1011 third-party tools like the Zope debugging console. The
1005 1012 %exit/%quit magics remain. In general, it's probably a good idea
1006 1013 not to delete anything from __builtin__, since we never know what
1007 1014 that will break. In any case, python now (for 2.5) will support
1008 1015 'real' exit/quit, so this issue is moot. Closes #55.
1009 1016
1010 1017 * IPython/genutils.py (with_obj): rename the 'with' function to
1011 1018 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1012 1019 becomes a language keyword. Closes #53.
1013 1020
1014 1021 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1015 1022 __file__ attribute to this so it fools more things into thinking
1016 1023 it is a real module. Closes #59.
1017 1024
1018 1025 * IPython/Magic.py (magic_edit): add -n option to open the editor
1019 1026 at a specific line number. After a patch by Stefan van der Walt.
1020 1027
1021 1028 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1022 1029
1023 1030 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1024 1031 reason the file could not be opened. After automatic crash
1025 1032 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1026 1033 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1027 1034 (_should_recompile): Don't fire editor if using %bg, since there
1028 1035 is no file in the first place. From the same report as above.
1029 1036 (raw_input): protect against faulty third-party prefilters. After
1030 1037 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1031 1038 while running under SAGE.
1032 1039
1033 1040 2006-05-23 Ville Vainio <vivainio@gmail.com>
1034 1041
1035 1042 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1036 1043 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1037 1044 now returns None (again), unless dummy is specifically allowed by
1038 1045 ipapi.get(allow_dummy=True).
1039 1046
1040 1047 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1041 1048
1042 1049 * IPython: remove all 2.2-compatibility objects and hacks from
1043 1050 everywhere, since we only support 2.3 at this point. Docs
1044 1051 updated.
1045 1052
1046 1053 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1047 1054 Anything requiring extra validation can be turned into a Python
1048 1055 property in the future. I used a property for the db one b/c
1049 1056 there was a nasty circularity problem with the initialization
1050 1057 order, which right now I don't have time to clean up.
1051 1058
1052 1059 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1053 1060 another locking bug reported by Jorgen. I'm not 100% sure though,
1054 1061 so more testing is needed...
1055 1062
1056 1063 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1057 1064
1058 1065 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1059 1066 local variables from any routine in user code (typically executed
1060 1067 with %run) directly into the interactive namespace. Very useful
1061 1068 when doing complex debugging.
1062 1069 (IPythonNotRunning): Changed the default None object to a dummy
1063 1070 whose attributes can be queried as well as called without
1064 1071 exploding, to ease writing code which works transparently both in
1065 1072 and out of ipython and uses some of this API.
1066 1073
1067 1074 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1068 1075
1069 1076 * IPython/hooks.py (result_display): Fix the fact that our display
1070 1077 hook was using str() instead of repr(), as the default python
1071 1078 console does. This had gone unnoticed b/c it only happened if
1072 1079 %Pprint was off, but the inconsistency was there.
1073 1080
1074 1081 2006-05-15 Ville Vainio <vivainio@gmail.com>
1075 1082
1076 1083 * Oinspect.py: Only show docstring for nonexisting/binary files
1077 1084 when doing object??, closing ticket #62
1078 1085
1079 1086 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1080 1087
1081 1088 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1082 1089 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1083 1090 was being released in a routine which hadn't checked if it had
1084 1091 been the one to acquire it.
1085 1092
1086 1093 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1087 1094
1088 1095 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1089 1096
1090 1097 2006-04-11 Ville Vainio <vivainio@gmail.com>
1091 1098
1092 1099 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1093 1100 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1094 1101 prefilters, allowing stuff like magics and aliases in the file.
1095 1102
1096 1103 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1097 1104 added. Supported now are "%clear in" and "%clear out" (clear input and
1098 1105 output history, respectively). Also fixed CachedOutput.flush to
1099 1106 properly flush the output cache.
1100 1107
1101 1108 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1102 1109 half-success (and fail explicitly).
1103 1110
1104 1111 2006-03-28 Ville Vainio <vivainio@gmail.com>
1105 1112
1106 1113 * iplib.py: Fix quoting of aliases so that only argless ones
1107 1114 are quoted
1108 1115
1109 1116 2006-03-28 Ville Vainio <vivainio@gmail.com>
1110 1117
1111 1118 * iplib.py: Quote aliases with spaces in the name.
1112 1119 "c:\program files\blah\bin" is now legal alias target.
1113 1120
1114 1121 * ext_rehashdir.py: Space no longer allowed as arg
1115 1122 separator, since space is legal in path names.
1116 1123
1117 1124 2006-03-16 Ville Vainio <vivainio@gmail.com>
1118 1125
1119 1126 * upgrade_dir.py: Take path.py from Extensions, correcting
1120 1127 %upgrade magic
1121 1128
1122 1129 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1123 1130
1124 1131 * hooks.py: Only enclose editor binary in quotes if legal and
1125 1132 necessary (space in the name, and is an existing file). Fixes a bug
1126 1133 reported by Zachary Pincus.
1127 1134
1128 1135 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1129 1136
1130 1137 * Manual: thanks to a tip on proper color handling for Emacs, by
1131 1138 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1132 1139
1133 1140 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1134 1141 by applying the provided patch. Thanks to Liu Jin
1135 1142 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1136 1143 XEmacs/Linux, I'm trusting the submitter that it actually helps
1137 1144 under win32/GNU Emacs. Will revisit if any problems are reported.
1138 1145
1139 1146 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1140 1147
1141 1148 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1142 1149 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1143 1150
1144 1151 2006-03-12 Ville Vainio <vivainio@gmail.com>
1145 1152
1146 1153 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1147 1154 Torsten Marek.
1148 1155
1149 1156 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1150 1157
1151 1158 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1152 1159 line ranges works again.
1153 1160
1154 1161 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1155 1162
1156 1163 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1157 1164 and friends, after a discussion with Zach Pincus on ipython-user.
1158 1165 I'm not 100% sure, but after thinking about it quite a bit, it may
1159 1166 be OK. Testing with the multithreaded shells didn't reveal any
1160 1167 problems, but let's keep an eye out.
1161 1168
1162 1169 In the process, I fixed a few things which were calling
1163 1170 self.InteractiveTB() directly (like safe_execfile), which is a
1164 1171 mistake: ALL exception reporting should be done by calling
1165 1172 self.showtraceback(), which handles state and tab-completion and
1166 1173 more.
1167 1174
1168 1175 2006-03-01 Ville Vainio <vivainio@gmail.com>
1169 1176
1170 1177 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1171 1178 To use, do "from ipipe import *".
1172 1179
1173 1180 2006-02-24 Ville Vainio <vivainio@gmail.com>
1174 1181
1175 1182 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1176 1183 "cleanly" and safely than the older upgrade mechanism.
1177 1184
1178 1185 2006-02-21 Ville Vainio <vivainio@gmail.com>
1179 1186
1180 1187 * Magic.py: %save works again.
1181 1188
1182 1189 2006-02-15 Ville Vainio <vivainio@gmail.com>
1183 1190
1184 1191 * Magic.py: %Pprint works again
1185 1192
1186 1193 * Extensions/ipy_sane_defaults.py: Provide everything provided
1187 1194 in default ipythonrc, to make it possible to have a completely empty
1188 1195 ipythonrc (and thus completely rc-file free configuration)
1189 1196
1190 1197 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1191 1198
1192 1199 * IPython/hooks.py (editor): quote the call to the editor command,
1193 1200 to allow commands with spaces in them. Problem noted by watching
1194 1201 Ian Oswald's video about textpad under win32 at
1195 1202 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1196 1203
1197 1204 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1198 1205 describing magics (we haven't used @ for a loong time).
1199 1206
1200 1207 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1201 1208 contributed by marienz to close
1202 1209 http://www.scipy.net/roundup/ipython/issue53.
1203 1210
1204 1211 2006-02-10 Ville Vainio <vivainio@gmail.com>
1205 1212
1206 1213 * genutils.py: getoutput now works in win32 too
1207 1214
1208 1215 * completer.py: alias and magic completion only invoked
1209 1216 at the first "item" in the line, to avoid "cd %store"
1210 1217 nonsense.
1211 1218
1212 1219 2006-02-09 Ville Vainio <vivainio@gmail.com>
1213 1220
1214 1221 * test/*: Added a unit testing framework (finally).
1215 1222 '%run runtests.py' to run test_*.
1216 1223
1217 1224 * ipapi.py: Exposed runlines and set_custom_exc
1218 1225
1219 1226 2006-02-07 Ville Vainio <vivainio@gmail.com>
1220 1227
1221 1228 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1222 1229 instead use "f(1 2)" as before.
1223 1230
1224 1231 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1225 1232
1226 1233 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1227 1234 facilities, for demos processed by the IPython input filter
1228 1235 (IPythonDemo), and for running a script one-line-at-a-time as a
1229 1236 demo, both for pure Python (LineDemo) and for IPython-processed
1230 1237 input (IPythonLineDemo). After a request by Dave Kohel, from the
1231 1238 SAGE team.
1232 1239 (Demo.edit): added an edit() method to the demo objects, to edit
1233 1240 the in-memory copy of the last executed block.
1234 1241
1235 1242 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1236 1243 processing to %edit, %macro and %save. These commands can now be
1237 1244 invoked on the unprocessed input as it was typed by the user
1238 1245 (without any prefilters applied). After requests by the SAGE team
1239 1246 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1240 1247
1241 1248 2006-02-01 Ville Vainio <vivainio@gmail.com>
1242 1249
1243 1250 * setup.py, eggsetup.py: easy_install ipython==dev works
1244 1251 correctly now (on Linux)
1245 1252
1246 1253 * ipy_user_conf,ipmaker: user config changes, removed spurious
1247 1254 warnings
1248 1255
1249 1256 * iplib: if rc.banner is string, use it as is.
1250 1257
1251 1258 * Magic: %pycat accepts a string argument and pages it's contents.
1252 1259
1253 1260
1254 1261 2006-01-30 Ville Vainio <vivainio@gmail.com>
1255 1262
1256 1263 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1257 1264 Now %store and bookmarks work through PickleShare, meaning that
1258 1265 concurrent access is possible and all ipython sessions see the
1259 1266 same database situation all the time, instead of snapshot of
1260 1267 the situation when the session was started. Hence, %bookmark
1261 1268 results are immediately accessible from othes sessions. The database
1262 1269 is also available for use by user extensions. See:
1263 1270 http://www.python.org/pypi/pickleshare
1264 1271
1265 1272 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1266 1273
1267 1274 * aliases can now be %store'd
1268 1275
1269 1276 * path.py moved to Extensions so that pickleshare does not need
1270 1277 IPython-specific import. Extensions added to pythonpath right
1271 1278 at __init__.
1272 1279
1273 1280 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1274 1281 called with _ip.system and the pre-transformed command string.
1275 1282
1276 1283 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1277 1284
1278 1285 * IPython/iplib.py (interact): Fix that we were not catching
1279 1286 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1280 1287 logic here had to change, but it's fixed now.
1281 1288
1282 1289 2006-01-29 Ville Vainio <vivainio@gmail.com>
1283 1290
1284 1291 * iplib.py: Try to import pyreadline on Windows.
1285 1292
1286 1293 2006-01-27 Ville Vainio <vivainio@gmail.com>
1287 1294
1288 1295 * iplib.py: Expose ipapi as _ip in builtin namespace.
1289 1296 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1290 1297 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1291 1298 syntax now produce _ip.* variant of the commands.
1292 1299
1293 1300 * "_ip.options().autoedit_syntax = 2" automatically throws
1294 1301 user to editor for syntax error correction without prompting.
1295 1302
1296 1303 2006-01-27 Ville Vainio <vivainio@gmail.com>
1297 1304
1298 1305 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1299 1306 'ipython' at argv[0]) executed through command line.
1300 1307 NOTE: this DEPRECATES calling ipython with multiple scripts
1301 1308 ("ipython a.py b.py c.py")
1302 1309
1303 1310 * iplib.py, hooks.py: Added configurable input prefilter,
1304 1311 named 'input_prefilter'. See ext_rescapture.py for example
1305 1312 usage.
1306 1313
1307 1314 * ext_rescapture.py, Magic.py: Better system command output capture
1308 1315 through 'var = !ls' (deprecates user-visible %sc). Same notation
1309 1316 applies for magics, 'var = %alias' assigns alias list to var.
1310 1317
1311 1318 * ipapi.py: added meta() for accessing extension-usable data store.
1312 1319
1313 1320 * iplib.py: added InteractiveShell.getapi(). New magics should be
1314 1321 written doing self.getapi() instead of using the shell directly.
1315 1322
1316 1323 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1317 1324 %store foo >> ~/myfoo.txt to store variables to files (in clean
1318 1325 textual form, not a restorable pickle).
1319 1326
1320 1327 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1321 1328
1322 1329 * usage.py, Magic.py: added %quickref
1323 1330
1324 1331 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1325 1332
1326 1333 * GetoptErrors when invoking magics etc. with wrong args
1327 1334 are now more helpful:
1328 1335 GetoptError: option -l not recognized (allowed: "qb" )
1329 1336
1330 1337 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1331 1338
1332 1339 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1333 1340 computationally intensive blocks don't appear to stall the demo.
1334 1341
1335 1342 2006-01-24 Ville Vainio <vivainio@gmail.com>
1336 1343
1337 1344 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1338 1345 value to manipulate resulting history entry.
1339 1346
1340 1347 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1341 1348 to instance methods of IPApi class, to make extending an embedded
1342 1349 IPython feasible. See ext_rehashdir.py for example usage.
1343 1350
1344 1351 * Merged 1071-1076 from branches/0.7.1
1345 1352
1346 1353
1347 1354 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1348 1355
1349 1356 * tools/release (daystamp): Fix build tools to use the new
1350 1357 eggsetup.py script to build lightweight eggs.
1351 1358
1352 1359 * Applied changesets 1062 and 1064 before 0.7.1 release.
1353 1360
1354 1361 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1355 1362 see the raw input history (without conversions like %ls ->
1356 1363 ipmagic("ls")). After a request from W. Stein, SAGE
1357 1364 (http://modular.ucsd.edu/sage) developer. This information is
1358 1365 stored in the input_hist_raw attribute of the IPython instance, so
1359 1366 developers can access it if needed (it's an InputList instance).
1360 1367
1361 1368 * Versionstring = 0.7.2.svn
1362 1369
1363 1370 * eggsetup.py: A separate script for constructing eggs, creates
1364 1371 proper launch scripts even on Windows (an .exe file in
1365 1372 \python24\scripts).
1366 1373
1367 1374 * ipapi.py: launch_new_instance, launch entry point needed for the
1368 1375 egg.
1369 1376
1370 1377 2006-01-23 Ville Vainio <vivainio@gmail.com>
1371 1378
1372 1379 * Added %cpaste magic for pasting python code
1373 1380
1374 1381 2006-01-22 Ville Vainio <vivainio@gmail.com>
1375 1382
1376 1383 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1377 1384
1378 1385 * Versionstring = 0.7.2.svn
1379 1386
1380 1387 * eggsetup.py: A separate script for constructing eggs, creates
1381 1388 proper launch scripts even on Windows (an .exe file in
1382 1389 \python24\scripts).
1383 1390
1384 1391 * ipapi.py: launch_new_instance, launch entry point needed for the
1385 1392 egg.
1386 1393
1387 1394 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1388 1395
1389 1396 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1390 1397 %pfile foo would print the file for foo even if it was a binary.
1391 1398 Now, extensions '.so' and '.dll' are skipped.
1392 1399
1393 1400 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1394 1401 bug, where macros would fail in all threaded modes. I'm not 100%
1395 1402 sure, so I'm going to put out an rc instead of making a release
1396 1403 today, and wait for feedback for at least a few days.
1397 1404
1398 1405 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1399 1406 it...) the handling of pasting external code with autoindent on.
1400 1407 To get out of a multiline input, the rule will appear for most
1401 1408 users unchanged: two blank lines or change the indent level
1402 1409 proposed by IPython. But there is a twist now: you can
1403 1410 add/subtract only *one or two spaces*. If you add/subtract three
1404 1411 or more (unless you completely delete the line), IPython will
1405 1412 accept that line, and you'll need to enter a second one of pure
1406 1413 whitespace. I know it sounds complicated, but I can't find a
1407 1414 different solution that covers all the cases, with the right
1408 1415 heuristics. Hopefully in actual use, nobody will really notice
1409 1416 all these strange rules and things will 'just work'.
1410 1417
1411 1418 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1412 1419
1413 1420 * IPython/iplib.py (interact): catch exceptions which can be
1414 1421 triggered asynchronously by signal handlers. Thanks to an
1415 1422 automatic crash report, submitted by Colin Kingsley
1416 1423 <tercel-AT-gentoo.org>.
1417 1424
1418 1425 2006-01-20 Ville Vainio <vivainio@gmail.com>
1419 1426
1420 1427 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1421 1428 (%rehashdir, very useful, try it out) of how to extend ipython
1422 1429 with new magics. Also added Extensions dir to pythonpath to make
1423 1430 importing extensions easy.
1424 1431
1425 1432 * %store now complains when trying to store interactively declared
1426 1433 classes / instances of those classes.
1427 1434
1428 1435 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1429 1436 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1430 1437 if they exist, and ipy_user_conf.py with some defaults is created for
1431 1438 the user.
1432 1439
1433 1440 * Startup rehashing done by the config file, not InterpreterExec.
1434 1441 This means system commands are available even without selecting the
1435 1442 pysh profile. It's the sensible default after all.
1436 1443
1437 1444 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1438 1445
1439 1446 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1440 1447 multiline code with autoindent on working. But I am really not
1441 1448 sure, so this needs more testing. Will commit a debug-enabled
1442 1449 version for now, while I test it some more, so that Ville and
1443 1450 others may also catch any problems. Also made
1444 1451 self.indent_current_str() a method, to ensure that there's no
1445 1452 chance of the indent space count and the corresponding string
1446 1453 falling out of sync. All code needing the string should just call
1447 1454 the method.
1448 1455
1449 1456 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1450 1457
1451 1458 * IPython/Magic.py (magic_edit): fix check for when users don't
1452 1459 save their output files, the try/except was in the wrong section.
1453 1460
1454 1461 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1455 1462
1456 1463 * IPython/Magic.py (magic_run): fix __file__ global missing from
1457 1464 script's namespace when executed via %run. After a report by
1458 1465 Vivian.
1459 1466
1460 1467 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1461 1468 when using python 2.4. The parent constructor changed in 2.4, and
1462 1469 we need to track it directly (we can't call it, as it messes up
1463 1470 readline and tab-completion inside our pdb would stop working).
1464 1471 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1465 1472
1466 1473 2006-01-16 Ville Vainio <vivainio@gmail.com>
1467 1474
1468 1475 * Ipython/magic.py: Reverted back to old %edit functionality
1469 1476 that returns file contents on exit.
1470 1477
1471 1478 * IPython/path.py: Added Jason Orendorff's "path" module to
1472 1479 IPython tree, http://www.jorendorff.com/articles/python/path/.
1473 1480 You can get path objects conveniently through %sc, and !!, e.g.:
1474 1481 sc files=ls
1475 1482 for p in files.paths: # or files.p
1476 1483 print p,p.mtime
1477 1484
1478 1485 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1479 1486 now work again without considering the exclusion regexp -
1480 1487 hence, things like ',foo my/path' turn to 'foo("my/path")'
1481 1488 instead of syntax error.
1482 1489
1483 1490
1484 1491 2006-01-14 Ville Vainio <vivainio@gmail.com>
1485 1492
1486 1493 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1487 1494 ipapi decorators for python 2.4 users, options() provides access to rc
1488 1495 data.
1489 1496
1490 1497 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1491 1498 as path separators (even on Linux ;-). Space character after
1492 1499 backslash (as yielded by tab completer) is still space;
1493 1500 "%cd long\ name" works as expected.
1494 1501
1495 1502 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1496 1503 as "chain of command", with priority. API stays the same,
1497 1504 TryNext exception raised by a hook function signals that
1498 1505 current hook failed and next hook should try handling it, as
1499 1506 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1500 1507 requested configurable display hook, which is now implemented.
1501 1508
1502 1509 2006-01-13 Ville Vainio <vivainio@gmail.com>
1503 1510
1504 1511 * IPython/platutils*.py: platform specific utility functions,
1505 1512 so far only set_term_title is implemented (change terminal
1506 1513 label in windowing systems). %cd now changes the title to
1507 1514 current dir.
1508 1515
1509 1516 * IPython/Release.py: Added myself to "authors" list,
1510 1517 had to create new files.
1511 1518
1512 1519 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1513 1520 shell escape; not a known bug but had potential to be one in the
1514 1521 future.
1515 1522
1516 1523 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1517 1524 extension API for IPython! See the module for usage example. Fix
1518 1525 OInspect for docstring-less magic functions.
1519 1526
1520 1527
1521 1528 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1522 1529
1523 1530 * IPython/iplib.py (raw_input): temporarily deactivate all
1524 1531 attempts at allowing pasting of code with autoindent on. It
1525 1532 introduced bugs (reported by Prabhu) and I can't seem to find a
1526 1533 robust combination which works in all cases. Will have to revisit
1527 1534 later.
1528 1535
1529 1536 * IPython/genutils.py: remove isspace() function. We've dropped
1530 1537 2.2 compatibility, so it's OK to use the string method.
1531 1538
1532 1539 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1533 1540
1534 1541 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1535 1542 matching what NOT to autocall on, to include all python binary
1536 1543 operators (including things like 'and', 'or', 'is' and 'in').
1537 1544 Prompted by a bug report on 'foo & bar', but I realized we had
1538 1545 many more potential bug cases with other operators. The regexp is
1539 1546 self.re_exclude_auto, it's fairly commented.
1540 1547
1541 1548 2006-01-12 Ville Vainio <vivainio@gmail.com>
1542 1549
1543 1550 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1544 1551 Prettified and hardened string/backslash quoting with ipsystem(),
1545 1552 ipalias() and ipmagic(). Now even \ characters are passed to
1546 1553 %magics, !shell escapes and aliases exactly as they are in the
1547 1554 ipython command line. Should improve backslash experience,
1548 1555 particularly in Windows (path delimiter for some commands that
1549 1556 won't understand '/'), but Unix benefits as well (regexps). %cd
1550 1557 magic still doesn't support backslash path delimiters, though. Also
1551 1558 deleted all pretense of supporting multiline command strings in
1552 1559 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1553 1560
1554 1561 * doc/build_doc_instructions.txt added. Documentation on how to
1555 1562 use doc/update_manual.py, added yesterday. Both files contributed
1556 1563 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1557 1564 doc/*.sh for deprecation at a later date.
1558 1565
1559 1566 * /ipython.py Added ipython.py to root directory for
1560 1567 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1561 1568 ipython.py) and development convenience (no need to keep doing
1562 1569 "setup.py install" between changes).
1563 1570
1564 1571 * Made ! and !! shell escapes work (again) in multiline expressions:
1565 1572 if 1:
1566 1573 !ls
1567 1574 !!ls
1568 1575
1569 1576 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1570 1577
1571 1578 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1572 1579 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1573 1580 module in case-insensitive installation. Was causing crashes
1574 1581 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1575 1582
1576 1583 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1577 1584 <marienz-AT-gentoo.org>, closes
1578 1585 http://www.scipy.net/roundup/ipython/issue51.
1579 1586
1580 1587 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1581 1588
1582 1589 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1583 1590 problem of excessive CPU usage under *nix and keyboard lag under
1584 1591 win32.
1585 1592
1586 1593 2006-01-10 *** Released version 0.7.0
1587 1594
1588 1595 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1589 1596
1590 1597 * IPython/Release.py (revision): tag version number to 0.7.0,
1591 1598 ready for release.
1592 1599
1593 1600 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1594 1601 it informs the user of the name of the temp. file used. This can
1595 1602 help if you decide later to reuse that same file, so you know
1596 1603 where to copy the info from.
1597 1604
1598 1605 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1599 1606
1600 1607 * setup_bdist_egg.py: little script to build an egg. Added
1601 1608 support in the release tools as well.
1602 1609
1603 1610 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1604 1611
1605 1612 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1606 1613 version selection (new -wxversion command line and ipythonrc
1607 1614 parameter). Patch contributed by Arnd Baecker
1608 1615 <arnd.baecker-AT-web.de>.
1609 1616
1610 1617 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1611 1618 embedded instances, for variables defined at the interactive
1612 1619 prompt of the embedded ipython. Reported by Arnd.
1613 1620
1614 1621 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1615 1622 it can be used as a (stateful) toggle, or with a direct parameter.
1616 1623
1617 1624 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1618 1625 could be triggered in certain cases and cause the traceback
1619 1626 printer not to work.
1620 1627
1621 1628 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1622 1629
1623 1630 * IPython/iplib.py (_should_recompile): Small fix, closes
1624 1631 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1625 1632
1626 1633 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1627 1634
1628 1635 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1629 1636 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1630 1637 Moad for help with tracking it down.
1631 1638
1632 1639 * IPython/iplib.py (handle_auto): fix autocall handling for
1633 1640 objects which support BOTH __getitem__ and __call__ (so that f [x]
1634 1641 is left alone, instead of becoming f([x]) automatically).
1635 1642
1636 1643 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1637 1644 Ville's patch.
1638 1645
1639 1646 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1640 1647
1641 1648 * IPython/iplib.py (handle_auto): changed autocall semantics to
1642 1649 include 'smart' mode, where the autocall transformation is NOT
1643 1650 applied if there are no arguments on the line. This allows you to
1644 1651 just type 'foo' if foo is a callable to see its internal form,
1645 1652 instead of having it called with no arguments (typically a
1646 1653 mistake). The old 'full' autocall still exists: for that, you
1647 1654 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1648 1655
1649 1656 * IPython/completer.py (Completer.attr_matches): add
1650 1657 tab-completion support for Enthoughts' traits. After a report by
1651 1658 Arnd and a patch by Prabhu.
1652 1659
1653 1660 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1654 1661
1655 1662 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1656 1663 Schmolck's patch to fix inspect.getinnerframes().
1657 1664
1658 1665 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1659 1666 for embedded instances, regarding handling of namespaces and items
1660 1667 added to the __builtin__ one. Multiple embedded instances and
1661 1668 recursive embeddings should work better now (though I'm not sure
1662 1669 I've got all the corner cases fixed, that code is a bit of a brain
1663 1670 twister).
1664 1671
1665 1672 * IPython/Magic.py (magic_edit): added support to edit in-memory
1666 1673 macros (automatically creates the necessary temp files). %edit
1667 1674 also doesn't return the file contents anymore, it's just noise.
1668 1675
1669 1676 * IPython/completer.py (Completer.attr_matches): revert change to
1670 1677 complete only on attributes listed in __all__. I realized it
1671 1678 cripples the tab-completion system as a tool for exploring the
1672 1679 internals of unknown libraries (it renders any non-__all__
1673 1680 attribute off-limits). I got bit by this when trying to see
1674 1681 something inside the dis module.
1675 1682
1676 1683 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1677 1684
1678 1685 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1679 1686 namespace for users and extension writers to hold data in. This
1680 1687 follows the discussion in
1681 1688 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1682 1689
1683 1690 * IPython/completer.py (IPCompleter.complete): small patch to help
1684 1691 tab-completion under Emacs, after a suggestion by John Barnard
1685 1692 <barnarj-AT-ccf.org>.
1686 1693
1687 1694 * IPython/Magic.py (Magic.extract_input_slices): added support for
1688 1695 the slice notation in magics to use N-M to represent numbers N...M
1689 1696 (closed endpoints). This is used by %macro and %save.
1690 1697
1691 1698 * IPython/completer.py (Completer.attr_matches): for modules which
1692 1699 define __all__, complete only on those. After a patch by Jeffrey
1693 1700 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1694 1701 speed up this routine.
1695 1702
1696 1703 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1697 1704 don't know if this is the end of it, but the behavior now is
1698 1705 certainly much more correct. Note that coupled with macros,
1699 1706 slightly surprising (at first) behavior may occur: a macro will in
1700 1707 general expand to multiple lines of input, so upon exiting, the
1701 1708 in/out counters will both be bumped by the corresponding amount
1702 1709 (as if the macro's contents had been typed interactively). Typing
1703 1710 %hist will reveal the intermediate (silently processed) lines.
1704 1711
1705 1712 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1706 1713 pickle to fail (%run was overwriting __main__ and not restoring
1707 1714 it, but pickle relies on __main__ to operate).
1708 1715
1709 1716 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1710 1717 using properties, but forgot to make the main InteractiveShell
1711 1718 class a new-style class. Properties fail silently, and
1712 1719 mysteriously, with old-style class (getters work, but
1713 1720 setters don't do anything).
1714 1721
1715 1722 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1716 1723
1717 1724 * IPython/Magic.py (magic_history): fix history reporting bug (I
1718 1725 know some nasties are still there, I just can't seem to find a
1719 1726 reproducible test case to track them down; the input history is
1720 1727 falling out of sync...)
1721 1728
1722 1729 * IPython/iplib.py (handle_shell_escape): fix bug where both
1723 1730 aliases and system accesses where broken for indented code (such
1724 1731 as loops).
1725 1732
1726 1733 * IPython/genutils.py (shell): fix small but critical bug for
1727 1734 win32 system access.
1728 1735
1729 1736 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1730 1737
1731 1738 * IPython/iplib.py (showtraceback): remove use of the
1732 1739 sys.last_{type/value/traceback} structures, which are non
1733 1740 thread-safe.
1734 1741 (_prefilter): change control flow to ensure that we NEVER
1735 1742 introspect objects when autocall is off. This will guarantee that
1736 1743 having an input line of the form 'x.y', where access to attribute
1737 1744 'y' has side effects, doesn't trigger the side effect TWICE. It
1738 1745 is important to note that, with autocall on, these side effects
1739 1746 can still happen.
1740 1747 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1741 1748 trio. IPython offers these three kinds of special calls which are
1742 1749 not python code, and it's a good thing to have their call method
1743 1750 be accessible as pure python functions (not just special syntax at
1744 1751 the command line). It gives us a better internal implementation
1745 1752 structure, as well as exposing these for user scripting more
1746 1753 cleanly.
1747 1754
1748 1755 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1749 1756 file. Now that they'll be more likely to be used with the
1750 1757 persistance system (%store), I want to make sure their module path
1751 1758 doesn't change in the future, so that we don't break things for
1752 1759 users' persisted data.
1753 1760
1754 1761 * IPython/iplib.py (autoindent_update): move indentation
1755 1762 management into the _text_ processing loop, not the keyboard
1756 1763 interactive one. This is necessary to correctly process non-typed
1757 1764 multiline input (such as macros).
1758 1765
1759 1766 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1760 1767 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1761 1768 which was producing problems in the resulting manual.
1762 1769 (magic_whos): improve reporting of instances (show their class,
1763 1770 instead of simply printing 'instance' which isn't terribly
1764 1771 informative).
1765 1772
1766 1773 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1767 1774 (minor mods) to support network shares under win32.
1768 1775
1769 1776 * IPython/winconsole.py (get_console_size): add new winconsole
1770 1777 module and fixes to page_dumb() to improve its behavior under
1771 1778 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1772 1779
1773 1780 * IPython/Magic.py (Macro): simplified Macro class to just
1774 1781 subclass list. We've had only 2.2 compatibility for a very long
1775 1782 time, yet I was still avoiding subclassing the builtin types. No
1776 1783 more (I'm also starting to use properties, though I won't shift to
1777 1784 2.3-specific features quite yet).
1778 1785 (magic_store): added Ville's patch for lightweight variable
1779 1786 persistence, after a request on the user list by Matt Wilkie
1780 1787 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1781 1788 details.
1782 1789
1783 1790 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1784 1791 changed the default logfile name from 'ipython.log' to
1785 1792 'ipython_log.py'. These logs are real python files, and now that
1786 1793 we have much better multiline support, people are more likely to
1787 1794 want to use them as such. Might as well name them correctly.
1788 1795
1789 1796 * IPython/Magic.py: substantial cleanup. While we can't stop
1790 1797 using magics as mixins, due to the existing customizations 'out
1791 1798 there' which rely on the mixin naming conventions, at least I
1792 1799 cleaned out all cross-class name usage. So once we are OK with
1793 1800 breaking compatibility, the two systems can be separated.
1794 1801
1795 1802 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1796 1803 anymore, and the class is a fair bit less hideous as well. New
1797 1804 features were also introduced: timestamping of input, and logging
1798 1805 of output results. These are user-visible with the -t and -o
1799 1806 options to %logstart. Closes
1800 1807 http://www.scipy.net/roundup/ipython/issue11 and a request by
1801 1808 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1802 1809
1803 1810 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1804 1811
1805 1812 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1806 1813 better handle backslashes in paths. See the thread 'More Windows
1807 1814 questions part 2 - \/ characters revisited' on the iypthon user
1808 1815 list:
1809 1816 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1810 1817
1811 1818 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1812 1819
1813 1820 (InteractiveShell.__init__): change threaded shells to not use the
1814 1821 ipython crash handler. This was causing more problems than not,
1815 1822 as exceptions in the main thread (GUI code, typically) would
1816 1823 always show up as a 'crash', when they really weren't.
1817 1824
1818 1825 The colors and exception mode commands (%colors/%xmode) have been
1819 1826 synchronized to also take this into account, so users can get
1820 1827 verbose exceptions for their threaded code as well. I also added
1821 1828 support for activating pdb inside this exception handler as well,
1822 1829 so now GUI authors can use IPython's enhanced pdb at runtime.
1823 1830
1824 1831 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1825 1832 true by default, and add it to the shipped ipythonrc file. Since
1826 1833 this asks the user before proceeding, I think it's OK to make it
1827 1834 true by default.
1828 1835
1829 1836 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1830 1837 of the previous special-casing of input in the eval loop. I think
1831 1838 this is cleaner, as they really are commands and shouldn't have
1832 1839 a special role in the middle of the core code.
1833 1840
1834 1841 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1835 1842
1836 1843 * IPython/iplib.py (edit_syntax_error): added support for
1837 1844 automatically reopening the editor if the file had a syntax error
1838 1845 in it. Thanks to scottt who provided the patch at:
1839 1846 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1840 1847 version committed).
1841 1848
1842 1849 * IPython/iplib.py (handle_normal): add suport for multi-line
1843 1850 input with emtpy lines. This fixes
1844 1851 http://www.scipy.net/roundup/ipython/issue43 and a similar
1845 1852 discussion on the user list.
1846 1853
1847 1854 WARNING: a behavior change is necessarily introduced to support
1848 1855 blank lines: now a single blank line with whitespace does NOT
1849 1856 break the input loop, which means that when autoindent is on, by
1850 1857 default hitting return on the next (indented) line does NOT exit.
1851 1858
1852 1859 Instead, to exit a multiline input you can either have:
1853 1860
1854 1861 - TWO whitespace lines (just hit return again), or
1855 1862 - a single whitespace line of a different length than provided
1856 1863 by the autoindent (add or remove a space).
1857 1864
1858 1865 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1859 1866 module to better organize all readline-related functionality.
1860 1867 I've deleted FlexCompleter and put all completion clases here.
1861 1868
1862 1869 * IPython/iplib.py (raw_input): improve indentation management.
1863 1870 It is now possible to paste indented code with autoindent on, and
1864 1871 the code is interpreted correctly (though it still looks bad on
1865 1872 screen, due to the line-oriented nature of ipython).
1866 1873 (MagicCompleter.complete): change behavior so that a TAB key on an
1867 1874 otherwise empty line actually inserts a tab, instead of completing
1868 1875 on the entire global namespace. This makes it easier to use the
1869 1876 TAB key for indentation. After a request by Hans Meine
1870 1877 <hans_meine-AT-gmx.net>
1871 1878 (_prefilter): add support so that typing plain 'exit' or 'quit'
1872 1879 does a sensible thing. Originally I tried to deviate as little as
1873 1880 possible from the default python behavior, but even that one may
1874 1881 change in this direction (thread on python-dev to that effect).
1875 1882 Regardless, ipython should do the right thing even if CPython's
1876 1883 '>>>' prompt doesn't.
1877 1884 (InteractiveShell): removed subclassing code.InteractiveConsole
1878 1885 class. By now we'd overridden just about all of its methods: I've
1879 1886 copied the remaining two over, and now ipython is a standalone
1880 1887 class. This will provide a clearer picture for the chainsaw
1881 1888 branch refactoring.
1882 1889
1883 1890 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1884 1891
1885 1892 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1886 1893 failures for objects which break when dir() is called on them.
1887 1894
1888 1895 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1889 1896 distinct local and global namespaces in the completer API. This
1890 1897 change allows us to properly handle completion with distinct
1891 1898 scopes, including in embedded instances (this had never really
1892 1899 worked correctly).
1893 1900
1894 1901 Note: this introduces a change in the constructor for
1895 1902 MagicCompleter, as a new global_namespace parameter is now the
1896 1903 second argument (the others were bumped one position).
1897 1904
1898 1905 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1899 1906
1900 1907 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1901 1908 embedded instances (which can be done now thanks to Vivian's
1902 1909 frame-handling fixes for pdb).
1903 1910 (InteractiveShell.__init__): Fix namespace handling problem in
1904 1911 embedded instances. We were overwriting __main__ unconditionally,
1905 1912 and this should only be done for 'full' (non-embedded) IPython;
1906 1913 embedded instances must respect the caller's __main__. Thanks to
1907 1914 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1908 1915
1909 1916 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1910 1917
1911 1918 * setup.py: added download_url to setup(). This registers the
1912 1919 download address at PyPI, which is not only useful to humans
1913 1920 browsing the site, but is also picked up by setuptools (the Eggs
1914 1921 machinery). Thanks to Ville and R. Kern for the info/discussion
1915 1922 on this.
1916 1923
1917 1924 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1918 1925
1919 1926 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1920 1927 This brings a lot of nice functionality to the pdb mode, which now
1921 1928 has tab-completion, syntax highlighting, and better stack handling
1922 1929 than before. Many thanks to Vivian De Smedt
1923 1930 <vivian-AT-vdesmedt.com> for the original patches.
1924 1931
1925 1932 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1926 1933
1927 1934 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1928 1935 sequence to consistently accept the banner argument. The
1929 1936 inconsistency was tripping SAGE, thanks to Gary Zablackis
1930 1937 <gzabl-AT-yahoo.com> for the report.
1931 1938
1932 1939 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1933 1940
1934 1941 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1935 1942 Fix bug where a naked 'alias' call in the ipythonrc file would
1936 1943 cause a crash. Bug reported by Jorgen Stenarson.
1937 1944
1938 1945 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1939 1946
1940 1947 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1941 1948 startup time.
1942 1949
1943 1950 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1944 1951 instances had introduced a bug with globals in normal code. Now
1945 1952 it's working in all cases.
1946 1953
1947 1954 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1948 1955 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1949 1956 has been introduced to set the default case sensitivity of the
1950 1957 searches. Users can still select either mode at runtime on a
1951 1958 per-search basis.
1952 1959
1953 1960 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1954 1961
1955 1962 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1956 1963 attributes in wildcard searches for subclasses. Modified version
1957 1964 of a patch by Jorgen.
1958 1965
1959 1966 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1960 1967
1961 1968 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1962 1969 embedded instances. I added a user_global_ns attribute to the
1963 1970 InteractiveShell class to handle this.
1964 1971
1965 1972 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1966 1973
1967 1974 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1968 1975 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1969 1976 (reported under win32, but may happen also in other platforms).
1970 1977 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1971 1978
1972 1979 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1973 1980
1974 1981 * IPython/Magic.py (magic_psearch): new support for wildcard
1975 1982 patterns. Now, typing ?a*b will list all names which begin with a
1976 1983 and end in b, for example. The %psearch magic has full
1977 1984 docstrings. Many thanks to JΓΆrgen Stenarson
1978 1985 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1979 1986 implementing this functionality.
1980 1987
1981 1988 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1982 1989
1983 1990 * Manual: fixed long-standing annoyance of double-dashes (as in
1984 1991 --prefix=~, for example) being stripped in the HTML version. This
1985 1992 is a latex2html bug, but a workaround was provided. Many thanks
1986 1993 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1987 1994 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1988 1995 rolling. This seemingly small issue had tripped a number of users
1989 1996 when first installing, so I'm glad to see it gone.
1990 1997
1991 1998 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1992 1999
1993 2000 * IPython/Extensions/numeric_formats.py: fix missing import,
1994 2001 reported by Stephen Walton.
1995 2002
1996 2003 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1997 2004
1998 2005 * IPython/demo.py: finish demo module, fully documented now.
1999 2006
2000 2007 * IPython/genutils.py (file_read): simple little utility to read a
2001 2008 file and ensure it's closed afterwards.
2002 2009
2003 2010 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2004 2011
2005 2012 * IPython/demo.py (Demo.__init__): added support for individually
2006 2013 tagging blocks for automatic execution.
2007 2014
2008 2015 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2009 2016 syntax-highlighted python sources, requested by John.
2010 2017
2011 2018 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2012 2019
2013 2020 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2014 2021 finishing.
2015 2022
2016 2023 * IPython/genutils.py (shlex_split): moved from Magic to here,
2017 2024 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2018 2025
2019 2026 * IPython/demo.py (Demo.__init__): added support for silent
2020 2027 blocks, improved marks as regexps, docstrings written.
2021 2028 (Demo.__init__): better docstring, added support for sys.argv.
2022 2029
2023 2030 * IPython/genutils.py (marquee): little utility used by the demo
2024 2031 code, handy in general.
2025 2032
2026 2033 * IPython/demo.py (Demo.__init__): new class for interactive
2027 2034 demos. Not documented yet, I just wrote it in a hurry for
2028 2035 scipy'05. Will docstring later.
2029 2036
2030 2037 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2031 2038
2032 2039 * IPython/Shell.py (sigint_handler): Drastic simplification which
2033 2040 also seems to make Ctrl-C work correctly across threads! This is
2034 2041 so simple, that I can't beleive I'd missed it before. Needs more
2035 2042 testing, though.
2036 2043 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2037 2044 like this before...
2038 2045
2039 2046 * IPython/genutils.py (get_home_dir): add protection against
2040 2047 non-dirs in win32 registry.
2041 2048
2042 2049 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2043 2050 bug where dict was mutated while iterating (pysh crash).
2044 2051
2045 2052 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2046 2053
2047 2054 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2048 2055 spurious newlines added by this routine. After a report by
2049 2056 F. Mantegazza.
2050 2057
2051 2058 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2052 2059
2053 2060 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2054 2061 calls. These were a leftover from the GTK 1.x days, and can cause
2055 2062 problems in certain cases (after a report by John Hunter).
2056 2063
2057 2064 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2058 2065 os.getcwd() fails at init time. Thanks to patch from David Remahl
2059 2066 <chmod007-AT-mac.com>.
2060 2067 (InteractiveShell.__init__): prevent certain special magics from
2061 2068 being shadowed by aliases. Closes
2062 2069 http://www.scipy.net/roundup/ipython/issue41.
2063 2070
2064 2071 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2065 2072
2066 2073 * IPython/iplib.py (InteractiveShell.complete): Added new
2067 2074 top-level completion method to expose the completion mechanism
2068 2075 beyond readline-based environments.
2069 2076
2070 2077 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2071 2078
2072 2079 * tools/ipsvnc (svnversion): fix svnversion capture.
2073 2080
2074 2081 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2075 2082 attribute to self, which was missing. Before, it was set by a
2076 2083 routine which in certain cases wasn't being called, so the
2077 2084 instance could end up missing the attribute. This caused a crash.
2078 2085 Closes http://www.scipy.net/roundup/ipython/issue40.
2079 2086
2080 2087 2005-08-16 Fernando Perez <fperez@colorado.edu>
2081 2088
2082 2089 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2083 2090 contains non-string attribute. Closes
2084 2091 http://www.scipy.net/roundup/ipython/issue38.
2085 2092
2086 2093 2005-08-14 Fernando Perez <fperez@colorado.edu>
2087 2094
2088 2095 * tools/ipsvnc: Minor improvements, to add changeset info.
2089 2096
2090 2097 2005-08-12 Fernando Perez <fperez@colorado.edu>
2091 2098
2092 2099 * IPython/iplib.py (runsource): remove self.code_to_run_src
2093 2100 attribute. I realized this is nothing more than
2094 2101 '\n'.join(self.buffer), and having the same data in two different
2095 2102 places is just asking for synchronization bugs. This may impact
2096 2103 people who have custom exception handlers, so I need to warn
2097 2104 ipython-dev about it (F. Mantegazza may use them).
2098 2105
2099 2106 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2100 2107
2101 2108 * IPython/genutils.py: fix 2.2 compatibility (generators)
2102 2109
2103 2110 2005-07-18 Fernando Perez <fperez@colorado.edu>
2104 2111
2105 2112 * IPython/genutils.py (get_home_dir): fix to help users with
2106 2113 invalid $HOME under win32.
2107 2114
2108 2115 2005-07-17 Fernando Perez <fperez@colorado.edu>
2109 2116
2110 2117 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2111 2118 some old hacks and clean up a bit other routines; code should be
2112 2119 simpler and a bit faster.
2113 2120
2114 2121 * IPython/iplib.py (interact): removed some last-resort attempts
2115 2122 to survive broken stdout/stderr. That code was only making it
2116 2123 harder to abstract out the i/o (necessary for gui integration),
2117 2124 and the crashes it could prevent were extremely rare in practice
2118 2125 (besides being fully user-induced in a pretty violent manner).
2119 2126
2120 2127 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2121 2128 Nothing major yet, but the code is simpler to read; this should
2122 2129 make it easier to do more serious modifications in the future.
2123 2130
2124 2131 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2125 2132 which broke in .15 (thanks to a report by Ville).
2126 2133
2127 2134 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2128 2135 be quite correct, I know next to nothing about unicode). This
2129 2136 will allow unicode strings to be used in prompts, amongst other
2130 2137 cases. It also will prevent ipython from crashing when unicode
2131 2138 shows up unexpectedly in many places. If ascii encoding fails, we
2132 2139 assume utf_8. Currently the encoding is not a user-visible
2133 2140 setting, though it could be made so if there is demand for it.
2134 2141
2135 2142 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2136 2143
2137 2144 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2138 2145
2139 2146 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2140 2147
2141 2148 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2142 2149 code can work transparently for 2.2/2.3.
2143 2150
2144 2151 2005-07-16 Fernando Perez <fperez@colorado.edu>
2145 2152
2146 2153 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2147 2154 out of the color scheme table used for coloring exception
2148 2155 tracebacks. This allows user code to add new schemes at runtime.
2149 2156 This is a minimally modified version of the patch at
2150 2157 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2151 2158 for the contribution.
2152 2159
2153 2160 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2154 2161 slightly modified version of the patch in
2155 2162 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2156 2163 to remove the previous try/except solution (which was costlier).
2157 2164 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2158 2165
2159 2166 2005-06-08 Fernando Perez <fperez@colorado.edu>
2160 2167
2161 2168 * IPython/iplib.py (write/write_err): Add methods to abstract all
2162 2169 I/O a bit more.
2163 2170
2164 2171 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2165 2172 warning, reported by Aric Hagberg, fix by JD Hunter.
2166 2173
2167 2174 2005-06-02 *** Released version 0.6.15
2168 2175
2169 2176 2005-06-01 Fernando Perez <fperez@colorado.edu>
2170 2177
2171 2178 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2172 2179 tab-completion of filenames within open-quoted strings. Note that
2173 2180 this requires that in ~/.ipython/ipythonrc, users change the
2174 2181 readline delimiters configuration to read:
2175 2182
2176 2183 readline_remove_delims -/~
2177 2184
2178 2185
2179 2186 2005-05-31 *** Released version 0.6.14
2180 2187
2181 2188 2005-05-29 Fernando Perez <fperez@colorado.edu>
2182 2189
2183 2190 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2184 2191 with files not on the filesystem. Reported by Eliyahu Sandler
2185 2192 <eli@gondolin.net>
2186 2193
2187 2194 2005-05-22 Fernando Perez <fperez@colorado.edu>
2188 2195
2189 2196 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2190 2197 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2191 2198
2192 2199 2005-05-19 Fernando Perez <fperez@colorado.edu>
2193 2200
2194 2201 * IPython/iplib.py (safe_execfile): close a file which could be
2195 2202 left open (causing problems in win32, which locks open files).
2196 2203 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2197 2204
2198 2205 2005-05-18 Fernando Perez <fperez@colorado.edu>
2199 2206
2200 2207 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2201 2208 keyword arguments correctly to safe_execfile().
2202 2209
2203 2210 2005-05-13 Fernando Perez <fperez@colorado.edu>
2204 2211
2205 2212 * ipython.1: Added info about Qt to manpage, and threads warning
2206 2213 to usage page (invoked with --help).
2207 2214
2208 2215 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2209 2216 new matcher (it goes at the end of the priority list) to do
2210 2217 tab-completion on named function arguments. Submitted by George
2211 2218 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2212 2219 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2213 2220 for more details.
2214 2221
2215 2222 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2216 2223 SystemExit exceptions in the script being run. Thanks to a report
2217 2224 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2218 2225 producing very annoying behavior when running unit tests.
2219 2226
2220 2227 2005-05-12 Fernando Perez <fperez@colorado.edu>
2221 2228
2222 2229 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2223 2230 which I'd broken (again) due to a changed regexp. In the process,
2224 2231 added ';' as an escape to auto-quote the whole line without
2225 2232 splitting its arguments. Thanks to a report by Jerry McRae
2226 2233 <qrs0xyc02-AT-sneakemail.com>.
2227 2234
2228 2235 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2229 2236 possible crashes caused by a TokenError. Reported by Ed Schofield
2230 2237 <schofield-AT-ftw.at>.
2231 2238
2232 2239 2005-05-06 Fernando Perez <fperez@colorado.edu>
2233 2240
2234 2241 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2235 2242
2236 2243 2005-04-29 Fernando Perez <fperez@colorado.edu>
2237 2244
2238 2245 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2239 2246 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2240 2247 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2241 2248 which provides support for Qt interactive usage (similar to the
2242 2249 existing one for WX and GTK). This had been often requested.
2243 2250
2244 2251 2005-04-14 *** Released version 0.6.13
2245 2252
2246 2253 2005-04-08 Fernando Perez <fperez@colorado.edu>
2247 2254
2248 2255 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2249 2256 from _ofind, which gets called on almost every input line. Now,
2250 2257 we only try to get docstrings if they are actually going to be
2251 2258 used (the overhead of fetching unnecessary docstrings can be
2252 2259 noticeable for certain objects, such as Pyro proxies).
2253 2260
2254 2261 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2255 2262 for completers. For some reason I had been passing them the state
2256 2263 variable, which completers never actually need, and was in
2257 2264 conflict with the rlcompleter API. Custom completers ONLY need to
2258 2265 take the text parameter.
2259 2266
2260 2267 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2261 2268 work correctly in pysh. I've also moved all the logic which used
2262 2269 to be in pysh.py here, which will prevent problems with future
2263 2270 upgrades. However, this time I must warn users to update their
2264 2271 pysh profile to include the line
2265 2272
2266 2273 import_all IPython.Extensions.InterpreterExec
2267 2274
2268 2275 because otherwise things won't work for them. They MUST also
2269 2276 delete pysh.py and the line
2270 2277
2271 2278 execfile pysh.py
2272 2279
2273 2280 from their ipythonrc-pysh.
2274 2281
2275 2282 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2276 2283 robust in the face of objects whose dir() returns non-strings
2277 2284 (which it shouldn't, but some broken libs like ITK do). Thanks to
2278 2285 a patch by John Hunter (implemented differently, though). Also
2279 2286 minor improvements by using .extend instead of + on lists.
2280 2287
2281 2288 * pysh.py:
2282 2289
2283 2290 2005-04-06 Fernando Perez <fperez@colorado.edu>
2284 2291
2285 2292 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2286 2293 by default, so that all users benefit from it. Those who don't
2287 2294 want it can still turn it off.
2288 2295
2289 2296 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2290 2297 config file, I'd forgotten about this, so users were getting it
2291 2298 off by default.
2292 2299
2293 2300 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2294 2301 consistency. Now magics can be called in multiline statements,
2295 2302 and python variables can be expanded in magic calls via $var.
2296 2303 This makes the magic system behave just like aliases or !system
2297 2304 calls.
2298 2305
2299 2306 2005-03-28 Fernando Perez <fperez@colorado.edu>
2300 2307
2301 2308 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2302 2309 expensive string additions for building command. Add support for
2303 2310 trailing ';' when autocall is used.
2304 2311
2305 2312 2005-03-26 Fernando Perez <fperez@colorado.edu>
2306 2313
2307 2314 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2308 2315 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2309 2316 ipython.el robust against prompts with any number of spaces
2310 2317 (including 0) after the ':' character.
2311 2318
2312 2319 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2313 2320 continuation prompt, which misled users to think the line was
2314 2321 already indented. Closes debian Bug#300847, reported to me by
2315 2322 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2316 2323
2317 2324 2005-03-23 Fernando Perez <fperez@colorado.edu>
2318 2325
2319 2326 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2320 2327 properly aligned if they have embedded newlines.
2321 2328
2322 2329 * IPython/iplib.py (runlines): Add a public method to expose
2323 2330 IPython's code execution machinery, so that users can run strings
2324 2331 as if they had been typed at the prompt interactively.
2325 2332 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2326 2333 methods which can call the system shell, but with python variable
2327 2334 expansion. The three such methods are: __IPYTHON__.system,
2328 2335 .getoutput and .getoutputerror. These need to be documented in a
2329 2336 'public API' section (to be written) of the manual.
2330 2337
2331 2338 2005-03-20 Fernando Perez <fperez@colorado.edu>
2332 2339
2333 2340 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2334 2341 for custom exception handling. This is quite powerful, and it
2335 2342 allows for user-installable exception handlers which can trap
2336 2343 custom exceptions at runtime and treat them separately from
2337 2344 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2338 2345 Mantegazza <mantegazza-AT-ill.fr>.
2339 2346 (InteractiveShell.set_custom_completer): public API function to
2340 2347 add new completers at runtime.
2341 2348
2342 2349 2005-03-19 Fernando Perez <fperez@colorado.edu>
2343 2350
2344 2351 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2345 2352 allow objects which provide their docstrings via non-standard
2346 2353 mechanisms (like Pyro proxies) to still be inspected by ipython's
2347 2354 ? system.
2348 2355
2349 2356 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2350 2357 automatic capture system. I tried quite hard to make it work
2351 2358 reliably, and simply failed. I tried many combinations with the
2352 2359 subprocess module, but eventually nothing worked in all needed
2353 2360 cases (not blocking stdin for the child, duplicating stdout
2354 2361 without blocking, etc). The new %sc/%sx still do capture to these
2355 2362 magical list/string objects which make shell use much more
2356 2363 conveninent, so not all is lost.
2357 2364
2358 2365 XXX - FIX MANUAL for the change above!
2359 2366
2360 2367 (runsource): I copied code.py's runsource() into ipython to modify
2361 2368 it a bit. Now the code object and source to be executed are
2362 2369 stored in ipython. This makes this info accessible to third-party
2363 2370 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2364 2371 Mantegazza <mantegazza-AT-ill.fr>.
2365 2372
2366 2373 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2367 2374 history-search via readline (like C-p/C-n). I'd wanted this for a
2368 2375 long time, but only recently found out how to do it. For users
2369 2376 who already have their ipythonrc files made and want this, just
2370 2377 add:
2371 2378
2372 2379 readline_parse_and_bind "\e[A": history-search-backward
2373 2380 readline_parse_and_bind "\e[B": history-search-forward
2374 2381
2375 2382 2005-03-18 Fernando Perez <fperez@colorado.edu>
2376 2383
2377 2384 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2378 2385 LSString and SList classes which allow transparent conversions
2379 2386 between list mode and whitespace-separated string.
2380 2387 (magic_r): Fix recursion problem in %r.
2381 2388
2382 2389 * IPython/genutils.py (LSString): New class to be used for
2383 2390 automatic storage of the results of all alias/system calls in _o
2384 2391 and _e (stdout/err). These provide a .l/.list attribute which
2385 2392 does automatic splitting on newlines. This means that for most
2386 2393 uses, you'll never need to do capturing of output with %sc/%sx
2387 2394 anymore, since ipython keeps this always done for you. Note that
2388 2395 only the LAST results are stored, the _o/e variables are
2389 2396 overwritten on each call. If you need to save their contents
2390 2397 further, simply bind them to any other name.
2391 2398
2392 2399 2005-03-17 Fernando Perez <fperez@colorado.edu>
2393 2400
2394 2401 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2395 2402 prompt namespace handling.
2396 2403
2397 2404 2005-03-16 Fernando Perez <fperez@colorado.edu>
2398 2405
2399 2406 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2400 2407 classic prompts to be '>>> ' (final space was missing, and it
2401 2408 trips the emacs python mode).
2402 2409 (BasePrompt.__str__): Added safe support for dynamic prompt
2403 2410 strings. Now you can set your prompt string to be '$x', and the
2404 2411 value of x will be printed from your interactive namespace. The
2405 2412 interpolation syntax includes the full Itpl support, so
2406 2413 ${foo()+x+bar()} is a valid prompt string now, and the function
2407 2414 calls will be made at runtime.
2408 2415
2409 2416 2005-03-15 Fernando Perez <fperez@colorado.edu>
2410 2417
2411 2418 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2412 2419 avoid name clashes in pylab. %hist still works, it just forwards
2413 2420 the call to %history.
2414 2421
2415 2422 2005-03-02 *** Released version 0.6.12
2416 2423
2417 2424 2005-03-02 Fernando Perez <fperez@colorado.edu>
2418 2425
2419 2426 * IPython/iplib.py (handle_magic): log magic calls properly as
2420 2427 ipmagic() function calls.
2421 2428
2422 2429 * IPython/Magic.py (magic_time): Improved %time to support
2423 2430 statements and provide wall-clock as well as CPU time.
2424 2431
2425 2432 2005-02-27 Fernando Perez <fperez@colorado.edu>
2426 2433
2427 2434 * IPython/hooks.py: New hooks module, to expose user-modifiable
2428 2435 IPython functionality in a clean manner. For now only the editor
2429 2436 hook is actually written, and other thigns which I intend to turn
2430 2437 into proper hooks aren't yet there. The display and prefilter
2431 2438 stuff, for example, should be hooks. But at least now the
2432 2439 framework is in place, and the rest can be moved here with more
2433 2440 time later. IPython had had a .hooks variable for a long time for
2434 2441 this purpose, but I'd never actually used it for anything.
2435 2442
2436 2443 2005-02-26 Fernando Perez <fperez@colorado.edu>
2437 2444
2438 2445 * IPython/ipmaker.py (make_IPython): make the default ipython
2439 2446 directory be called _ipython under win32, to follow more the
2440 2447 naming peculiarities of that platform (where buggy software like
2441 2448 Visual Sourcesafe breaks with .named directories). Reported by
2442 2449 Ville Vainio.
2443 2450
2444 2451 2005-02-23 Fernando Perez <fperez@colorado.edu>
2445 2452
2446 2453 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2447 2454 auto_aliases for win32 which were causing problems. Users can
2448 2455 define the ones they personally like.
2449 2456
2450 2457 2005-02-21 Fernando Perez <fperez@colorado.edu>
2451 2458
2452 2459 * IPython/Magic.py (magic_time): new magic to time execution of
2453 2460 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2454 2461
2455 2462 2005-02-19 Fernando Perez <fperez@colorado.edu>
2456 2463
2457 2464 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2458 2465 into keys (for prompts, for example).
2459 2466
2460 2467 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2461 2468 prompts in case users want them. This introduces a small behavior
2462 2469 change: ipython does not automatically add a space to all prompts
2463 2470 anymore. To get the old prompts with a space, users should add it
2464 2471 manually to their ipythonrc file, so for example prompt_in1 should
2465 2472 now read 'In [\#]: ' instead of 'In [\#]:'.
2466 2473 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2467 2474 file) to control left-padding of secondary prompts.
2468 2475
2469 2476 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2470 2477 the profiler can't be imported. Fix for Debian, which removed
2471 2478 profile.py because of License issues. I applied a slightly
2472 2479 modified version of the original Debian patch at
2473 2480 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2474 2481
2475 2482 2005-02-17 Fernando Perez <fperez@colorado.edu>
2476 2483
2477 2484 * IPython/genutils.py (native_line_ends): Fix bug which would
2478 2485 cause improper line-ends under win32 b/c I was not opening files
2479 2486 in binary mode. Bug report and fix thanks to Ville.
2480 2487
2481 2488 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2482 2489 trying to catch spurious foo[1] autocalls. My fix actually broke
2483 2490 ',/' autoquote/call with explicit escape (bad regexp).
2484 2491
2485 2492 2005-02-15 *** Released version 0.6.11
2486 2493
2487 2494 2005-02-14 Fernando Perez <fperez@colorado.edu>
2488 2495
2489 2496 * IPython/background_jobs.py: New background job management
2490 2497 subsystem. This is implemented via a new set of classes, and
2491 2498 IPython now provides a builtin 'jobs' object for background job
2492 2499 execution. A convenience %bg magic serves as a lightweight
2493 2500 frontend for starting the more common type of calls. This was
2494 2501 inspired by discussions with B. Granger and the BackgroundCommand
2495 2502 class described in the book Python Scripting for Computational
2496 2503 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2497 2504 (although ultimately no code from this text was used, as IPython's
2498 2505 system is a separate implementation).
2499 2506
2500 2507 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2501 2508 to control the completion of single/double underscore names
2502 2509 separately. As documented in the example ipytonrc file, the
2503 2510 readline_omit__names variable can now be set to 2, to omit even
2504 2511 single underscore names. Thanks to a patch by Brian Wong
2505 2512 <BrianWong-AT-AirgoNetworks.Com>.
2506 2513 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2507 2514 be autocalled as foo([1]) if foo were callable. A problem for
2508 2515 things which are both callable and implement __getitem__.
2509 2516 (init_readline): Fix autoindentation for win32. Thanks to a patch
2510 2517 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2511 2518
2512 2519 2005-02-12 Fernando Perez <fperez@colorado.edu>
2513 2520
2514 2521 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2515 2522 which I had written long ago to sort out user error messages which
2516 2523 may occur during startup. This seemed like a good idea initially,
2517 2524 but it has proven a disaster in retrospect. I don't want to
2518 2525 change much code for now, so my fix is to set the internal 'debug'
2519 2526 flag to true everywhere, whose only job was precisely to control
2520 2527 this subsystem. This closes issue 28 (as well as avoiding all
2521 2528 sorts of strange hangups which occur from time to time).
2522 2529
2523 2530 2005-02-07 Fernando Perez <fperez@colorado.edu>
2524 2531
2525 2532 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2526 2533 previous call produced a syntax error.
2527 2534
2528 2535 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2529 2536 classes without constructor.
2530 2537
2531 2538 2005-02-06 Fernando Perez <fperez@colorado.edu>
2532 2539
2533 2540 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2534 2541 completions with the results of each matcher, so we return results
2535 2542 to the user from all namespaces. This breaks with ipython
2536 2543 tradition, but I think it's a nicer behavior. Now you get all
2537 2544 possible completions listed, from all possible namespaces (python,
2538 2545 filesystem, magics...) After a request by John Hunter
2539 2546 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2540 2547
2541 2548 2005-02-05 Fernando Perez <fperez@colorado.edu>
2542 2549
2543 2550 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2544 2551 the call had quote characters in it (the quotes were stripped).
2545 2552
2546 2553 2005-01-31 Fernando Perez <fperez@colorado.edu>
2547 2554
2548 2555 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2549 2556 Itpl.itpl() to make the code more robust against psyco
2550 2557 optimizations.
2551 2558
2552 2559 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2553 2560 of causing an exception. Quicker, cleaner.
2554 2561
2555 2562 2005-01-28 Fernando Perez <fperez@colorado.edu>
2556 2563
2557 2564 * scripts/ipython_win_post_install.py (install): hardcode
2558 2565 sys.prefix+'python.exe' as the executable path. It turns out that
2559 2566 during the post-installation run, sys.executable resolves to the
2560 2567 name of the binary installer! I should report this as a distutils
2561 2568 bug, I think. I updated the .10 release with this tiny fix, to
2562 2569 avoid annoying the lists further.
2563 2570
2564 2571 2005-01-27 *** Released version 0.6.10
2565 2572
2566 2573 2005-01-27 Fernando Perez <fperez@colorado.edu>
2567 2574
2568 2575 * IPython/numutils.py (norm): Added 'inf' as optional name for
2569 2576 L-infinity norm, included references to mathworld.com for vector
2570 2577 norm definitions.
2571 2578 (amin/amax): added amin/amax for array min/max. Similar to what
2572 2579 pylab ships with after the recent reorganization of names.
2573 2580 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2574 2581
2575 2582 * ipython.el: committed Alex's recent fixes and improvements.
2576 2583 Tested with python-mode from CVS, and it looks excellent. Since
2577 2584 python-mode hasn't released anything in a while, I'm temporarily
2578 2585 putting a copy of today's CVS (v 4.70) of python-mode in:
2579 2586 http://ipython.scipy.org/tmp/python-mode.el
2580 2587
2581 2588 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2582 2589 sys.executable for the executable name, instead of assuming it's
2583 2590 called 'python.exe' (the post-installer would have produced broken
2584 2591 setups on systems with a differently named python binary).
2585 2592
2586 2593 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2587 2594 references to os.linesep, to make the code more
2588 2595 platform-independent. This is also part of the win32 coloring
2589 2596 fixes.
2590 2597
2591 2598 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2592 2599 lines, which actually cause coloring bugs because the length of
2593 2600 the line is very difficult to correctly compute with embedded
2594 2601 escapes. This was the source of all the coloring problems under
2595 2602 Win32. I think that _finally_, Win32 users have a properly
2596 2603 working ipython in all respects. This would never have happened
2597 2604 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2598 2605
2599 2606 2005-01-26 *** Released version 0.6.9
2600 2607
2601 2608 2005-01-25 Fernando Perez <fperez@colorado.edu>
2602 2609
2603 2610 * setup.py: finally, we have a true Windows installer, thanks to
2604 2611 the excellent work of Viktor Ransmayr
2605 2612 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2606 2613 Windows users. The setup routine is quite a bit cleaner thanks to
2607 2614 this, and the post-install script uses the proper functions to
2608 2615 allow a clean de-installation using the standard Windows Control
2609 2616 Panel.
2610 2617
2611 2618 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2612 2619 environment variable under all OSes (including win32) if
2613 2620 available. This will give consistency to win32 users who have set
2614 2621 this variable for any reason. If os.environ['HOME'] fails, the
2615 2622 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2616 2623
2617 2624 2005-01-24 Fernando Perez <fperez@colorado.edu>
2618 2625
2619 2626 * IPython/numutils.py (empty_like): add empty_like(), similar to
2620 2627 zeros_like() but taking advantage of the new empty() Numeric routine.
2621 2628
2622 2629 2005-01-23 *** Released version 0.6.8
2623 2630
2624 2631 2005-01-22 Fernando Perez <fperez@colorado.edu>
2625 2632
2626 2633 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2627 2634 automatic show() calls. After discussing things with JDH, it
2628 2635 turns out there are too many corner cases where this can go wrong.
2629 2636 It's best not to try to be 'too smart', and simply have ipython
2630 2637 reproduce as much as possible the default behavior of a normal
2631 2638 python shell.
2632 2639
2633 2640 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2634 2641 line-splitting regexp and _prefilter() to avoid calling getattr()
2635 2642 on assignments. This closes
2636 2643 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2637 2644 readline uses getattr(), so a simple <TAB> keypress is still
2638 2645 enough to trigger getattr() calls on an object.
2639 2646
2640 2647 2005-01-21 Fernando Perez <fperez@colorado.edu>
2641 2648
2642 2649 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2643 2650 docstring under pylab so it doesn't mask the original.
2644 2651
2645 2652 2005-01-21 *** Released version 0.6.7
2646 2653
2647 2654 2005-01-21 Fernando Perez <fperez@colorado.edu>
2648 2655
2649 2656 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2650 2657 signal handling for win32 users in multithreaded mode.
2651 2658
2652 2659 2005-01-17 Fernando Perez <fperez@colorado.edu>
2653 2660
2654 2661 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2655 2662 instances with no __init__. After a crash report by Norbert Nemec
2656 2663 <Norbert-AT-nemec-online.de>.
2657 2664
2658 2665 2005-01-14 Fernando Perez <fperez@colorado.edu>
2659 2666
2660 2667 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2661 2668 names for verbose exceptions, when multiple dotted names and the
2662 2669 'parent' object were present on the same line.
2663 2670
2664 2671 2005-01-11 Fernando Perez <fperez@colorado.edu>
2665 2672
2666 2673 * IPython/genutils.py (flag_calls): new utility to trap and flag
2667 2674 calls in functions. I need it to clean up matplotlib support.
2668 2675 Also removed some deprecated code in genutils.
2669 2676
2670 2677 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2671 2678 that matplotlib scripts called with %run, which don't call show()
2672 2679 themselves, still have their plotting windows open.
2673 2680
2674 2681 2005-01-05 Fernando Perez <fperez@colorado.edu>
2675 2682
2676 2683 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2677 2684 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2678 2685
2679 2686 2004-12-19 Fernando Perez <fperez@colorado.edu>
2680 2687
2681 2688 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2682 2689 parent_runcode, which was an eyesore. The same result can be
2683 2690 obtained with Python's regular superclass mechanisms.
2684 2691
2685 2692 2004-12-17 Fernando Perez <fperez@colorado.edu>
2686 2693
2687 2694 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2688 2695 reported by Prabhu.
2689 2696 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2690 2697 sys.stderr) instead of explicitly calling sys.stderr. This helps
2691 2698 maintain our I/O abstractions clean, for future GUI embeddings.
2692 2699
2693 2700 * IPython/genutils.py (info): added new utility for sys.stderr
2694 2701 unified info message handling (thin wrapper around warn()).
2695 2702
2696 2703 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2697 2704 composite (dotted) names on verbose exceptions.
2698 2705 (VerboseTB.nullrepr): harden against another kind of errors which
2699 2706 Python's inspect module can trigger, and which were crashing
2700 2707 IPython. Thanks to a report by Marco Lombardi
2701 2708 <mlombard-AT-ma010192.hq.eso.org>.
2702 2709
2703 2710 2004-12-13 *** Released version 0.6.6
2704 2711
2705 2712 2004-12-12 Fernando Perez <fperez@colorado.edu>
2706 2713
2707 2714 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2708 2715 generated by pygtk upon initialization if it was built without
2709 2716 threads (for matplotlib users). After a crash reported by
2710 2717 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2711 2718
2712 2719 * IPython/ipmaker.py (make_IPython): fix small bug in the
2713 2720 import_some parameter for multiple imports.
2714 2721
2715 2722 * IPython/iplib.py (ipmagic): simplified the interface of
2716 2723 ipmagic() to take a single string argument, just as it would be
2717 2724 typed at the IPython cmd line.
2718 2725 (ipalias): Added new ipalias() with an interface identical to
2719 2726 ipmagic(). This completes exposing a pure python interface to the
2720 2727 alias and magic system, which can be used in loops or more complex
2721 2728 code where IPython's automatic line mangling is not active.
2722 2729
2723 2730 * IPython/genutils.py (timing): changed interface of timing to
2724 2731 simply run code once, which is the most common case. timings()
2725 2732 remains unchanged, for the cases where you want multiple runs.
2726 2733
2727 2734 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2728 2735 bug where Python2.2 crashes with exec'ing code which does not end
2729 2736 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2730 2737 before.
2731 2738
2732 2739 2004-12-10 Fernando Perez <fperez@colorado.edu>
2733 2740
2734 2741 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2735 2742 -t to -T, to accomodate the new -t flag in %run (the %run and
2736 2743 %prun options are kind of intermixed, and it's not easy to change
2737 2744 this with the limitations of python's getopt).
2738 2745
2739 2746 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2740 2747 the execution of scripts. It's not as fine-tuned as timeit.py,
2741 2748 but it works from inside ipython (and under 2.2, which lacks
2742 2749 timeit.py). Optionally a number of runs > 1 can be given for
2743 2750 timing very short-running code.
2744 2751
2745 2752 * IPython/genutils.py (uniq_stable): new routine which returns a
2746 2753 list of unique elements in any iterable, but in stable order of
2747 2754 appearance. I needed this for the ultraTB fixes, and it's a handy
2748 2755 utility.
2749 2756
2750 2757 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2751 2758 dotted names in Verbose exceptions. This had been broken since
2752 2759 the very start, now x.y will properly be printed in a Verbose
2753 2760 traceback, instead of x being shown and y appearing always as an
2754 2761 'undefined global'. Getting this to work was a bit tricky,
2755 2762 because by default python tokenizers are stateless. Saved by
2756 2763 python's ability to easily add a bit of state to an arbitrary
2757 2764 function (without needing to build a full-blown callable object).
2758 2765
2759 2766 Also big cleanup of this code, which had horrendous runtime
2760 2767 lookups of zillions of attributes for colorization. Moved all
2761 2768 this code into a few templates, which make it cleaner and quicker.
2762 2769
2763 2770 Printout quality was also improved for Verbose exceptions: one
2764 2771 variable per line, and memory addresses are printed (this can be
2765 2772 quite handy in nasty debugging situations, which is what Verbose
2766 2773 is for).
2767 2774
2768 2775 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2769 2776 the command line as scripts to be loaded by embedded instances.
2770 2777 Doing so has the potential for an infinite recursion if there are
2771 2778 exceptions thrown in the process. This fixes a strange crash
2772 2779 reported by Philippe MULLER <muller-AT-irit.fr>.
2773 2780
2774 2781 2004-12-09 Fernando Perez <fperez@colorado.edu>
2775 2782
2776 2783 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2777 2784 to reflect new names in matplotlib, which now expose the
2778 2785 matlab-compatible interface via a pylab module instead of the
2779 2786 'matlab' name. The new code is backwards compatible, so users of
2780 2787 all matplotlib versions are OK. Patch by J. Hunter.
2781 2788
2782 2789 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2783 2790 of __init__ docstrings for instances (class docstrings are already
2784 2791 automatically printed). Instances with customized docstrings
2785 2792 (indep. of the class) are also recognized and all 3 separate
2786 2793 docstrings are printed (instance, class, constructor). After some
2787 2794 comments/suggestions by J. Hunter.
2788 2795
2789 2796 2004-12-05 Fernando Perez <fperez@colorado.edu>
2790 2797
2791 2798 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2792 2799 warnings when tab-completion fails and triggers an exception.
2793 2800
2794 2801 2004-12-03 Fernando Perez <fperez@colorado.edu>
2795 2802
2796 2803 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2797 2804 be triggered when using 'run -p'. An incorrect option flag was
2798 2805 being set ('d' instead of 'D').
2799 2806 (manpage): fix missing escaped \- sign.
2800 2807
2801 2808 2004-11-30 *** Released version 0.6.5
2802 2809
2803 2810 2004-11-30 Fernando Perez <fperez@colorado.edu>
2804 2811
2805 2812 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2806 2813 setting with -d option.
2807 2814
2808 2815 * setup.py (docfiles): Fix problem where the doc glob I was using
2809 2816 was COMPLETELY BROKEN. It was giving the right files by pure
2810 2817 accident, but failed once I tried to include ipython.el. Note:
2811 2818 glob() does NOT allow you to do exclusion on multiple endings!
2812 2819
2813 2820 2004-11-29 Fernando Perez <fperez@colorado.edu>
2814 2821
2815 2822 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2816 2823 the manpage as the source. Better formatting & consistency.
2817 2824
2818 2825 * IPython/Magic.py (magic_run): Added new -d option, to run
2819 2826 scripts under the control of the python pdb debugger. Note that
2820 2827 this required changing the %prun option -d to -D, to avoid a clash
2821 2828 (since %run must pass options to %prun, and getopt is too dumb to
2822 2829 handle options with string values with embedded spaces). Thanks
2823 2830 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2824 2831 (magic_who_ls): added type matching to %who and %whos, so that one
2825 2832 can filter their output to only include variables of certain
2826 2833 types. Another suggestion by Matthew.
2827 2834 (magic_whos): Added memory summaries in kb and Mb for arrays.
2828 2835 (magic_who): Improve formatting (break lines every 9 vars).
2829 2836
2830 2837 2004-11-28 Fernando Perez <fperez@colorado.edu>
2831 2838
2832 2839 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2833 2840 cache when empty lines were present.
2834 2841
2835 2842 2004-11-24 Fernando Perez <fperez@colorado.edu>
2836 2843
2837 2844 * IPython/usage.py (__doc__): document the re-activated threading
2838 2845 options for WX and GTK.
2839 2846
2840 2847 2004-11-23 Fernando Perez <fperez@colorado.edu>
2841 2848
2842 2849 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2843 2850 the -wthread and -gthread options, along with a new -tk one to try
2844 2851 and coordinate Tk threading with wx/gtk. The tk support is very
2845 2852 platform dependent, since it seems to require Tcl and Tk to be
2846 2853 built with threads (Fedora1/2 appears NOT to have it, but in
2847 2854 Prabhu's Debian boxes it works OK). But even with some Tk
2848 2855 limitations, this is a great improvement.
2849 2856
2850 2857 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2851 2858 info in user prompts. Patch by Prabhu.
2852 2859
2853 2860 2004-11-18 Fernando Perez <fperez@colorado.edu>
2854 2861
2855 2862 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2856 2863 EOFErrors and bail, to avoid infinite loops if a non-terminating
2857 2864 file is fed into ipython. Patch submitted in issue 19 by user,
2858 2865 many thanks.
2859 2866
2860 2867 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2861 2868 autoquote/parens in continuation prompts, which can cause lots of
2862 2869 problems. Closes roundup issue 20.
2863 2870
2864 2871 2004-11-17 Fernando Perez <fperez@colorado.edu>
2865 2872
2866 2873 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2867 2874 reported as debian bug #280505. I'm not sure my local changelog
2868 2875 entry has the proper debian format (Jack?).
2869 2876
2870 2877 2004-11-08 *** Released version 0.6.4
2871 2878
2872 2879 2004-11-08 Fernando Perez <fperez@colorado.edu>
2873 2880
2874 2881 * IPython/iplib.py (init_readline): Fix exit message for Windows
2875 2882 when readline is active. Thanks to a report by Eric Jones
2876 2883 <eric-AT-enthought.com>.
2877 2884
2878 2885 2004-11-07 Fernando Perez <fperez@colorado.edu>
2879 2886
2880 2887 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2881 2888 sometimes seen by win2k/cygwin users.
2882 2889
2883 2890 2004-11-06 Fernando Perez <fperez@colorado.edu>
2884 2891
2885 2892 * IPython/iplib.py (interact): Change the handling of %Exit from
2886 2893 trying to propagate a SystemExit to an internal ipython flag.
2887 2894 This is less elegant than using Python's exception mechanism, but
2888 2895 I can't get that to work reliably with threads, so under -pylab
2889 2896 %Exit was hanging IPython. Cross-thread exception handling is
2890 2897 really a bitch. Thaks to a bug report by Stephen Walton
2891 2898 <stephen.walton-AT-csun.edu>.
2892 2899
2893 2900 2004-11-04 Fernando Perez <fperez@colorado.edu>
2894 2901
2895 2902 * IPython/iplib.py (raw_input_original): store a pointer to the
2896 2903 true raw_input to harden against code which can modify it
2897 2904 (wx.py.PyShell does this and would otherwise crash ipython).
2898 2905 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2899 2906
2900 2907 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2901 2908 Ctrl-C problem, which does not mess up the input line.
2902 2909
2903 2910 2004-11-03 Fernando Perez <fperez@colorado.edu>
2904 2911
2905 2912 * IPython/Release.py: Changed licensing to BSD, in all files.
2906 2913 (name): lowercase name for tarball/RPM release.
2907 2914
2908 2915 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2909 2916 use throughout ipython.
2910 2917
2911 2918 * IPython/Magic.py (Magic._ofind): Switch to using the new
2912 2919 OInspect.getdoc() function.
2913 2920
2914 2921 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2915 2922 of the line currently being canceled via Ctrl-C. It's extremely
2916 2923 ugly, but I don't know how to do it better (the problem is one of
2917 2924 handling cross-thread exceptions).
2918 2925
2919 2926 2004-10-28 Fernando Perez <fperez@colorado.edu>
2920 2927
2921 2928 * IPython/Shell.py (signal_handler): add signal handlers to trap
2922 2929 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2923 2930 report by Francesc Alted.
2924 2931
2925 2932 2004-10-21 Fernando Perez <fperez@colorado.edu>
2926 2933
2927 2934 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2928 2935 to % for pysh syntax extensions.
2929 2936
2930 2937 2004-10-09 Fernando Perez <fperez@colorado.edu>
2931 2938
2932 2939 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2933 2940 arrays to print a more useful summary, without calling str(arr).
2934 2941 This avoids the problem of extremely lengthy computations which
2935 2942 occur if arr is large, and appear to the user as a system lockup
2936 2943 with 100% cpu activity. After a suggestion by Kristian Sandberg
2937 2944 <Kristian.Sandberg@colorado.edu>.
2938 2945 (Magic.__init__): fix bug in global magic escapes not being
2939 2946 correctly set.
2940 2947
2941 2948 2004-10-08 Fernando Perez <fperez@colorado.edu>
2942 2949
2943 2950 * IPython/Magic.py (__license__): change to absolute imports of
2944 2951 ipython's own internal packages, to start adapting to the absolute
2945 2952 import requirement of PEP-328.
2946 2953
2947 2954 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2948 2955 files, and standardize author/license marks through the Release
2949 2956 module instead of having per/file stuff (except for files with
2950 2957 particular licenses, like the MIT/PSF-licensed codes).
2951 2958
2952 2959 * IPython/Debugger.py: remove dead code for python 2.1
2953 2960
2954 2961 2004-10-04 Fernando Perez <fperez@colorado.edu>
2955 2962
2956 2963 * IPython/iplib.py (ipmagic): New function for accessing magics
2957 2964 via a normal python function call.
2958 2965
2959 2966 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2960 2967 from '@' to '%', to accomodate the new @decorator syntax of python
2961 2968 2.4.
2962 2969
2963 2970 2004-09-29 Fernando Perez <fperez@colorado.edu>
2964 2971
2965 2972 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2966 2973 matplotlib.use to prevent running scripts which try to switch
2967 2974 interactive backends from within ipython. This will just crash
2968 2975 the python interpreter, so we can't allow it (but a detailed error
2969 2976 is given to the user).
2970 2977
2971 2978 2004-09-28 Fernando Perez <fperez@colorado.edu>
2972 2979
2973 2980 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2974 2981 matplotlib-related fixes so that using @run with non-matplotlib
2975 2982 scripts doesn't pop up spurious plot windows. This requires
2976 2983 matplotlib >= 0.63, where I had to make some changes as well.
2977 2984
2978 2985 * IPython/ipmaker.py (make_IPython): update version requirement to
2979 2986 python 2.2.
2980 2987
2981 2988 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2982 2989 banner arg for embedded customization.
2983 2990
2984 2991 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2985 2992 explicit uses of __IP as the IPython's instance name. Now things
2986 2993 are properly handled via the shell.name value. The actual code
2987 2994 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2988 2995 is much better than before. I'll clean things completely when the
2989 2996 magic stuff gets a real overhaul.
2990 2997
2991 2998 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2992 2999 minor changes to debian dir.
2993 3000
2994 3001 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2995 3002 pointer to the shell itself in the interactive namespace even when
2996 3003 a user-supplied dict is provided. This is needed for embedding
2997 3004 purposes (found by tests with Michel Sanner).
2998 3005
2999 3006 2004-09-27 Fernando Perez <fperez@colorado.edu>
3000 3007
3001 3008 * IPython/UserConfig/ipythonrc: remove []{} from
3002 3009 readline_remove_delims, so that things like [modname.<TAB> do
3003 3010 proper completion. This disables [].TAB, but that's a less common
3004 3011 case than module names in list comprehensions, for example.
3005 3012 Thanks to a report by Andrea Riciputi.
3006 3013
3007 3014 2004-09-09 Fernando Perez <fperez@colorado.edu>
3008 3015
3009 3016 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3010 3017 blocking problems in win32 and osx. Fix by John.
3011 3018
3012 3019 2004-09-08 Fernando Perez <fperez@colorado.edu>
3013 3020
3014 3021 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3015 3022 for Win32 and OSX. Fix by John Hunter.
3016 3023
3017 3024 2004-08-30 *** Released version 0.6.3
3018 3025
3019 3026 2004-08-30 Fernando Perez <fperez@colorado.edu>
3020 3027
3021 3028 * setup.py (isfile): Add manpages to list of dependent files to be
3022 3029 updated.
3023 3030
3024 3031 2004-08-27 Fernando Perez <fperez@colorado.edu>
3025 3032
3026 3033 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3027 3034 for now. They don't really work with standalone WX/GTK code
3028 3035 (though matplotlib IS working fine with both of those backends).
3029 3036 This will neeed much more testing. I disabled most things with
3030 3037 comments, so turning it back on later should be pretty easy.
3031 3038
3032 3039 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3033 3040 autocalling of expressions like r'foo', by modifying the line
3034 3041 split regexp. Closes
3035 3042 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3036 3043 Riley <ipythonbugs-AT-sabi.net>.
3037 3044 (InteractiveShell.mainloop): honor --nobanner with banner
3038 3045 extensions.
3039 3046
3040 3047 * IPython/Shell.py: Significant refactoring of all classes, so
3041 3048 that we can really support ALL matplotlib backends and threading
3042 3049 models (John spotted a bug with Tk which required this). Now we
3043 3050 should support single-threaded, WX-threads and GTK-threads, both
3044 3051 for generic code and for matplotlib.
3045 3052
3046 3053 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3047 3054 -pylab, to simplify things for users. Will also remove the pylab
3048 3055 profile, since now all of matplotlib configuration is directly
3049 3056 handled here. This also reduces startup time.
3050 3057
3051 3058 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3052 3059 shell wasn't being correctly called. Also in IPShellWX.
3053 3060
3054 3061 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3055 3062 fine-tune banner.
3056 3063
3057 3064 * IPython/numutils.py (spike): Deprecate these spike functions,
3058 3065 delete (long deprecated) gnuplot_exec handler.
3059 3066
3060 3067 2004-08-26 Fernando Perez <fperez@colorado.edu>
3061 3068
3062 3069 * ipython.1: Update for threading options, plus some others which
3063 3070 were missing.
3064 3071
3065 3072 * IPython/ipmaker.py (__call__): Added -wthread option for
3066 3073 wxpython thread handling. Make sure threading options are only
3067 3074 valid at the command line.
3068 3075
3069 3076 * scripts/ipython: moved shell selection into a factory function
3070 3077 in Shell.py, to keep the starter script to a minimum.
3071 3078
3072 3079 2004-08-25 Fernando Perez <fperez@colorado.edu>
3073 3080
3074 3081 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3075 3082 John. Along with some recent changes he made to matplotlib, the
3076 3083 next versions of both systems should work very well together.
3077 3084
3078 3085 2004-08-24 Fernando Perez <fperez@colorado.edu>
3079 3086
3080 3087 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3081 3088 tried to switch the profiling to using hotshot, but I'm getting
3082 3089 strange errors from prof.runctx() there. I may be misreading the
3083 3090 docs, but it looks weird. For now the profiling code will
3084 3091 continue to use the standard profiler.
3085 3092
3086 3093 2004-08-23 Fernando Perez <fperez@colorado.edu>
3087 3094
3088 3095 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3089 3096 threaded shell, by John Hunter. It's not quite ready yet, but
3090 3097 close.
3091 3098
3092 3099 2004-08-22 Fernando Perez <fperez@colorado.edu>
3093 3100
3094 3101 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3095 3102 in Magic and ultraTB.
3096 3103
3097 3104 * ipython.1: document threading options in manpage.
3098 3105
3099 3106 * scripts/ipython: Changed name of -thread option to -gthread,
3100 3107 since this is GTK specific. I want to leave the door open for a
3101 3108 -wthread option for WX, which will most likely be necessary. This
3102 3109 change affects usage and ipmaker as well.
3103 3110
3104 3111 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3105 3112 handle the matplotlib shell issues. Code by John Hunter
3106 3113 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3107 3114 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3108 3115 broken (and disabled for end users) for now, but it puts the
3109 3116 infrastructure in place.
3110 3117
3111 3118 2004-08-21 Fernando Perez <fperez@colorado.edu>
3112 3119
3113 3120 * ipythonrc-pylab: Add matplotlib support.
3114 3121
3115 3122 * matplotlib_config.py: new files for matplotlib support, part of
3116 3123 the pylab profile.
3117 3124
3118 3125 * IPython/usage.py (__doc__): documented the threading options.
3119 3126
3120 3127 2004-08-20 Fernando Perez <fperez@colorado.edu>
3121 3128
3122 3129 * ipython: Modified the main calling routine to handle the -thread
3123 3130 and -mpthread options. This needs to be done as a top-level hack,
3124 3131 because it determines which class to instantiate for IPython
3125 3132 itself.
3126 3133
3127 3134 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3128 3135 classes to support multithreaded GTK operation without blocking,
3129 3136 and matplotlib with all backends. This is a lot of still very
3130 3137 experimental code, and threads are tricky. So it may still have a
3131 3138 few rough edges... This code owes a lot to
3132 3139 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3133 3140 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3134 3141 to John Hunter for all the matplotlib work.
3135 3142
3136 3143 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3137 3144 options for gtk thread and matplotlib support.
3138 3145
3139 3146 2004-08-16 Fernando Perez <fperez@colorado.edu>
3140 3147
3141 3148 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3142 3149 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3143 3150 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3144 3151
3145 3152 2004-08-11 Fernando Perez <fperez@colorado.edu>
3146 3153
3147 3154 * setup.py (isfile): Fix build so documentation gets updated for
3148 3155 rpms (it was only done for .tgz builds).
3149 3156
3150 3157 2004-08-10 Fernando Perez <fperez@colorado.edu>
3151 3158
3152 3159 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3153 3160
3154 3161 * iplib.py : Silence syntax error exceptions in tab-completion.
3155 3162
3156 3163 2004-08-05 Fernando Perez <fperez@colorado.edu>
3157 3164
3158 3165 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3159 3166 'color off' mark for continuation prompts. This was causing long
3160 3167 continuation lines to mis-wrap.
3161 3168
3162 3169 2004-08-01 Fernando Perez <fperez@colorado.edu>
3163 3170
3164 3171 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3165 3172 for building ipython to be a parameter. All this is necessary
3166 3173 right now to have a multithreaded version, but this insane
3167 3174 non-design will be cleaned up soon. For now, it's a hack that
3168 3175 works.
3169 3176
3170 3177 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3171 3178 args in various places. No bugs so far, but it's a dangerous
3172 3179 practice.
3173 3180
3174 3181 2004-07-31 Fernando Perez <fperez@colorado.edu>
3175 3182
3176 3183 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3177 3184 fix completion of files with dots in their names under most
3178 3185 profiles (pysh was OK because the completion order is different).
3179 3186
3180 3187 2004-07-27 Fernando Perez <fperez@colorado.edu>
3181 3188
3182 3189 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3183 3190 keywords manually, b/c the one in keyword.py was removed in python
3184 3191 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3185 3192 This is NOT a bug under python 2.3 and earlier.
3186 3193
3187 3194 2004-07-26 Fernando Perez <fperez@colorado.edu>
3188 3195
3189 3196 * IPython/ultraTB.py (VerboseTB.text): Add another
3190 3197 linecache.checkcache() call to try to prevent inspect.py from
3191 3198 crashing under python 2.3. I think this fixes
3192 3199 http://www.scipy.net/roundup/ipython/issue17.
3193 3200
3194 3201 2004-07-26 *** Released version 0.6.2
3195 3202
3196 3203 2004-07-26 Fernando Perez <fperez@colorado.edu>
3197 3204
3198 3205 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3199 3206 fail for any number.
3200 3207 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3201 3208 empty bookmarks.
3202 3209
3203 3210 2004-07-26 *** Released version 0.6.1
3204 3211
3205 3212 2004-07-26 Fernando Perez <fperez@colorado.edu>
3206 3213
3207 3214 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3208 3215
3209 3216 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3210 3217 escaping '()[]{}' in filenames.
3211 3218
3212 3219 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3213 3220 Python 2.2 users who lack a proper shlex.split.
3214 3221
3215 3222 2004-07-19 Fernando Perez <fperez@colorado.edu>
3216 3223
3217 3224 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3218 3225 for reading readline's init file. I follow the normal chain:
3219 3226 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3220 3227 report by Mike Heeter. This closes
3221 3228 http://www.scipy.net/roundup/ipython/issue16.
3222 3229
3223 3230 2004-07-18 Fernando Perez <fperez@colorado.edu>
3224 3231
3225 3232 * IPython/iplib.py (__init__): Add better handling of '\' under
3226 3233 Win32 for filenames. After a patch by Ville.
3227 3234
3228 3235 2004-07-17 Fernando Perez <fperez@colorado.edu>
3229 3236
3230 3237 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3231 3238 autocalling would be triggered for 'foo is bar' if foo is
3232 3239 callable. I also cleaned up the autocall detection code to use a
3233 3240 regexp, which is faster. Bug reported by Alexander Schmolck.
3234 3241
3235 3242 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3236 3243 '?' in them would confuse the help system. Reported by Alex
3237 3244 Schmolck.
3238 3245
3239 3246 2004-07-16 Fernando Perez <fperez@colorado.edu>
3240 3247
3241 3248 * IPython/GnuplotInteractive.py (__all__): added plot2.
3242 3249
3243 3250 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3244 3251 plotting dictionaries, lists or tuples of 1d arrays.
3245 3252
3246 3253 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3247 3254 optimizations.
3248 3255
3249 3256 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3250 3257 the information which was there from Janko's original IPP code:
3251 3258
3252 3259 03.05.99 20:53 porto.ifm.uni-kiel.de
3253 3260 --Started changelog.
3254 3261 --make clear do what it say it does
3255 3262 --added pretty output of lines from inputcache
3256 3263 --Made Logger a mixin class, simplifies handling of switches
3257 3264 --Added own completer class. .string<TAB> expands to last history
3258 3265 line which starts with string. The new expansion is also present
3259 3266 with Ctrl-r from the readline library. But this shows, who this
3260 3267 can be done for other cases.
3261 3268 --Added convention that all shell functions should accept a
3262 3269 parameter_string This opens the door for different behaviour for
3263 3270 each function. @cd is a good example of this.
3264 3271
3265 3272 04.05.99 12:12 porto.ifm.uni-kiel.de
3266 3273 --added logfile rotation
3267 3274 --added new mainloop method which freezes first the namespace
3268 3275
3269 3276 07.05.99 21:24 porto.ifm.uni-kiel.de
3270 3277 --added the docreader classes. Now there is a help system.
3271 3278 -This is only a first try. Currently it's not easy to put new
3272 3279 stuff in the indices. But this is the way to go. Info would be
3273 3280 better, but HTML is every where and not everybody has an info
3274 3281 system installed and it's not so easy to change html-docs to info.
3275 3282 --added global logfile option
3276 3283 --there is now a hook for object inspection method pinfo needs to
3277 3284 be provided for this. Can be reached by two '??'.
3278 3285
3279 3286 08.05.99 20:51 porto.ifm.uni-kiel.de
3280 3287 --added a README
3281 3288 --bug in rc file. Something has changed so functions in the rc
3282 3289 file need to reference the shell and not self. Not clear if it's a
3283 3290 bug or feature.
3284 3291 --changed rc file for new behavior
3285 3292
3286 3293 2004-07-15 Fernando Perez <fperez@colorado.edu>
3287 3294
3288 3295 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3289 3296 cache was falling out of sync in bizarre manners when multi-line
3290 3297 input was present. Minor optimizations and cleanup.
3291 3298
3292 3299 (Logger): Remove old Changelog info for cleanup. This is the
3293 3300 information which was there from Janko's original code:
3294 3301
3295 3302 Changes to Logger: - made the default log filename a parameter
3296 3303
3297 3304 - put a check for lines beginning with !@? in log(). Needed
3298 3305 (even if the handlers properly log their lines) for mid-session
3299 3306 logging activation to work properly. Without this, lines logged
3300 3307 in mid session, which get read from the cache, would end up
3301 3308 'bare' (with !@? in the open) in the log. Now they are caught
3302 3309 and prepended with a #.
3303 3310
3304 3311 * IPython/iplib.py (InteractiveShell.init_readline): added check
3305 3312 in case MagicCompleter fails to be defined, so we don't crash.
3306 3313
3307 3314 2004-07-13 Fernando Perez <fperez@colorado.edu>
3308 3315
3309 3316 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3310 3317 of EPS if the requested filename ends in '.eps'.
3311 3318
3312 3319 2004-07-04 Fernando Perez <fperez@colorado.edu>
3313 3320
3314 3321 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3315 3322 escaping of quotes when calling the shell.
3316 3323
3317 3324 2004-07-02 Fernando Perez <fperez@colorado.edu>
3318 3325
3319 3326 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3320 3327 gettext not working because we were clobbering '_'. Fixes
3321 3328 http://www.scipy.net/roundup/ipython/issue6.
3322 3329
3323 3330 2004-07-01 Fernando Perez <fperez@colorado.edu>
3324 3331
3325 3332 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3326 3333 into @cd. Patch by Ville.
3327 3334
3328 3335 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3329 3336 new function to store things after ipmaker runs. Patch by Ville.
3330 3337 Eventually this will go away once ipmaker is removed and the class
3331 3338 gets cleaned up, but for now it's ok. Key functionality here is
3332 3339 the addition of the persistent storage mechanism, a dict for
3333 3340 keeping data across sessions (for now just bookmarks, but more can
3334 3341 be implemented later).
3335 3342
3336 3343 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3337 3344 persistent across sections. Patch by Ville, I modified it
3338 3345 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3339 3346 added a '-l' option to list all bookmarks.
3340 3347
3341 3348 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3342 3349 center for cleanup. Registered with atexit.register(). I moved
3343 3350 here the old exit_cleanup(). After a patch by Ville.
3344 3351
3345 3352 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3346 3353 characters in the hacked shlex_split for python 2.2.
3347 3354
3348 3355 * IPython/iplib.py (file_matches): more fixes to filenames with
3349 3356 whitespace in them. It's not perfect, but limitations in python's
3350 3357 readline make it impossible to go further.
3351 3358
3352 3359 2004-06-29 Fernando Perez <fperez@colorado.edu>
3353 3360
3354 3361 * IPython/iplib.py (file_matches): escape whitespace correctly in
3355 3362 filename completions. Bug reported by Ville.
3356 3363
3357 3364 2004-06-28 Fernando Perez <fperez@colorado.edu>
3358 3365
3359 3366 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3360 3367 the history file will be called 'history-PROFNAME' (or just
3361 3368 'history' if no profile is loaded). I was getting annoyed at
3362 3369 getting my Numerical work history clobbered by pysh sessions.
3363 3370
3364 3371 * IPython/iplib.py (InteractiveShell.__init__): Internal
3365 3372 getoutputerror() function so that we can honor the system_verbose
3366 3373 flag for _all_ system calls. I also added escaping of #
3367 3374 characters here to avoid confusing Itpl.
3368 3375
3369 3376 * IPython/Magic.py (shlex_split): removed call to shell in
3370 3377 parse_options and replaced it with shlex.split(). The annoying
3371 3378 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3372 3379 to backport it from 2.3, with several frail hacks (the shlex
3373 3380 module is rather limited in 2.2). Thanks to a suggestion by Ville
3374 3381 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3375 3382 problem.
3376 3383
3377 3384 (Magic.magic_system_verbose): new toggle to print the actual
3378 3385 system calls made by ipython. Mainly for debugging purposes.
3379 3386
3380 3387 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3381 3388 doesn't support persistence. Reported (and fix suggested) by
3382 3389 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3383 3390
3384 3391 2004-06-26 Fernando Perez <fperez@colorado.edu>
3385 3392
3386 3393 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3387 3394 continue prompts.
3388 3395
3389 3396 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3390 3397 function (basically a big docstring) and a few more things here to
3391 3398 speedup startup. pysh.py is now very lightweight. We want because
3392 3399 it gets execfile'd, while InterpreterExec gets imported, so
3393 3400 byte-compilation saves time.
3394 3401
3395 3402 2004-06-25 Fernando Perez <fperez@colorado.edu>
3396 3403
3397 3404 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3398 3405 -NUM', which was recently broken.
3399 3406
3400 3407 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3401 3408 in multi-line input (but not !!, which doesn't make sense there).
3402 3409
3403 3410 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3404 3411 It's just too useful, and people can turn it off in the less
3405 3412 common cases where it's a problem.
3406 3413
3407 3414 2004-06-24 Fernando Perez <fperez@colorado.edu>
3408 3415
3409 3416 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3410 3417 special syntaxes (like alias calling) is now allied in multi-line
3411 3418 input. This is still _very_ experimental, but it's necessary for
3412 3419 efficient shell usage combining python looping syntax with system
3413 3420 calls. For now it's restricted to aliases, I don't think it
3414 3421 really even makes sense to have this for magics.
3415 3422
3416 3423 2004-06-23 Fernando Perez <fperez@colorado.edu>
3417 3424
3418 3425 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3419 3426 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3420 3427
3421 3428 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3422 3429 extensions under Windows (after code sent by Gary Bishop). The
3423 3430 extensions considered 'executable' are stored in IPython's rc
3424 3431 structure as win_exec_ext.
3425 3432
3426 3433 * IPython/genutils.py (shell): new function, like system() but
3427 3434 without return value. Very useful for interactive shell work.
3428 3435
3429 3436 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3430 3437 delete aliases.
3431 3438
3432 3439 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3433 3440 sure that the alias table doesn't contain python keywords.
3434 3441
3435 3442 2004-06-21 Fernando Perez <fperez@colorado.edu>
3436 3443
3437 3444 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3438 3445 non-existent items are found in $PATH. Reported by Thorsten.
3439 3446
3440 3447 2004-06-20 Fernando Perez <fperez@colorado.edu>
3441 3448
3442 3449 * IPython/iplib.py (complete): modified the completer so that the
3443 3450 order of priorities can be easily changed at runtime.
3444 3451
3445 3452 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3446 3453 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3447 3454
3448 3455 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3449 3456 expand Python variables prepended with $ in all system calls. The
3450 3457 same was done to InteractiveShell.handle_shell_escape. Now all
3451 3458 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3452 3459 expansion of python variables and expressions according to the
3453 3460 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3454 3461
3455 3462 Though PEP-215 has been rejected, a similar (but simpler) one
3456 3463 seems like it will go into Python 2.4, PEP-292 -
3457 3464 http://www.python.org/peps/pep-0292.html.
3458 3465
3459 3466 I'll keep the full syntax of PEP-215, since IPython has since the
3460 3467 start used Ka-Ping Yee's reference implementation discussed there
3461 3468 (Itpl), and I actually like the powerful semantics it offers.
3462 3469
3463 3470 In order to access normal shell variables, the $ has to be escaped
3464 3471 via an extra $. For example:
3465 3472
3466 3473 In [7]: PATH='a python variable'
3467 3474
3468 3475 In [8]: !echo $PATH
3469 3476 a python variable
3470 3477
3471 3478 In [9]: !echo $$PATH
3472 3479 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3473 3480
3474 3481 (Magic.parse_options): escape $ so the shell doesn't evaluate
3475 3482 things prematurely.
3476 3483
3477 3484 * IPython/iplib.py (InteractiveShell.call_alias): added the
3478 3485 ability for aliases to expand python variables via $.
3479 3486
3480 3487 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3481 3488 system, now there's a @rehash/@rehashx pair of magics. These work
3482 3489 like the csh rehash command, and can be invoked at any time. They
3483 3490 build a table of aliases to everything in the user's $PATH
3484 3491 (@rehash uses everything, @rehashx is slower but only adds
3485 3492 executable files). With this, the pysh.py-based shell profile can
3486 3493 now simply call rehash upon startup, and full access to all
3487 3494 programs in the user's path is obtained.
3488 3495
3489 3496 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3490 3497 functionality is now fully in place. I removed the old dynamic
3491 3498 code generation based approach, in favor of a much lighter one
3492 3499 based on a simple dict. The advantage is that this allows me to
3493 3500 now have thousands of aliases with negligible cost (unthinkable
3494 3501 with the old system).
3495 3502
3496 3503 2004-06-19 Fernando Perez <fperez@colorado.edu>
3497 3504
3498 3505 * IPython/iplib.py (__init__): extended MagicCompleter class to
3499 3506 also complete (last in priority) on user aliases.
3500 3507
3501 3508 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3502 3509 call to eval.
3503 3510 (ItplNS.__init__): Added a new class which functions like Itpl,
3504 3511 but allows configuring the namespace for the evaluation to occur
3505 3512 in.
3506 3513
3507 3514 2004-06-18 Fernando Perez <fperez@colorado.edu>
3508 3515
3509 3516 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3510 3517 better message when 'exit' or 'quit' are typed (a common newbie
3511 3518 confusion).
3512 3519
3513 3520 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3514 3521 check for Windows users.
3515 3522
3516 3523 * IPython/iplib.py (InteractiveShell.user_setup): removed
3517 3524 disabling of colors for Windows. I'll test at runtime and issue a
3518 3525 warning if Gary's readline isn't found, as to nudge users to
3519 3526 download it.
3520 3527
3521 3528 2004-06-16 Fernando Perez <fperez@colorado.edu>
3522 3529
3523 3530 * IPython/genutils.py (Stream.__init__): changed to print errors
3524 3531 to sys.stderr. I had a circular dependency here. Now it's
3525 3532 possible to run ipython as IDLE's shell (consider this pre-alpha,
3526 3533 since true stdout things end up in the starting terminal instead
3527 3534 of IDLE's out).
3528 3535
3529 3536 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3530 3537 users who haven't # updated their prompt_in2 definitions. Remove
3531 3538 eventually.
3532 3539 (multiple_replace): added credit to original ASPN recipe.
3533 3540
3534 3541 2004-06-15 Fernando Perez <fperez@colorado.edu>
3535 3542
3536 3543 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3537 3544 list of auto-defined aliases.
3538 3545
3539 3546 2004-06-13 Fernando Perez <fperez@colorado.edu>
3540 3547
3541 3548 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3542 3549 install was really requested (so setup.py can be used for other
3543 3550 things under Windows).
3544 3551
3545 3552 2004-06-10 Fernando Perez <fperez@colorado.edu>
3546 3553
3547 3554 * IPython/Logger.py (Logger.create_log): Manually remove any old
3548 3555 backup, since os.remove may fail under Windows. Fixes bug
3549 3556 reported by Thorsten.
3550 3557
3551 3558 2004-06-09 Fernando Perez <fperez@colorado.edu>
3552 3559
3553 3560 * examples/example-embed.py: fixed all references to %n (replaced
3554 3561 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3555 3562 for all examples and the manual as well.
3556 3563
3557 3564 2004-06-08 Fernando Perez <fperez@colorado.edu>
3558 3565
3559 3566 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3560 3567 alignment and color management. All 3 prompt subsystems now
3561 3568 inherit from BasePrompt.
3562 3569
3563 3570 * tools/release: updates for windows installer build and tag rpms
3564 3571 with python version (since paths are fixed).
3565 3572
3566 3573 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3567 3574 which will become eventually obsolete. Also fixed the default
3568 3575 prompt_in2 to use \D, so at least new users start with the correct
3569 3576 defaults.
3570 3577 WARNING: Users with existing ipythonrc files will need to apply
3571 3578 this fix manually!
3572 3579
3573 3580 * setup.py: make windows installer (.exe). This is finally the
3574 3581 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3575 3582 which I hadn't included because it required Python 2.3 (or recent
3576 3583 distutils).
3577 3584
3578 3585 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3579 3586 usage of new '\D' escape.
3580 3587
3581 3588 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3582 3589 lacks os.getuid())
3583 3590 (CachedOutput.set_colors): Added the ability to turn coloring
3584 3591 on/off with @colors even for manually defined prompt colors. It
3585 3592 uses a nasty global, but it works safely and via the generic color
3586 3593 handling mechanism.
3587 3594 (Prompt2.__init__): Introduced new escape '\D' for continuation
3588 3595 prompts. It represents the counter ('\#') as dots.
3589 3596 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3590 3597 need to update their ipythonrc files and replace '%n' with '\D' in
3591 3598 their prompt_in2 settings everywhere. Sorry, but there's
3592 3599 otherwise no clean way to get all prompts to properly align. The
3593 3600 ipythonrc shipped with IPython has been updated.
3594 3601
3595 3602 2004-06-07 Fernando Perez <fperez@colorado.edu>
3596 3603
3597 3604 * setup.py (isfile): Pass local_icons option to latex2html, so the
3598 3605 resulting HTML file is self-contained. Thanks to
3599 3606 dryice-AT-liu.com.cn for the tip.
3600 3607
3601 3608 * pysh.py: I created a new profile 'shell', which implements a
3602 3609 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3603 3610 system shell, nor will it become one anytime soon. It's mainly
3604 3611 meant to illustrate the use of the new flexible bash-like prompts.
3605 3612 I guess it could be used by hardy souls for true shell management,
3606 3613 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3607 3614 profile. This uses the InterpreterExec extension provided by
3608 3615 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3609 3616
3610 3617 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3611 3618 auto-align itself with the length of the previous input prompt
3612 3619 (taking into account the invisible color escapes).
3613 3620 (CachedOutput.__init__): Large restructuring of this class. Now
3614 3621 all three prompts (primary1, primary2, output) are proper objects,
3615 3622 managed by the 'parent' CachedOutput class. The code is still a
3616 3623 bit hackish (all prompts share state via a pointer to the cache),
3617 3624 but it's overall far cleaner than before.
3618 3625
3619 3626 * IPython/genutils.py (getoutputerror): modified to add verbose,
3620 3627 debug and header options. This makes the interface of all getout*
3621 3628 functions uniform.
3622 3629 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3623 3630
3624 3631 * IPython/Magic.py (Magic.default_option): added a function to
3625 3632 allow registering default options for any magic command. This
3626 3633 makes it easy to have profiles which customize the magics globally
3627 3634 for a certain use. The values set through this function are
3628 3635 picked up by the parse_options() method, which all magics should
3629 3636 use to parse their options.
3630 3637
3631 3638 * IPython/genutils.py (warn): modified the warnings framework to
3632 3639 use the Term I/O class. I'm trying to slowly unify all of
3633 3640 IPython's I/O operations to pass through Term.
3634 3641
3635 3642 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3636 3643 the secondary prompt to correctly match the length of the primary
3637 3644 one for any prompt. Now multi-line code will properly line up
3638 3645 even for path dependent prompts, such as the new ones available
3639 3646 via the prompt_specials.
3640 3647
3641 3648 2004-06-06 Fernando Perez <fperez@colorado.edu>
3642 3649
3643 3650 * IPython/Prompts.py (prompt_specials): Added the ability to have
3644 3651 bash-like special sequences in the prompts, which get
3645 3652 automatically expanded. Things like hostname, current working
3646 3653 directory and username are implemented already, but it's easy to
3647 3654 add more in the future. Thanks to a patch by W.J. van der Laan
3648 3655 <gnufnork-AT-hetdigitalegat.nl>
3649 3656 (prompt_specials): Added color support for prompt strings, so
3650 3657 users can define arbitrary color setups for their prompts.
3651 3658
3652 3659 2004-06-05 Fernando Perez <fperez@colorado.edu>
3653 3660
3654 3661 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3655 3662 code to load Gary Bishop's readline and configure it
3656 3663 automatically. Thanks to Gary for help on this.
3657 3664
3658 3665 2004-06-01 Fernando Perez <fperez@colorado.edu>
3659 3666
3660 3667 * IPython/Logger.py (Logger.create_log): fix bug for logging
3661 3668 with no filename (previous fix was incomplete).
3662 3669
3663 3670 2004-05-25 Fernando Perez <fperez@colorado.edu>
3664 3671
3665 3672 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3666 3673 parens would get passed to the shell.
3667 3674
3668 3675 2004-05-20 Fernando Perez <fperez@colorado.edu>
3669 3676
3670 3677 * IPython/Magic.py (Magic.magic_prun): changed default profile
3671 3678 sort order to 'time' (the more common profiling need).
3672 3679
3673 3680 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3674 3681 so that source code shown is guaranteed in sync with the file on
3675 3682 disk (also changed in psource). Similar fix to the one for
3676 3683 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3677 3684 <yann.ledu-AT-noos.fr>.
3678 3685
3679 3686 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3680 3687 with a single option would not be correctly parsed. Closes
3681 3688 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3682 3689 introduced in 0.6.0 (on 2004-05-06).
3683 3690
3684 3691 2004-05-13 *** Released version 0.6.0
3685 3692
3686 3693 2004-05-13 Fernando Perez <fperez@colorado.edu>
3687 3694
3688 3695 * debian/: Added debian/ directory to CVS, so that debian support
3689 3696 is publicly accessible. The debian package is maintained by Jack
3690 3697 Moffit <jack-AT-xiph.org>.
3691 3698
3692 3699 * Documentation: included the notes about an ipython-based system
3693 3700 shell (the hypothetical 'pysh') into the new_design.pdf document,
3694 3701 so that these ideas get distributed to users along with the
3695 3702 official documentation.
3696 3703
3697 3704 2004-05-10 Fernando Perez <fperez@colorado.edu>
3698 3705
3699 3706 * IPython/Logger.py (Logger.create_log): fix recently introduced
3700 3707 bug (misindented line) where logstart would fail when not given an
3701 3708 explicit filename.
3702 3709
3703 3710 2004-05-09 Fernando Perez <fperez@colorado.edu>
3704 3711
3705 3712 * IPython/Magic.py (Magic.parse_options): skip system call when
3706 3713 there are no options to look for. Faster, cleaner for the common
3707 3714 case.
3708 3715
3709 3716 * Documentation: many updates to the manual: describing Windows
3710 3717 support better, Gnuplot updates, credits, misc small stuff. Also
3711 3718 updated the new_design doc a bit.
3712 3719
3713 3720 2004-05-06 *** Released version 0.6.0.rc1
3714 3721
3715 3722 2004-05-06 Fernando Perez <fperez@colorado.edu>
3716 3723
3717 3724 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3718 3725 operations to use the vastly more efficient list/''.join() method.
3719 3726 (FormattedTB.text): Fix
3720 3727 http://www.scipy.net/roundup/ipython/issue12 - exception source
3721 3728 extract not updated after reload. Thanks to Mike Salib
3722 3729 <msalib-AT-mit.edu> for pinning the source of the problem.
3723 3730 Fortunately, the solution works inside ipython and doesn't require
3724 3731 any changes to python proper.
3725 3732
3726 3733 * IPython/Magic.py (Magic.parse_options): Improved to process the
3727 3734 argument list as a true shell would (by actually using the
3728 3735 underlying system shell). This way, all @magics automatically get
3729 3736 shell expansion for variables. Thanks to a comment by Alex
3730 3737 Schmolck.
3731 3738
3732 3739 2004-04-04 Fernando Perez <fperez@colorado.edu>
3733 3740
3734 3741 * IPython/iplib.py (InteractiveShell.interact): Added a special
3735 3742 trap for a debugger quit exception, which is basically impossible
3736 3743 to handle by normal mechanisms, given what pdb does to the stack.
3737 3744 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3738 3745
3739 3746 2004-04-03 Fernando Perez <fperez@colorado.edu>
3740 3747
3741 3748 * IPython/genutils.py (Term): Standardized the names of the Term
3742 3749 class streams to cin/cout/cerr, following C++ naming conventions
3743 3750 (I can't use in/out/err because 'in' is not a valid attribute
3744 3751 name).
3745 3752
3746 3753 * IPython/iplib.py (InteractiveShell.interact): don't increment
3747 3754 the prompt if there's no user input. By Daniel 'Dang' Griffith
3748 3755 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3749 3756 Francois Pinard.
3750 3757
3751 3758 2004-04-02 Fernando Perez <fperez@colorado.edu>
3752 3759
3753 3760 * IPython/genutils.py (Stream.__init__): Modified to survive at
3754 3761 least importing in contexts where stdin/out/err aren't true file
3755 3762 objects, such as PyCrust (they lack fileno() and mode). However,
3756 3763 the recovery facilities which rely on these things existing will
3757 3764 not work.
3758 3765
3759 3766 2004-04-01 Fernando Perez <fperez@colorado.edu>
3760 3767
3761 3768 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3762 3769 use the new getoutputerror() function, so it properly
3763 3770 distinguishes stdout/err.
3764 3771
3765 3772 * IPython/genutils.py (getoutputerror): added a function to
3766 3773 capture separately the standard output and error of a command.
3767 3774 After a comment from dang on the mailing lists. This code is
3768 3775 basically a modified version of commands.getstatusoutput(), from
3769 3776 the standard library.
3770 3777
3771 3778 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3772 3779 '!!' as a special syntax (shorthand) to access @sx.
3773 3780
3774 3781 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3775 3782 command and return its output as a list split on '\n'.
3776 3783
3777 3784 2004-03-31 Fernando Perez <fperez@colorado.edu>
3778 3785
3779 3786 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3780 3787 method to dictionaries used as FakeModule instances if they lack
3781 3788 it. At least pydoc in python2.3 breaks for runtime-defined
3782 3789 functions without this hack. At some point I need to _really_
3783 3790 understand what FakeModule is doing, because it's a gross hack.
3784 3791 But it solves Arnd's problem for now...
3785 3792
3786 3793 2004-02-27 Fernando Perez <fperez@colorado.edu>
3787 3794
3788 3795 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3789 3796 mode would behave erratically. Also increased the number of
3790 3797 possible logs in rotate mod to 999. Thanks to Rod Holland
3791 3798 <rhh@StructureLABS.com> for the report and fixes.
3792 3799
3793 3800 2004-02-26 Fernando Perez <fperez@colorado.edu>
3794 3801
3795 3802 * IPython/genutils.py (page): Check that the curses module really
3796 3803 has the initscr attribute before trying to use it. For some
3797 3804 reason, the Solaris curses module is missing this. I think this
3798 3805 should be considered a Solaris python bug, but I'm not sure.
3799 3806
3800 3807 2004-01-17 Fernando Perez <fperez@colorado.edu>
3801 3808
3802 3809 * IPython/genutils.py (Stream.__init__): Changes to try to make
3803 3810 ipython robust against stdin/out/err being closed by the user.
3804 3811 This is 'user error' (and blocks a normal python session, at least
3805 3812 the stdout case). However, Ipython should be able to survive such
3806 3813 instances of abuse as gracefully as possible. To simplify the
3807 3814 coding and maintain compatibility with Gary Bishop's Term
3808 3815 contributions, I've made use of classmethods for this. I think
3809 3816 this introduces a dependency on python 2.2.
3810 3817
3811 3818 2004-01-13 Fernando Perez <fperez@colorado.edu>
3812 3819
3813 3820 * IPython/numutils.py (exp_safe): simplified the code a bit and
3814 3821 removed the need for importing the kinds module altogether.
3815 3822
3816 3823 2004-01-06 Fernando Perez <fperez@colorado.edu>
3817 3824
3818 3825 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3819 3826 a magic function instead, after some community feedback. No
3820 3827 special syntax will exist for it, but its name is deliberately
3821 3828 very short.
3822 3829
3823 3830 2003-12-20 Fernando Perez <fperez@colorado.edu>
3824 3831
3825 3832 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3826 3833 new functionality, to automagically assign the result of a shell
3827 3834 command to a variable. I'll solicit some community feedback on
3828 3835 this before making it permanent.
3829 3836
3830 3837 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3831 3838 requested about callables for which inspect couldn't obtain a
3832 3839 proper argspec. Thanks to a crash report sent by Etienne
3833 3840 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3834 3841
3835 3842 2003-12-09 Fernando Perez <fperez@colorado.edu>
3836 3843
3837 3844 * IPython/genutils.py (page): patch for the pager to work across
3838 3845 various versions of Windows. By Gary Bishop.
3839 3846
3840 3847 2003-12-04 Fernando Perez <fperez@colorado.edu>
3841 3848
3842 3849 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3843 3850 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3844 3851 While I tested this and it looks ok, there may still be corner
3845 3852 cases I've missed.
3846 3853
3847 3854 2003-12-01 Fernando Perez <fperez@colorado.edu>
3848 3855
3849 3856 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3850 3857 where a line like 'p,q=1,2' would fail because the automagic
3851 3858 system would be triggered for @p.
3852 3859
3853 3860 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3854 3861 cleanups, code unmodified.
3855 3862
3856 3863 * IPython/genutils.py (Term): added a class for IPython to handle
3857 3864 output. In most cases it will just be a proxy for stdout/err, but
3858 3865 having this allows modifications to be made for some platforms,
3859 3866 such as handling color escapes under Windows. All of this code
3860 3867 was contributed by Gary Bishop, with minor modifications by me.
3861 3868 The actual changes affect many files.
3862 3869
3863 3870 2003-11-30 Fernando Perez <fperez@colorado.edu>
3864 3871
3865 3872 * IPython/iplib.py (file_matches): new completion code, courtesy
3866 3873 of Jeff Collins. This enables filename completion again under
3867 3874 python 2.3, which disabled it at the C level.
3868 3875
3869 3876 2003-11-11 Fernando Perez <fperez@colorado.edu>
3870 3877
3871 3878 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3872 3879 for Numeric.array(map(...)), but often convenient.
3873 3880
3874 3881 2003-11-05 Fernando Perez <fperez@colorado.edu>
3875 3882
3876 3883 * IPython/numutils.py (frange): Changed a call from int() to
3877 3884 int(round()) to prevent a problem reported with arange() in the
3878 3885 numpy list.
3879 3886
3880 3887 2003-10-06 Fernando Perez <fperez@colorado.edu>
3881 3888
3882 3889 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3883 3890 prevent crashes if sys lacks an argv attribute (it happens with
3884 3891 embedded interpreters which build a bare-bones sys module).
3885 3892 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3886 3893
3887 3894 2003-09-24 Fernando Perez <fperez@colorado.edu>
3888 3895
3889 3896 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3890 3897 to protect against poorly written user objects where __getattr__
3891 3898 raises exceptions other than AttributeError. Thanks to a bug
3892 3899 report by Oliver Sander <osander-AT-gmx.de>.
3893 3900
3894 3901 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3895 3902 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3896 3903
3897 3904 2003-09-09 Fernando Perez <fperez@colorado.edu>
3898 3905
3899 3906 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3900 3907 unpacking a list whith a callable as first element would
3901 3908 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3902 3909 Collins.
3903 3910
3904 3911 2003-08-25 *** Released version 0.5.0
3905 3912
3906 3913 2003-08-22 Fernando Perez <fperez@colorado.edu>
3907 3914
3908 3915 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3909 3916 improperly defined user exceptions. Thanks to feedback from Mark
3910 3917 Russell <mrussell-AT-verio.net>.
3911 3918
3912 3919 2003-08-20 Fernando Perez <fperez@colorado.edu>
3913 3920
3914 3921 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3915 3922 printing so that it would print multi-line string forms starting
3916 3923 with a new line. This way the formatting is better respected for
3917 3924 objects which work hard to make nice string forms.
3918 3925
3919 3926 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3920 3927 autocall would overtake data access for objects with both
3921 3928 __getitem__ and __call__.
3922 3929
3923 3930 2003-08-19 *** Released version 0.5.0-rc1
3924 3931
3925 3932 2003-08-19 Fernando Perez <fperez@colorado.edu>
3926 3933
3927 3934 * IPython/deep_reload.py (load_tail): single tiny change here
3928 3935 seems to fix the long-standing bug of dreload() failing to work
3929 3936 for dotted names. But this module is pretty tricky, so I may have
3930 3937 missed some subtlety. Needs more testing!.
3931 3938
3932 3939 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3933 3940 exceptions which have badly implemented __str__ methods.
3934 3941 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3935 3942 which I've been getting reports about from Python 2.3 users. I
3936 3943 wish I had a simple test case to reproduce the problem, so I could
3937 3944 either write a cleaner workaround or file a bug report if
3938 3945 necessary.
3939 3946
3940 3947 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3941 3948 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3942 3949 a bug report by Tjabo Kloppenburg.
3943 3950
3944 3951 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3945 3952 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3946 3953 seems rather unstable. Thanks to a bug report by Tjabo
3947 3954 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3948 3955
3949 3956 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3950 3957 this out soon because of the critical fixes in the inner loop for
3951 3958 generators.
3952 3959
3953 3960 * IPython/Magic.py (Magic.getargspec): removed. This (and
3954 3961 _get_def) have been obsoleted by OInspect for a long time, I
3955 3962 hadn't noticed that they were dead code.
3956 3963 (Magic._ofind): restored _ofind functionality for a few literals
3957 3964 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3958 3965 for things like "hello".capitalize?, since that would require a
3959 3966 potentially dangerous eval() again.
3960 3967
3961 3968 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3962 3969 logic a bit more to clean up the escapes handling and minimize the
3963 3970 use of _ofind to only necessary cases. The interactive 'feel' of
3964 3971 IPython should have improved quite a bit with the changes in
3965 3972 _prefilter and _ofind (besides being far safer than before).
3966 3973
3967 3974 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3968 3975 obscure, never reported). Edit would fail to find the object to
3969 3976 edit under some circumstances.
3970 3977 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3971 3978 which were causing double-calling of generators. Those eval calls
3972 3979 were _very_ dangerous, since code with side effects could be
3973 3980 triggered. As they say, 'eval is evil'... These were the
3974 3981 nastiest evals in IPython. Besides, _ofind is now far simpler,
3975 3982 and it should also be quite a bit faster. Its use of inspect is
3976 3983 also safer, so perhaps some of the inspect-related crashes I've
3977 3984 seen lately with Python 2.3 might be taken care of. That will
3978 3985 need more testing.
3979 3986
3980 3987 2003-08-17 Fernando Perez <fperez@colorado.edu>
3981 3988
3982 3989 * IPython/iplib.py (InteractiveShell._prefilter): significant
3983 3990 simplifications to the logic for handling user escapes. Faster
3984 3991 and simpler code.
3985 3992
3986 3993 2003-08-14 Fernando Perez <fperez@colorado.edu>
3987 3994
3988 3995 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3989 3996 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3990 3997 but it should be quite a bit faster. And the recursive version
3991 3998 generated O(log N) intermediate storage for all rank>1 arrays,
3992 3999 even if they were contiguous.
3993 4000 (l1norm): Added this function.
3994 4001 (norm): Added this function for arbitrary norms (including
3995 4002 l-infinity). l1 and l2 are still special cases for convenience
3996 4003 and speed.
3997 4004
3998 4005 2003-08-03 Fernando Perez <fperez@colorado.edu>
3999 4006
4000 4007 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4001 4008 exceptions, which now raise PendingDeprecationWarnings in Python
4002 4009 2.3. There were some in Magic and some in Gnuplot2.
4003 4010
4004 4011 2003-06-30 Fernando Perez <fperez@colorado.edu>
4005 4012
4006 4013 * IPython/genutils.py (page): modified to call curses only for
4007 4014 terminals where TERM=='xterm'. After problems under many other
4008 4015 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4009 4016
4010 4017 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4011 4018 would be triggered when readline was absent. This was just an old
4012 4019 debugging statement I'd forgotten to take out.
4013 4020
4014 4021 2003-06-20 Fernando Perez <fperez@colorado.edu>
4015 4022
4016 4023 * IPython/genutils.py (clock): modified to return only user time
4017 4024 (not counting system time), after a discussion on scipy. While
4018 4025 system time may be a useful quantity occasionally, it may much
4019 4026 more easily be skewed by occasional swapping or other similar
4020 4027 activity.
4021 4028
4022 4029 2003-06-05 Fernando Perez <fperez@colorado.edu>
4023 4030
4024 4031 * IPython/numutils.py (identity): new function, for building
4025 4032 arbitrary rank Kronecker deltas (mostly backwards compatible with
4026 4033 Numeric.identity)
4027 4034
4028 4035 2003-06-03 Fernando Perez <fperez@colorado.edu>
4029 4036
4030 4037 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4031 4038 arguments passed to magics with spaces, to allow trailing '\' to
4032 4039 work normally (mainly for Windows users).
4033 4040
4034 4041 2003-05-29 Fernando Perez <fperez@colorado.edu>
4035 4042
4036 4043 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4037 4044 instead of pydoc.help. This fixes a bizarre behavior where
4038 4045 printing '%s' % locals() would trigger the help system. Now
4039 4046 ipython behaves like normal python does.
4040 4047
4041 4048 Note that if one does 'from pydoc import help', the bizarre
4042 4049 behavior returns, but this will also happen in normal python, so
4043 4050 it's not an ipython bug anymore (it has to do with how pydoc.help
4044 4051 is implemented).
4045 4052
4046 4053 2003-05-22 Fernando Perez <fperez@colorado.edu>
4047 4054
4048 4055 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4049 4056 return [] instead of None when nothing matches, also match to end
4050 4057 of line. Patch by Gary Bishop.
4051 4058
4052 4059 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4053 4060 protection as before, for files passed on the command line. This
4054 4061 prevents the CrashHandler from kicking in if user files call into
4055 4062 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4056 4063 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4057 4064
4058 4065 2003-05-20 *** Released version 0.4.0
4059 4066
4060 4067 2003-05-20 Fernando Perez <fperez@colorado.edu>
4061 4068
4062 4069 * setup.py: added support for manpages. It's a bit hackish b/c of
4063 4070 a bug in the way the bdist_rpm distutils target handles gzipped
4064 4071 manpages, but it works. After a patch by Jack.
4065 4072
4066 4073 2003-05-19 Fernando Perez <fperez@colorado.edu>
4067 4074
4068 4075 * IPython/numutils.py: added a mockup of the kinds module, since
4069 4076 it was recently removed from Numeric. This way, numutils will
4070 4077 work for all users even if they are missing kinds.
4071 4078
4072 4079 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4073 4080 failure, which can occur with SWIG-wrapped extensions. After a
4074 4081 crash report from Prabhu.
4075 4082
4076 4083 2003-05-16 Fernando Perez <fperez@colorado.edu>
4077 4084
4078 4085 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4079 4086 protect ipython from user code which may call directly
4080 4087 sys.excepthook (this looks like an ipython crash to the user, even
4081 4088 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4082 4089 This is especially important to help users of WxWindows, but may
4083 4090 also be useful in other cases.
4084 4091
4085 4092 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4086 4093 an optional tb_offset to be specified, and to preserve exception
4087 4094 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4088 4095
4089 4096 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4090 4097
4091 4098 2003-05-15 Fernando Perez <fperez@colorado.edu>
4092 4099
4093 4100 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4094 4101 installing for a new user under Windows.
4095 4102
4096 4103 2003-05-12 Fernando Perez <fperez@colorado.edu>
4097 4104
4098 4105 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4099 4106 handler for Emacs comint-based lines. Currently it doesn't do
4100 4107 much (but importantly, it doesn't update the history cache). In
4101 4108 the future it may be expanded if Alex needs more functionality
4102 4109 there.
4103 4110
4104 4111 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4105 4112 info to crash reports.
4106 4113
4107 4114 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4108 4115 just like Python's -c. Also fixed crash with invalid -color
4109 4116 option value at startup. Thanks to Will French
4110 4117 <wfrench-AT-bestweb.net> for the bug report.
4111 4118
4112 4119 2003-05-09 Fernando Perez <fperez@colorado.edu>
4113 4120
4114 4121 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4115 4122 to EvalDict (it's a mapping, after all) and simplified its code
4116 4123 quite a bit, after a nice discussion on c.l.py where Gustavo
4117 4124 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4118 4125
4119 4126 2003-04-30 Fernando Perez <fperez@colorado.edu>
4120 4127
4121 4128 * IPython/genutils.py (timings_out): modified it to reduce its
4122 4129 overhead in the common reps==1 case.
4123 4130
4124 4131 2003-04-29 Fernando Perez <fperez@colorado.edu>
4125 4132
4126 4133 * IPython/genutils.py (timings_out): Modified to use the resource
4127 4134 module, which avoids the wraparound problems of time.clock().
4128 4135
4129 4136 2003-04-17 *** Released version 0.2.15pre4
4130 4137
4131 4138 2003-04-17 Fernando Perez <fperez@colorado.edu>
4132 4139
4133 4140 * setup.py (scriptfiles): Split windows-specific stuff over to a
4134 4141 separate file, in an attempt to have a Windows GUI installer.
4135 4142 That didn't work, but part of the groundwork is done.
4136 4143
4137 4144 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4138 4145 indent/unindent with 4 spaces. Particularly useful in combination
4139 4146 with the new auto-indent option.
4140 4147
4141 4148 2003-04-16 Fernando Perez <fperez@colorado.edu>
4142 4149
4143 4150 * IPython/Magic.py: various replacements of self.rc for
4144 4151 self.shell.rc. A lot more remains to be done to fully disentangle
4145 4152 this class from the main Shell class.
4146 4153
4147 4154 * IPython/GnuplotRuntime.py: added checks for mouse support so
4148 4155 that we don't try to enable it if the current gnuplot doesn't
4149 4156 really support it. Also added checks so that we don't try to
4150 4157 enable persist under Windows (where Gnuplot doesn't recognize the
4151 4158 option).
4152 4159
4153 4160 * IPython/iplib.py (InteractiveShell.interact): Added optional
4154 4161 auto-indenting code, after a patch by King C. Shu
4155 4162 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4156 4163 get along well with pasting indented code. If I ever figure out
4157 4164 how to make that part go well, it will become on by default.
4158 4165
4159 4166 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4160 4167 crash ipython if there was an unmatched '%' in the user's prompt
4161 4168 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4162 4169
4163 4170 * IPython/iplib.py (InteractiveShell.interact): removed the
4164 4171 ability to ask the user whether he wants to crash or not at the
4165 4172 'last line' exception handler. Calling functions at that point
4166 4173 changes the stack, and the error reports would have incorrect
4167 4174 tracebacks.
4168 4175
4169 4176 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4170 4177 pass through a peger a pretty-printed form of any object. After a
4171 4178 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4172 4179
4173 4180 2003-04-14 Fernando Perez <fperez@colorado.edu>
4174 4181
4175 4182 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4176 4183 all files in ~ would be modified at first install (instead of
4177 4184 ~/.ipython). This could be potentially disastrous, as the
4178 4185 modification (make line-endings native) could damage binary files.
4179 4186
4180 4187 2003-04-10 Fernando Perez <fperez@colorado.edu>
4181 4188
4182 4189 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4183 4190 handle only lines which are invalid python. This now means that
4184 4191 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4185 4192 for the bug report.
4186 4193
4187 4194 2003-04-01 Fernando Perez <fperez@colorado.edu>
4188 4195
4189 4196 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4190 4197 where failing to set sys.last_traceback would crash pdb.pm().
4191 4198 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4192 4199 report.
4193 4200
4194 4201 2003-03-25 Fernando Perez <fperez@colorado.edu>
4195 4202
4196 4203 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4197 4204 before printing it (it had a lot of spurious blank lines at the
4198 4205 end).
4199 4206
4200 4207 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4201 4208 output would be sent 21 times! Obviously people don't use this
4202 4209 too often, or I would have heard about it.
4203 4210
4204 4211 2003-03-24 Fernando Perez <fperez@colorado.edu>
4205 4212
4206 4213 * setup.py (scriptfiles): renamed the data_files parameter from
4207 4214 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4208 4215 for the patch.
4209 4216
4210 4217 2003-03-20 Fernando Perez <fperez@colorado.edu>
4211 4218
4212 4219 * IPython/genutils.py (error): added error() and fatal()
4213 4220 functions.
4214 4221
4215 4222 2003-03-18 *** Released version 0.2.15pre3
4216 4223
4217 4224 2003-03-18 Fernando Perez <fperez@colorado.edu>
4218 4225
4219 4226 * setupext/install_data_ext.py
4220 4227 (install_data_ext.initialize_options): Class contributed by Jack
4221 4228 Moffit for fixing the old distutils hack. He is sending this to
4222 4229 the distutils folks so in the future we may not need it as a
4223 4230 private fix.
4224 4231
4225 4232 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4226 4233 changes for Debian packaging. See his patch for full details.
4227 4234 The old distutils hack of making the ipythonrc* files carry a
4228 4235 bogus .py extension is gone, at last. Examples were moved to a
4229 4236 separate subdir under doc/, and the separate executable scripts
4230 4237 now live in their own directory. Overall a great cleanup. The
4231 4238 manual was updated to use the new files, and setup.py has been
4232 4239 fixed for this setup.
4233 4240
4234 4241 * IPython/PyColorize.py (Parser.usage): made non-executable and
4235 4242 created a pycolor wrapper around it to be included as a script.
4236 4243
4237 4244 2003-03-12 *** Released version 0.2.15pre2
4238 4245
4239 4246 2003-03-12 Fernando Perez <fperez@colorado.edu>
4240 4247
4241 4248 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4242 4249 long-standing problem with garbage characters in some terminals.
4243 4250 The issue was really that the \001 and \002 escapes must _only_ be
4244 4251 passed to input prompts (which call readline), but _never_ to
4245 4252 normal text to be printed on screen. I changed ColorANSI to have
4246 4253 two classes: TermColors and InputTermColors, each with the
4247 4254 appropriate escapes for input prompts or normal text. The code in
4248 4255 Prompts.py got slightly more complicated, but this very old and
4249 4256 annoying bug is finally fixed.
4250 4257
4251 4258 All the credit for nailing down the real origin of this problem
4252 4259 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4253 4260 *Many* thanks to him for spending quite a bit of effort on this.
4254 4261
4255 4262 2003-03-05 *** Released version 0.2.15pre1
4256 4263
4257 4264 2003-03-03 Fernando Perez <fperez@colorado.edu>
4258 4265
4259 4266 * IPython/FakeModule.py: Moved the former _FakeModule to a
4260 4267 separate file, because it's also needed by Magic (to fix a similar
4261 4268 pickle-related issue in @run).
4262 4269
4263 4270 2003-03-02 Fernando Perez <fperez@colorado.edu>
4264 4271
4265 4272 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4266 4273 the autocall option at runtime.
4267 4274 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4268 4275 across Magic.py to start separating Magic from InteractiveShell.
4269 4276 (Magic._ofind): Fixed to return proper namespace for dotted
4270 4277 names. Before, a dotted name would always return 'not currently
4271 4278 defined', because it would find the 'parent'. s.x would be found,
4272 4279 but since 'x' isn't defined by itself, it would get confused.
4273 4280 (Magic.magic_run): Fixed pickling problems reported by Ralf
4274 4281 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4275 4282 that I'd used when Mike Heeter reported similar issues at the
4276 4283 top-level, but now for @run. It boils down to injecting the
4277 4284 namespace where code is being executed with something that looks
4278 4285 enough like a module to fool pickle.dump(). Since a pickle stores
4279 4286 a named reference to the importing module, we need this for
4280 4287 pickles to save something sensible.
4281 4288
4282 4289 * IPython/ipmaker.py (make_IPython): added an autocall option.
4283 4290
4284 4291 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4285 4292 the auto-eval code. Now autocalling is an option, and the code is
4286 4293 also vastly safer. There is no more eval() involved at all.
4287 4294
4288 4295 2003-03-01 Fernando Perez <fperez@colorado.edu>
4289 4296
4290 4297 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4291 4298 dict with named keys instead of a tuple.
4292 4299
4293 4300 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4294 4301
4295 4302 * setup.py (make_shortcut): Fixed message about directories
4296 4303 created during Windows installation (the directories were ok, just
4297 4304 the printed message was misleading). Thanks to Chris Liechti
4298 4305 <cliechti-AT-gmx.net> for the heads up.
4299 4306
4300 4307 2003-02-21 Fernando Perez <fperez@colorado.edu>
4301 4308
4302 4309 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4303 4310 of ValueError exception when checking for auto-execution. This
4304 4311 one is raised by things like Numeric arrays arr.flat when the
4305 4312 array is non-contiguous.
4306 4313
4307 4314 2003-01-31 Fernando Perez <fperez@colorado.edu>
4308 4315
4309 4316 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4310 4317 not return any value at all (even though the command would get
4311 4318 executed).
4312 4319 (xsys): Flush stdout right after printing the command to ensure
4313 4320 proper ordering of commands and command output in the total
4314 4321 output.
4315 4322 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4316 4323 system/getoutput as defaults. The old ones are kept for
4317 4324 compatibility reasons, so no code which uses this library needs
4318 4325 changing.
4319 4326
4320 4327 2003-01-27 *** Released version 0.2.14
4321 4328
4322 4329 2003-01-25 Fernando Perez <fperez@colorado.edu>
4323 4330
4324 4331 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4325 4332 functions defined in previous edit sessions could not be re-edited
4326 4333 (because the temp files were immediately removed). Now temp files
4327 4334 are removed only at IPython's exit.
4328 4335 (Magic.magic_run): Improved @run to perform shell-like expansions
4329 4336 on its arguments (~users and $VARS). With this, @run becomes more
4330 4337 like a normal command-line.
4331 4338
4332 4339 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4333 4340 bugs related to embedding and cleaned up that code. A fairly
4334 4341 important one was the impossibility to access the global namespace
4335 4342 through the embedded IPython (only local variables were visible).
4336 4343
4337 4344 2003-01-14 Fernando Perez <fperez@colorado.edu>
4338 4345
4339 4346 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4340 4347 auto-calling to be a bit more conservative. Now it doesn't get
4341 4348 triggered if any of '!=()<>' are in the rest of the input line, to
4342 4349 allow comparing callables. Thanks to Alex for the heads up.
4343 4350
4344 4351 2003-01-07 Fernando Perez <fperez@colorado.edu>
4345 4352
4346 4353 * IPython/genutils.py (page): fixed estimation of the number of
4347 4354 lines in a string to be paged to simply count newlines. This
4348 4355 prevents over-guessing due to embedded escape sequences. A better
4349 4356 long-term solution would involve stripping out the control chars
4350 4357 for the count, but it's potentially so expensive I just don't
4351 4358 think it's worth doing.
4352 4359
4353 4360 2002-12-19 *** Released version 0.2.14pre50
4354 4361
4355 4362 2002-12-19 Fernando Perez <fperez@colorado.edu>
4356 4363
4357 4364 * tools/release (version): Changed release scripts to inform
4358 4365 Andrea and build a NEWS file with a list of recent changes.
4359 4366
4360 4367 * IPython/ColorANSI.py (__all__): changed terminal detection
4361 4368 code. Seems to work better for xterms without breaking
4362 4369 konsole. Will need more testing to determine if WinXP and Mac OSX
4363 4370 also work ok.
4364 4371
4365 4372 2002-12-18 *** Released version 0.2.14pre49
4366 4373
4367 4374 2002-12-18 Fernando Perez <fperez@colorado.edu>
4368 4375
4369 4376 * Docs: added new info about Mac OSX, from Andrea.
4370 4377
4371 4378 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4372 4379 allow direct plotting of python strings whose format is the same
4373 4380 of gnuplot data files.
4374 4381
4375 4382 2002-12-16 Fernando Perez <fperez@colorado.edu>
4376 4383
4377 4384 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4378 4385 value of exit question to be acknowledged.
4379 4386
4380 4387 2002-12-03 Fernando Perez <fperez@colorado.edu>
4381 4388
4382 4389 * IPython/ipmaker.py: removed generators, which had been added
4383 4390 by mistake in an earlier debugging run. This was causing trouble
4384 4391 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4385 4392 for pointing this out.
4386 4393
4387 4394 2002-11-17 Fernando Perez <fperez@colorado.edu>
4388 4395
4389 4396 * Manual: updated the Gnuplot section.
4390 4397
4391 4398 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4392 4399 a much better split of what goes in Runtime and what goes in
4393 4400 Interactive.
4394 4401
4395 4402 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4396 4403 being imported from iplib.
4397 4404
4398 4405 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4399 4406 for command-passing. Now the global Gnuplot instance is called
4400 4407 'gp' instead of 'g', which was really a far too fragile and
4401 4408 common name.
4402 4409
4403 4410 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4404 4411 bounding boxes generated by Gnuplot for square plots.
4405 4412
4406 4413 * IPython/genutils.py (popkey): new function added. I should
4407 4414 suggest this on c.l.py as a dict method, it seems useful.
4408 4415
4409 4416 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4410 4417 to transparently handle PostScript generation. MUCH better than
4411 4418 the previous plot_eps/replot_eps (which I removed now). The code
4412 4419 is also fairly clean and well documented now (including
4413 4420 docstrings).
4414 4421
4415 4422 2002-11-13 Fernando Perez <fperez@colorado.edu>
4416 4423
4417 4424 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4418 4425 (inconsistent with options).
4419 4426
4420 4427 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4421 4428 manually disabled, I don't know why. Fixed it.
4422 4429 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4423 4430 eps output.
4424 4431
4425 4432 2002-11-12 Fernando Perez <fperez@colorado.edu>
4426 4433
4427 4434 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4428 4435 don't propagate up to caller. Fixes crash reported by François
4429 4436 Pinard.
4430 4437
4431 4438 2002-11-09 Fernando Perez <fperez@colorado.edu>
4432 4439
4433 4440 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4434 4441 history file for new users.
4435 4442 (make_IPython): fixed bug where initial install would leave the
4436 4443 user running in the .ipython dir.
4437 4444 (make_IPython): fixed bug where config dir .ipython would be
4438 4445 created regardless of the given -ipythondir option. Thanks to Cory
4439 4446 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4440 4447
4441 4448 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4442 4449 type confirmations. Will need to use it in all of IPython's code
4443 4450 consistently.
4444 4451
4445 4452 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4446 4453 context to print 31 lines instead of the default 5. This will make
4447 4454 the crash reports extremely detailed in case the problem is in
4448 4455 libraries I don't have access to.
4449 4456
4450 4457 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4451 4458 line of defense' code to still crash, but giving users fair
4452 4459 warning. I don't want internal errors to go unreported: if there's
4453 4460 an internal problem, IPython should crash and generate a full
4454 4461 report.
4455 4462
4456 4463 2002-11-08 Fernando Perez <fperez@colorado.edu>
4457 4464
4458 4465 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4459 4466 otherwise uncaught exceptions which can appear if people set
4460 4467 sys.stdout to something badly broken. Thanks to a crash report
4461 4468 from henni-AT-mail.brainbot.com.
4462 4469
4463 4470 2002-11-04 Fernando Perez <fperez@colorado.edu>
4464 4471
4465 4472 * IPython/iplib.py (InteractiveShell.interact): added
4466 4473 __IPYTHON__active to the builtins. It's a flag which goes on when
4467 4474 the interaction starts and goes off again when it stops. This
4468 4475 allows embedding code to detect being inside IPython. Before this
4469 4476 was done via __IPYTHON__, but that only shows that an IPython
4470 4477 instance has been created.
4471 4478
4472 4479 * IPython/Magic.py (Magic.magic_env): I realized that in a
4473 4480 UserDict, instance.data holds the data as a normal dict. So I
4474 4481 modified @env to return os.environ.data instead of rebuilding a
4475 4482 dict by hand.
4476 4483
4477 4484 2002-11-02 Fernando Perez <fperez@colorado.edu>
4478 4485
4479 4486 * IPython/genutils.py (warn): changed so that level 1 prints no
4480 4487 header. Level 2 is now the default (with 'WARNING' header, as
4481 4488 before). I think I tracked all places where changes were needed in
4482 4489 IPython, but outside code using the old level numbering may have
4483 4490 broken.
4484 4491
4485 4492 * IPython/iplib.py (InteractiveShell.runcode): added this to
4486 4493 handle the tracebacks in SystemExit traps correctly. The previous
4487 4494 code (through interact) was printing more of the stack than
4488 4495 necessary, showing IPython internal code to the user.
4489 4496
4490 4497 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4491 4498 default. Now that the default at the confirmation prompt is yes,
4492 4499 it's not so intrusive. François' argument that ipython sessions
4493 4500 tend to be complex enough not to lose them from an accidental C-d,
4494 4501 is a valid one.
4495 4502
4496 4503 * IPython/iplib.py (InteractiveShell.interact): added a
4497 4504 showtraceback() call to the SystemExit trap, and modified the exit
4498 4505 confirmation to have yes as the default.
4499 4506
4500 4507 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4501 4508 this file. It's been gone from the code for a long time, this was
4502 4509 simply leftover junk.
4503 4510
4504 4511 2002-11-01 Fernando Perez <fperez@colorado.edu>
4505 4512
4506 4513 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4507 4514 added. If set, IPython now traps EOF and asks for
4508 4515 confirmation. After a request by François Pinard.
4509 4516
4510 4517 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4511 4518 of @abort, and with a new (better) mechanism for handling the
4512 4519 exceptions.
4513 4520
4514 4521 2002-10-27 Fernando Perez <fperez@colorado.edu>
4515 4522
4516 4523 * IPython/usage.py (__doc__): updated the --help information and
4517 4524 the ipythonrc file to indicate that -log generates
4518 4525 ./ipython.log. Also fixed the corresponding info in @logstart.
4519 4526 This and several other fixes in the manuals thanks to reports by
4520 4527 François Pinard <pinard-AT-iro.umontreal.ca>.
4521 4528
4522 4529 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4523 4530 refer to @logstart (instead of @log, which doesn't exist).
4524 4531
4525 4532 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4526 4533 AttributeError crash. Thanks to Christopher Armstrong
4527 4534 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4528 4535 introduced recently (in 0.2.14pre37) with the fix to the eval
4529 4536 problem mentioned below.
4530 4537
4531 4538 2002-10-17 Fernando Perez <fperez@colorado.edu>
4532 4539
4533 4540 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4534 4541 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4535 4542
4536 4543 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4537 4544 this function to fix a problem reported by Alex Schmolck. He saw
4538 4545 it with list comprehensions and generators, which were getting
4539 4546 called twice. The real problem was an 'eval' call in testing for
4540 4547 automagic which was evaluating the input line silently.
4541 4548
4542 4549 This is a potentially very nasty bug, if the input has side
4543 4550 effects which must not be repeated. The code is much cleaner now,
4544 4551 without any blanket 'except' left and with a regexp test for
4545 4552 actual function names.
4546 4553
4547 4554 But an eval remains, which I'm not fully comfortable with. I just
4548 4555 don't know how to find out if an expression could be a callable in
4549 4556 the user's namespace without doing an eval on the string. However
4550 4557 that string is now much more strictly checked so that no code
4551 4558 slips by, so the eval should only happen for things that can
4552 4559 really be only function/method names.
4553 4560
4554 4561 2002-10-15 Fernando Perez <fperez@colorado.edu>
4555 4562
4556 4563 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4557 4564 OSX information to main manual, removed README_Mac_OSX file from
4558 4565 distribution. Also updated credits for recent additions.
4559 4566
4560 4567 2002-10-10 Fernando Perez <fperez@colorado.edu>
4561 4568
4562 4569 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4563 4570 terminal-related issues. Many thanks to Andrea Riciputi
4564 4571 <andrea.riciputi-AT-libero.it> for writing it.
4565 4572
4566 4573 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4567 4574 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4568 4575
4569 4576 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4570 4577 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4571 4578 <syver-en-AT-online.no> who both submitted patches for this problem.
4572 4579
4573 4580 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4574 4581 global embedding to make sure that things don't overwrite user
4575 4582 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4576 4583
4577 4584 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4578 4585 compatibility. Thanks to Hayden Callow
4579 4586 <h.callow-AT-elec.canterbury.ac.nz>
4580 4587
4581 4588 2002-10-04 Fernando Perez <fperez@colorado.edu>
4582 4589
4583 4590 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4584 4591 Gnuplot.File objects.
4585 4592
4586 4593 2002-07-23 Fernando Perez <fperez@colorado.edu>
4587 4594
4588 4595 * IPython/genutils.py (timing): Added timings() and timing() for
4589 4596 quick access to the most commonly needed data, the execution
4590 4597 times. Old timing() renamed to timings_out().
4591 4598
4592 4599 2002-07-18 Fernando Perez <fperez@colorado.edu>
4593 4600
4594 4601 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4595 4602 bug with nested instances disrupting the parent's tab completion.
4596 4603
4597 4604 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4598 4605 all_completions code to begin the emacs integration.
4599 4606
4600 4607 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4601 4608 argument to allow titling individual arrays when plotting.
4602 4609
4603 4610 2002-07-15 Fernando Perez <fperez@colorado.edu>
4604 4611
4605 4612 * setup.py (make_shortcut): changed to retrieve the value of
4606 4613 'Program Files' directory from the registry (this value changes in
4607 4614 non-english versions of Windows). Thanks to Thomas Fanslau
4608 4615 <tfanslau-AT-gmx.de> for the report.
4609 4616
4610 4617 2002-07-10 Fernando Perez <fperez@colorado.edu>
4611 4618
4612 4619 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4613 4620 a bug in pdb, which crashes if a line with only whitespace is
4614 4621 entered. Bug report submitted to sourceforge.
4615 4622
4616 4623 2002-07-09 Fernando Perez <fperez@colorado.edu>
4617 4624
4618 4625 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4619 4626 reporting exceptions (it's a bug in inspect.py, I just set a
4620 4627 workaround).
4621 4628
4622 4629 2002-07-08 Fernando Perez <fperez@colorado.edu>
4623 4630
4624 4631 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4625 4632 __IPYTHON__ in __builtins__ to show up in user_ns.
4626 4633
4627 4634 2002-07-03 Fernando Perez <fperez@colorado.edu>
4628 4635
4629 4636 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4630 4637 name from @gp_set_instance to @gp_set_default.
4631 4638
4632 4639 * IPython/ipmaker.py (make_IPython): default editor value set to
4633 4640 '0' (a string), to match the rc file. Otherwise will crash when
4634 4641 .strip() is called on it.
4635 4642
4636 4643
4637 4644 2002-06-28 Fernando Perez <fperez@colorado.edu>
4638 4645
4639 4646 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4640 4647 of files in current directory when a file is executed via
4641 4648 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4642 4649
4643 4650 * setup.py (manfiles): fix for rpm builds, submitted by RA
4644 4651 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4645 4652
4646 4653 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4647 4654 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4648 4655 string!). A. Schmolck caught this one.
4649 4656
4650 4657 2002-06-27 Fernando Perez <fperez@colorado.edu>
4651 4658
4652 4659 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4653 4660 defined files at the cmd line. __name__ wasn't being set to
4654 4661 __main__.
4655 4662
4656 4663 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4657 4664 regular lists and tuples besides Numeric arrays.
4658 4665
4659 4666 * IPython/Prompts.py (CachedOutput.__call__): Added output
4660 4667 supression for input ending with ';'. Similar to Mathematica and
4661 4668 Matlab. The _* vars and Out[] list are still updated, just like
4662 4669 Mathematica behaves.
4663 4670
4664 4671 2002-06-25 Fernando Perez <fperez@colorado.edu>
4665 4672
4666 4673 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4667 4674 .ini extensions for profiels under Windows.
4668 4675
4669 4676 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4670 4677 string form. Fix contributed by Alexander Schmolck
4671 4678 <a.schmolck-AT-gmx.net>
4672 4679
4673 4680 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4674 4681 pre-configured Gnuplot instance.
4675 4682
4676 4683 2002-06-21 Fernando Perez <fperez@colorado.edu>
4677 4684
4678 4685 * IPython/numutils.py (exp_safe): new function, works around the
4679 4686 underflow problems in Numeric.
4680 4687 (log2): New fn. Safe log in base 2: returns exact integer answer
4681 4688 for exact integer powers of 2.
4682 4689
4683 4690 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4684 4691 properly.
4685 4692
4686 4693 2002-06-20 Fernando Perez <fperez@colorado.edu>
4687 4694
4688 4695 * IPython/genutils.py (timing): new function like
4689 4696 Mathematica's. Similar to time_test, but returns more info.
4690 4697
4691 4698 2002-06-18 Fernando Perez <fperez@colorado.edu>
4692 4699
4693 4700 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4694 4701 according to Mike Heeter's suggestions.
4695 4702
4696 4703 2002-06-16 Fernando Perez <fperez@colorado.edu>
4697 4704
4698 4705 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4699 4706 system. GnuplotMagic is gone as a user-directory option. New files
4700 4707 make it easier to use all the gnuplot stuff both from external
4701 4708 programs as well as from IPython. Had to rewrite part of
4702 4709 hardcopy() b/c of a strange bug: often the ps files simply don't
4703 4710 get created, and require a repeat of the command (often several
4704 4711 times).
4705 4712
4706 4713 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4707 4714 resolve output channel at call time, so that if sys.stderr has
4708 4715 been redirected by user this gets honored.
4709 4716
4710 4717 2002-06-13 Fernando Perez <fperez@colorado.edu>
4711 4718
4712 4719 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4713 4720 IPShell. Kept a copy with the old names to avoid breaking people's
4714 4721 embedded code.
4715 4722
4716 4723 * IPython/ipython: simplified it to the bare minimum after
4717 4724 Holger's suggestions. Added info about how to use it in
4718 4725 PYTHONSTARTUP.
4719 4726
4720 4727 * IPython/Shell.py (IPythonShell): changed the options passing
4721 4728 from a string with funky %s replacements to a straight list. Maybe
4722 4729 a bit more typing, but it follows sys.argv conventions, so there's
4723 4730 less special-casing to remember.
4724 4731
4725 4732 2002-06-12 Fernando Perez <fperez@colorado.edu>
4726 4733
4727 4734 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4728 4735 command. Thanks to a suggestion by Mike Heeter.
4729 4736 (Magic.magic_pfile): added behavior to look at filenames if given
4730 4737 arg is not a defined object.
4731 4738 (Magic.magic_save): New @save function to save code snippets. Also
4732 4739 a Mike Heeter idea.
4733 4740
4734 4741 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4735 4742 plot() and replot(). Much more convenient now, especially for
4736 4743 interactive use.
4737 4744
4738 4745 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4739 4746 filenames.
4740 4747
4741 4748 2002-06-02 Fernando Perez <fperez@colorado.edu>
4742 4749
4743 4750 * IPython/Struct.py (Struct.__init__): modified to admit
4744 4751 initialization via another struct.
4745 4752
4746 4753 * IPython/genutils.py (SystemExec.__init__): New stateful
4747 4754 interface to xsys and bq. Useful for writing system scripts.
4748 4755
4749 4756 2002-05-30 Fernando Perez <fperez@colorado.edu>
4750 4757
4751 4758 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4752 4759 documents. This will make the user download smaller (it's getting
4753 4760 too big).
4754 4761
4755 4762 2002-05-29 Fernando Perez <fperez@colorado.edu>
4756 4763
4757 4764 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4758 4765 fix problems with shelve and pickle. Seems to work, but I don't
4759 4766 know if corner cases break it. Thanks to Mike Heeter
4760 4767 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4761 4768
4762 4769 2002-05-24 Fernando Perez <fperez@colorado.edu>
4763 4770
4764 4771 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4765 4772 macros having broken.
4766 4773
4767 4774 2002-05-21 Fernando Perez <fperez@colorado.edu>
4768 4775
4769 4776 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4770 4777 introduced logging bug: all history before logging started was
4771 4778 being written one character per line! This came from the redesign
4772 4779 of the input history as a special list which slices to strings,
4773 4780 not to lists.
4774 4781
4775 4782 2002-05-20 Fernando Perez <fperez@colorado.edu>
4776 4783
4777 4784 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4778 4785 be an attribute of all classes in this module. The design of these
4779 4786 classes needs some serious overhauling.
4780 4787
4781 4788 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4782 4789 which was ignoring '_' in option names.
4783 4790
4784 4791 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4785 4792 'Verbose_novars' to 'Context' and made it the new default. It's a
4786 4793 bit more readable and also safer than verbose.
4787 4794
4788 4795 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4789 4796 triple-quoted strings.
4790 4797
4791 4798 * IPython/OInspect.py (__all__): new module exposing the object
4792 4799 introspection facilities. Now the corresponding magics are dummy
4793 4800 wrappers around this. Having this module will make it much easier
4794 4801 to put these functions into our modified pdb.
4795 4802 This new object inspector system uses the new colorizing module,
4796 4803 so source code and other things are nicely syntax highlighted.
4797 4804
4798 4805 2002-05-18 Fernando Perez <fperez@colorado.edu>
4799 4806
4800 4807 * IPython/ColorANSI.py: Split the coloring tools into a separate
4801 4808 module so I can use them in other code easier (they were part of
4802 4809 ultraTB).
4803 4810
4804 4811 2002-05-17 Fernando Perez <fperez@colorado.edu>
4805 4812
4806 4813 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4807 4814 fixed it to set the global 'g' also to the called instance, as
4808 4815 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4809 4816 user's 'g' variables).
4810 4817
4811 4818 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4812 4819 global variables (aliases to _ih,_oh) so that users which expect
4813 4820 In[5] or Out[7] to work aren't unpleasantly surprised.
4814 4821 (InputList.__getslice__): new class to allow executing slices of
4815 4822 input history directly. Very simple class, complements the use of
4816 4823 macros.
4817 4824
4818 4825 2002-05-16 Fernando Perez <fperez@colorado.edu>
4819 4826
4820 4827 * setup.py (docdirbase): make doc directory be just doc/IPython
4821 4828 without version numbers, it will reduce clutter for users.
4822 4829
4823 4830 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4824 4831 execfile call to prevent possible memory leak. See for details:
4825 4832 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4826 4833
4827 4834 2002-05-15 Fernando Perez <fperez@colorado.edu>
4828 4835
4829 4836 * IPython/Magic.py (Magic.magic_psource): made the object
4830 4837 introspection names be more standard: pdoc, pdef, pfile and
4831 4838 psource. They all print/page their output, and it makes
4832 4839 remembering them easier. Kept old names for compatibility as
4833 4840 aliases.
4834 4841
4835 4842 2002-05-14 Fernando Perez <fperez@colorado.edu>
4836 4843
4837 4844 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4838 4845 what the mouse problem was. The trick is to use gnuplot with temp
4839 4846 files and NOT with pipes (for data communication), because having
4840 4847 both pipes and the mouse on is bad news.
4841 4848
4842 4849 2002-05-13 Fernando Perez <fperez@colorado.edu>
4843 4850
4844 4851 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4845 4852 bug. Information would be reported about builtins even when
4846 4853 user-defined functions overrode them.
4847 4854
4848 4855 2002-05-11 Fernando Perez <fperez@colorado.edu>
4849 4856
4850 4857 * IPython/__init__.py (__all__): removed FlexCompleter from
4851 4858 __all__ so that things don't fail in platforms without readline.
4852 4859
4853 4860 2002-05-10 Fernando Perez <fperez@colorado.edu>
4854 4861
4855 4862 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4856 4863 it requires Numeric, effectively making Numeric a dependency for
4857 4864 IPython.
4858 4865
4859 4866 * Released 0.2.13
4860 4867
4861 4868 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4862 4869 profiler interface. Now all the major options from the profiler
4863 4870 module are directly supported in IPython, both for single
4864 4871 expressions (@prun) and for full programs (@run -p).
4865 4872
4866 4873 2002-05-09 Fernando Perez <fperez@colorado.edu>
4867 4874
4868 4875 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4869 4876 magic properly formatted for screen.
4870 4877
4871 4878 * setup.py (make_shortcut): Changed things to put pdf version in
4872 4879 doc/ instead of doc/manual (had to change lyxport a bit).
4873 4880
4874 4881 * IPython/Magic.py (Profile.string_stats): made profile runs go
4875 4882 through pager (they are long and a pager allows searching, saving,
4876 4883 etc.)
4877 4884
4878 4885 2002-05-08 Fernando Perez <fperez@colorado.edu>
4879 4886
4880 4887 * Released 0.2.12
4881 4888
4882 4889 2002-05-06 Fernando Perez <fperez@colorado.edu>
4883 4890
4884 4891 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4885 4892 introduced); 'hist n1 n2' was broken.
4886 4893 (Magic.magic_pdb): added optional on/off arguments to @pdb
4887 4894 (Magic.magic_run): added option -i to @run, which executes code in
4888 4895 the IPython namespace instead of a clean one. Also added @irun as
4889 4896 an alias to @run -i.
4890 4897
4891 4898 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4892 4899 fixed (it didn't really do anything, the namespaces were wrong).
4893 4900
4894 4901 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4895 4902
4896 4903 * IPython/__init__.py (__all__): Fixed package namespace, now
4897 4904 'import IPython' does give access to IPython.<all> as
4898 4905 expected. Also renamed __release__ to Release.
4899 4906
4900 4907 * IPython/Debugger.py (__license__): created new Pdb class which
4901 4908 functions like a drop-in for the normal pdb.Pdb but does NOT
4902 4909 import readline by default. This way it doesn't muck up IPython's
4903 4910 readline handling, and now tab-completion finally works in the
4904 4911 debugger -- sort of. It completes things globally visible, but the
4905 4912 completer doesn't track the stack as pdb walks it. That's a bit
4906 4913 tricky, and I'll have to implement it later.
4907 4914
4908 4915 2002-05-05 Fernando Perez <fperez@colorado.edu>
4909 4916
4910 4917 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4911 4918 magic docstrings when printed via ? (explicit \'s were being
4912 4919 printed).
4913 4920
4914 4921 * IPython/ipmaker.py (make_IPython): fixed namespace
4915 4922 identification bug. Now variables loaded via logs or command-line
4916 4923 files are recognized in the interactive namespace by @who.
4917 4924
4918 4925 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4919 4926 log replay system stemming from the string form of Structs.
4920 4927
4921 4928 * IPython/Magic.py (Macro.__init__): improved macros to properly
4922 4929 handle magic commands in them.
4923 4930 (Magic.magic_logstart): usernames are now expanded so 'logstart
4924 4931 ~/mylog' now works.
4925 4932
4926 4933 * IPython/iplib.py (complete): fixed bug where paths starting with
4927 4934 '/' would be completed as magic names.
4928 4935
4929 4936 2002-05-04 Fernando Perez <fperez@colorado.edu>
4930 4937
4931 4938 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4932 4939 allow running full programs under the profiler's control.
4933 4940
4934 4941 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4935 4942 mode to report exceptions verbosely but without formatting
4936 4943 variables. This addresses the issue of ipython 'freezing' (it's
4937 4944 not frozen, but caught in an expensive formatting loop) when huge
4938 4945 variables are in the context of an exception.
4939 4946 (VerboseTB.text): Added '--->' markers at line where exception was
4940 4947 triggered. Much clearer to read, especially in NoColor modes.
4941 4948
4942 4949 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4943 4950 implemented in reverse when changing to the new parse_options().
4944 4951
4945 4952 2002-05-03 Fernando Perez <fperez@colorado.edu>
4946 4953
4947 4954 * IPython/Magic.py (Magic.parse_options): new function so that
4948 4955 magics can parse options easier.
4949 4956 (Magic.magic_prun): new function similar to profile.run(),
4950 4957 suggested by Chris Hart.
4951 4958 (Magic.magic_cd): fixed behavior so that it only changes if
4952 4959 directory actually is in history.
4953 4960
4954 4961 * IPython/usage.py (__doc__): added information about potential
4955 4962 slowness of Verbose exception mode when there are huge data
4956 4963 structures to be formatted (thanks to Archie Paulson).
4957 4964
4958 4965 * IPython/ipmaker.py (make_IPython): Changed default logging
4959 4966 (when simply called with -log) to use curr_dir/ipython.log in
4960 4967 rotate mode. Fixed crash which was occuring with -log before
4961 4968 (thanks to Jim Boyle).
4962 4969
4963 4970 2002-05-01 Fernando Perez <fperez@colorado.edu>
4964 4971
4965 4972 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4966 4973 was nasty -- though somewhat of a corner case).
4967 4974
4968 4975 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4969 4976 text (was a bug).
4970 4977
4971 4978 2002-04-30 Fernando Perez <fperez@colorado.edu>
4972 4979
4973 4980 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4974 4981 a print after ^D or ^C from the user so that the In[] prompt
4975 4982 doesn't over-run the gnuplot one.
4976 4983
4977 4984 2002-04-29 Fernando Perez <fperez@colorado.edu>
4978 4985
4979 4986 * Released 0.2.10
4980 4987
4981 4988 * IPython/__release__.py (version): get date dynamically.
4982 4989
4983 4990 * Misc. documentation updates thanks to Arnd's comments. Also ran
4984 4991 a full spellcheck on the manual (hadn't been done in a while).
4985 4992
4986 4993 2002-04-27 Fernando Perez <fperez@colorado.edu>
4987 4994
4988 4995 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4989 4996 starting a log in mid-session would reset the input history list.
4990 4997
4991 4998 2002-04-26 Fernando Perez <fperez@colorado.edu>
4992 4999
4993 5000 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4994 5001 all files were being included in an update. Now anything in
4995 5002 UserConfig that matches [A-Za-z]*.py will go (this excludes
4996 5003 __init__.py)
4997 5004
4998 5005 2002-04-25 Fernando Perez <fperez@colorado.edu>
4999 5006
5000 5007 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5001 5008 to __builtins__ so that any form of embedded or imported code can
5002 5009 test for being inside IPython.
5003 5010
5004 5011 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5005 5012 changed to GnuplotMagic because it's now an importable module,
5006 5013 this makes the name follow that of the standard Gnuplot module.
5007 5014 GnuplotMagic can now be loaded at any time in mid-session.
5008 5015
5009 5016 2002-04-24 Fernando Perez <fperez@colorado.edu>
5010 5017
5011 5018 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5012 5019 the globals (IPython has its own namespace) and the
5013 5020 PhysicalQuantity stuff is much better anyway.
5014 5021
5015 5022 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5016 5023 embedding example to standard user directory for
5017 5024 distribution. Also put it in the manual.
5018 5025
5019 5026 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5020 5027 instance as first argument (so it doesn't rely on some obscure
5021 5028 hidden global).
5022 5029
5023 5030 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5024 5031 delimiters. While it prevents ().TAB from working, it allows
5025 5032 completions in open (... expressions. This is by far a more common
5026 5033 case.
5027 5034
5028 5035 2002-04-23 Fernando Perez <fperez@colorado.edu>
5029 5036
5030 5037 * IPython/Extensions/InterpreterPasteInput.py: new
5031 5038 syntax-processing module for pasting lines with >>> or ... at the
5032 5039 start.
5033 5040
5034 5041 * IPython/Extensions/PhysicalQ_Interactive.py
5035 5042 (PhysicalQuantityInteractive.__int__): fixed to work with either
5036 5043 Numeric or math.
5037 5044
5038 5045 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5039 5046 provided profiles. Now we have:
5040 5047 -math -> math module as * and cmath with its own namespace.
5041 5048 -numeric -> Numeric as *, plus gnuplot & grace
5042 5049 -physics -> same as before
5043 5050
5044 5051 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5045 5052 user-defined magics wouldn't be found by @magic if they were
5046 5053 defined as class methods. Also cleaned up the namespace search
5047 5054 logic and the string building (to use %s instead of many repeated
5048 5055 string adds).
5049 5056
5050 5057 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5051 5058 of user-defined magics to operate with class methods (cleaner, in
5052 5059 line with the gnuplot code).
5053 5060
5054 5061 2002-04-22 Fernando Perez <fperez@colorado.edu>
5055 5062
5056 5063 * setup.py: updated dependency list so that manual is updated when
5057 5064 all included files change.
5058 5065
5059 5066 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5060 5067 the delimiter removal option (the fix is ugly right now).
5061 5068
5062 5069 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5063 5070 all of the math profile (quicker loading, no conflict between
5064 5071 g-9.8 and g-gnuplot).
5065 5072
5066 5073 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5067 5074 name of post-mortem files to IPython_crash_report.txt.
5068 5075
5069 5076 * Cleanup/update of the docs. Added all the new readline info and
5070 5077 formatted all lists as 'real lists'.
5071 5078
5072 5079 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5073 5080 tab-completion options, since the full readline parse_and_bind is
5074 5081 now accessible.
5075 5082
5076 5083 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5077 5084 handling of readline options. Now users can specify any string to
5078 5085 be passed to parse_and_bind(), as well as the delimiters to be
5079 5086 removed.
5080 5087 (InteractiveShell.__init__): Added __name__ to the global
5081 5088 namespace so that things like Itpl which rely on its existence
5082 5089 don't crash.
5083 5090 (InteractiveShell._prefilter): Defined the default with a _ so
5084 5091 that prefilter() is easier to override, while the default one
5085 5092 remains available.
5086 5093
5087 5094 2002-04-18 Fernando Perez <fperez@colorado.edu>
5088 5095
5089 5096 * Added information about pdb in the docs.
5090 5097
5091 5098 2002-04-17 Fernando Perez <fperez@colorado.edu>
5092 5099
5093 5100 * IPython/ipmaker.py (make_IPython): added rc_override option to
5094 5101 allow passing config options at creation time which may override
5095 5102 anything set in the config files or command line. This is
5096 5103 particularly useful for configuring embedded instances.
5097 5104
5098 5105 2002-04-15 Fernando Perez <fperez@colorado.edu>
5099 5106
5100 5107 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5101 5108 crash embedded instances because of the input cache falling out of
5102 5109 sync with the output counter.
5103 5110
5104 5111 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5105 5112 mode which calls pdb after an uncaught exception in IPython itself.
5106 5113
5107 5114 2002-04-14 Fernando Perez <fperez@colorado.edu>
5108 5115
5109 5116 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5110 5117 readline, fix it back after each call.
5111 5118
5112 5119 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5113 5120 method to force all access via __call__(), which guarantees that
5114 5121 traceback references are properly deleted.
5115 5122
5116 5123 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5117 5124 improve printing when pprint is in use.
5118 5125
5119 5126 2002-04-13 Fernando Perez <fperez@colorado.edu>
5120 5127
5121 5128 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5122 5129 exceptions aren't caught anymore. If the user triggers one, he
5123 5130 should know why he's doing it and it should go all the way up,
5124 5131 just like any other exception. So now @abort will fully kill the
5125 5132 embedded interpreter and the embedding code (unless that happens
5126 5133 to catch SystemExit).
5127 5134
5128 5135 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5129 5136 and a debugger() method to invoke the interactive pdb debugger
5130 5137 after printing exception information. Also added the corresponding
5131 5138 -pdb option and @pdb magic to control this feature, and updated
5132 5139 the docs. After a suggestion from Christopher Hart
5133 5140 (hart-AT-caltech.edu).
5134 5141
5135 5142 2002-04-12 Fernando Perez <fperez@colorado.edu>
5136 5143
5137 5144 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5138 5145 the exception handlers defined by the user (not the CrashHandler)
5139 5146 so that user exceptions don't trigger an ipython bug report.
5140 5147
5141 5148 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5142 5149 configurable (it should have always been so).
5143 5150
5144 5151 2002-03-26 Fernando Perez <fperez@colorado.edu>
5145 5152
5146 5153 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5147 5154 and there to fix embedding namespace issues. This should all be
5148 5155 done in a more elegant way.
5149 5156
5150 5157 2002-03-25 Fernando Perez <fperez@colorado.edu>
5151 5158
5152 5159 * IPython/genutils.py (get_home_dir): Try to make it work under
5153 5160 win9x also.
5154 5161
5155 5162 2002-03-20 Fernando Perez <fperez@colorado.edu>
5156 5163
5157 5164 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5158 5165 sys.displayhook untouched upon __init__.
5159 5166
5160 5167 2002-03-19 Fernando Perez <fperez@colorado.edu>
5161 5168
5162 5169 * Released 0.2.9 (for embedding bug, basically).
5163 5170
5164 5171 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5165 5172 exceptions so that enclosing shell's state can be restored.
5166 5173
5167 5174 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5168 5175 naming conventions in the .ipython/ dir.
5169 5176
5170 5177 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5171 5178 from delimiters list so filenames with - in them get expanded.
5172 5179
5173 5180 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5174 5181 sys.displayhook not being properly restored after an embedded call.
5175 5182
5176 5183 2002-03-18 Fernando Perez <fperez@colorado.edu>
5177 5184
5178 5185 * Released 0.2.8
5179 5186
5180 5187 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5181 5188 some files weren't being included in a -upgrade.
5182 5189 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5183 5190 on' so that the first tab completes.
5184 5191 (InteractiveShell.handle_magic): fixed bug with spaces around
5185 5192 quotes breaking many magic commands.
5186 5193
5187 5194 * setup.py: added note about ignoring the syntax error messages at
5188 5195 installation.
5189 5196
5190 5197 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5191 5198 streamlining the gnuplot interface, now there's only one magic @gp.
5192 5199
5193 5200 2002-03-17 Fernando Perez <fperez@colorado.edu>
5194 5201
5195 5202 * IPython/UserConfig/magic_gnuplot.py: new name for the
5196 5203 example-magic_pm.py file. Much enhanced system, now with a shell
5197 5204 for communicating directly with gnuplot, one command at a time.
5198 5205
5199 5206 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5200 5207 setting __name__=='__main__'.
5201 5208
5202 5209 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5203 5210 mini-shell for accessing gnuplot from inside ipython. Should
5204 5211 extend it later for grace access too. Inspired by Arnd's
5205 5212 suggestion.
5206 5213
5207 5214 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5208 5215 calling magic functions with () in their arguments. Thanks to Arnd
5209 5216 Baecker for pointing this to me.
5210 5217
5211 5218 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5212 5219 infinitely for integer or complex arrays (only worked with floats).
5213 5220
5214 5221 2002-03-16 Fernando Perez <fperez@colorado.edu>
5215 5222
5216 5223 * setup.py: Merged setup and setup_windows into a single script
5217 5224 which properly handles things for windows users.
5218 5225
5219 5226 2002-03-15 Fernando Perez <fperez@colorado.edu>
5220 5227
5221 5228 * Big change to the manual: now the magics are all automatically
5222 5229 documented. This information is generated from their docstrings
5223 5230 and put in a latex file included by the manual lyx file. This way
5224 5231 we get always up to date information for the magics. The manual
5225 5232 now also has proper version information, also auto-synced.
5226 5233
5227 5234 For this to work, an undocumented --magic_docstrings option was added.
5228 5235
5229 5236 2002-03-13 Fernando Perez <fperez@colorado.edu>
5230 5237
5231 5238 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5232 5239 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5233 5240
5234 5241 2002-03-12 Fernando Perez <fperez@colorado.edu>
5235 5242
5236 5243 * IPython/ultraTB.py (TermColors): changed color escapes again to
5237 5244 fix the (old, reintroduced) line-wrapping bug. Basically, if
5238 5245 \001..\002 aren't given in the color escapes, lines get wrapped
5239 5246 weirdly. But giving those screws up old xterms and emacs terms. So
5240 5247 I added some logic for emacs terms to be ok, but I can't identify old
5241 5248 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5242 5249
5243 5250 2002-03-10 Fernando Perez <fperez@colorado.edu>
5244 5251
5245 5252 * IPython/usage.py (__doc__): Various documentation cleanups and
5246 5253 updates, both in usage docstrings and in the manual.
5247 5254
5248 5255 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5249 5256 handling of caching. Set minimum acceptabe value for having a
5250 5257 cache at 20 values.
5251 5258
5252 5259 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5253 5260 install_first_time function to a method, renamed it and added an
5254 5261 'upgrade' mode. Now people can update their config directory with
5255 5262 a simple command line switch (-upgrade, also new).
5256 5263
5257 5264 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5258 5265 @file (convenient for automagic users under Python >= 2.2).
5259 5266 Removed @files (it seemed more like a plural than an abbrev. of
5260 5267 'file show').
5261 5268
5262 5269 * IPython/iplib.py (install_first_time): Fixed crash if there were
5263 5270 backup files ('~') in .ipython/ install directory.
5264 5271
5265 5272 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5266 5273 system. Things look fine, but these changes are fairly
5267 5274 intrusive. Test them for a few days.
5268 5275
5269 5276 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5270 5277 the prompts system. Now all in/out prompt strings are user
5271 5278 controllable. This is particularly useful for embedding, as one
5272 5279 can tag embedded instances with particular prompts.
5273 5280
5274 5281 Also removed global use of sys.ps1/2, which now allows nested
5275 5282 embeddings without any problems. Added command-line options for
5276 5283 the prompt strings.
5277 5284
5278 5285 2002-03-08 Fernando Perez <fperez@colorado.edu>
5279 5286
5280 5287 * IPython/UserConfig/example-embed-short.py (ipshell): added
5281 5288 example file with the bare minimum code for embedding.
5282 5289
5283 5290 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5284 5291 functionality for the embeddable shell to be activated/deactivated
5285 5292 either globally or at each call.
5286 5293
5287 5294 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5288 5295 rewriting the prompt with '--->' for auto-inputs with proper
5289 5296 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5290 5297 this is handled by the prompts class itself, as it should.
5291 5298
5292 5299 2002-03-05 Fernando Perez <fperez@colorado.edu>
5293 5300
5294 5301 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5295 5302 @logstart to avoid name clashes with the math log function.
5296 5303
5297 5304 * Big updates to X/Emacs section of the manual.
5298 5305
5299 5306 * Removed ipython_emacs. Milan explained to me how to pass
5300 5307 arguments to ipython through Emacs. Some day I'm going to end up
5301 5308 learning some lisp...
5302 5309
5303 5310 2002-03-04 Fernando Perez <fperez@colorado.edu>
5304 5311
5305 5312 * IPython/ipython_emacs: Created script to be used as the
5306 5313 py-python-command Emacs variable so we can pass IPython
5307 5314 parameters. I can't figure out how to tell Emacs directly to pass
5308 5315 parameters to IPython, so a dummy shell script will do it.
5309 5316
5310 5317 Other enhancements made for things to work better under Emacs'
5311 5318 various types of terminals. Many thanks to Milan Zamazal
5312 5319 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5313 5320
5314 5321 2002-03-01 Fernando Perez <fperez@colorado.edu>
5315 5322
5316 5323 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5317 5324 that loading of readline is now optional. This gives better
5318 5325 control to emacs users.
5319 5326
5320 5327 * IPython/ultraTB.py (__date__): Modified color escape sequences
5321 5328 and now things work fine under xterm and in Emacs' term buffers
5322 5329 (though not shell ones). Well, in emacs you get colors, but all
5323 5330 seem to be 'light' colors (no difference between dark and light
5324 5331 ones). But the garbage chars are gone, and also in xterms. It
5325 5332 seems that now I'm using 'cleaner' ansi sequences.
5326 5333
5327 5334 2002-02-21 Fernando Perez <fperez@colorado.edu>
5328 5335
5329 5336 * Released 0.2.7 (mainly to publish the scoping fix).
5330 5337
5331 5338 * IPython/Logger.py (Logger.logstate): added. A corresponding
5332 5339 @logstate magic was created.
5333 5340
5334 5341 * IPython/Magic.py: fixed nested scoping problem under Python
5335 5342 2.1.x (automagic wasn't working).
5336 5343
5337 5344 2002-02-20 Fernando Perez <fperez@colorado.edu>
5338 5345
5339 5346 * Released 0.2.6.
5340 5347
5341 5348 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5342 5349 option so that logs can come out without any headers at all.
5343 5350
5344 5351 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5345 5352 SciPy.
5346 5353
5347 5354 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5348 5355 that embedded IPython calls don't require vars() to be explicitly
5349 5356 passed. Now they are extracted from the caller's frame (code
5350 5357 snatched from Eric Jones' weave). Added better documentation to
5351 5358 the section on embedding and the example file.
5352 5359
5353 5360 * IPython/genutils.py (page): Changed so that under emacs, it just
5354 5361 prints the string. You can then page up and down in the emacs
5355 5362 buffer itself. This is how the builtin help() works.
5356 5363
5357 5364 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5358 5365 macro scoping: macros need to be executed in the user's namespace
5359 5366 to work as if they had been typed by the user.
5360 5367
5361 5368 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5362 5369 execute automatically (no need to type 'exec...'). They then
5363 5370 behave like 'true macros'. The printing system was also modified
5364 5371 for this to work.
5365 5372
5366 5373 2002-02-19 Fernando Perez <fperez@colorado.edu>
5367 5374
5368 5375 * IPython/genutils.py (page_file): new function for paging files
5369 5376 in an OS-independent way. Also necessary for file viewing to work
5370 5377 well inside Emacs buffers.
5371 5378 (page): Added checks for being in an emacs buffer.
5372 5379 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5373 5380 same bug in iplib.
5374 5381
5375 5382 2002-02-18 Fernando Perez <fperez@colorado.edu>
5376 5383
5377 5384 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5378 5385 of readline so that IPython can work inside an Emacs buffer.
5379 5386
5380 5387 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5381 5388 method signatures (they weren't really bugs, but it looks cleaner
5382 5389 and keeps PyChecker happy).
5383 5390
5384 5391 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5385 5392 for implementing various user-defined hooks. Currently only
5386 5393 display is done.
5387 5394
5388 5395 * IPython/Prompts.py (CachedOutput._display): changed display
5389 5396 functions so that they can be dynamically changed by users easily.
5390 5397
5391 5398 * IPython/Extensions/numeric_formats.py (num_display): added an
5392 5399 extension for printing NumPy arrays in flexible manners. It
5393 5400 doesn't do anything yet, but all the structure is in
5394 5401 place. Ultimately the plan is to implement output format control
5395 5402 like in Octave.
5396 5403
5397 5404 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5398 5405 methods are found at run-time by all the automatic machinery.
5399 5406
5400 5407 2002-02-17 Fernando Perez <fperez@colorado.edu>
5401 5408
5402 5409 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5403 5410 whole file a little.
5404 5411
5405 5412 * ToDo: closed this document. Now there's a new_design.lyx
5406 5413 document for all new ideas. Added making a pdf of it for the
5407 5414 end-user distro.
5408 5415
5409 5416 * IPython/Logger.py (Logger.switch_log): Created this to replace
5410 5417 logon() and logoff(). It also fixes a nasty crash reported by
5411 5418 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5412 5419
5413 5420 * IPython/iplib.py (complete): got auto-completion to work with
5414 5421 automagic (I had wanted this for a long time).
5415 5422
5416 5423 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5417 5424 to @file, since file() is now a builtin and clashes with automagic
5418 5425 for @file.
5419 5426
5420 5427 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5421 5428 of this was previously in iplib, which had grown to more than 2000
5422 5429 lines, way too long. No new functionality, but it makes managing
5423 5430 the code a bit easier.
5424 5431
5425 5432 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5426 5433 information to crash reports.
5427 5434
5428 5435 2002-02-12 Fernando Perez <fperez@colorado.edu>
5429 5436
5430 5437 * Released 0.2.5.
5431 5438
5432 5439 2002-02-11 Fernando Perez <fperez@colorado.edu>
5433 5440
5434 5441 * Wrote a relatively complete Windows installer. It puts
5435 5442 everything in place, creates Start Menu entries and fixes the
5436 5443 color issues. Nothing fancy, but it works.
5437 5444
5438 5445 2002-02-10 Fernando Perez <fperez@colorado.edu>
5439 5446
5440 5447 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5441 5448 os.path.expanduser() call so that we can type @run ~/myfile.py and
5442 5449 have thigs work as expected.
5443 5450
5444 5451 * IPython/genutils.py (page): fixed exception handling so things
5445 5452 work both in Unix and Windows correctly. Quitting a pager triggers
5446 5453 an IOError/broken pipe in Unix, and in windows not finding a pager
5447 5454 is also an IOError, so I had to actually look at the return value
5448 5455 of the exception, not just the exception itself. Should be ok now.
5449 5456
5450 5457 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5451 5458 modified to allow case-insensitive color scheme changes.
5452 5459
5453 5460 2002-02-09 Fernando Perez <fperez@colorado.edu>
5454 5461
5455 5462 * IPython/genutils.py (native_line_ends): new function to leave
5456 5463 user config files with os-native line-endings.
5457 5464
5458 5465 * README and manual updates.
5459 5466
5460 5467 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5461 5468 instead of StringType to catch Unicode strings.
5462 5469
5463 5470 * IPython/genutils.py (filefind): fixed bug for paths with
5464 5471 embedded spaces (very common in Windows).
5465 5472
5466 5473 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5467 5474 files under Windows, so that they get automatically associated
5468 5475 with a text editor. Windows makes it a pain to handle
5469 5476 extension-less files.
5470 5477
5471 5478 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5472 5479 warning about readline only occur for Posix. In Windows there's no
5473 5480 way to get readline, so why bother with the warning.
5474 5481
5475 5482 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5476 5483 for __str__ instead of dir(self), since dir() changed in 2.2.
5477 5484
5478 5485 * Ported to Windows! Tested on XP, I suspect it should work fine
5479 5486 on NT/2000, but I don't think it will work on 98 et al. That
5480 5487 series of Windows is such a piece of junk anyway that I won't try
5481 5488 porting it there. The XP port was straightforward, showed a few
5482 5489 bugs here and there (fixed all), in particular some string
5483 5490 handling stuff which required considering Unicode strings (which
5484 5491 Windows uses). This is good, but hasn't been too tested :) No
5485 5492 fancy installer yet, I'll put a note in the manual so people at
5486 5493 least make manually a shortcut.
5487 5494
5488 5495 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5489 5496 into a single one, "colors". This now controls both prompt and
5490 5497 exception color schemes, and can be changed both at startup
5491 5498 (either via command-line switches or via ipythonrc files) and at
5492 5499 runtime, with @colors.
5493 5500 (Magic.magic_run): renamed @prun to @run and removed the old
5494 5501 @run. The two were too similar to warrant keeping both.
5495 5502
5496 5503 2002-02-03 Fernando Perez <fperez@colorado.edu>
5497 5504
5498 5505 * IPython/iplib.py (install_first_time): Added comment on how to
5499 5506 configure the color options for first-time users. Put a <return>
5500 5507 request at the end so that small-terminal users get a chance to
5501 5508 read the startup info.
5502 5509
5503 5510 2002-01-23 Fernando Perez <fperez@colorado.edu>
5504 5511
5505 5512 * IPython/iplib.py (CachedOutput.update): Changed output memory
5506 5513 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5507 5514 input history we still use _i. Did this b/c these variable are
5508 5515 very commonly used in interactive work, so the less we need to
5509 5516 type the better off we are.
5510 5517 (Magic.magic_prun): updated @prun to better handle the namespaces
5511 5518 the file will run in, including a fix for __name__ not being set
5512 5519 before.
5513 5520
5514 5521 2002-01-20 Fernando Perez <fperez@colorado.edu>
5515 5522
5516 5523 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5517 5524 extra garbage for Python 2.2. Need to look more carefully into
5518 5525 this later.
5519 5526
5520 5527 2002-01-19 Fernando Perez <fperez@colorado.edu>
5521 5528
5522 5529 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5523 5530 display SyntaxError exceptions properly formatted when they occur
5524 5531 (they can be triggered by imported code).
5525 5532
5526 5533 2002-01-18 Fernando Perez <fperez@colorado.edu>
5527 5534
5528 5535 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5529 5536 SyntaxError exceptions are reported nicely formatted, instead of
5530 5537 spitting out only offset information as before.
5531 5538 (Magic.magic_prun): Added the @prun function for executing
5532 5539 programs with command line args inside IPython.
5533 5540
5534 5541 2002-01-16 Fernando Perez <fperez@colorado.edu>
5535 5542
5536 5543 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5537 5544 to *not* include the last item given in a range. This brings their
5538 5545 behavior in line with Python's slicing:
5539 5546 a[n1:n2] -> a[n1]...a[n2-1]
5540 5547 It may be a bit less convenient, but I prefer to stick to Python's
5541 5548 conventions *everywhere*, so users never have to wonder.
5542 5549 (Magic.magic_macro): Added @macro function to ease the creation of
5543 5550 macros.
5544 5551
5545 5552 2002-01-05 Fernando Perez <fperez@colorado.edu>
5546 5553
5547 5554 * Released 0.2.4.
5548 5555
5549 5556 * IPython/iplib.py (Magic.magic_pdef):
5550 5557 (InteractiveShell.safe_execfile): report magic lines and error
5551 5558 lines without line numbers so one can easily copy/paste them for
5552 5559 re-execution.
5553 5560
5554 5561 * Updated manual with recent changes.
5555 5562
5556 5563 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5557 5564 docstring printing when class? is called. Very handy for knowing
5558 5565 how to create class instances (as long as __init__ is well
5559 5566 documented, of course :)
5560 5567 (Magic.magic_doc): print both class and constructor docstrings.
5561 5568 (Magic.magic_pdef): give constructor info if passed a class and
5562 5569 __call__ info for callable object instances.
5563 5570
5564 5571 2002-01-04 Fernando Perez <fperez@colorado.edu>
5565 5572
5566 5573 * Made deep_reload() off by default. It doesn't always work
5567 5574 exactly as intended, so it's probably safer to have it off. It's
5568 5575 still available as dreload() anyway, so nothing is lost.
5569 5576
5570 5577 2002-01-02 Fernando Perez <fperez@colorado.edu>
5571 5578
5572 5579 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5573 5580 so I wanted an updated release).
5574 5581
5575 5582 2001-12-27 Fernando Perez <fperez@colorado.edu>
5576 5583
5577 5584 * IPython/iplib.py (InteractiveShell.interact): Added the original
5578 5585 code from 'code.py' for this module in order to change the
5579 5586 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5580 5587 the history cache would break when the user hit Ctrl-C, and
5581 5588 interact() offers no way to add any hooks to it.
5582 5589
5583 5590 2001-12-23 Fernando Perez <fperez@colorado.edu>
5584 5591
5585 5592 * setup.py: added check for 'MANIFEST' before trying to remove
5586 5593 it. Thanks to Sean Reifschneider.
5587 5594
5588 5595 2001-12-22 Fernando Perez <fperez@colorado.edu>
5589 5596
5590 5597 * Released 0.2.2.
5591 5598
5592 5599 * Finished (reasonably) writing the manual. Later will add the
5593 5600 python-standard navigation stylesheets, but for the time being
5594 5601 it's fairly complete. Distribution will include html and pdf
5595 5602 versions.
5596 5603
5597 5604 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5598 5605 (MayaVi author).
5599 5606
5600 5607 2001-12-21 Fernando Perez <fperez@colorado.edu>
5601 5608
5602 5609 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5603 5610 good public release, I think (with the manual and the distutils
5604 5611 installer). The manual can use some work, but that can go
5605 5612 slowly. Otherwise I think it's quite nice for end users. Next
5606 5613 summer, rewrite the guts of it...
5607 5614
5608 5615 * Changed format of ipythonrc files to use whitespace as the
5609 5616 separator instead of an explicit '='. Cleaner.
5610 5617
5611 5618 2001-12-20 Fernando Perez <fperez@colorado.edu>
5612 5619
5613 5620 * Started a manual in LyX. For now it's just a quick merge of the
5614 5621 various internal docstrings and READMEs. Later it may grow into a
5615 5622 nice, full-blown manual.
5616 5623
5617 5624 * Set up a distutils based installer. Installation should now be
5618 5625 trivially simple for end-users.
5619 5626
5620 5627 2001-12-11 Fernando Perez <fperez@colorado.edu>
5621 5628
5622 5629 * Released 0.2.0. First public release, announced it at
5623 5630 comp.lang.python. From now on, just bugfixes...
5624 5631
5625 5632 * Went through all the files, set copyright/license notices and
5626 5633 cleaned up things. Ready for release.
5627 5634
5628 5635 2001-12-10 Fernando Perez <fperez@colorado.edu>
5629 5636
5630 5637 * Changed the first-time installer not to use tarfiles. It's more
5631 5638 robust now and less unix-dependent. Also makes it easier for
5632 5639 people to later upgrade versions.
5633 5640
5634 5641 * Changed @exit to @abort to reflect the fact that it's pretty
5635 5642 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5636 5643 becomes significant only when IPyhton is embedded: in that case,
5637 5644 C-D closes IPython only, but @abort kills the enclosing program
5638 5645 too (unless it had called IPython inside a try catching
5639 5646 SystemExit).
5640 5647
5641 5648 * Created Shell module which exposes the actuall IPython Shell
5642 5649 classes, currently the normal and the embeddable one. This at
5643 5650 least offers a stable interface we won't need to change when
5644 5651 (later) the internals are rewritten. That rewrite will be confined
5645 5652 to iplib and ipmaker, but the Shell interface should remain as is.
5646 5653
5647 5654 * Added embed module which offers an embeddable IPShell object,
5648 5655 useful to fire up IPython *inside* a running program. Great for
5649 5656 debugging or dynamical data analysis.
5650 5657
5651 5658 2001-12-08 Fernando Perez <fperez@colorado.edu>
5652 5659
5653 5660 * Fixed small bug preventing seeing info from methods of defined
5654 5661 objects (incorrect namespace in _ofind()).
5655 5662
5656 5663 * Documentation cleanup. Moved the main usage docstrings to a
5657 5664 separate file, usage.py (cleaner to maintain, and hopefully in the
5658 5665 future some perlpod-like way of producing interactive, man and
5659 5666 html docs out of it will be found).
5660 5667
5661 5668 * Added @profile to see your profile at any time.
5662 5669
5663 5670 * Added @p as an alias for 'print'. It's especially convenient if
5664 5671 using automagic ('p x' prints x).
5665 5672
5666 5673 * Small cleanups and fixes after a pychecker run.
5667 5674
5668 5675 * Changed the @cd command to handle @cd - and @cd -<n> for
5669 5676 visiting any directory in _dh.
5670 5677
5671 5678 * Introduced _dh, a history of visited directories. @dhist prints
5672 5679 it out with numbers.
5673 5680
5674 5681 2001-12-07 Fernando Perez <fperez@colorado.edu>
5675 5682
5676 5683 * Released 0.1.22
5677 5684
5678 5685 * Made initialization a bit more robust against invalid color
5679 5686 options in user input (exit, not traceback-crash).
5680 5687
5681 5688 * Changed the bug crash reporter to write the report only in the
5682 5689 user's .ipython directory. That way IPython won't litter people's
5683 5690 hard disks with crash files all over the place. Also print on
5684 5691 screen the necessary mail command.
5685 5692
5686 5693 * With the new ultraTB, implemented LightBG color scheme for light
5687 5694 background terminals. A lot of people like white backgrounds, so I
5688 5695 guess we should at least give them something readable.
5689 5696
5690 5697 2001-12-06 Fernando Perez <fperez@colorado.edu>
5691 5698
5692 5699 * Modified the structure of ultraTB. Now there's a proper class
5693 5700 for tables of color schemes which allow adding schemes easily and
5694 5701 switching the active scheme without creating a new instance every
5695 5702 time (which was ridiculous). The syntax for creating new schemes
5696 5703 is also cleaner. I think ultraTB is finally done, with a clean
5697 5704 class structure. Names are also much cleaner (now there's proper
5698 5705 color tables, no need for every variable to also have 'color' in
5699 5706 its name).
5700 5707
5701 5708 * Broke down genutils into separate files. Now genutils only
5702 5709 contains utility functions, and classes have been moved to their
5703 5710 own files (they had enough independent functionality to warrant
5704 5711 it): ConfigLoader, OutputTrap, Struct.
5705 5712
5706 5713 2001-12-05 Fernando Perez <fperez@colorado.edu>
5707 5714
5708 5715 * IPython turns 21! Released version 0.1.21, as a candidate for
5709 5716 public consumption. If all goes well, release in a few days.
5710 5717
5711 5718 * Fixed path bug (files in Extensions/ directory wouldn't be found
5712 5719 unless IPython/ was explicitly in sys.path).
5713 5720
5714 5721 * Extended the FlexCompleter class as MagicCompleter to allow
5715 5722 completion of @-starting lines.
5716 5723
5717 5724 * Created __release__.py file as a central repository for release
5718 5725 info that other files can read from.
5719 5726
5720 5727 * Fixed small bug in logging: when logging was turned on in
5721 5728 mid-session, old lines with special meanings (!@?) were being
5722 5729 logged without the prepended comment, which is necessary since
5723 5730 they are not truly valid python syntax. This should make session
5724 5731 restores produce less errors.
5725 5732
5726 5733 * The namespace cleanup forced me to make a FlexCompleter class
5727 5734 which is nothing but a ripoff of rlcompleter, but with selectable
5728 5735 namespace (rlcompleter only works in __main__.__dict__). I'll try
5729 5736 to submit a note to the authors to see if this change can be
5730 5737 incorporated in future rlcompleter releases (Dec.6: done)
5731 5738
5732 5739 * More fixes to namespace handling. It was a mess! Now all
5733 5740 explicit references to __main__.__dict__ are gone (except when
5734 5741 really needed) and everything is handled through the namespace
5735 5742 dicts in the IPython instance. We seem to be getting somewhere
5736 5743 with this, finally...
5737 5744
5738 5745 * Small documentation updates.
5739 5746
5740 5747 * Created the Extensions directory under IPython (with an
5741 5748 __init__.py). Put the PhysicalQ stuff there. This directory should
5742 5749 be used for all special-purpose extensions.
5743 5750
5744 5751 * File renaming:
5745 5752 ipythonlib --> ipmaker
5746 5753 ipplib --> iplib
5747 5754 This makes a bit more sense in terms of what these files actually do.
5748 5755
5749 5756 * Moved all the classes and functions in ipythonlib to ipplib, so
5750 5757 now ipythonlib only has make_IPython(). This will ease up its
5751 5758 splitting in smaller functional chunks later.
5752 5759
5753 5760 * Cleaned up (done, I think) output of @whos. Better column
5754 5761 formatting, and now shows str(var) for as much as it can, which is
5755 5762 typically what one gets with a 'print var'.
5756 5763
5757 5764 2001-12-04 Fernando Perez <fperez@colorado.edu>
5758 5765
5759 5766 * Fixed namespace problems. Now builtin/IPyhton/user names get
5760 5767 properly reported in their namespace. Internal namespace handling
5761 5768 is finally getting decent (not perfect yet, but much better than
5762 5769 the ad-hoc mess we had).
5763 5770
5764 5771 * Removed -exit option. If people just want to run a python
5765 5772 script, that's what the normal interpreter is for. Less
5766 5773 unnecessary options, less chances for bugs.
5767 5774
5768 5775 * Added a crash handler which generates a complete post-mortem if
5769 5776 IPython crashes. This will help a lot in tracking bugs down the
5770 5777 road.
5771 5778
5772 5779 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5773 5780 which were boud to functions being reassigned would bypass the
5774 5781 logger, breaking the sync of _il with the prompt counter. This
5775 5782 would then crash IPython later when a new line was logged.
5776 5783
5777 5784 2001-12-02 Fernando Perez <fperez@colorado.edu>
5778 5785
5779 5786 * Made IPython a package. This means people don't have to clutter
5780 5787 their sys.path with yet another directory. Changed the INSTALL
5781 5788 file accordingly.
5782 5789
5783 5790 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5784 5791 sorts its output (so @who shows it sorted) and @whos formats the
5785 5792 table according to the width of the first column. Nicer, easier to
5786 5793 read. Todo: write a generic table_format() which takes a list of
5787 5794 lists and prints it nicely formatted, with optional row/column
5788 5795 separators and proper padding and justification.
5789 5796
5790 5797 * Released 0.1.20
5791 5798
5792 5799 * Fixed bug in @log which would reverse the inputcache list (a
5793 5800 copy operation was missing).
5794 5801
5795 5802 * Code cleanup. @config was changed to use page(). Better, since
5796 5803 its output is always quite long.
5797 5804
5798 5805 * Itpl is back as a dependency. I was having too many problems
5799 5806 getting the parametric aliases to work reliably, and it's just
5800 5807 easier to code weird string operations with it than playing %()s
5801 5808 games. It's only ~6k, so I don't think it's too big a deal.
5802 5809
5803 5810 * Found (and fixed) a very nasty bug with history. !lines weren't
5804 5811 getting cached, and the out of sync caches would crash
5805 5812 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5806 5813 division of labor a bit better. Bug fixed, cleaner structure.
5807 5814
5808 5815 2001-12-01 Fernando Perez <fperez@colorado.edu>
5809 5816
5810 5817 * Released 0.1.19
5811 5818
5812 5819 * Added option -n to @hist to prevent line number printing. Much
5813 5820 easier to copy/paste code this way.
5814 5821
5815 5822 * Created global _il to hold the input list. Allows easy
5816 5823 re-execution of blocks of code by slicing it (inspired by Janko's
5817 5824 comment on 'macros').
5818 5825
5819 5826 * Small fixes and doc updates.
5820 5827
5821 5828 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5822 5829 much too fragile with automagic. Handles properly multi-line
5823 5830 statements and takes parameters.
5824 5831
5825 5832 2001-11-30 Fernando Perez <fperez@colorado.edu>
5826 5833
5827 5834 * Version 0.1.18 released.
5828 5835
5829 5836 * Fixed nasty namespace bug in initial module imports.
5830 5837
5831 5838 * Added copyright/license notes to all code files (except
5832 5839 DPyGetOpt). For the time being, LGPL. That could change.
5833 5840
5834 5841 * Rewrote a much nicer README, updated INSTALL, cleaned up
5835 5842 ipythonrc-* samples.
5836 5843
5837 5844 * Overall code/documentation cleanup. Basically ready for
5838 5845 release. Only remaining thing: licence decision (LGPL?).
5839 5846
5840 5847 * Converted load_config to a class, ConfigLoader. Now recursion
5841 5848 control is better organized. Doesn't include the same file twice.
5842 5849
5843 5850 2001-11-29 Fernando Perez <fperez@colorado.edu>
5844 5851
5845 5852 * Got input history working. Changed output history variables from
5846 5853 _p to _o so that _i is for input and _o for output. Just cleaner
5847 5854 convention.
5848 5855
5849 5856 * Implemented parametric aliases. This pretty much allows the
5850 5857 alias system to offer full-blown shell convenience, I think.
5851 5858
5852 5859 * Version 0.1.17 released, 0.1.18 opened.
5853 5860
5854 5861 * dot_ipython/ipythonrc (alias): added documentation.
5855 5862 (xcolor): Fixed small bug (xcolors -> xcolor)
5856 5863
5857 5864 * Changed the alias system. Now alias is a magic command to define
5858 5865 aliases just like the shell. Rationale: the builtin magics should
5859 5866 be there for things deeply connected to IPython's
5860 5867 architecture. And this is a much lighter system for what I think
5861 5868 is the really important feature: allowing users to define quickly
5862 5869 magics that will do shell things for them, so they can customize
5863 5870 IPython easily to match their work habits. If someone is really
5864 5871 desperate to have another name for a builtin alias, they can
5865 5872 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5866 5873 works.
5867 5874
5868 5875 2001-11-28 Fernando Perez <fperez@colorado.edu>
5869 5876
5870 5877 * Changed @file so that it opens the source file at the proper
5871 5878 line. Since it uses less, if your EDITOR environment is
5872 5879 configured, typing v will immediately open your editor of choice
5873 5880 right at the line where the object is defined. Not as quick as
5874 5881 having a direct @edit command, but for all intents and purposes it
5875 5882 works. And I don't have to worry about writing @edit to deal with
5876 5883 all the editors, less does that.
5877 5884
5878 5885 * Version 0.1.16 released, 0.1.17 opened.
5879 5886
5880 5887 * Fixed some nasty bugs in the page/page_dumb combo that could
5881 5888 crash IPython.
5882 5889
5883 5890 2001-11-27 Fernando Perez <fperez@colorado.edu>
5884 5891
5885 5892 * Version 0.1.15 released, 0.1.16 opened.
5886 5893
5887 5894 * Finally got ? and ?? to work for undefined things: now it's
5888 5895 possible to type {}.get? and get information about the get method
5889 5896 of dicts, or os.path? even if only os is defined (so technically
5890 5897 os.path isn't). Works at any level. For example, after import os,
5891 5898 os?, os.path?, os.path.abspath? all work. This is great, took some
5892 5899 work in _ofind.
5893 5900
5894 5901 * Fixed more bugs with logging. The sanest way to do it was to add
5895 5902 to @log a 'mode' parameter. Killed two in one shot (this mode
5896 5903 option was a request of Janko's). I think it's finally clean
5897 5904 (famous last words).
5898 5905
5899 5906 * Added a page_dumb() pager which does a decent job of paging on
5900 5907 screen, if better things (like less) aren't available. One less
5901 5908 unix dependency (someday maybe somebody will port this to
5902 5909 windows).
5903 5910
5904 5911 * Fixed problem in magic_log: would lock of logging out if log
5905 5912 creation failed (because it would still think it had succeeded).
5906 5913
5907 5914 * Improved the page() function using curses to auto-detect screen
5908 5915 size. Now it can make a much better decision on whether to print
5909 5916 or page a string. Option screen_length was modified: a value 0
5910 5917 means auto-detect, and that's the default now.
5911 5918
5912 5919 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5913 5920 go out. I'll test it for a few days, then talk to Janko about
5914 5921 licences and announce it.
5915 5922
5916 5923 * Fixed the length of the auto-generated ---> prompt which appears
5917 5924 for auto-parens and auto-quotes. Getting this right isn't trivial,
5918 5925 with all the color escapes, different prompt types and optional
5919 5926 separators. But it seems to be working in all the combinations.
5920 5927
5921 5928 2001-11-26 Fernando Perez <fperez@colorado.edu>
5922 5929
5923 5930 * Wrote a regexp filter to get option types from the option names
5924 5931 string. This eliminates the need to manually keep two duplicate
5925 5932 lists.
5926 5933
5927 5934 * Removed the unneeded check_option_names. Now options are handled
5928 5935 in a much saner manner and it's easy to visually check that things
5929 5936 are ok.
5930 5937
5931 5938 * Updated version numbers on all files I modified to carry a
5932 5939 notice so Janko and Nathan have clear version markers.
5933 5940
5934 5941 * Updated docstring for ultraTB with my changes. I should send
5935 5942 this to Nathan.
5936 5943
5937 5944 * Lots of small fixes. Ran everything through pychecker again.
5938 5945
5939 5946 * Made loading of deep_reload an cmd line option. If it's not too
5940 5947 kosher, now people can just disable it. With -nodeep_reload it's
5941 5948 still available as dreload(), it just won't overwrite reload().
5942 5949
5943 5950 * Moved many options to the no| form (-opt and -noopt
5944 5951 accepted). Cleaner.
5945 5952
5946 5953 * Changed magic_log so that if called with no parameters, it uses
5947 5954 'rotate' mode. That way auto-generated logs aren't automatically
5948 5955 over-written. For normal logs, now a backup is made if it exists
5949 5956 (only 1 level of backups). A new 'backup' mode was added to the
5950 5957 Logger class to support this. This was a request by Janko.
5951 5958
5952 5959 * Added @logoff/@logon to stop/restart an active log.
5953 5960
5954 5961 * Fixed a lot of bugs in log saving/replay. It was pretty
5955 5962 broken. Now special lines (!@,/) appear properly in the command
5956 5963 history after a log replay.
5957 5964
5958 5965 * Tried and failed to implement full session saving via pickle. My
5959 5966 idea was to pickle __main__.__dict__, but modules can't be
5960 5967 pickled. This would be a better alternative to replaying logs, but
5961 5968 seems quite tricky to get to work. Changed -session to be called
5962 5969 -logplay, which more accurately reflects what it does. And if we
5963 5970 ever get real session saving working, -session is now available.
5964 5971
5965 5972 * Implemented color schemes for prompts also. As for tracebacks,
5966 5973 currently only NoColor and Linux are supported. But now the
5967 5974 infrastructure is in place, based on a generic ColorScheme
5968 5975 class. So writing and activating new schemes both for the prompts
5969 5976 and the tracebacks should be straightforward.
5970 5977
5971 5978 * Version 0.1.13 released, 0.1.14 opened.
5972 5979
5973 5980 * Changed handling of options for output cache. Now counter is
5974 5981 hardwired starting at 1 and one specifies the maximum number of
5975 5982 entries *in the outcache* (not the max prompt counter). This is
5976 5983 much better, since many statements won't increase the cache
5977 5984 count. It also eliminated some confusing options, now there's only
5978 5985 one: cache_size.
5979 5986
5980 5987 * Added 'alias' magic function and magic_alias option in the
5981 5988 ipythonrc file. Now the user can easily define whatever names he
5982 5989 wants for the magic functions without having to play weird
5983 5990 namespace games. This gives IPython a real shell-like feel.
5984 5991
5985 5992 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5986 5993 @ or not).
5987 5994
5988 5995 This was one of the last remaining 'visible' bugs (that I know
5989 5996 of). I think if I can clean up the session loading so it works
5990 5997 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5991 5998 about licensing).
5992 5999
5993 6000 2001-11-25 Fernando Perez <fperez@colorado.edu>
5994 6001
5995 6002 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5996 6003 there's a cleaner distinction between what ? and ?? show.
5997 6004
5998 6005 * Added screen_length option. Now the user can define his own
5999 6006 screen size for page() operations.
6000 6007
6001 6008 * Implemented magic shell-like functions with automatic code
6002 6009 generation. Now adding another function is just a matter of adding
6003 6010 an entry to a dict, and the function is dynamically generated at
6004 6011 run-time. Python has some really cool features!
6005 6012
6006 6013 * Renamed many options to cleanup conventions a little. Now all
6007 6014 are lowercase, and only underscores where needed. Also in the code
6008 6015 option name tables are clearer.
6009 6016
6010 6017 * Changed prompts a little. Now input is 'In [n]:' instead of
6011 6018 'In[n]:='. This allows it the numbers to be aligned with the
6012 6019 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6013 6020 Python (it was a Mathematica thing). The '...' continuation prompt
6014 6021 was also changed a little to align better.
6015 6022
6016 6023 * Fixed bug when flushing output cache. Not all _p<n> variables
6017 6024 exist, so their deletion needs to be wrapped in a try:
6018 6025
6019 6026 * Figured out how to properly use inspect.formatargspec() (it
6020 6027 requires the args preceded by *). So I removed all the code from
6021 6028 _get_pdef in Magic, which was just replicating that.
6022 6029
6023 6030 * Added test to prefilter to allow redefining magic function names
6024 6031 as variables. This is ok, since the @ form is always available,
6025 6032 but whe should allow the user to define a variable called 'ls' if
6026 6033 he needs it.
6027 6034
6028 6035 * Moved the ToDo information from README into a separate ToDo.
6029 6036
6030 6037 * General code cleanup and small bugfixes. I think it's close to a
6031 6038 state where it can be released, obviously with a big 'beta'
6032 6039 warning on it.
6033 6040
6034 6041 * Got the magic function split to work. Now all magics are defined
6035 6042 in a separate class. It just organizes things a bit, and now
6036 6043 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6037 6044 was too long).
6038 6045
6039 6046 * Changed @clear to @reset to avoid potential confusions with
6040 6047 the shell command clear. Also renamed @cl to @clear, which does
6041 6048 exactly what people expect it to from their shell experience.
6042 6049
6043 6050 Added a check to the @reset command (since it's so
6044 6051 destructive, it's probably a good idea to ask for confirmation).
6045 6052 But now reset only works for full namespace resetting. Since the
6046 6053 del keyword is already there for deleting a few specific
6047 6054 variables, I don't see the point of having a redundant magic
6048 6055 function for the same task.
6049 6056
6050 6057 2001-11-24 Fernando Perez <fperez@colorado.edu>
6051 6058
6052 6059 * Updated the builtin docs (esp. the ? ones).
6053 6060
6054 6061 * Ran all the code through pychecker. Not terribly impressed with
6055 6062 it: lots of spurious warnings and didn't really find anything of
6056 6063 substance (just a few modules being imported and not used).
6057 6064
6058 6065 * Implemented the new ultraTB functionality into IPython. New
6059 6066 option: xcolors. This chooses color scheme. xmode now only selects
6060 6067 between Plain and Verbose. Better orthogonality.
6061 6068
6062 6069 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6063 6070 mode and color scheme for the exception handlers. Now it's
6064 6071 possible to have the verbose traceback with no coloring.
6065 6072
6066 6073 2001-11-23 Fernando Perez <fperez@colorado.edu>
6067 6074
6068 6075 * Version 0.1.12 released, 0.1.13 opened.
6069 6076
6070 6077 * Removed option to set auto-quote and auto-paren escapes by
6071 6078 user. The chances of breaking valid syntax are just too high. If
6072 6079 someone *really* wants, they can always dig into the code.
6073 6080
6074 6081 * Made prompt separators configurable.
6075 6082
6076 6083 2001-11-22 Fernando Perez <fperez@colorado.edu>
6077 6084
6078 6085 * Small bugfixes in many places.
6079 6086
6080 6087 * Removed the MyCompleter class from ipplib. It seemed redundant
6081 6088 with the C-p,C-n history search functionality. Less code to
6082 6089 maintain.
6083 6090
6084 6091 * Moved all the original ipython.py code into ipythonlib.py. Right
6085 6092 now it's just one big dump into a function called make_IPython, so
6086 6093 no real modularity has been gained. But at least it makes the
6087 6094 wrapper script tiny, and since ipythonlib is a module, it gets
6088 6095 compiled and startup is much faster.
6089 6096
6090 6097 This is a reasobably 'deep' change, so we should test it for a
6091 6098 while without messing too much more with the code.
6092 6099
6093 6100 2001-11-21 Fernando Perez <fperez@colorado.edu>
6094 6101
6095 6102 * Version 0.1.11 released, 0.1.12 opened for further work.
6096 6103
6097 6104 * Removed dependency on Itpl. It was only needed in one place. It
6098 6105 would be nice if this became part of python, though. It makes life
6099 6106 *a lot* easier in some cases.
6100 6107
6101 6108 * Simplified the prefilter code a bit. Now all handlers are
6102 6109 expected to explicitly return a value (at least a blank string).
6103 6110
6104 6111 * Heavy edits in ipplib. Removed the help system altogether. Now
6105 6112 obj?/?? is used for inspecting objects, a magic @doc prints
6106 6113 docstrings, and full-blown Python help is accessed via the 'help'
6107 6114 keyword. This cleans up a lot of code (less to maintain) and does
6108 6115 the job. Since 'help' is now a standard Python component, might as
6109 6116 well use it and remove duplicate functionality.
6110 6117
6111 6118 Also removed the option to use ipplib as a standalone program. By
6112 6119 now it's too dependent on other parts of IPython to function alone.
6113 6120
6114 6121 * Fixed bug in genutils.pager. It would crash if the pager was
6115 6122 exited immediately after opening (broken pipe).
6116 6123
6117 6124 * Trimmed down the VerboseTB reporting a little. The header is
6118 6125 much shorter now and the repeated exception arguments at the end
6119 6126 have been removed. For interactive use the old header seemed a bit
6120 6127 excessive.
6121 6128
6122 6129 * Fixed small bug in output of @whos for variables with multi-word
6123 6130 types (only first word was displayed).
6124 6131
6125 6132 2001-11-17 Fernando Perez <fperez@colorado.edu>
6126 6133
6127 6134 * Version 0.1.10 released, 0.1.11 opened for further work.
6128 6135
6129 6136 * Modified dirs and friends. dirs now *returns* the stack (not
6130 6137 prints), so one can manipulate it as a variable. Convenient to
6131 6138 travel along many directories.
6132 6139
6133 6140 * Fixed bug in magic_pdef: would only work with functions with
6134 6141 arguments with default values.
6135 6142
6136 6143 2001-11-14 Fernando Perez <fperez@colorado.edu>
6137 6144
6138 6145 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6139 6146 example with IPython. Various other minor fixes and cleanups.
6140 6147
6141 6148 * Version 0.1.9 released, 0.1.10 opened for further work.
6142 6149
6143 6150 * Added sys.path to the list of directories searched in the
6144 6151 execfile= option. It used to be the current directory and the
6145 6152 user's IPYTHONDIR only.
6146 6153
6147 6154 2001-11-13 Fernando Perez <fperez@colorado.edu>
6148 6155
6149 6156 * Reinstated the raw_input/prefilter separation that Janko had
6150 6157 initially. This gives a more convenient setup for extending the
6151 6158 pre-processor from the outside: raw_input always gets a string,
6152 6159 and prefilter has to process it. We can then redefine prefilter
6153 6160 from the outside and implement extensions for special
6154 6161 purposes.
6155 6162
6156 6163 Today I got one for inputting PhysicalQuantity objects
6157 6164 (from Scientific) without needing any function calls at
6158 6165 all. Extremely convenient, and it's all done as a user-level
6159 6166 extension (no IPython code was touched). Now instead of:
6160 6167 a = PhysicalQuantity(4.2,'m/s**2')
6161 6168 one can simply say
6162 6169 a = 4.2 m/s**2
6163 6170 or even
6164 6171 a = 4.2 m/s^2
6165 6172
6166 6173 I use this, but it's also a proof of concept: IPython really is
6167 6174 fully user-extensible, even at the level of the parsing of the
6168 6175 command line. It's not trivial, but it's perfectly doable.
6169 6176
6170 6177 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6171 6178 the problem of modules being loaded in the inverse order in which
6172 6179 they were defined in
6173 6180
6174 6181 * Version 0.1.8 released, 0.1.9 opened for further work.
6175 6182
6176 6183 * Added magics pdef, source and file. They respectively show the
6177 6184 definition line ('prototype' in C), source code and full python
6178 6185 file for any callable object. The object inspector oinfo uses
6179 6186 these to show the same information.
6180 6187
6181 6188 * Version 0.1.7 released, 0.1.8 opened for further work.
6182 6189
6183 6190 * Separated all the magic functions into a class called Magic. The
6184 6191 InteractiveShell class was becoming too big for Xemacs to handle
6185 6192 (de-indenting a line would lock it up for 10 seconds while it
6186 6193 backtracked on the whole class!)
6187 6194
6188 6195 FIXME: didn't work. It can be done, but right now namespaces are
6189 6196 all messed up. Do it later (reverted it for now, so at least
6190 6197 everything works as before).
6191 6198
6192 6199 * Got the object introspection system (magic_oinfo) working! I
6193 6200 think this is pretty much ready for release to Janko, so he can
6194 6201 test it for a while and then announce it. Pretty much 100% of what
6195 6202 I wanted for the 'phase 1' release is ready. Happy, tired.
6196 6203
6197 6204 2001-11-12 Fernando Perez <fperez@colorado.edu>
6198 6205
6199 6206 * Version 0.1.6 released, 0.1.7 opened for further work.
6200 6207
6201 6208 * Fixed bug in printing: it used to test for truth before
6202 6209 printing, so 0 wouldn't print. Now checks for None.
6203 6210
6204 6211 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6205 6212 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6206 6213 reaches by hand into the outputcache. Think of a better way to do
6207 6214 this later.
6208 6215
6209 6216 * Various small fixes thanks to Nathan's comments.
6210 6217
6211 6218 * Changed magic_pprint to magic_Pprint. This way it doesn't
6212 6219 collide with pprint() and the name is consistent with the command
6213 6220 line option.
6214 6221
6215 6222 * Changed prompt counter behavior to be fully like
6216 6223 Mathematica's. That is, even input that doesn't return a result
6217 6224 raises the prompt counter. The old behavior was kind of confusing
6218 6225 (getting the same prompt number several times if the operation
6219 6226 didn't return a result).
6220 6227
6221 6228 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6222 6229
6223 6230 * Fixed -Classic mode (wasn't working anymore).
6224 6231
6225 6232 * Added colored prompts using Nathan's new code. Colors are
6226 6233 currently hardwired, they can be user-configurable. For
6227 6234 developers, they can be chosen in file ipythonlib.py, at the
6228 6235 beginning of the CachedOutput class def.
6229 6236
6230 6237 2001-11-11 Fernando Perez <fperez@colorado.edu>
6231 6238
6232 6239 * Version 0.1.5 released, 0.1.6 opened for further work.
6233 6240
6234 6241 * Changed magic_env to *return* the environment as a dict (not to
6235 6242 print it). This way it prints, but it can also be processed.
6236 6243
6237 6244 * Added Verbose exception reporting to interactive
6238 6245 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6239 6246 traceback. Had to make some changes to the ultraTB file. This is
6240 6247 probably the last 'big' thing in my mental todo list. This ties
6241 6248 in with the next entry:
6242 6249
6243 6250 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6244 6251 has to specify is Plain, Color or Verbose for all exception
6245 6252 handling.
6246 6253
6247 6254 * Removed ShellServices option. All this can really be done via
6248 6255 the magic system. It's easier to extend, cleaner and has automatic
6249 6256 namespace protection and documentation.
6250 6257
6251 6258 2001-11-09 Fernando Perez <fperez@colorado.edu>
6252 6259
6253 6260 * Fixed bug in output cache flushing (missing parameter to
6254 6261 __init__). Other small bugs fixed (found using pychecker).
6255 6262
6256 6263 * Version 0.1.4 opened for bugfixing.
6257 6264
6258 6265 2001-11-07 Fernando Perez <fperez@colorado.edu>
6259 6266
6260 6267 * Version 0.1.3 released, mainly because of the raw_input bug.
6261 6268
6262 6269 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6263 6270 and when testing for whether things were callable, a call could
6264 6271 actually be made to certain functions. They would get called again
6265 6272 once 'really' executed, with a resulting double call. A disaster
6266 6273 in many cases (list.reverse() would never work!).
6267 6274
6268 6275 * Removed prefilter() function, moved its code to raw_input (which
6269 6276 after all was just a near-empty caller for prefilter). This saves
6270 6277 a function call on every prompt, and simplifies the class a tiny bit.
6271 6278
6272 6279 * Fix _ip to __ip name in magic example file.
6273 6280
6274 6281 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6275 6282 work with non-gnu versions of tar.
6276 6283
6277 6284 2001-11-06 Fernando Perez <fperez@colorado.edu>
6278 6285
6279 6286 * Version 0.1.2. Just to keep track of the recent changes.
6280 6287
6281 6288 * Fixed nasty bug in output prompt routine. It used to check 'if
6282 6289 arg != None...'. Problem is, this fails if arg implements a
6283 6290 special comparison (__cmp__) which disallows comparing to
6284 6291 None. Found it when trying to use the PhysicalQuantity module from
6285 6292 ScientificPython.
6286 6293
6287 6294 2001-11-05 Fernando Perez <fperez@colorado.edu>
6288 6295
6289 6296 * Also added dirs. Now the pushd/popd/dirs family functions
6290 6297 basically like the shell, with the added convenience of going home
6291 6298 when called with no args.
6292 6299
6293 6300 * pushd/popd slightly modified to mimic shell behavior more
6294 6301 closely.
6295 6302
6296 6303 * Added env,pushd,popd from ShellServices as magic functions. I
6297 6304 think the cleanest will be to port all desired functions from
6298 6305 ShellServices as magics and remove ShellServices altogether. This
6299 6306 will provide a single, clean way of adding functionality
6300 6307 (shell-type or otherwise) to IP.
6301 6308
6302 6309 2001-11-04 Fernando Perez <fperez@colorado.edu>
6303 6310
6304 6311 * Added .ipython/ directory to sys.path. This way users can keep
6305 6312 customizations there and access them via import.
6306 6313
6307 6314 2001-11-03 Fernando Perez <fperez@colorado.edu>
6308 6315
6309 6316 * Opened version 0.1.1 for new changes.
6310 6317
6311 6318 * Changed version number to 0.1.0: first 'public' release, sent to
6312 6319 Nathan and Janko.
6313 6320
6314 6321 * Lots of small fixes and tweaks.
6315 6322
6316 6323 * Minor changes to whos format. Now strings are shown, snipped if
6317 6324 too long.
6318 6325
6319 6326 * Changed ShellServices to work on __main__ so they show up in @who
6320 6327
6321 6328 * Help also works with ? at the end of a line:
6322 6329 ?sin and sin?
6323 6330 both produce the same effect. This is nice, as often I use the
6324 6331 tab-complete to find the name of a method, but I used to then have
6325 6332 to go to the beginning of the line to put a ? if I wanted more
6326 6333 info. Now I can just add the ? and hit return. Convenient.
6327 6334
6328 6335 2001-11-02 Fernando Perez <fperez@colorado.edu>
6329 6336
6330 6337 * Python version check (>=2.1) added.
6331 6338
6332 6339 * Added LazyPython documentation. At this point the docs are quite
6333 6340 a mess. A cleanup is in order.
6334 6341
6335 6342 * Auto-installer created. For some bizarre reason, the zipfiles
6336 6343 module isn't working on my system. So I made a tar version
6337 6344 (hopefully the command line options in various systems won't kill
6338 6345 me).
6339 6346
6340 6347 * Fixes to Struct in genutils. Now all dictionary-like methods are
6341 6348 protected (reasonably).
6342 6349
6343 6350 * Added pager function to genutils and changed ? to print usage
6344 6351 note through it (it was too long).
6345 6352
6346 6353 * Added the LazyPython functionality. Works great! I changed the
6347 6354 auto-quote escape to ';', it's on home row and next to '. But
6348 6355 both auto-quote and auto-paren (still /) escapes are command-line
6349 6356 parameters.
6350 6357
6351 6358
6352 6359 2001-11-01 Fernando Perez <fperez@colorado.edu>
6353 6360
6354 6361 * Version changed to 0.0.7. Fairly large change: configuration now
6355 6362 is all stored in a directory, by default .ipython. There, all
6356 6363 config files have normal looking names (not .names)
6357 6364
6358 6365 * Version 0.0.6 Released first to Lucas and Archie as a test
6359 6366 run. Since it's the first 'semi-public' release, change version to
6360 6367 > 0.0.6 for any changes now.
6361 6368
6362 6369 * Stuff I had put in the ipplib.py changelog:
6363 6370
6364 6371 Changes to InteractiveShell:
6365 6372
6366 6373 - Made the usage message a parameter.
6367 6374
6368 6375 - Require the name of the shell variable to be given. It's a bit
6369 6376 of a hack, but allows the name 'shell' not to be hardwired in the
6370 6377 magic (@) handler, which is problematic b/c it requires
6371 6378 polluting the global namespace with 'shell'. This in turn is
6372 6379 fragile: if a user redefines a variable called shell, things
6373 6380 break.
6374 6381
6375 6382 - magic @: all functions available through @ need to be defined
6376 6383 as magic_<name>, even though they can be called simply as
6377 6384 @<name>. This allows the special command @magic to gather
6378 6385 information automatically about all existing magic functions,
6379 6386 even if they are run-time user extensions, by parsing the shell
6380 6387 instance __dict__ looking for special magic_ names.
6381 6388
6382 6389 - mainloop: added *two* local namespace parameters. This allows
6383 6390 the class to differentiate between parameters which were there
6384 6391 before and after command line initialization was processed. This
6385 6392 way, later @who can show things loaded at startup by the
6386 6393 user. This trick was necessary to make session saving/reloading
6387 6394 really work: ideally after saving/exiting/reloading a session,
6388 6395 *everything* should look the same, including the output of @who. I
6389 6396 was only able to make this work with this double namespace
6390 6397 trick.
6391 6398
6392 6399 - added a header to the logfile which allows (almost) full
6393 6400 session restoring.
6394 6401
6395 6402 - prepend lines beginning with @ or !, with a and log
6396 6403 them. Why? !lines: may be useful to know what you did @lines:
6397 6404 they may affect session state. So when restoring a session, at
6398 6405 least inform the user of their presence. I couldn't quite get
6399 6406 them to properly re-execute, but at least the user is warned.
6400 6407
6401 6408 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now