##// END OF EJS Templates
- improve support for tab-completion under emacs...
fperez -
Show More
@@ -1,2677 +1,2690 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Magic.py 986 2005-12-31 23:07:31Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 8 # Copyright (C) 2001-2004 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 from cStringIO import StringIO
35 35 from getopt import getopt
36 36 from pprint import pprint, pformat
37 37
38 38 # profile isn't bundled by default in Debian for license reasons
39 39 try:
40 40 import profile,pstats
41 41 except ImportError:
42 42 profile = pstats = None
43 43
44 44 # Homebrewed
45 45 from IPython import Debugger, OInspect, wildcard
46 46 from IPython.FakeModule import FakeModule
47 47 from IPython.Itpl import Itpl, itpl, printpl,itplns
48 48 from IPython.PyColorize import Parser
49 49 from IPython.Struct import Struct
50 50 from IPython.macro import Macro
51 51 from IPython.genutils import *
52 52
53 53 #***************************************************************************
54 54 # Utility functions
55 55 def on_off(tag):
56 56 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
57 57 return ['OFF','ON'][tag]
58 58
59 59
60 60 #***************************************************************************
61 61 # Main class implementing Magic functionality
62 62 class Magic:
63 63 """Magic functions for InteractiveShell.
64 64
65 65 Shell functions which can be reached as %function_name. All magic
66 66 functions should accept a string, which they can parse for their own
67 67 needs. This can make some functions easier to type, eg `%cd ../`
68 68 vs. `%cd("../")`
69 69
70 70 ALL definitions MUST begin with the prefix magic_. The user won't need it
71 71 at the command line, but it is is needed in the definition. """
72 72
73 73 # class globals
74 74 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
75 75 'Automagic is ON, % prefix NOT needed for magic functions.']
76 76
77 77 #......................................................................
78 78 # some utility functions
79 79
80 80 def __init__(self,shell):
81 81
82 82 self.options_table = {}
83 83 if profile is None:
84 84 self.magic_prun = self.profile_missing_notice
85 85 self.shell = shell
86 86
87 87 def profile_missing_notice(self, *args, **kwargs):
88 88 error("""\
89 89 The profile module could not be found. If you are a Debian user,
90 90 it has been removed from the standard Debian package because of its non-free
91 91 license. To use profiling, please install"python2.3-profiler" from non-free.""")
92 92
93 93 def default_option(self,fn,optstr):
94 94 """Make an entry in the options_table for fn, with value optstr"""
95 95
96 96 if fn not in self.lsmagic():
97 97 error("%s is not a magic function" % fn)
98 98 self.options_table[fn] = optstr
99 99
100 100 def lsmagic(self):
101 101 """Return a list of currently available magic functions.
102 102
103 103 Gives a list of the bare names after mangling (['ls','cd', ...], not
104 104 ['magic_ls','magic_cd',...]"""
105 105
106 106 # FIXME. This needs a cleanup, in the way the magics list is built.
107 107
108 108 # magics in class definition
109 109 class_magic = lambda fn: fn.startswith('magic_') and \
110 110 callable(Magic.__dict__[fn])
111 111 # in instance namespace (run-time user additions)
112 112 inst_magic = lambda fn: fn.startswith('magic_') and \
113 113 callable(self.__dict__[fn])
114 114 # and bound magics by user (so they can access self):
115 115 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
116 116 callable(self.__class__.__dict__[fn])
117 117 magics = filter(class_magic,Magic.__dict__.keys()) + \
118 118 filter(inst_magic,self.__dict__.keys()) + \
119 119 filter(inst_bound_magic,self.__class__.__dict__.keys())
120 120 out = []
121 121 for fn in magics:
122 122 out.append(fn.replace('magic_','',1))
123 123 out.sort()
124 124 return out
125 125
126 126 def extract_input_slices(self,slices):
127 127 """Return as a string a set of input history slices.
128 128
129 129 The set of slices is given as a list of strings (like ['1','4:8','9'],
130 130 since this function is for use by magic functions which get their
131 arguments as strings."""
131 arguments as strings.
132
133 Note that slices can be called with two notations:
134
135 N:M -> standard python form, means including items N...(M-1).
136
137 N-M -> include items N..M (closed endpoint)."""
132 138
133 139 cmds = []
134 140 for chunk in slices:
135 141 if ':' in chunk:
136 142 ini,fin = map(int,chunk.split(':'))
143 elif '-' in chunk:
144 ini,fin = map(int,chunk.split('-'))
145 fin += 1
137 146 else:
138 147 ini = int(chunk)
139 148 fin = ini+1
140 149 cmds.append(self.shell.input_hist[ini:fin])
141 150 return cmds
142 151
143 152 def _ofind(self,oname):
144 153 """Find an object in the available namespaces.
145 154
146 155 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
147 156
148 157 Has special code to detect magic functions.
149 158 """
150 159
151 160 oname = oname.strip()
152 161
153 162 # Namespaces to search in:
154 163 user_ns = self.shell.user_ns
155 164 internal_ns = self.shell.internal_ns
156 165 builtin_ns = __builtin__.__dict__
157 166 alias_ns = self.shell.alias_table
158 167
159 168 # Put them in a list. The order is important so that we find things in
160 169 # the same order that Python finds them.
161 170 namespaces = [ ('Interactive',user_ns),
162 171 ('IPython internal',internal_ns),
163 172 ('Python builtin',builtin_ns),
164 173 ('Alias',alias_ns),
165 174 ]
166 175
167 176 # initialize results to 'null'
168 177 found = 0; obj = None; ospace = None; ds = None;
169 178 ismagic = 0; isalias = 0
170 179
171 180 # Look for the given name by splitting it in parts. If the head is
172 181 # found, then we look for all the remaining parts as members, and only
173 182 # declare success if we can find them all.
174 183 oname_parts = oname.split('.')
175 184 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
176 185 for nsname,ns in namespaces:
177 186 try:
178 187 obj = ns[oname_head]
179 188 except KeyError:
180 189 continue
181 190 else:
182 191 for part in oname_rest:
183 192 try:
184 193 obj = getattr(obj,part)
185 194 except:
186 195 # Blanket except b/c some badly implemented objects
187 196 # allow __getattr__ to raise exceptions other than
188 197 # AttributeError, which then crashes IPython.
189 198 break
190 199 else:
191 200 # If we finish the for loop (no break), we got all members
192 201 found = 1
193 202 ospace = nsname
194 203 if ns == alias_ns:
195 204 isalias = 1
196 205 break # namespace loop
197 206
198 207 # Try to see if it's magic
199 208 if not found:
200 209 if oname.startswith(self.shell.ESC_MAGIC):
201 210 oname = oname[1:]
202 211 obj = getattr(self,'magic_'+oname,None)
203 212 if obj is not None:
204 213 found = 1
205 214 ospace = 'IPython internal'
206 215 ismagic = 1
207 216
208 217 # Last try: special-case some literals like '', [], {}, etc:
209 218 if not found and oname_head in ["''",'""','[]','{}','()']:
210 219 obj = eval(oname_head)
211 220 found = 1
212 221 ospace = 'Interactive'
213 222
214 223 return {'found':found, 'obj':obj, 'namespace':ospace,
215 224 'ismagic':ismagic, 'isalias':isalias}
216 225
217 226 def arg_err(self,func):
218 227 """Print docstring if incorrect arguments were passed"""
219 228 print 'Error in arguments:'
220 229 print OInspect.getdoc(func)
221 230
222 231 def format_latex(self,strng):
223 232 """Format a string for latex inclusion."""
224 233
225 234 # Characters that need to be escaped for latex:
226 235 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
227 236 # Magic command names as headers:
228 237 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
229 238 re.MULTILINE)
230 239 # Magic commands
231 240 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
232 241 re.MULTILINE)
233 242 # Paragraph continue
234 243 par_re = re.compile(r'\\$',re.MULTILINE)
235 244
236 245 # The "\n" symbol
237 246 newline_re = re.compile(r'\\n')
238 247
239 248 # Now build the string for output:
240 249 strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
241 250 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
242 251 strng = par_re.sub(r'\\\\',strng)
243 252 strng = escape_re.sub(r'\\\1',strng)
244 253 strng = newline_re.sub(r'\\textbackslash{}n',strng)
245 254 return strng
246 255
247 256 def format_screen(self,strng):
248 257 """Format a string for screen printing.
249 258
250 259 This removes some latex-type format codes."""
251 260 # Paragraph continue
252 261 par_re = re.compile(r'\\$',re.MULTILINE)
253 262 strng = par_re.sub('',strng)
254 263 return strng
255 264
256 265 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
257 266 """Parse options passed to an argument string.
258 267
259 268 The interface is similar to that of getopt(), but it returns back a
260 269 Struct with the options as keys and the stripped argument string still
261 270 as a string.
262 271
263 272 arg_str is quoted as a true sys.argv vector by using shlex.split.
264 273 This allows us to easily expand variables, glob files, quote
265 274 arguments, etc.
266 275
267 276 Options:
268 277 -mode: default 'string'. If given as 'list', the argument string is
269 278 returned as a list (split on whitespace) instead of a string.
270 279
271 280 -list_all: put all option values in lists. Normally only options
272 281 appearing more than once are put in a list."""
273 282
274 283 # inject default options at the beginning of the input line
275 284 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
276 285 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
277 286
278 287 mode = kw.get('mode','string')
279 288 if mode not in ['string','list']:
280 289 raise ValueError,'incorrect mode given: %s' % mode
281 290 # Get options
282 291 list_all = kw.get('list_all',0)
283 292
284 293 # Check if we have more than one argument to warrant extra processing:
285 294 odict = {} # Dictionary with options
286 295 args = arg_str.split()
287 296 if len(args) >= 1:
288 297 # If the list of inputs only has 0 or 1 thing in it, there's no
289 298 # need to look for options
290 299 argv = shlex_split(arg_str)
291 300 # Do regular option processing
292 301 opts,args = getopt(argv,opt_str,*long_opts)
293 302 for o,a in opts:
294 303 if o.startswith('--'):
295 304 o = o[2:]
296 305 else:
297 306 o = o[1:]
298 307 try:
299 308 odict[o].append(a)
300 309 except AttributeError:
301 310 odict[o] = [odict[o],a]
302 311 except KeyError:
303 312 if list_all:
304 313 odict[o] = [a]
305 314 else:
306 315 odict[o] = a
307 316
308 317 # Prepare opts,args for return
309 318 opts = Struct(odict)
310 319 if mode == 'string':
311 320 args = ' '.join(args)
312 321
313 322 return opts,args
314 323
315 324 #......................................................................
316 325 # And now the actual magic functions
317 326
318 327 # Functions for IPython shell work (vars,funcs, config, etc)
319 328 def magic_lsmagic(self, parameter_s = ''):
320 329 """List currently available magic functions."""
321 330 mesc = self.shell.ESC_MAGIC
322 331 print 'Available magic functions:\n'+mesc+\
323 332 (' '+mesc).join(self.lsmagic())
324 333 print '\n' + Magic.auto_status[self.shell.rc.automagic]
325 334 return None
326 335
327 336 def magic_magic(self, parameter_s = ''):
328 337 """Print information about the magic function system."""
329 338
330 339 mode = ''
331 340 try:
332 341 if parameter_s.split()[0] == '-latex':
333 342 mode = 'latex'
334 343 except:
335 344 pass
336 345
337 346 magic_docs = []
338 347 for fname in self.lsmagic():
339 348 mname = 'magic_' + fname
340 349 for space in (Magic,self,self.__class__):
341 350 try:
342 351 fn = space.__dict__[mname]
343 352 except KeyError:
344 353 pass
345 354 else:
346 355 break
347 356 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
348 357 fname,fn.__doc__))
349 358 magic_docs = ''.join(magic_docs)
350 359
351 360 if mode == 'latex':
352 361 print self.format_latex(magic_docs)
353 362 return
354 363 else:
355 364 magic_docs = self.format_screen(magic_docs)
356 365
357 366 outmsg = """
358 367 IPython's 'magic' functions
359 368 ===========================
360 369
361 370 The magic function system provides a series of functions which allow you to
362 371 control the behavior of IPython itself, plus a lot of system-type
363 372 features. All these functions are prefixed with a % character, but parameters
364 373 are given without parentheses or quotes.
365 374
366 375 NOTE: If you have 'automagic' enabled (via the command line option or with the
367 376 %automagic function), you don't need to type in the % explicitly. By default,
368 377 IPython ships with automagic on, so you should only rarely need the % escape.
369 378
370 379 Example: typing '%cd mydir' (without the quotes) changes you working directory
371 380 to 'mydir', if it exists.
372 381
373 382 You can define your own magic functions to extend the system. See the supplied
374 383 ipythonrc and example-magic.py files for details (in your ipython
375 384 configuration directory, typically $HOME/.ipython/).
376 385
377 386 You can also define your own aliased names for magic functions. In your
378 387 ipythonrc file, placing a line like:
379 388
380 389 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
381 390
382 391 will define %pf as a new name for %profile.
383 392
384 393 You can also call magics in code using the ipmagic() function, which IPython
385 394 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
386 395
387 396 For a list of the available magic functions, use %lsmagic. For a description
388 397 of any of them, type %magic_name?, e.g. '%cd?'.
389 398
390 399 Currently the magic system has the following functions:\n"""
391 400
392 401 mesc = self.shell.ESC_MAGIC
393 402 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
394 403 "\n\n%s%s\n\n%s" % (outmsg,
395 404 magic_docs,mesc,mesc,
396 405 (' '+mesc).join(self.lsmagic()),
397 406 Magic.auto_status[self.shell.rc.automagic] ) )
398 407
399 408 page(outmsg,screen_lines=self.shell.rc.screen_length)
400 409
401 410 def magic_automagic(self, parameter_s = ''):
402 411 """Make magic functions callable without having to type the initial %.
403 412
404 413 Toggles on/off (when off, you must call it as %automagic, of
405 414 course). Note that magic functions have lowest priority, so if there's
406 415 a variable whose name collides with that of a magic fn, automagic
407 416 won't work for that function (you get the variable instead). However,
408 417 if you delete the variable (del var), the previously shadowed magic
409 418 function becomes visible to automagic again."""
410 419
411 420 rc = self.shell.rc
412 421 rc.automagic = not rc.automagic
413 422 print '\n' + Magic.auto_status[rc.automagic]
414 423
415 424 def magic_autocall(self, parameter_s = ''):
416 425 """Make functions callable without having to type parentheses.
417 426
418 427 This toggles the autocall command line option on and off."""
419 428
420 429 rc = self.shell.rc
421 430 rc.autocall = not rc.autocall
422 431 print "Automatic calling is:",['OFF','ON'][rc.autocall]
423 432
424 433 def magic_autoindent(self, parameter_s = ''):
425 434 """Toggle autoindent on/off (if available)."""
426 435
427 436 self.shell.set_autoindent()
428 437 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
429 438
430 439 def magic_system_verbose(self, parameter_s = ''):
431 440 """Toggle verbose printing of system calls on/off."""
432 441
433 442 self.shell.rc_set_toggle('system_verbose')
434 443 print "System verbose printing is:",\
435 444 ['OFF','ON'][self.shell.rc.system_verbose]
436 445
437 446 def magic_history(self, parameter_s = ''):
438 447 """Print input history (_i<n> variables), with most recent last.
439 448
440 449 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
441 450 %history [-n] n -> print at most n inputs\\
442 451 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
443 452
444 453 Each input's number <n> is shown, and is accessible as the
445 454 automatically generated variable _i<n>. Multi-line statements are
446 455 printed starting at a new line for easy copy/paste.
447 456
448 457 If option -n is used, input numbers are not printed. This is useful if
449 458 you want to get a printout of many lines which can be directly pasted
450 459 into a text editor.
451 460
452 461 This feature is only available if numbered prompts are in use."""
453 462
454 463 shell = self.shell
455 464 if not shell.outputcache.do_full_cache:
456 465 print 'This feature is only available if numbered prompts are in use.'
457 466 return
458 467 opts,args = self.parse_options(parameter_s,'n',mode='list')
459 468
460 469 input_hist = shell.input_hist
461 470 default_length = 40
462 471 if len(args) == 0:
463 472 final = len(input_hist)
464 473 init = max(1,final-default_length)
465 474 elif len(args) == 1:
466 475 final = len(input_hist)
467 476 init = max(1,final-int(args[0]))
468 477 elif len(args) == 2:
469 478 init,final = map(int,args)
470 479 else:
471 480 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
472 481 print self.magic_hist.__doc__
473 482 return
474 483 width = len(str(final))
475 484 line_sep = ['','\n']
476 485 print_nums = not opts.has_key('n')
477 486 for in_num in range(init,final):
478 487 inline = input_hist[in_num]
479 488 multiline = int(inline.count('\n') > 1)
480 489 if print_nums:
481 490 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
482 491 print inline,
483 492
484 493 def magic_hist(self, parameter_s=''):
485 494 """Alternate name for %history."""
486 495 return self.magic_history(parameter_s)
487 496
488 497 def magic_p(self, parameter_s=''):
489 498 """Just a short alias for Python's 'print'."""
490 499 exec 'print ' + parameter_s in self.shell.user_ns
491 500
492 501 def magic_r(self, parameter_s=''):
493 502 """Repeat previous input.
494 503
495 504 If given an argument, repeats the previous command which starts with
496 505 the same string, otherwise it just repeats the previous input.
497 506
498 507 Shell escaped commands (with ! as first character) are not recognized
499 508 by this system, only pure python code and magic commands.
500 509 """
501 510
502 511 start = parameter_s.strip()
503 512 esc_magic = self.shell.ESC_MAGIC
504 513 # Identify magic commands even if automagic is on (which means
505 514 # the in-memory version is different from that typed by the user).
506 515 if self.shell.rc.automagic:
507 516 start_magic = esc_magic+start
508 517 else:
509 518 start_magic = start
510 519 # Look through the input history in reverse
511 520 for n in range(len(self.shell.input_hist)-2,0,-1):
512 521 input = self.shell.input_hist[n]
513 522 # skip plain 'r' lines so we don't recurse to infinity
514 523 if input != 'ipmagic("r")\n' and \
515 524 (input.startswith(start) or input.startswith(start_magic)):
516 525 #print 'match',`input` # dbg
517 526 print 'Executing:',input,
518 527 self.shell.runlines(input)
519 528 return
520 529 print 'No previous input matching `%s` found.' % start
521 530
522 531 def magic_page(self, parameter_s=''):
523 532 """Pretty print the object and display it through a pager.
524 533
525 534 If no parameter is given, use _ (last output)."""
526 535 # After a function contributed by Olivier Aubert, slightly modified.
527 536
528 537 oname = parameter_s and parameter_s or '_'
529 538 info = self._ofind(oname)
530 539 if info['found']:
531 540 page(pformat(info['obj']))
532 541 else:
533 542 print 'Object `%s` not found' % oname
534 543
535 544 def magic_profile(self, parameter_s=''):
536 545 """Print your currently active IPyhton profile."""
537 546 if self.shell.rc.profile:
538 547 printpl('Current IPython profile: $self.shell.rc.profile.')
539 548 else:
540 549 print 'No profile active.'
541 550
542 551 def _inspect(self,meth,oname,**kw):
543 552 """Generic interface to the inspector system.
544 553
545 554 This function is meant to be called by pdef, pdoc & friends."""
546 555
547 556 oname = oname.strip()
548 557 info = Struct(self._ofind(oname))
549 558 if info.found:
550 559 pmethod = getattr(self.shell.inspector,meth)
551 560 formatter = info.ismagic and self.format_screen or None
552 561 if meth == 'pdoc':
553 562 pmethod(info.obj,oname,formatter)
554 563 elif meth == 'pinfo':
555 564 pmethod(info.obj,oname,formatter,info,**kw)
556 565 else:
557 566 pmethod(info.obj,oname)
558 567 else:
559 568 print 'Object `%s` not found.' % oname
560 569 return 'not found' # so callers can take other action
561 570
562 571 def magic_pdef(self, parameter_s=''):
563 572 """Print the definition header for any callable object.
564 573
565 574 If the object is a class, print the constructor information."""
566 575 self._inspect('pdef',parameter_s)
567 576
568 577 def magic_pdoc(self, parameter_s=''):
569 578 """Print the docstring for an object.
570 579
571 580 If the given object is a class, it will print both the class and the
572 581 constructor docstrings."""
573 582 self._inspect('pdoc',parameter_s)
574 583
575 584 def magic_psource(self, parameter_s=''):
576 585 """Print (or run through pager) the source code for an object."""
577 586 self._inspect('psource',parameter_s)
578 587
579 588 def magic_pfile(self, parameter_s=''):
580 589 """Print (or run through pager) the file where an object is defined.
581 590
582 591 The file opens at the line where the object definition begins. IPython
583 592 will honor the environment variable PAGER if set, and otherwise will
584 593 do its best to print the file in a convenient form.
585 594
586 595 If the given argument is not an object currently defined, IPython will
587 596 try to interpret it as a filename (automatically adding a .py extension
588 597 if needed). You can thus use %pfile as a syntax highlighting code
589 598 viewer."""
590 599
591 600 # first interpret argument as an object name
592 601 out = self._inspect('pfile',parameter_s)
593 602 # if not, try the input as a filename
594 603 if out == 'not found':
595 604 try:
596 605 filename = get_py_filename(parameter_s)
597 606 except IOError,msg:
598 607 print msg
599 608 return
600 609 page(self.shell.inspector.format(file(filename).read()))
601 610
602 611 def magic_pinfo(self, parameter_s=''):
603 612 """Provide detailed information about an object.
604 613
605 614 '%pinfo object' is just a synonym for object? or ?object."""
606 615
607 616 #print 'pinfo par: <%s>' % parameter_s # dbg
608 617
609 618 # detail_level: 0 -> obj? , 1 -> obj??
610 619 detail_level = 0
611 620 # We need to detect if we got called as 'pinfo pinfo foo', which can
612 621 # happen if the user types 'pinfo foo?' at the cmd line.
613 622 pinfo,qmark1,oname,qmark2 = \
614 623 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
615 624 if pinfo or qmark1 or qmark2:
616 625 detail_level = 1
617 626 if "*" in oname:
618 627 self.magic_psearch(oname)
619 628 else:
620 629 self._inspect('pinfo',oname,detail_level=detail_level)
621 630
622 631 def magic_psearch(self, parameter_s=''):
623 632 """Search for object in namespaces by wildcard.
624 633
625 634 %psearch [options] PATTERN [OBJECT TYPE]
626 635
627 636 Note: ? can be used as a synonym for %psearch, at the beginning or at
628 637 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
629 638 rest of the command line must be unchanged (options come first), so
630 639 for example the following forms are equivalent
631 640
632 641 %psearch -i a* function
633 642 -i a* function?
634 643 ?-i a* function
635 644
636 645 Arguments:
637 646
638 647 PATTERN
639 648
640 649 where PATTERN is a string containing * as a wildcard similar to its
641 650 use in a shell. The pattern is matched in all namespaces on the
642 651 search path. By default objects starting with a single _ are not
643 652 matched, many IPython generated objects have a single
644 653 underscore. The default is case insensitive matching. Matching is
645 654 also done on the attributes of objects and not only on the objects
646 655 in a module.
647 656
648 657 [OBJECT TYPE]
649 658
650 659 Is the name of a python type from the types module. The name is
651 660 given in lowercase without the ending type, ex. StringType is
652 661 written string. By adding a type here only objects matching the
653 662 given type are matched. Using all here makes the pattern match all
654 663 types (this is the default).
655 664
656 665 Options:
657 666
658 667 -a: makes the pattern match even objects whose names start with a
659 668 single underscore. These names are normally ommitted from the
660 669 search.
661 670
662 671 -i/-c: make the pattern case insensitive/sensitive. If neither of
663 672 these options is given, the default is read from your ipythonrc
664 673 file. The option name which sets this value is
665 674 'wildcards_case_sensitive'. If this option is not specified in your
666 675 ipythonrc file, IPython's internal default is to do a case sensitive
667 676 search.
668 677
669 678 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
670 679 specifiy can be searched in any of the following namespaces:
671 680 'builtin', 'user', 'user_global','internal', 'alias', where
672 681 'builtin' and 'user' are the search defaults. Note that you should
673 682 not use quotes when specifying namespaces.
674 683
675 684 'Builtin' contains the python module builtin, 'user' contains all
676 685 user data, 'alias' only contain the shell aliases and no python
677 686 objects, 'internal' contains objects used by IPython. The
678 687 'user_global' namespace is only used by embedded IPython instances,
679 688 and it contains module-level globals. You can add namespaces to the
680 689 search with -s or exclude them with -e (these options can be given
681 690 more than once).
682 691
683 692 Examples:
684 693
685 694 %psearch a* -> objects beginning with an a
686 695 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
687 696 %psearch a* function -> all functions beginning with an a
688 697 %psearch re.e* -> objects beginning with an e in module re
689 698 %psearch r*.e* -> objects that start with e in modules starting in r
690 699 %psearch r*.* string -> all strings in modules beginning with r
691 700
692 701 Case sensitve search:
693 702
694 703 %psearch -c a* list all object beginning with lower case a
695 704
696 705 Show objects beginning with a single _:
697 706
698 707 %psearch -a _* list objects beginning with a single underscore"""
699 708
700 709 # default namespaces to be searched
701 710 def_search = ['user','builtin']
702 711
703 712 # Process options/args
704 713 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
705 714 opt = opts.get
706 715 shell = self.shell
707 716 psearch = shell.inspector.psearch
708 717
709 718 # select case options
710 719 if opts.has_key('i'):
711 720 ignore_case = True
712 721 elif opts.has_key('c'):
713 722 ignore_case = False
714 723 else:
715 724 ignore_case = not shell.rc.wildcards_case_sensitive
716 725
717 726 # Build list of namespaces to search from user options
718 727 def_search.extend(opt('s',[]))
719 728 ns_exclude = ns_exclude=opt('e',[])
720 729 ns_search = [nm for nm in def_search if nm not in ns_exclude]
721 730
722 731 # Call the actual search
723 732 try:
724 733 psearch(args,shell.ns_table,ns_search,
725 734 show_all=opt('a'),ignore_case=ignore_case)
726 735 except:
727 736 shell.showtraceback()
728 737
729 738 def magic_who_ls(self, parameter_s=''):
730 739 """Return a sorted list of all interactive variables.
731 740
732 741 If arguments are given, only variables of types matching these
733 742 arguments are returned."""
734 743
735 744 user_ns = self.shell.user_ns
736 745 out = []
737 746 typelist = parameter_s.split()
738 747 for i in self.shell.user_ns.keys():
739 748 if not (i.startswith('_') or i.startswith('_i')) \
740 749 and not (self.shell.internal_ns.has_key(i) or
741 750 self.shell.user_config_ns.has_key(i)):
742 751 if typelist:
743 752 if type(user_ns[i]).__name__ in typelist:
744 753 out.append(i)
745 754 else:
746 755 out.append(i)
747 756 out.sort()
748 757 return out
749 758
750 759 def magic_who(self, parameter_s=''):
751 760 """Print all interactive variables, with some minimal formatting.
752 761
753 762 If any arguments are given, only variables whose type matches one of
754 763 these are printed. For example:
755 764
756 765 %who function str
757 766
758 767 will only list functions and strings, excluding all other types of
759 768 variables. To find the proper type names, simply use type(var) at a
760 769 command line to see how python prints type names. For example:
761 770
762 771 In [1]: type('hello')\\
763 772 Out[1]: <type 'str'>
764 773
765 774 indicates that the type name for strings is 'str'.
766 775
767 776 %who always excludes executed names loaded through your configuration
768 777 file and things which are internal to IPython.
769 778
770 779 This is deliberate, as typically you may load many modules and the
771 780 purpose of %who is to show you only what you've manually defined."""
772 781
773 782 varlist = self.magic_who_ls(parameter_s)
774 783 if not varlist:
775 784 print 'Interactive namespace is empty.'
776 785 return
777 786
778 787 # if we have variables, move on...
779 788
780 789 # stupid flushing problem: when prompts have no separators, stdout is
781 790 # getting lost. I'm starting to think this is a python bug. I'm having
782 791 # to force a flush with a print because even a sys.stdout.flush
783 792 # doesn't seem to do anything!
784 793
785 794 count = 0
786 795 for i in varlist:
787 796 print i+'\t',
788 797 count += 1
789 798 if count > 8:
790 799 count = 0
791 800 print
792 801 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
793 802
794 803 print # well, this does force a flush at the expense of an extra \n
795 804
796 805 def magic_whos(self, parameter_s=''):
797 806 """Like %who, but gives some extra information about each variable.
798 807
799 808 The same type filtering of %who can be applied here.
800 809
801 810 For all variables, the type is printed. Additionally it prints:
802 811
803 812 - For {},[],(): their length.
804 813
805 814 - For Numeric arrays, a summary with shape, number of elements,
806 815 typecode and size in memory.
807 816
808 817 - Everything else: a string representation, snipping their middle if
809 818 too long."""
810 819
811 820 varnames = self.magic_who_ls(parameter_s)
812 821 if not varnames:
813 822 print 'Interactive namespace is empty.'
814 823 return
815 824
816 825 # if we have variables, move on...
817 826
818 827 # for these types, show len() instead of data:
819 828 seq_types = [types.DictType,types.ListType,types.TupleType]
820 829
821 830 # for Numeric arrays, display summary info
822 831 try:
823 832 import Numeric
824 833 except ImportError:
825 834 array_type = None
826 835 else:
827 836 array_type = Numeric.ArrayType.__name__
828 837
829 838 # Find all variable names and types so we can figure out column sizes
830 839 get_vars = lambda i: self.shell.user_ns[i]
831 840 type_name = lambda v: type(v).__name__
832 841 varlist = map(get_vars,varnames)
833 842
834 843 typelist = []
835 844 for vv in varlist:
836 845 tt = type_name(vv)
837 846 if tt=='instance':
838 847 typelist.append(str(vv.__class__))
839 848 else:
840 849 typelist.append(tt)
841 850
842 851 # column labels and # of spaces as separator
843 852 varlabel = 'Variable'
844 853 typelabel = 'Type'
845 854 datalabel = 'Data/Info'
846 855 colsep = 3
847 856 # variable format strings
848 857 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
849 858 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
850 859 aformat = "%s: %s elems, type `%s`, %s bytes"
851 860 # find the size of the columns to format the output nicely
852 861 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
853 862 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
854 863 # table header
855 864 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
856 865 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
857 866 # and the table itself
858 867 kb = 1024
859 868 Mb = 1048576 # kb**2
860 869 for vname,var,vtype in zip(varnames,varlist,typelist):
861 870 print itpl(vformat),
862 871 if vtype in seq_types:
863 872 print len(var)
864 873 elif vtype==array_type:
865 874 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
866 875 vsize = Numeric.size(var)
867 876 vbytes = vsize*var.itemsize()
868 877 if vbytes < 100000:
869 878 print aformat % (vshape,vsize,var.typecode(),vbytes)
870 879 else:
871 880 print aformat % (vshape,vsize,var.typecode(),vbytes),
872 881 if vbytes < Mb:
873 882 print '(%s kb)' % (vbytes/kb,)
874 883 else:
875 884 print '(%s Mb)' % (vbytes/Mb,)
876 885 else:
877 886 vstr = str(var).replace('\n','\\n')
878 887 if len(vstr) < 50:
879 888 print vstr
880 889 else:
881 890 printpl(vfmt_short)
882 891
883 892 def magic_reset(self, parameter_s=''):
884 893 """Resets the namespace by removing all names defined by the user.
885 894
886 895 Input/Output history are left around in case you need them."""
887 896
888 897 ans = raw_input(
889 898 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
890 899 if not ans.lower() == 'y':
891 900 print 'Nothing done.'
892 901 return
893 902 user_ns = self.shell.user_ns
894 903 for i in self.magic_who_ls():
895 904 del(user_ns[i])
896 905
897 906 def magic_config(self,parameter_s=''):
898 907 """Show IPython's internal configuration."""
899 908
900 909 page('Current configuration structure:\n'+
901 910 pformat(self.shell.rc.dict()))
902 911
903 912 def magic_logstart(self,parameter_s=''):
904 913 """Start logging anywhere in a session.
905 914
906 915 %logstart [-o|-t] [log_name [log_mode]]
907 916
908 917 If no name is given, it defaults to a file named 'ipython_log.py' in your
909 918 current directory, in 'rotate' mode (see below).
910 919
911 920 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
912 921 history up to that point and then continues logging.
913 922
914 923 %logstart takes a second optional parameter: logging mode. This can be one
915 924 of (note that the modes are given unquoted):\\
916 925 append: well, that says it.\\
917 926 backup: rename (if exists) to name~ and start name.\\
918 927 global: single logfile in your home dir, appended to.\\
919 928 over : overwrite existing log.\\
920 929 rotate: create rotating logs name.1~, name.2~, etc.
921 930
922 931 Options:
923 932
924 933 -o: log also IPython's output. In this mode, all commands which
925 934 generate an Out[NN] prompt are recorded to the logfile, right after
926 935 their corresponding input line. The output lines are always
927 936 prepended with a '#[Out]# ' marker, so that the log remains valid
928 937 Python code.
929 938
930 939 Since this marker is always the same, filtering only the output from
931 940 a log is very easy, using for example a simple awk call:
932 941
933 942 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
934 943
935 944 -t: put timestamps before each input line logged (these are put in
936 945 comments)."""
937 946
938 947 opts,par = self.parse_options(parameter_s,'ot')
939 948 log_output = 'o' in opts
940 949 timestamp = 't' in opts
941 950
942 951 rc = self.shell.rc
943 952 logger = self.shell.logger
944 953
945 954 # if no args are given, the defaults set in the logger constructor by
946 955 # ipytohn remain valid
947 956 if par:
948 957 try:
949 958 logfname,logmode = par.split()
950 959 except:
951 960 logfname = par
952 961 logmode = 'backup'
953 962 else:
954 963 logfname = logger.logfname
955 964 logmode = logger.logmode
956 965 # put logfname into rc struct as if it had been called on the command
957 966 # line, so it ends up saved in the log header Save it in case we need
958 967 # to restore it...
959 968 old_logfile = rc.opts.get('logfile','')
960 969 if logfname:
961 970 logfname = os.path.expanduser(logfname)
962 971 rc.opts.logfile = logfname
963 972 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
964 973 try:
965 974 started = logger.logstart(logfname,loghead,logmode,
966 975 log_output,timestamp)
967 976 except:
968 977 rc.opts.logfile = old_logfile
969 978 warn("Couldn't start log: %s" % sys.exc_info()[1])
970 979 else:
971 980 # log input history up to this point, optionally interleaving
972 981 # output if requested
973 982
974 983 if timestamp:
975 984 # disable timestamping for the previous history, since we've
976 985 # lost those already (no time machine here).
977 986 logger.timestamp = False
978 987 if log_output:
979 988 log_write = logger.log_write
980 989 input_hist = self.shell.input_hist
981 990 output_hist = self.shell.output_hist
982 991 for n in range(1,len(input_hist)-1):
983 992 log_write(input_hist[n].rstrip())
984 993 if n in output_hist:
985 994 log_write(repr(output_hist[n]),'output')
986 995 else:
987 996 logger.log_write(self.shell.input_hist[1:])
988 997 if timestamp:
989 998 # re-enable timestamping
990 999 logger.timestamp = True
991 1000
992 1001 print ('Activating auto-logging. '
993 1002 'Current session state plus future input saved.')
994 1003 logger.logstate()
995 1004
996 1005 def magic_logoff(self,parameter_s=''):
997 1006 """Temporarily stop logging.
998 1007
999 1008 You must have previously started logging."""
1000 1009 self.shell.logger.switch_log(0)
1001 1010
1002 1011 def magic_logon(self,parameter_s=''):
1003 1012 """Restart logging.
1004 1013
1005 1014 This function is for restarting logging which you've temporarily
1006 1015 stopped with %logoff. For starting logging for the first time, you
1007 1016 must use the %logstart function, which allows you to specify an
1008 1017 optional log filename."""
1009 1018
1010 1019 self.shell.logger.switch_log(1)
1011 1020
1012 1021 def magic_logstate(self,parameter_s=''):
1013 1022 """Print the status of the logging system."""
1014 1023
1015 1024 self.shell.logger.logstate()
1016 1025
1017 1026 def magic_pdb(self, parameter_s=''):
1018 1027 """Control the calling of the pdb interactive debugger.
1019 1028
1020 1029 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1021 1030 argument it works as a toggle.
1022 1031
1023 1032 When an exception is triggered, IPython can optionally call the
1024 1033 interactive pdb debugger after the traceback printout. %pdb toggles
1025 1034 this feature on and off."""
1026 1035
1027 1036 par = parameter_s.strip().lower()
1028 1037
1029 1038 if par:
1030 1039 try:
1031 1040 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1032 1041 except KeyError:
1033 1042 print ('Incorrect argument. Use on/1, off/0, '
1034 1043 'or nothing for a toggle.')
1035 1044 return
1036 1045 else:
1037 1046 # toggle
1038 1047 new_pdb = not self.shell.InteractiveTB.call_pdb
1039 1048
1040 1049 # set on the shell
1041 1050 self.shell.call_pdb = new_pdb
1042 1051 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1043 1052
1044 1053 def magic_prun(self, parameter_s ='',user_mode=1,
1045 1054 opts=None,arg_lst=None,prog_ns=None):
1046 1055
1047 1056 """Run a statement through the python code profiler.
1048 1057
1049 1058 Usage:\\
1050 1059 %prun [options] statement
1051 1060
1052 1061 The given statement (which doesn't require quote marks) is run via the
1053 1062 python profiler in a manner similar to the profile.run() function.
1054 1063 Namespaces are internally managed to work correctly; profile.run
1055 1064 cannot be used in IPython because it makes certain assumptions about
1056 1065 namespaces which do not hold under IPython.
1057 1066
1058 1067 Options:
1059 1068
1060 1069 -l <limit>: you can place restrictions on what or how much of the
1061 1070 profile gets printed. The limit value can be:
1062 1071
1063 1072 * A string: only information for function names containing this string
1064 1073 is printed.
1065 1074
1066 1075 * An integer: only these many lines are printed.
1067 1076
1068 1077 * A float (between 0 and 1): this fraction of the report is printed
1069 1078 (for example, use a limit of 0.4 to see the topmost 40% only).
1070 1079
1071 1080 You can combine several limits with repeated use of the option. For
1072 1081 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1073 1082 information about class constructors.
1074 1083
1075 1084 -r: return the pstats.Stats object generated by the profiling. This
1076 1085 object has all the information about the profile in it, and you can
1077 1086 later use it for further analysis or in other functions.
1078 1087
1079 1088 Since magic functions have a particular form of calling which prevents
1080 1089 you from writing something like:\\
1081 1090 In [1]: p = %prun -r print 4 # invalid!\\
1082 1091 you must instead use IPython's automatic variables to assign this:\\
1083 1092 In [1]: %prun -r print 4 \\
1084 1093 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1085 1094 In [2]: stats = _
1086 1095
1087 1096 If you really need to assign this value via an explicit function call,
1088 1097 you can always tap directly into the true name of the magic function
1089 1098 by using the ipmagic function (which IPython automatically adds to the
1090 1099 builtins):\\
1091 1100 In [3]: stats = ipmagic('prun','-r print 4')
1092 1101
1093 1102 You can type ipmagic? for more details on ipmagic.
1094 1103
1095 1104 -s <key>: sort profile by given key. You can provide more than one key
1096 1105 by using the option several times: '-s key1 -s key2 -s key3...'. The
1097 1106 default sorting key is 'time'.
1098 1107
1099 1108 The following is copied verbatim from the profile documentation
1100 1109 referenced below:
1101 1110
1102 1111 When more than one key is provided, additional keys are used as
1103 1112 secondary criteria when the there is equality in all keys selected
1104 1113 before them.
1105 1114
1106 1115 Abbreviations can be used for any key names, as long as the
1107 1116 abbreviation is unambiguous. The following are the keys currently
1108 1117 defined:
1109 1118
1110 1119 Valid Arg Meaning\\
1111 1120 "calls" call count\\
1112 1121 "cumulative" cumulative time\\
1113 1122 "file" file name\\
1114 1123 "module" file name\\
1115 1124 "pcalls" primitive call count\\
1116 1125 "line" line number\\
1117 1126 "name" function name\\
1118 1127 "nfl" name/file/line\\
1119 1128 "stdname" standard name\\
1120 1129 "time" internal time
1121 1130
1122 1131 Note that all sorts on statistics are in descending order (placing
1123 1132 most time consuming items first), where as name, file, and line number
1124 1133 searches are in ascending order (i.e., alphabetical). The subtle
1125 1134 distinction between "nfl" and "stdname" is that the standard name is a
1126 1135 sort of the name as printed, which means that the embedded line
1127 1136 numbers get compared in an odd way. For example, lines 3, 20, and 40
1128 1137 would (if the file names were the same) appear in the string order
1129 1138 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1130 1139 line numbers. In fact, sort_stats("nfl") is the same as
1131 1140 sort_stats("name", "file", "line").
1132 1141
1133 1142 -T <filename>: save profile results as shown on screen to a text
1134 1143 file. The profile is still shown on screen.
1135 1144
1136 1145 -D <filename>: save (via dump_stats) profile statistics to given
1137 1146 filename. This data is in a format understod by the pstats module, and
1138 1147 is generated by a call to the dump_stats() method of profile
1139 1148 objects. The profile is still shown on screen.
1140 1149
1141 1150 If you want to run complete programs under the profiler's control, use
1142 1151 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1143 1152 contains profiler specific options as described here.
1144 1153
1145 1154 You can read the complete documentation for the profile module with:\\
1146 1155 In [1]: import profile; profile.help() """
1147 1156
1148 1157 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1149 1158 # protect user quote marks
1150 1159 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1151 1160
1152 1161 if user_mode: # regular user call
1153 1162 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1154 1163 list_all=1)
1155 1164 namespace = self.shell.user_ns
1156 1165 else: # called to run a program by %run -p
1157 1166 try:
1158 1167 filename = get_py_filename(arg_lst[0])
1159 1168 except IOError,msg:
1160 1169 error(msg)
1161 1170 return
1162 1171
1163 1172 arg_str = 'execfile(filename,prog_ns)'
1164 1173 namespace = locals()
1165 1174
1166 1175 opts.merge(opts_def)
1167 1176
1168 1177 prof = profile.Profile()
1169 1178 try:
1170 1179 prof = prof.runctx(arg_str,namespace,namespace)
1171 1180 sys_exit = ''
1172 1181 except SystemExit:
1173 1182 sys_exit = """*** SystemExit exception caught in code being profiled."""
1174 1183
1175 1184 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1176 1185
1177 1186 lims = opts.l
1178 1187 if lims:
1179 1188 lims = [] # rebuild lims with ints/floats/strings
1180 1189 for lim in opts.l:
1181 1190 try:
1182 1191 lims.append(int(lim))
1183 1192 except ValueError:
1184 1193 try:
1185 1194 lims.append(float(lim))
1186 1195 except ValueError:
1187 1196 lims.append(lim)
1188 1197
1189 1198 # trap output
1190 1199 sys_stdout = sys.stdout
1191 1200 stdout_trap = StringIO()
1192 1201 try:
1193 1202 sys.stdout = stdout_trap
1194 1203 stats.print_stats(*lims)
1195 1204 finally:
1196 1205 sys.stdout = sys_stdout
1197 1206 output = stdout_trap.getvalue()
1198 1207 output = output.rstrip()
1199 1208
1200 1209 page(output,screen_lines=self.shell.rc.screen_length)
1201 1210 print sys_exit,
1202 1211
1203 1212 dump_file = opts.D[0]
1204 1213 text_file = opts.T[0]
1205 1214 if dump_file:
1206 1215 prof.dump_stats(dump_file)
1207 1216 print '\n*** Profile stats marshalled to file',\
1208 1217 `dump_file`+'.',sys_exit
1209 1218 if text_file:
1210 1219 file(text_file,'w').write(output)
1211 1220 print '\n*** Profile printout saved to text file',\
1212 1221 `text_file`+'.',sys_exit
1213 1222
1214 1223 if opts.has_key('r'):
1215 1224 return stats
1216 1225 else:
1217 1226 return None
1218 1227
1219 1228 def magic_run(self, parameter_s ='',runner=None):
1220 1229 """Run the named file inside IPython as a program.
1221 1230
1222 1231 Usage:\\
1223 1232 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1224 1233
1225 1234 Parameters after the filename are passed as command-line arguments to
1226 1235 the program (put in sys.argv). Then, control returns to IPython's
1227 1236 prompt.
1228 1237
1229 1238 This is similar to running at a system prompt:\\
1230 1239 $ python file args\\
1231 1240 but with the advantage of giving you IPython's tracebacks, and of
1232 1241 loading all variables into your interactive namespace for further use
1233 1242 (unless -p is used, see below).
1234 1243
1235 1244 The file is executed in a namespace initially consisting only of
1236 1245 __name__=='__main__' and sys.argv constructed as indicated. It thus
1237 1246 sees its environment as if it were being run as a stand-alone
1238 1247 program. But after execution, the IPython interactive namespace gets
1239 1248 updated with all variables defined in the program (except for __name__
1240 1249 and sys.argv). This allows for very convenient loading of code for
1241 1250 interactive work, while giving each program a 'clean sheet' to run in.
1242 1251
1243 1252 Options:
1244 1253
1245 1254 -n: __name__ is NOT set to '__main__', but to the running file's name
1246 1255 without extension (as python does under import). This allows running
1247 1256 scripts and reloading the definitions in them without calling code
1248 1257 protected by an ' if __name__ == "__main__" ' clause.
1249 1258
1250 1259 -i: run the file in IPython's namespace instead of an empty one. This
1251 1260 is useful if you are experimenting with code written in a text editor
1252 1261 which depends on variables defined interactively.
1253 1262
1254 1263 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1255 1264 being run. This is particularly useful if IPython is being used to
1256 1265 run unittests, which always exit with a sys.exit() call. In such
1257 1266 cases you are interested in the output of the test results, not in
1258 1267 seeing a traceback of the unittest module.
1259 1268
1260 1269 -t: print timing information at the end of the run. IPython will give
1261 1270 you an estimated CPU time consumption for your script, which under
1262 1271 Unix uses the resource module to avoid the wraparound problems of
1263 1272 time.clock(). Under Unix, an estimate of time spent on system tasks
1264 1273 is also given (for Windows platforms this is reported as 0.0).
1265 1274
1266 1275 If -t is given, an additional -N<N> option can be given, where <N>
1267 1276 must be an integer indicating how many times you want the script to
1268 1277 run. The final timing report will include total and per run results.
1269 1278
1270 1279 For example (testing the script uniq_stable.py):
1271 1280
1272 1281 In [1]: run -t uniq_stable
1273 1282
1274 1283 IPython CPU timings (estimated):\\
1275 1284 User : 0.19597 s.\\
1276 1285 System: 0.0 s.\\
1277 1286
1278 1287 In [2]: run -t -N5 uniq_stable
1279 1288
1280 1289 IPython CPU timings (estimated):\\
1281 1290 Total runs performed: 5\\
1282 1291 Times : Total Per run\\
1283 1292 User : 0.910862 s, 0.1821724 s.\\
1284 1293 System: 0.0 s, 0.0 s.
1285 1294
1286 1295 -d: run your program under the control of pdb, the Python debugger.
1287 1296 This allows you to execute your program step by step, watch variables,
1288 1297 etc. Internally, what IPython does is similar to calling:
1289 1298
1290 1299 pdb.run('execfile("YOURFILENAME")')
1291 1300
1292 1301 with a breakpoint set on line 1 of your file. You can change the line
1293 1302 number for this automatic breakpoint to be <N> by using the -bN option
1294 1303 (where N must be an integer). For example:
1295 1304
1296 1305 %run -d -b40 myscript
1297 1306
1298 1307 will set the first breakpoint at line 40 in myscript.py. Note that
1299 1308 the first breakpoint must be set on a line which actually does
1300 1309 something (not a comment or docstring) for it to stop execution.
1301 1310
1302 1311 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1303 1312 first enter 'c' (without qoutes) to start execution up to the first
1304 1313 breakpoint.
1305 1314
1306 1315 Entering 'help' gives information about the use of the debugger. You
1307 1316 can easily see pdb's full documentation with "import pdb;pdb.help()"
1308 1317 at a prompt.
1309 1318
1310 1319 -p: run program under the control of the Python profiler module (which
1311 1320 prints a detailed report of execution times, function calls, etc).
1312 1321
1313 1322 You can pass other options after -p which affect the behavior of the
1314 1323 profiler itself. See the docs for %prun for details.
1315 1324
1316 1325 In this mode, the program's variables do NOT propagate back to the
1317 1326 IPython interactive namespace (because they remain in the namespace
1318 1327 where the profiler executes them).
1319 1328
1320 1329 Internally this triggers a call to %prun, see its documentation for
1321 1330 details on the options available specifically for profiling."""
1322 1331
1323 1332 # get arguments and set sys.argv for program to be run.
1324 1333 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1325 1334 mode='list',list_all=1)
1326 1335
1327 1336 try:
1328 1337 filename = get_py_filename(arg_lst[0])
1329 1338 except IndexError:
1330 1339 warn('you must provide at least a filename.')
1331 1340 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1332 1341 return
1333 1342 except IOError,msg:
1334 1343 error(msg)
1335 1344 return
1336 1345
1337 1346 # Control the response to exit() calls made by the script being run
1338 1347 exit_ignore = opts.has_key('e')
1339 1348
1340 1349 # Make sure that the running script gets a proper sys.argv as if it
1341 1350 # were run from a system shell.
1342 1351 save_argv = sys.argv # save it for later restoring
1343 1352 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1344 1353
1345 1354 if opts.has_key('i'):
1346 1355 prog_ns = self.shell.user_ns
1347 1356 __name__save = self.shell.user_ns['__name__']
1348 1357 prog_ns['__name__'] = '__main__'
1349 1358 else:
1350 1359 if opts.has_key('n'):
1351 1360 name = os.path.splitext(os.path.basename(filename))[0]
1352 1361 else:
1353 1362 name = '__main__'
1354 1363 prog_ns = {'__name__':name}
1355 1364
1356 1365 # pickle fix. See iplib for an explanation. But we need to make sure
1357 1366 # that, if we overwrite __main__, we replace it at the end
1358 1367 if prog_ns['__name__'] == '__main__':
1359 1368 restore_main = sys.modules['__main__']
1360 1369 else:
1361 1370 restore_main = False
1362 1371
1363 1372 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1364 1373
1365 1374 stats = None
1366 1375 try:
1367 1376 if opts.has_key('p'):
1368 1377 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1369 1378 else:
1370 1379 if opts.has_key('d'):
1371 1380 deb = Debugger.Pdb(self.shell.rc.colors)
1372 1381 # reset Breakpoint state, which is moronically kept
1373 1382 # in a class
1374 1383 bdb.Breakpoint.next = 1
1375 1384 bdb.Breakpoint.bplist = {}
1376 1385 bdb.Breakpoint.bpbynumber = [None]
1377 1386 # Set an initial breakpoint to stop execution
1378 1387 maxtries = 10
1379 1388 bp = int(opts.get('b',[1])[0])
1380 1389 checkline = deb.checkline(filename,bp)
1381 1390 if not checkline:
1382 1391 for bp in range(bp+1,bp+maxtries+1):
1383 1392 if deb.checkline(filename,bp):
1384 1393 break
1385 1394 else:
1386 1395 msg = ("\nI failed to find a valid line to set "
1387 1396 "a breakpoint\n"
1388 1397 "after trying up to line: %s.\n"
1389 1398 "Please set a valid breakpoint manually "
1390 1399 "with the -b option." % bp)
1391 1400 error(msg)
1392 1401 return
1393 1402 # if we find a good linenumber, set the breakpoint
1394 1403 deb.do_break('%s:%s' % (filename,bp))
1395 1404 # Start file run
1396 1405 print "NOTE: Enter 'c' at the",
1397 1406 print "ipdb> prompt to start your script."
1398 1407 try:
1399 1408 deb.run('execfile("%s")' % filename,prog_ns)
1400 1409 except:
1401 1410 etype, value, tb = sys.exc_info()
1402 1411 # Skip three frames in the traceback: the %run one,
1403 1412 # one inside bdb.py, and the command-line typed by the
1404 1413 # user (run by exec in pdb itself).
1405 1414 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1406 1415 else:
1407 1416 if runner is None:
1408 1417 runner = self.shell.safe_execfile
1409 1418 if opts.has_key('t'):
1410 1419 try:
1411 1420 nruns = int(opts['N'][0])
1412 1421 if nruns < 1:
1413 1422 error('Number of runs must be >=1')
1414 1423 return
1415 1424 except (KeyError):
1416 1425 nruns = 1
1417 1426 if nruns == 1:
1418 1427 t0 = clock2()
1419 1428 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1420 1429 t1 = clock2()
1421 1430 t_usr = t1[0]-t0[0]
1422 1431 t_sys = t1[1]-t1[1]
1423 1432 print "\nIPython CPU timings (estimated):"
1424 1433 print " User : %10s s." % t_usr
1425 1434 print " System: %10s s." % t_sys
1426 1435 else:
1427 1436 runs = range(nruns)
1428 1437 t0 = clock2()
1429 1438 for nr in runs:
1430 1439 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1431 1440 t1 = clock2()
1432 1441 t_usr = t1[0]-t0[0]
1433 1442 t_sys = t1[1]-t1[1]
1434 1443 print "\nIPython CPU timings (estimated):"
1435 1444 print "Total runs performed:",nruns
1436 1445 print " Times : %10s %10s" % ('Total','Per run')
1437 1446 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1438 1447 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1439 1448
1440 1449 else:
1441 1450 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1442 1451 if opts.has_key('i'):
1443 1452 self.shell.user_ns['__name__'] = __name__save
1444 1453 else:
1445 1454 # update IPython interactive namespace
1446 1455 del prog_ns['__name__']
1447 1456 self.shell.user_ns.update(prog_ns)
1448 1457 finally:
1449 1458 sys.argv = save_argv
1450 1459 if restore_main:
1451 1460 sys.modules['__main__'] = restore_main
1452 1461 return stats
1453 1462
1454 1463 def magic_runlog(self, parameter_s =''):
1455 1464 """Run files as logs.
1456 1465
1457 1466 Usage:\\
1458 1467 %runlog file1 file2 ...
1459 1468
1460 1469 Run the named files (treating them as log files) in sequence inside
1461 1470 the interpreter, and return to the prompt. This is much slower than
1462 1471 %run because each line is executed in a try/except block, but it
1463 1472 allows running files with syntax errors in them.
1464 1473
1465 1474 Normally IPython will guess when a file is one of its own logfiles, so
1466 1475 you can typically use %run even for logs. This shorthand allows you to
1467 1476 force any file to be treated as a log file."""
1468 1477
1469 1478 for f in parameter_s.split():
1470 1479 self.shell.safe_execfile(f,self.shell.user_ns,
1471 1480 self.shell.user_ns,islog=1)
1472 1481
1473 1482 def magic_time(self,parameter_s = ''):
1474 1483 """Time execution of a Python statement or expression.
1475 1484
1476 1485 The CPU and wall clock times are printed, and the value of the
1477 1486 expression (if any) is returned. Note that under Win32, system time
1478 1487 is always reported as 0, since it can not be measured.
1479 1488
1480 1489 This function provides very basic timing functionality. In Python
1481 1490 2.3, the timeit module offers more control and sophistication, but for
1482 1491 now IPython supports Python 2.2, so we can not rely on timeit being
1483 1492 present.
1484 1493
1485 1494 Some examples:
1486 1495
1487 1496 In [1]: time 2**128
1488 1497 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1489 1498 Wall time: 0.00
1490 1499 Out[1]: 340282366920938463463374607431768211456L
1491 1500
1492 1501 In [2]: n = 1000000
1493 1502
1494 1503 In [3]: time sum(range(n))
1495 1504 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1496 1505 Wall time: 1.37
1497 1506 Out[3]: 499999500000L
1498 1507
1499 1508 In [4]: time print 'hello world'
1500 1509 hello world
1501 1510 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1502 1511 Wall time: 0.00
1503 1512 """
1504 1513
1505 1514 # fail immediately if the given expression can't be compiled
1506 1515 try:
1507 1516 mode = 'eval'
1508 1517 code = compile(parameter_s,'<timed eval>',mode)
1509 1518 except SyntaxError:
1510 1519 mode = 'exec'
1511 1520 code = compile(parameter_s,'<timed exec>',mode)
1512 1521 # skew measurement as little as possible
1513 1522 glob = self.shell.user_ns
1514 1523 clk = clock2
1515 1524 wtime = time.time
1516 1525 # time execution
1517 1526 wall_st = wtime()
1518 1527 if mode=='eval':
1519 1528 st = clk()
1520 1529 out = eval(code,glob)
1521 1530 end = clk()
1522 1531 else:
1523 1532 st = clk()
1524 1533 exec code in glob
1525 1534 end = clk()
1526 1535 out = None
1527 1536 wall_end = wtime()
1528 1537 # Compute actual times and report
1529 1538 wall_time = wall_end-wall_st
1530 1539 cpu_user = end[0]-st[0]
1531 1540 cpu_sys = end[1]-st[1]
1532 1541 cpu_tot = cpu_user+cpu_sys
1533 1542 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1534 1543 (cpu_user,cpu_sys,cpu_tot)
1535 1544 print "Wall time: %.2f" % wall_time
1536 1545 return out
1537 1546
1538 1547 def magic_macro(self,parameter_s = ''):
1539 1548 """Define a set of input lines as a macro for future re-execution.
1540 1549
1541 1550 Usage:\\
1542 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1551 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1543 1552
1544 1553 This will define a global variable called `name` which is a string
1545 1554 made of joining the slices and lines you specify (n1,n2,... numbers
1546 1555 above) from your input history into a single string. This variable
1547 1556 acts like an automatic function which re-executes those lines as if
1548 1557 you had typed them. You just type 'name' at the prompt and the code
1549 1558 executes.
1550 1559
1551 Note that the slices use the standard Python slicing notation (5:8
1552 means include lines numbered 5,6,7).
1560 The notation for indicating number ranges is: n1-n2 means 'use line
1561 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1562 using the lines numbered 5,6 and 7.
1563
1564 Note: as a 'hidden' feature, you can also use traditional python slice
1565 notation, where N:M means numbers N through M-1.
1553 1566
1554 1567 For example, if your history contains (%hist prints it):
1555 1568
1556 1569 44: x=1\\
1557 1570 45: y=3\\
1558 1571 46: z=x+y\\
1559 1572 47: print x\\
1560 1573 48: a=5\\
1561 1574 49: print 'x',x,'y',y\\
1562 1575
1563 1576 you can create a macro with lines 44 through 47 (included) and line 49
1564 1577 called my_macro with:
1565 1578
1566 In [51]: %macro my_macro 44:48 49
1579 In [51]: %macro my_macro 44-47 49
1567 1580
1568 1581 Now, typing `my_macro` (without quotes) will re-execute all this code
1569 1582 in one pass.
1570 1583
1571 1584 You don't need to give the line-numbers in order, and any given line
1572 1585 number can appear multiple times. You can assemble macros with any
1573 1586 lines from your input history in any order.
1574 1587
1575 1588 The macro is a simple object which holds its value in an attribute,
1576 1589 but IPython's display system checks for macros and executes them as
1577 1590 code instead of printing them when you type their name.
1578 1591
1579 1592 You can view a macro's contents by explicitly printing it with:
1580 1593
1581 1594 'print macro_name'.
1582 1595
1583 1596 For one-off cases which DON'T contain magic function calls in them you
1584 1597 can obtain similar results by explicitly executing slices from your
1585 1598 input history with:
1586 1599
1587 1600 In [60]: exec In[44:48]+In[49]"""
1588 1601
1589 1602 args = parameter_s.split()
1590 1603 name,ranges = args[0], args[1:]
1591 1604 #print 'rng',ranges # dbg
1592 1605 lines = self.extract_input_slices(ranges)
1593 1606 macro = Macro(lines)
1594 1607 self.shell.user_ns.update({name:macro})
1595 1608 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1596 1609 print 'Macro contents:'
1597 1610 print macro,
1598 1611
1599 1612 def magic_save(self,parameter_s = ''):
1600 1613 """Save a set of lines to a given filename.
1601 1614
1602 1615 Usage:\\
1603 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1616 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1604 1617
1605 1618 This function uses the same syntax as %macro for line extraction, but
1606 1619 instead of creating a macro it saves the resulting string to the
1607 1620 filename you specify.
1608 1621
1609 1622 It adds a '.py' extension to the file if you don't do so yourself, and
1610 1623 it asks for confirmation before overwriting existing files."""
1611 1624
1612 1625 args = parameter_s.split()
1613 1626 fname,ranges = args[0], args[1:]
1614 1627 if not fname.endswith('.py'):
1615 1628 fname += '.py'
1616 1629 if os.path.isfile(fname):
1617 1630 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1618 1631 if ans.lower() not in ['y','yes']:
1619 1632 print 'Operation cancelled.'
1620 1633 return
1621 1634 cmds = ''.join(self.extract_input_slices(ranges))
1622 1635 f = file(fname,'w')
1623 1636 f.write(cmds)
1624 1637 f.close()
1625 1638 print 'The following commands were written to file `%s`:' % fname
1626 1639 print cmds
1627 1640
1628 1641 def magic_ed(self,parameter_s = ''):
1629 1642 """Alias to %edit."""
1630 1643 return self.magic_edit(parameter_s)
1631 1644
1632 1645 def magic_edit(self,parameter_s = '',last_call=['','']):
1633 1646 """Bring up an editor and execute the resulting code.
1634 1647
1635 1648 Usage:
1636 1649 %edit [options] [args]
1637 1650
1638 1651 %edit runs IPython's editor hook. The default version of this hook is
1639 1652 set to call the __IPYTHON__.rc.editor command. This is read from your
1640 1653 environment variable $EDITOR. If this isn't found, it will default to
1641 1654 vi under Linux/Unix and to notepad under Windows. See the end of this
1642 1655 docstring for how to change the editor hook.
1643 1656
1644 1657 You can also set the value of this editor via the command line option
1645 1658 '-editor' or in your ipythonrc file. This is useful if you wish to use
1646 1659 specifically for IPython an editor different from your typical default
1647 1660 (and for Windows users who typically don't set environment variables).
1648 1661
1649 1662 This command allows you to conveniently edit multi-line code right in
1650 1663 your IPython session.
1651 1664
1652 1665 If called without arguments, %edit opens up an empty editor with a
1653 1666 temporary file and will execute the contents of this file when you
1654 1667 close it (don't forget to save it!).
1655 1668
1656 1669 Options:
1657 1670
1658 1671 -p: this will call the editor with the same data as the previous time
1659 1672 it was used, regardless of how long ago (in your current session) it
1660 1673 was.
1661 1674
1662 1675 -x: do not execute the edited code immediately upon exit. This is
1663 1676 mainly useful if you are editing programs which need to be called with
1664 1677 command line arguments, which you can then do using %run.
1665 1678
1666 1679 Arguments:
1667 1680
1668 1681 If arguments are given, the following possibilites exist:
1669 1682
1670 1683 - The arguments are numbers or pairs of colon-separated numbers (like
1671 1684 1 4:8 9). These are interpreted as lines of previous input to be
1672 1685 loaded into the editor. The syntax is the same of the %macro command.
1673 1686
1674 1687 - If the argument doesn't start with a number, it is evaluated as a
1675 1688 variable and its contents loaded into the editor. You can thus edit
1676 1689 any string which contains python code (including the result of
1677 1690 previous edits).
1678 1691
1679 1692 - If the argument is the name of an object (other than a string),
1680 1693 IPython will try to locate the file where it was defined and open the
1681 1694 editor at the point where it is defined. You can use `%edit function`
1682 1695 to load an editor exactly at the point where 'function' is defined,
1683 1696 edit it and have the file be executed automatically.
1684 1697
1685 1698 Note: opening at an exact line is only supported under Unix, and some
1686 1699 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1687 1700 '+NUMBER' parameter necessary for this feature. Good editors like
1688 1701 (X)Emacs, vi, jed, pico and joe all do.
1689 1702
1690 1703 - If the argument is not found as a variable, IPython will look for a
1691 1704 file with that name (adding .py if necessary) and load it into the
1692 1705 editor. It will execute its contents with execfile() when you exit,
1693 1706 loading any code in the file into your interactive namespace.
1694 1707
1695 1708 After executing your code, %edit will return as output the code you
1696 1709 typed in the editor (except when it was an existing file). This way
1697 1710 you can reload the code in further invocations of %edit as a variable,
1698 1711 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1699 1712 the output.
1700 1713
1701 1714 Note that %edit is also available through the alias %ed.
1702 1715
1703 1716 This is an example of creating a simple function inside the editor and
1704 1717 then modifying it. First, start up the editor:
1705 1718
1706 1719 In [1]: ed\\
1707 1720 Editing... done. Executing edited code...\\
1708 1721 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1709 1722
1710 1723 We can then call the function foo():
1711 1724
1712 1725 In [2]: foo()\\
1713 1726 foo() was defined in an editing session
1714 1727
1715 1728 Now we edit foo. IPython automatically loads the editor with the
1716 1729 (temporary) file where foo() was previously defined:
1717 1730
1718 1731 In [3]: ed foo\\
1719 1732 Editing... done. Executing edited code...
1720 1733
1721 1734 And if we call foo() again we get the modified version:
1722 1735
1723 1736 In [4]: foo()\\
1724 1737 foo() has now been changed!
1725 1738
1726 1739 Here is an example of how to edit a code snippet successive
1727 1740 times. First we call the editor:
1728 1741
1729 1742 In [8]: ed\\
1730 1743 Editing... done. Executing edited code...\\
1731 1744 hello\\
1732 1745 Out[8]: "print 'hello'\\n"
1733 1746
1734 1747 Now we call it again with the previous output (stored in _):
1735 1748
1736 1749 In [9]: ed _\\
1737 1750 Editing... done. Executing edited code...\\
1738 1751 hello world\\
1739 1752 Out[9]: "print 'hello world'\\n"
1740 1753
1741 1754 Now we call it with the output #8 (stored in _8, also as Out[8]):
1742 1755
1743 1756 In [10]: ed _8\\
1744 1757 Editing... done. Executing edited code...\\
1745 1758 hello again\\
1746 1759 Out[10]: "print 'hello again'\\n"
1747 1760
1748 1761
1749 1762 Changing the default editor hook:
1750 1763
1751 1764 If you wish to write your own editor hook, you can put it in a
1752 1765 configuration file which you load at startup time. The default hook
1753 1766 is defined in the IPython.hooks module, and you can use that as a
1754 1767 starting example for further modifications. That file also has
1755 1768 general instructions on how to set a new hook for use once you've
1756 1769 defined it."""
1757 1770
1758 1771 # FIXME: This function has become a convoluted mess. It needs a
1759 1772 # ground-up rewrite with clean, simple logic.
1760 1773
1761 1774 def make_filename(arg):
1762 1775 "Make a filename from the given args"
1763 1776 try:
1764 1777 filename = get_py_filename(arg)
1765 1778 except IOError:
1766 1779 if args.endswith('.py'):
1767 1780 filename = arg
1768 1781 else:
1769 1782 filename = None
1770 1783 return filename
1771 1784
1772 1785 # custom exceptions
1773 1786 class DataIsObject(Exception): pass
1774 1787
1775 1788 opts,args = self.parse_options(parameter_s,'px')
1776 1789
1777 1790 # Default line number value
1778 1791 lineno = None
1779 1792 if opts.has_key('p'):
1780 1793 args = '_%s' % last_call[0]
1781 1794 if not self.shell.user_ns.has_key(args):
1782 1795 args = last_call[1]
1783 1796
1784 1797 # use last_call to remember the state of the previous call, but don't
1785 1798 # let it be clobbered by successive '-p' calls.
1786 1799 try:
1787 1800 last_call[0] = self.shell.outputcache.prompt_count
1788 1801 if not opts.has_key('p'):
1789 1802 last_call[1] = parameter_s
1790 1803 except:
1791 1804 pass
1792 1805
1793 1806 # by default this is done with temp files, except when the given
1794 1807 # arg is a filename
1795 1808 use_temp = 1
1796 1809
1797 1810 if re.match(r'\d',args):
1798 1811 # Mode where user specifies ranges of lines, like in %macro.
1799 1812 # This means that you can't edit files whose names begin with
1800 1813 # numbers this way. Tough.
1801 1814 ranges = args.split()
1802 1815 data = ''.join(self.extract_input_slices(ranges))
1803 1816 elif args.endswith('.py'):
1804 1817 filename = make_filename(args)
1805 1818 data = ''
1806 1819 use_temp = 0
1807 1820 elif args:
1808 1821 try:
1809 1822 # Load the parameter given as a variable. If not a string,
1810 1823 # process it as an object instead (below)
1811 1824
1812 1825 #print '*** args',args,'type',type(args) # dbg
1813 1826 data = eval(args,self.shell.user_ns)
1814 1827 if not type(data) in StringTypes:
1815 1828 raise DataIsObject
1816 1829 except (NameError,SyntaxError):
1817 1830 # given argument is not a variable, try as a filename
1818 1831 filename = make_filename(args)
1819 1832 if filename is None:
1820 1833 warn("Argument given (%s) can't be found as a variable "
1821 1834 "or as a filename." % args)
1822 1835 return
1823 1836 data = ''
1824 1837 use_temp = 0
1825 1838 except DataIsObject:
1826 1839 # For objects, try to edit the file where they are defined
1827 1840 try:
1828 1841 filename = inspect.getabsfile(data)
1829 1842 datafile = 1
1830 1843 except TypeError:
1831 1844 filename = make_filename(args)
1832 1845 datafile = 1
1833 1846 warn('Could not find file where `%s` is defined.\n'
1834 1847 'Opening a file named `%s`' % (args,filename))
1835 1848 # Now, make sure we can actually read the source (if it was in
1836 1849 # a temp file it's gone by now).
1837 1850 if datafile:
1838 1851 try:
1839 1852 lineno = inspect.getsourcelines(data)[1]
1840 1853 except IOError:
1841 1854 filename = make_filename(args)
1842 1855 if filename is None:
1843 1856 warn('The file `%s` where `%s` was defined cannot '
1844 1857 'be read.' % (filename,data))
1845 1858 return
1846 1859 use_temp = 0
1847 1860 else:
1848 1861 data = ''
1849 1862
1850 1863 if use_temp:
1851 1864 filename = tempfile.mktemp('.py')
1852 1865 self.shell.tempfiles.append(filename)
1853 1866
1854 1867 if data and use_temp:
1855 1868 tmp_file = open(filename,'w')
1856 1869 tmp_file.write(data)
1857 1870 tmp_file.close()
1858 1871
1859 1872 # do actual editing here
1860 1873 print 'Editing...',
1861 1874 sys.stdout.flush()
1862 1875 self.shell.hooks.editor(filename,lineno)
1863 1876 if opts.has_key('x'): # -x prevents actual execution
1864 1877 print
1865 1878 else:
1866 1879 print 'done. Executing edited code...'
1867 1880 try:
1868 1881 self.shell.safe_execfile(filename,self.shell.user_ns)
1869 1882 except IOError,msg:
1870 1883 if msg.filename == filename:
1871 1884 warn('File not found. Did you forget to save?')
1872 1885 return
1873 1886 else:
1874 1887 self.shell.showtraceback()
1875 1888 except:
1876 1889 self.shell.showtraceback()
1877 1890 if use_temp:
1878 1891 contents = open(filename).read()
1879 1892 return contents
1880 1893
1881 1894 def magic_xmode(self,parameter_s = ''):
1882 1895 """Switch modes for the exception handlers.
1883 1896
1884 1897 Valid modes: Plain, Context and Verbose.
1885 1898
1886 1899 If called without arguments, acts as a toggle."""
1887 1900
1888 1901 def xmode_switch_err(name):
1889 1902 warn('Error changing %s exception modes.\n%s' %
1890 1903 (name,sys.exc_info()[1]))
1891 1904
1892 1905 shell = self.shell
1893 1906 new_mode = parameter_s.strip().capitalize()
1894 1907 try:
1895 1908 shell.InteractiveTB.set_mode(mode=new_mode)
1896 1909 print 'Exception reporting mode:',shell.InteractiveTB.mode
1897 1910 except:
1898 1911 xmode_switch_err('user')
1899 1912
1900 1913 # threaded shells use a special handler in sys.excepthook
1901 1914 if shell.isthreaded:
1902 1915 try:
1903 1916 shell.sys_excepthook.set_mode(mode=new_mode)
1904 1917 except:
1905 1918 xmode_switch_err('threaded')
1906 1919
1907 1920 def magic_colors(self,parameter_s = ''):
1908 1921 """Switch color scheme for prompts, info system and exception handlers.
1909 1922
1910 1923 Currently implemented schemes: NoColor, Linux, LightBG.
1911 1924
1912 1925 Color scheme names are not case-sensitive."""
1913 1926
1914 1927 def color_switch_err(name):
1915 1928 warn('Error changing %s color schemes.\n%s' %
1916 1929 (name,sys.exc_info()[1]))
1917 1930
1918 1931
1919 1932 new_scheme = parameter_s.strip()
1920 1933 if not new_scheme:
1921 1934 print 'You must specify a color scheme.'
1922 1935 return
1923 1936 # Under Windows, check for Gary Bishop's readline, which is necessary
1924 1937 # for ANSI coloring
1925 1938 if os.name in ['nt','dos']:
1926 1939 try:
1927 1940 import readline
1928 1941 except ImportError:
1929 1942 has_readline = 0
1930 1943 else:
1931 1944 try:
1932 1945 readline.GetOutputFile()
1933 1946 except AttributeError:
1934 1947 has_readline = 0
1935 1948 else:
1936 1949 has_readline = 1
1937 1950 if not has_readline:
1938 1951 msg = """\
1939 1952 Proper color support under MS Windows requires Gary Bishop's readline library.
1940 1953 You can find it at:
1941 1954 http://sourceforge.net/projects/uncpythontools
1942 1955 Gary's readline needs the ctypes module, from:
1943 1956 http://starship.python.net/crew/theller/ctypes
1944 1957
1945 1958 Defaulting color scheme to 'NoColor'"""
1946 1959 new_scheme = 'NoColor'
1947 1960 warn(msg)
1948 1961 # local shortcut
1949 1962 shell = self.shell
1950 1963
1951 1964 # Set prompt colors
1952 1965 try:
1953 1966 shell.outputcache.set_colors(new_scheme)
1954 1967 except:
1955 1968 color_switch_err('prompt')
1956 1969 else:
1957 1970 shell.rc.colors = \
1958 1971 shell.outputcache.color_table.active_scheme_name
1959 1972 # Set exception colors
1960 1973 try:
1961 1974 shell.InteractiveTB.set_colors(scheme = new_scheme)
1962 1975 shell.SyntaxTB.set_colors(scheme = new_scheme)
1963 1976 except:
1964 1977 color_switch_err('exception')
1965 1978
1966 1979 # threaded shells use a verbose traceback in sys.excepthook
1967 1980 if shell.isthreaded:
1968 1981 try:
1969 1982 shell.sys_excepthook.set_colors(scheme=new_scheme)
1970 1983 except:
1971 1984 color_switch_err('system exception handler')
1972 1985
1973 1986 # Set info (for 'object?') colors
1974 1987 if shell.rc.color_info:
1975 1988 try:
1976 1989 shell.inspector.set_active_scheme(new_scheme)
1977 1990 except:
1978 1991 color_switch_err('object inspector')
1979 1992 else:
1980 1993 shell.inspector.set_active_scheme('NoColor')
1981 1994
1982 1995 def magic_color_info(self,parameter_s = ''):
1983 1996 """Toggle color_info.
1984 1997
1985 1998 The color_info configuration parameter controls whether colors are
1986 1999 used for displaying object details (by things like %psource, %pfile or
1987 2000 the '?' system). This function toggles this value with each call.
1988 2001
1989 2002 Note that unless you have a fairly recent pager (less works better
1990 2003 than more) in your system, using colored object information displays
1991 2004 will not work properly. Test it and see."""
1992 2005
1993 2006 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1994 2007 self.magic_colors(self.shell.rc.colors)
1995 2008 print 'Object introspection functions have now coloring:',
1996 2009 print ['OFF','ON'][self.shell.rc.color_info]
1997 2010
1998 2011 def magic_Pprint(self, parameter_s=''):
1999 2012 """Toggle pretty printing on/off."""
2000 2013
2001 2014 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2002 2015 print 'Pretty printing has been turned', \
2003 2016 ['OFF','ON'][self.shell.outputcache.Pprint]
2004 2017
2005 2018 def magic_exit(self, parameter_s=''):
2006 2019 """Exit IPython, confirming if configured to do so.
2007 2020
2008 2021 You can configure whether IPython asks for confirmation upon exit by
2009 2022 setting the confirm_exit flag in the ipythonrc file."""
2010 2023
2011 2024 self.shell.exit()
2012 2025
2013 2026 def magic_quit(self, parameter_s=''):
2014 2027 """Exit IPython, confirming if configured to do so (like %exit)"""
2015 2028
2016 2029 self.shell.exit()
2017 2030
2018 2031 def magic_Exit(self, parameter_s=''):
2019 2032 """Exit IPython without confirmation."""
2020 2033
2021 2034 self.shell.exit_now = True
2022 2035
2023 2036 def magic_Quit(self, parameter_s=''):
2024 2037 """Exit IPython without confirmation (like %Exit)."""
2025 2038
2026 2039 self.shell.exit_now = True
2027 2040
2028 2041 #......................................................................
2029 2042 # Functions to implement unix shell-type things
2030 2043
2031 2044 def magic_alias(self, parameter_s = ''):
2032 2045 """Define an alias for a system command.
2033 2046
2034 2047 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2035 2048
2036 2049 Then, typing 'alias_name params' will execute the system command 'cmd
2037 2050 params' (from your underlying operating system).
2038 2051
2039 2052 Aliases have lower precedence than magic functions and Python normal
2040 2053 variables, so if 'foo' is both a Python variable and an alias, the
2041 2054 alias can not be executed until 'del foo' removes the Python variable.
2042 2055
2043 2056 You can use the %l specifier in an alias definition to represent the
2044 2057 whole line when the alias is called. For example:
2045 2058
2046 2059 In [2]: alias all echo "Input in brackets: <%l>"\\
2047 2060 In [3]: all hello world\\
2048 2061 Input in brackets: <hello world>
2049 2062
2050 2063 You can also define aliases with parameters using %s specifiers (one
2051 2064 per parameter):
2052 2065
2053 2066 In [1]: alias parts echo first %s second %s\\
2054 2067 In [2]: %parts A B\\
2055 2068 first A second B\\
2056 2069 In [3]: %parts A\\
2057 2070 Incorrect number of arguments: 2 expected.\\
2058 2071 parts is an alias to: 'echo first %s second %s'
2059 2072
2060 2073 Note that %l and %s are mutually exclusive. You can only use one or
2061 2074 the other in your aliases.
2062 2075
2063 2076 Aliases expand Python variables just like system calls using ! or !!
2064 2077 do: all expressions prefixed with '$' get expanded. For details of
2065 2078 the semantic rules, see PEP-215:
2066 2079 http://www.python.org/peps/pep-0215.html. This is the library used by
2067 2080 IPython for variable expansion. If you want to access a true shell
2068 2081 variable, an extra $ is necessary to prevent its expansion by IPython:
2069 2082
2070 2083 In [6]: alias show echo\\
2071 2084 In [7]: PATH='A Python string'\\
2072 2085 In [8]: show $PATH\\
2073 2086 A Python string\\
2074 2087 In [9]: show $$PATH\\
2075 2088 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2076 2089
2077 2090 You can use the alias facility to acess all of $PATH. See the %rehash
2078 2091 and %rehashx functions, which automatically create aliases for the
2079 2092 contents of your $PATH.
2080 2093
2081 2094 If called with no parameters, %alias prints the current alias table."""
2082 2095
2083 2096 par = parameter_s.strip()
2084 2097 if not par:
2085 2098 if self.shell.rc.automagic:
2086 2099 prechar = ''
2087 2100 else:
2088 2101 prechar = self.shell.ESC_MAGIC
2089 2102 print 'Alias\t\tSystem Command\n'+'-'*30
2090 2103 atab = self.shell.alias_table
2091 2104 aliases = atab.keys()
2092 2105 aliases.sort()
2093 2106 for alias in aliases:
2094 2107 print prechar+alias+'\t\t'+atab[alias][1]
2095 2108 print '-'*30+'\nTotal number of aliases:',len(aliases)
2096 2109 return
2097 2110 try:
2098 2111 alias,cmd = par.split(None,1)
2099 2112 except:
2100 2113 print OInspect.getdoc(self.magic_alias)
2101 2114 else:
2102 2115 nargs = cmd.count('%s')
2103 2116 if nargs>0 and cmd.find('%l')>=0:
2104 2117 error('The %s and %l specifiers are mutually exclusive '
2105 2118 'in alias definitions.')
2106 2119 else: # all looks OK
2107 2120 self.shell.alias_table[alias] = (nargs,cmd)
2108 2121 self.shell.alias_table_validate(verbose=1)
2109 2122 # end magic_alias
2110 2123
2111 2124 def magic_unalias(self, parameter_s = ''):
2112 2125 """Remove an alias"""
2113 2126
2114 2127 aname = parameter_s.strip()
2115 2128 if aname in self.shell.alias_table:
2116 2129 del self.shell.alias_table[aname]
2117 2130
2118 2131 def magic_rehash(self, parameter_s = ''):
2119 2132 """Update the alias table with all entries in $PATH.
2120 2133
2121 2134 This version does no checks on execute permissions or whether the
2122 2135 contents of $PATH are truly files (instead of directories or something
2123 2136 else). For such a safer (but slower) version, use %rehashx."""
2124 2137
2125 2138 # This function (and rehashx) manipulate the alias_table directly
2126 2139 # rather than calling magic_alias, for speed reasons. A rehash on a
2127 2140 # typical Linux box involves several thousand entries, so efficiency
2128 2141 # here is a top concern.
2129 2142
2130 2143 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2131 2144 alias_table = self.shell.alias_table
2132 2145 for pdir in path:
2133 2146 for ff in os.listdir(pdir):
2134 2147 # each entry in the alias table must be (N,name), where
2135 2148 # N is the number of positional arguments of the alias.
2136 2149 alias_table[ff] = (0,ff)
2137 2150 # Make sure the alias table doesn't contain keywords or builtins
2138 2151 self.shell.alias_table_validate()
2139 2152 # Call again init_auto_alias() so we get 'rm -i' and other modified
2140 2153 # aliases since %rehash will probably clobber them
2141 2154 self.shell.init_auto_alias()
2142 2155
2143 2156 def magic_rehashx(self, parameter_s = ''):
2144 2157 """Update the alias table with all executable files in $PATH.
2145 2158
2146 2159 This version explicitly checks that every entry in $PATH is a file
2147 2160 with execute access (os.X_OK), so it is much slower than %rehash.
2148 2161
2149 2162 Under Windows, it checks executability as a match agains a
2150 2163 '|'-separated string of extensions, stored in the IPython config
2151 2164 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2152 2165
2153 2166 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2154 2167 alias_table = self.shell.alias_table
2155 2168
2156 2169 if os.name == 'posix':
2157 2170 isexec = lambda fname:os.path.isfile(fname) and \
2158 2171 os.access(fname,os.X_OK)
2159 2172 else:
2160 2173
2161 2174 try:
2162 2175 winext = os.environ['pathext'].replace(';','|').replace('.','')
2163 2176 except KeyError:
2164 2177 winext = 'exe|com|bat'
2165 2178
2166 2179 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2167 2180 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2168 2181 savedir = os.getcwd()
2169 2182 try:
2170 2183 # write the whole loop for posix/Windows so we don't have an if in
2171 2184 # the innermost part
2172 2185 if os.name == 'posix':
2173 2186 for pdir in path:
2174 2187 os.chdir(pdir)
2175 2188 for ff in os.listdir(pdir):
2176 2189 if isexec(ff):
2177 2190 # each entry in the alias table must be (N,name),
2178 2191 # where N is the number of positional arguments of the
2179 2192 # alias.
2180 2193 alias_table[ff] = (0,ff)
2181 2194 else:
2182 2195 for pdir in path:
2183 2196 os.chdir(pdir)
2184 2197 for ff in os.listdir(pdir):
2185 2198 if isexec(ff):
2186 2199 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2187 2200 # Make sure the alias table doesn't contain keywords or builtins
2188 2201 self.shell.alias_table_validate()
2189 2202 # Call again init_auto_alias() so we get 'rm -i' and other
2190 2203 # modified aliases since %rehashx will probably clobber them
2191 2204 self.shell.init_auto_alias()
2192 2205 finally:
2193 2206 os.chdir(savedir)
2194 2207
2195 2208 def magic_pwd(self, parameter_s = ''):
2196 2209 """Return the current working directory path."""
2197 2210 return os.getcwd()
2198 2211
2199 2212 def magic_cd(self, parameter_s=''):
2200 2213 """Change the current working directory.
2201 2214
2202 2215 This command automatically maintains an internal list of directories
2203 2216 you visit during your IPython session, in the variable _dh. The
2204 2217 command %dhist shows this history nicely formatted.
2205 2218
2206 2219 Usage:
2207 2220
2208 2221 cd 'dir': changes to directory 'dir'.
2209 2222
2210 2223 cd -: changes to the last visited directory.
2211 2224
2212 2225 cd -<n>: changes to the n-th directory in the directory history.
2213 2226
2214 2227 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2215 2228 (note: cd <bookmark_name> is enough if there is no
2216 2229 directory <bookmark_name>, but a bookmark with the name exists.)
2217 2230
2218 2231 Options:
2219 2232
2220 2233 -q: quiet. Do not print the working directory after the cd command is
2221 2234 executed. By default IPython's cd command does print this directory,
2222 2235 since the default prompts do not display path information.
2223 2236
2224 2237 Note that !cd doesn't work for this purpose because the shell where
2225 2238 !command runs is immediately discarded after executing 'command'."""
2226 2239
2227 2240 parameter_s = parameter_s.strip()
2228 2241 bkms = self.shell.persist.get("bookmarks",{})
2229 2242
2230 2243 numcd = re.match(r'(-)(\d+)$',parameter_s)
2231 2244 # jump in directory history by number
2232 2245 if numcd:
2233 2246 nn = int(numcd.group(2))
2234 2247 try:
2235 2248 ps = self.shell.user_ns['_dh'][nn]
2236 2249 except IndexError:
2237 2250 print 'The requested directory does not exist in history.'
2238 2251 return
2239 2252 else:
2240 2253 opts = {}
2241 2254 else:
2242 2255 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2243 2256 # jump to previous
2244 2257 if ps == '-':
2245 2258 try:
2246 2259 ps = self.shell.user_ns['_dh'][-2]
2247 2260 except IndexError:
2248 2261 print 'No previous directory to change to.'
2249 2262 return
2250 2263 # jump to bookmark
2251 2264 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2252 2265 if bkms.has_key(ps):
2253 2266 target = bkms[ps]
2254 2267 print '(bookmark:%s) -> %s' % (ps,target)
2255 2268 ps = target
2256 2269 else:
2257 2270 if bkms:
2258 2271 error("Bookmark '%s' not found. "
2259 2272 "Use '%bookmark -l' to see your bookmarks." % ps)
2260 2273 else:
2261 2274 print "Bookmarks not set - use %bookmark <bookmarkname>"
2262 2275 return
2263 2276
2264 2277 # at this point ps should point to the target dir
2265 2278 if ps:
2266 2279 try:
2267 2280 os.chdir(os.path.expanduser(ps))
2268 2281 except OSError:
2269 2282 print sys.exc_info()[1]
2270 2283 else:
2271 2284 self.shell.user_ns['_dh'].append(os.getcwd())
2272 2285 else:
2273 2286 os.chdir(self.shell.home_dir)
2274 2287 self.shell.user_ns['_dh'].append(os.getcwd())
2275 2288 if not 'q' in opts:
2276 2289 print self.shell.user_ns['_dh'][-1]
2277 2290
2278 2291 def magic_dhist(self, parameter_s=''):
2279 2292 """Print your history of visited directories.
2280 2293
2281 2294 %dhist -> print full history\\
2282 2295 %dhist n -> print last n entries only\\
2283 2296 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2284 2297
2285 2298 This history is automatically maintained by the %cd command, and
2286 2299 always available as the global list variable _dh. You can use %cd -<n>
2287 2300 to go to directory number <n>."""
2288 2301
2289 2302 dh = self.shell.user_ns['_dh']
2290 2303 if parameter_s:
2291 2304 try:
2292 2305 args = map(int,parameter_s.split())
2293 2306 except:
2294 2307 self.arg_err(Magic.magic_dhist)
2295 2308 return
2296 2309 if len(args) == 1:
2297 2310 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2298 2311 elif len(args) == 2:
2299 2312 ini,fin = args
2300 2313 else:
2301 2314 self.arg_err(Magic.magic_dhist)
2302 2315 return
2303 2316 else:
2304 2317 ini,fin = 0,len(dh)
2305 2318 nlprint(dh,
2306 2319 header = 'Directory history (kept in _dh)',
2307 2320 start=ini,stop=fin)
2308 2321
2309 2322 def magic_env(self, parameter_s=''):
2310 2323 """List environment variables."""
2311 2324
2312 2325 return os.environ.data
2313 2326
2314 2327 def magic_pushd(self, parameter_s=''):
2315 2328 """Place the current dir on stack and change directory.
2316 2329
2317 2330 Usage:\\
2318 2331 %pushd ['dirname']
2319 2332
2320 2333 %pushd with no arguments does a %pushd to your home directory.
2321 2334 """
2322 2335 if parameter_s == '': parameter_s = '~'
2323 2336 dir_s = self.shell.dir_stack
2324 2337 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2325 2338 os.path.expanduser(self.shell.dir_stack[0]):
2326 2339 try:
2327 2340 self.magic_cd(parameter_s)
2328 2341 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2329 2342 self.magic_dirs()
2330 2343 except:
2331 2344 print 'Invalid directory'
2332 2345 else:
2333 2346 print 'You are already there!'
2334 2347
2335 2348 def magic_popd(self, parameter_s=''):
2336 2349 """Change to directory popped off the top of the stack.
2337 2350 """
2338 2351 if len (self.shell.dir_stack) > 1:
2339 2352 self.shell.dir_stack.pop(0)
2340 2353 self.magic_cd(self.shell.dir_stack[0])
2341 2354 print self.shell.dir_stack[0]
2342 2355 else:
2343 2356 print "You can't remove the starting directory from the stack:",\
2344 2357 self.shell.dir_stack
2345 2358
2346 2359 def magic_dirs(self, parameter_s=''):
2347 2360 """Return the current directory stack."""
2348 2361
2349 2362 return self.shell.dir_stack[:]
2350 2363
2351 2364 def magic_sc(self, parameter_s=''):
2352 2365 """Shell capture - execute a shell command and capture its output.
2353 2366
2354 2367 %sc [options] varname=command
2355 2368
2356 2369 IPython will run the given command using commands.getoutput(), and
2357 2370 will then update the user's interactive namespace with a variable
2358 2371 called varname, containing the value of the call. Your command can
2359 2372 contain shell wildcards, pipes, etc.
2360 2373
2361 2374 The '=' sign in the syntax is mandatory, and the variable name you
2362 2375 supply must follow Python's standard conventions for valid names.
2363 2376
2364 2377 Options:
2365 2378
2366 2379 -l: list output. Split the output on newlines into a list before
2367 2380 assigning it to the given variable. By default the output is stored
2368 2381 as a single string.
2369 2382
2370 2383 -v: verbose. Print the contents of the variable.
2371 2384
2372 2385 In most cases you should not need to split as a list, because the
2373 2386 returned value is a special type of string which can automatically
2374 2387 provide its contents either as a list (split on newlines) or as a
2375 2388 space-separated string. These are convenient, respectively, either
2376 2389 for sequential processing or to be passed to a shell command.
2377 2390
2378 2391 For example:
2379 2392
2380 2393 # Capture into variable a
2381 2394 In [9]: sc a=ls *py
2382 2395
2383 2396 # a is a string with embedded newlines
2384 2397 In [10]: a
2385 2398 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2386 2399
2387 2400 # which can be seen as a list:
2388 2401 In [11]: a.l
2389 2402 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2390 2403
2391 2404 # or as a whitespace-separated string:
2392 2405 In [12]: a.s
2393 2406 Out[12]: 'setup.py win32_manual_post_install.py'
2394 2407
2395 2408 # a.s is useful to pass as a single command line:
2396 2409 In [13]: !wc -l $a.s
2397 2410 146 setup.py
2398 2411 130 win32_manual_post_install.py
2399 2412 276 total
2400 2413
2401 2414 # while the list form is useful to loop over:
2402 2415 In [14]: for f in a.l:
2403 2416 ....: !wc -l $f
2404 2417 ....:
2405 2418 146 setup.py
2406 2419 130 win32_manual_post_install.py
2407 2420
2408 2421 Similiarly, the lists returned by the -l option are also special, in
2409 2422 the sense that you can equally invoke the .s attribute on them to
2410 2423 automatically get a whitespace-separated string from their contents:
2411 2424
2412 2425 In [1]: sc -l b=ls *py
2413 2426
2414 2427 In [2]: b
2415 2428 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2416 2429
2417 2430 In [3]: b.s
2418 2431 Out[3]: 'setup.py win32_manual_post_install.py'
2419 2432
2420 2433 In summary, both the lists and strings used for ouptut capture have
2421 2434 the following special attributes:
2422 2435
2423 2436 .l (or .list) : value as list.
2424 2437 .n (or .nlstr): value as newline-separated string.
2425 2438 .s (or .spstr): value as space-separated string.
2426 2439 """
2427 2440
2428 2441 opts,args = self.parse_options(parameter_s,'lv')
2429 2442 # Try to get a variable name and command to run
2430 2443 try:
2431 2444 # the variable name must be obtained from the parse_options
2432 2445 # output, which uses shlex.split to strip options out.
2433 2446 var,_ = args.split('=',1)
2434 2447 var = var.strip()
2435 2448 # But the the command has to be extracted from the original input
2436 2449 # parameter_s, not on what parse_options returns, to avoid the
2437 2450 # quote stripping which shlex.split performs on it.
2438 2451 _,cmd = parameter_s.split('=',1)
2439 2452 except ValueError:
2440 2453 var,cmd = '',''
2441 2454 if not var:
2442 2455 error('you must specify a variable to assign the command to.')
2443 2456 return
2444 2457 # If all looks ok, proceed
2445 2458 out,err = self.shell.getoutputerror(cmd)
2446 2459 if err:
2447 2460 print >> Term.cerr,err
2448 2461 if opts.has_key('l'):
2449 2462 out = SList(out.split('\n'))
2450 2463 else:
2451 2464 out = LSString(out)
2452 2465 if opts.has_key('v'):
2453 2466 print '%s ==\n%s' % (var,pformat(out))
2454 2467 self.shell.user_ns.update({var:out})
2455 2468
2456 2469 def magic_sx(self, parameter_s=''):
2457 2470 """Shell execute - run a shell command and capture its output.
2458 2471
2459 2472 %sx command
2460 2473
2461 2474 IPython will run the given command using commands.getoutput(), and
2462 2475 return the result formatted as a list (split on '\\n'). Since the
2463 2476 output is _returned_, it will be stored in ipython's regular output
2464 2477 cache Out[N] and in the '_N' automatic variables.
2465 2478
2466 2479 Notes:
2467 2480
2468 2481 1) If an input line begins with '!!', then %sx is automatically
2469 2482 invoked. That is, while:
2470 2483 !ls
2471 2484 causes ipython to simply issue system('ls'), typing
2472 2485 !!ls
2473 2486 is a shorthand equivalent to:
2474 2487 %sx ls
2475 2488
2476 2489 2) %sx differs from %sc in that %sx automatically splits into a list,
2477 2490 like '%sc -l'. The reason for this is to make it as easy as possible
2478 2491 to process line-oriented shell output via further python commands.
2479 2492 %sc is meant to provide much finer control, but requires more
2480 2493 typing.
2481 2494
2482 2495 3) Just like %sc -l, this is a list with special attributes:
2483 2496
2484 2497 .l (or .list) : value as list.
2485 2498 .n (or .nlstr): value as newline-separated string.
2486 2499 .s (or .spstr): value as whitespace-separated string.
2487 2500
2488 2501 This is very useful when trying to use such lists as arguments to
2489 2502 system commands."""
2490 2503
2491 2504 if parameter_s:
2492 2505 out,err = self.shell.getoutputerror(parameter_s)
2493 2506 if err:
2494 2507 print >> Term.cerr,err
2495 2508 return SList(out.split('\n'))
2496 2509
2497 2510 def magic_bg(self, parameter_s=''):
2498 2511 """Run a job in the background, in a separate thread.
2499 2512
2500 2513 For example,
2501 2514
2502 2515 %bg myfunc(x,y,z=1)
2503 2516
2504 2517 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2505 2518 execution starts, a message will be printed indicating the job
2506 2519 number. If your job number is 5, you can use
2507 2520
2508 2521 myvar = jobs.result(5) or myvar = jobs[5].result
2509 2522
2510 2523 to assign this result to variable 'myvar'.
2511 2524
2512 2525 IPython has a job manager, accessible via the 'jobs' object. You can
2513 2526 type jobs? to get more information about it, and use jobs.<TAB> to see
2514 2527 its attributes. All attributes not starting with an underscore are
2515 2528 meant for public use.
2516 2529
2517 2530 In particular, look at the jobs.new() method, which is used to create
2518 2531 new jobs. This magic %bg function is just a convenience wrapper
2519 2532 around jobs.new(), for expression-based jobs. If you want to create a
2520 2533 new job with an explicit function object and arguments, you must call
2521 2534 jobs.new() directly.
2522 2535
2523 2536 The jobs.new docstring also describes in detail several important
2524 2537 caveats associated with a thread-based model for background job
2525 2538 execution. Type jobs.new? for details.
2526 2539
2527 2540 You can check the status of all jobs with jobs.status().
2528 2541
2529 2542 The jobs variable is set by IPython into the Python builtin namespace.
2530 2543 If you ever declare a variable named 'jobs', you will shadow this
2531 2544 name. You can either delete your global jobs variable to regain
2532 2545 access to the job manager, or make a new name and assign it manually
2533 2546 to the manager (stored in IPython's namespace). For example, to
2534 2547 assign the job manager to the Jobs name, use:
2535 2548
2536 2549 Jobs = __builtins__.jobs"""
2537 2550
2538 2551 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2539 2552
2540 2553 def magic_store(self, parameter_s=''):
2541 2554 """Lightweight persistence for python variables.
2542 2555
2543 2556 Example:
2544 2557
2545 2558 ville@badger[~]|1> A = ['hello',10,'world']\\
2546 2559 ville@badger[~]|2> %store A\\
2547 2560 ville@badger[~]|3> Exit
2548 2561
2549 2562 (IPython session is closed and started again...)
2550 2563
2551 2564 ville@badger:~$ ipython -p pysh\\
2552 2565 ville@badger[~]|1> print A
2553 2566
2554 2567 ['hello', 10, 'world']
2555 2568
2556 2569 Usage:
2557 2570
2558 2571 %store - Show list of all variables and their current values\\
2559 2572 %store <var> - Store the *current* value of the variable to disk\\
2560 2573 %store -d - Remove the variable and its value from storage\\
2561 2574 %store -r - Remove all variables from storage
2562 2575
2563 2576 It should be noted that if you change the value of a variable, you
2564 2577 need to %store it again if you want to persist the new value.
2565 2578
2566 2579 Note also that the variables will need to be pickleable; most basic
2567 2580 python types can be safely %stored.
2568 2581 """
2569 2582
2570 2583 opts,args = self.parse_options(parameter_s,'dr',mode='list')
2571 2584 # delete
2572 2585 if opts.has_key('d'):
2573 2586 try:
2574 2587 todel = args[0]
2575 2588 except IndexError:
2576 2589 error('You must provide the variable to forget')
2577 2590 else:
2578 2591 try:
2579 2592 del self.shell.persist['S:' + todel]
2580 2593 except:
2581 2594 error("Can't delete variable '%s'" % todel)
2582 2595 # reset
2583 2596 elif opts.has_key('r'):
2584 2597 for k in self.shell.persist.keys():
2585 2598 if k.startswith('S:'):
2586 2599 del self.shell.persist[k]
2587 2600
2588 2601 # run without arguments -> list variables & values
2589 2602 elif not args:
2590 2603 vars = [v[2:] for v in self.shell.persist.keys()
2591 2604 if v.startswith('S:')]
2592 2605 vars.sort()
2593 2606 if vars:
2594 2607 size = max(map(len,vars))
2595 2608 else:
2596 2609 size = 0
2597 2610
2598 2611 print 'Stored variables and their in-memory values:'
2599 2612 fmt = '%-'+str(size)+'s -> %s'
2600 2613 get = self.shell.user_ns.get
2601 2614 for var in vars:
2602 2615 # print 30 first characters from every var
2603 2616 print fmt % (var,repr(get(var,'<unavailable>'))[:50])
2604 2617
2605 2618 # default action - store the variable
2606 2619 else:
2607 2620 pickled = pickle.dumps(self.shell.user_ns[args[0] ])
2608 2621 self.shell.persist[ 'S:' + args[0] ] = pickled
2609 2622 print "Stored '%s' (%d bytes)" % (args[0], len(pickled))
2610 2623
2611 2624 def magic_bookmark(self, parameter_s=''):
2612 2625 """Manage IPython's bookmark system.
2613 2626
2614 2627 %bookmark <name> - set bookmark to current dir
2615 2628 %bookmark <name> <dir> - set bookmark to <dir>
2616 2629 %bookmark -l - list all bookmarks
2617 2630 %bookmark -d <name> - remove bookmark
2618 2631 %bookmark -r - remove all bookmarks
2619 2632
2620 2633 You can later on access a bookmarked folder with:
2621 2634 %cd -b <name>
2622 2635 or simply '%cd <name>' if there is no directory called <name> AND
2623 2636 there is such a bookmark defined.
2624 2637
2625 2638 Your bookmarks persist through IPython sessions, but they are
2626 2639 associated with each profile."""
2627 2640
2628 2641 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2629 2642 if len(args) > 2:
2630 2643 error('You can only give at most two arguments')
2631 2644 return
2632 2645
2633 2646 bkms = self.shell.persist.get('bookmarks',{})
2634 2647
2635 2648 if opts.has_key('d'):
2636 2649 try:
2637 2650 todel = args[0]
2638 2651 except IndexError:
2639 2652 error('You must provide a bookmark to delete')
2640 2653 else:
2641 2654 try:
2642 2655 del bkms[todel]
2643 2656 except:
2644 2657 error("Can't delete bookmark '%s'" % todel)
2645 2658 elif opts.has_key('r'):
2646 2659 bkms = {}
2647 2660 elif opts.has_key('l'):
2648 2661 bks = bkms.keys()
2649 2662 bks.sort()
2650 2663 if bks:
2651 2664 size = max(map(len,bks))
2652 2665 else:
2653 2666 size = 0
2654 2667 fmt = '%-'+str(size)+'s -> %s'
2655 2668 print 'Current bookmarks:'
2656 2669 for bk in bks:
2657 2670 print fmt % (bk,bkms[bk])
2658 2671 else:
2659 2672 if not args:
2660 2673 error("You must specify the bookmark name")
2661 2674 elif len(args)==1:
2662 2675 bkms[args[0]] = os.getcwd()
2663 2676 elif len(args)==2:
2664 2677 bkms[args[0]] = args[1]
2665 2678 self.shell.persist['bookmarks'] = bkms
2666 2679
2667 2680 def magic_pycat(self, parameter_s=''):
2668 2681 """Show a syntax-highlighted file through a pager.
2669 2682
2670 2683 This magic is similar to the cat utility, but it will assume the file
2671 2684 to be Python source and will show it with syntax highlighting. """
2672 2685
2673 2686 filename = get_py_filename(parameter_s)
2674 2687 page(self.shell.colorize(file_read(filename)),
2675 2688 screen_lines=self.shell.rc.screen_length)
2676 2689
2677 2690 # end Magic
@@ -1,76 +1,76 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Release data for the IPython project.
3 3
4 $Id: Release.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Release.py 986 2005-12-31 23:07:31Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
8 8 #
9 9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 10 # <n8gray@caltech.edu>
11 11 #
12 12 # Distributed under the terms of the BSD License. The full license is in
13 13 # the file COPYING, distributed as part of this software.
14 14 #*****************************************************************************
15 15
16 16 # Name of the package for release purposes. This is the name which labels
17 17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 18 name = 'ipython'
19 19
20 20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 21 # the new substring. We have to avoid using either dashes or underscores,
22 22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 23 # bdist_deb does not accept underscores (a Debian convention).
24 24
25 version = '0.7.0.rc4'
25 version = '0.7.0.rc5'
26 26
27 revision = '$Revision: 984 $'
27 revision = '$Revision: 986 $'
28 28
29 29 description = "An enhanced interactive Python shell."
30 30
31 31 long_description = \
32 32 """
33 33 IPython provides a replacement for the interactive Python interpreter with
34 34 extra functionality.
35 35
36 36 Main features:
37 37
38 38 * Comprehensive object introspection.
39 39
40 40 * Input history, persistent across sessions.
41 41
42 42 * Caching of output results during a session with automatically generated
43 43 references.
44 44
45 45 * Readline based name completion.
46 46
47 47 * Extensible system of 'magic' commands for controlling the environment and
48 48 performing many tasks related either to IPython or the operating system.
49 49
50 50 * Configuration system with easy switching between different setups (simpler
51 51 than changing $PYTHONSTARTUP environment variables every time).
52 52
53 53 * Session logging and reloading.
54 54
55 55 * Extensible syntax processing for special purpose situations.
56 56
57 57 * Access to the system shell with user-extensible alias system.
58 58
59 59 * Easily embeddable in other Python programs.
60 60
61 61 * Integrated access to the pdb debugger and the Python profiler. """
62 62
63 63 license = 'BSD'
64 64
65 65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
66 66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
67 67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
68 68 }
69 69
70 70 url = 'http://ipython.scipy.org'
71 71
72 72 download_url = 'http://ipython.scipy.org/dist'
73 73
74 74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
75 75
76 76 keywords = ['Interactive','Interpreter','Shell']
@@ -1,534 +1,543 b''
1 1 """Word completion for IPython.
2 2
3 3 This module is a fork of the rlcompleter module in the Python standard
4 4 library. The original enhancements made to rlcompleter have been sent
5 5 upstream and were accepted as of Python 2.3, but we need a lot more
6 6 functionality specific to IPython, so this module will continue to live as an
7 7 IPython-specific utility.
8 8
9 9 ---------------------------------------------------------------------------
10 10 Original rlcompleter documentation:
11 11
12 12 This requires the latest extension to the readline module (the
13 13 completes keywords, built-ins and globals in __main__; when completing
14 14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
15 15 completes its attributes.
16 16
17 17 It's very cool to do "import string" type "string.", hit the
18 18 completion key (twice), and see the list of names defined by the
19 19 string module!
20 20
21 21 Tip: to use the tab key as the completion key, call
22 22
23 23 readline.parse_and_bind("tab: complete")
24 24
25 25 Notes:
26 26
27 27 - Exceptions raised by the completer function are *ignored* (and
28 28 generally cause the completion to fail). This is a feature -- since
29 29 readline sets the tty device in raw (or cbreak) mode, printing a
30 30 traceback wouldn't work well without some complicated hoopla to save,
31 31 reset and restore the tty state.
32 32
33 33 - The evaluation of the NAME.NAME... form may cause arbitrary
34 34 application defined code to be executed if an object with a
35 35 __getattr__ hook is found. Since it is the responsibility of the
36 36 application (or the user) to enable this feature, I consider this an
37 37 acceptable risk. More complicated expressions (e.g. function calls or
38 38 indexing operations) are *not* evaluated.
39 39
40 40 - GNU readline is also used by the built-in functions input() and
41 41 raw_input(), and thus these also benefit/suffer from the completer
42 42 features. Clearly an interactive application can benefit by
43 43 specifying its own completer function and using raw_input() for all
44 44 its input.
45 45
46 46 - When the original stdin is not a tty device, GNU readline is never
47 47 used, and this module (and the readline module) are silently inactive.
48 48
49 49 """
50 50
51 51 #*****************************************************************************
52 52 #
53 53 # Since this file is essentially a minimally modified copy of the rlcompleter
54 54 # module which is part of the standard Python distribution, I assume that the
55 55 # proper procedure is to maintain its copyright as belonging to the Python
56 56 # Software Foundation (in addition to my own, for all new code).
57 57 #
58 58 # Copyright (C) 2001 Python Software Foundation, www.python.org
59 59 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
60 60 #
61 61 # Distributed under the terms of the BSD License. The full license is in
62 62 # the file COPYING, distributed as part of this software.
63 63 #
64 64 #*****************************************************************************
65 65
66 66 import __builtin__
67 67 import __main__
68 68 import glob
69 69 import keyword
70 70 import os
71 71 import re
72 72 import readline
73 73 import sys
74 74 import types
75 75
76 76 from IPython.genutils import shlex_split
77 77
78 78 __all__ = ['Completer','IPCompleter']
79 79
80 80 def get_class_members(cls):
81 81 ret = dir(cls)
82 82 if hasattr(cls,'__bases__'):
83 83 for base in cls.__bases__:
84 84 ret.extend(get_class_members(base))
85 85 return ret
86 86
87 87 class Completer:
88 88 def __init__(self,namespace=None,global_namespace=None):
89 89 """Create a new completer for the command line.
90 90
91 91 Completer([namespace,global_namespace]) -> completer instance.
92 92
93 93 If unspecified, the default namespace where completions are performed
94 94 is __main__ (technically, __main__.__dict__). Namespaces should be
95 95 given as dictionaries.
96 96
97 97 An optional second namespace can be given. This allows the completer
98 98 to handle cases where both the local and global scopes need to be
99 99 distinguished.
100 100
101 101 Completer instances should be used as the completion mechanism of
102 102 readline via the set_completer() call:
103 103
104 104 readline.set_completer(Completer(my_namespace).complete)
105 105 """
106 106
107 107 # some minimal strict typechecks. For some core data structures, I
108 108 # want actual basic python types, not just anything that looks like
109 109 # one. This is especially true for namespaces.
110 110 for ns in (namespace,global_namespace):
111 111 if ns is not None and type(ns) != types.DictType:
112 112 raise TypeError,'namespace must be a dictionary'
113 113
114 114 # Don't bind to namespace quite yet, but flag whether the user wants a
115 115 # specific namespace or to use __main__.__dict__. This will allow us
116 116 # to bind to __main__.__dict__ at completion time, not now.
117 117 if namespace is None:
118 118 self.use_main_ns = 1
119 119 else:
120 120 self.use_main_ns = 0
121 121 self.namespace = namespace
122 122
123 123 # The global namespace, if given, can be bound directly
124 124 if global_namespace is None:
125 125 self.global_namespace = {}
126 126 else:
127 127 self.global_namespace = global_namespace
128 128
129 129 def complete(self, text, state):
130 130 """Return the next possible completion for 'text'.
131 131
132 132 This is called successively with state == 0, 1, 2, ... until it
133 133 returns None. The completion should begin with 'text'.
134 134
135 135 """
136 136 if self.use_main_ns:
137 137 self.namespace = __main__.__dict__
138 138
139 139 if state == 0:
140 140 if "." in text:
141 141 self.matches = self.attr_matches(text)
142 142 else:
143 143 self.matches = self.global_matches(text)
144 144 try:
145 145 return self.matches[state]
146 146 except IndexError:
147 147 return None
148 148
149 149 def global_matches(self, text):
150 150 """Compute matches when text is a simple name.
151 151
152 152 Return a list of all keywords, built-in functions and names currently
153 153 defined in self.namespace or self.global_namespace that match.
154 154
155 155 """
156 156 matches = []
157 157 match_append = matches.append
158 158 n = len(text)
159 159 for lst in [keyword.kwlist,
160 160 __builtin__.__dict__.keys(),
161 161 self.namespace.keys(),
162 162 self.global_namespace.keys()]:
163 163 for word in lst:
164 164 if word[:n] == text and word != "__builtins__":
165 165 match_append(word)
166 166 return matches
167 167
168 168 def attr_matches(self, text):
169 169 """Compute matches when text contains a dot.
170 170
171 171 Assuming the text is of the form NAME.NAME....[NAME], and is
172 172 evaluatable in self.namespace or self.global_namespace, it will be
173 173 evaluated and its attributes (as revealed by dir()) are used as
174 174 possible completions. (For class instances, class members are are
175 175 also considered.)
176 176
177 177 WARNING: this can still invoke arbitrary C code, if an object
178 178 with a __getattr__ hook is evaluated.
179 179
180 180 """
181 181 import re
182 182
183 183 # Another option, seems to work great. Catches things like ''.<tab>
184 184 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
185 185
186 186 if not m:
187 187 return []
188 188
189 189 expr, attr = m.group(1, 3)
190 190 try:
191 191 object = eval(expr, self.namespace)
192 192 except:
193 193 object = eval(expr, self.global_namespace)
194 194
195 195 # for modules which define __all__, complete only on those.
196 196 if type(object) == types.ModuleType and hasattr(object, '__all__'):
197 197 words = getattr(object, '__all__')
198 198 else:
199 199 words = dir(object)
200 200 if hasattr(object,'__class__'):
201 201 words.append('__class__')
202 202 words.extend(get_class_members(object.__class__))
203 203
204 204 # filter out non-string attributes which may be stuffed by dir() calls
205 205 # and poor coding in third-party modules
206 206 words = [w for w in words
207 207 if isinstance(w, basestring) and w != "__builtins__"]
208 208 # Build match list to return
209 209 n = len(attr)
210 210 return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ]
211 211
212 212 class IPCompleter(Completer):
213 213 """Extension of the completer class with IPython-specific features"""
214 214
215 215 def __init__(self,shell,namespace=None,global_namespace=None,
216 216 omit__names=0,alias_table=None):
217 217 """IPCompleter() -> completer
218 218
219 219 Return a completer object suitable for use by the readline library
220 220 via readline.set_completer().
221 221
222 222 Inputs:
223 223
224 224 - shell: a pointer to the ipython shell itself. This is needed
225 225 because this completer knows about magic functions, and those can
226 226 only be accessed via the ipython instance.
227 227
228 228 - namespace: an optional dict where completions are performed.
229 229
230 230 - global_namespace: secondary optional dict for completions, to
231 231 handle cases (such as IPython embedded inside functions) where
232 232 both Python scopes are visible.
233 233
234 234 - The optional omit__names parameter sets the completer to omit the
235 235 'magic' names (__magicname__) for python objects unless the text
236 236 to be completed explicitly starts with one or more underscores.
237 237
238 238 - If alias_table is supplied, it should be a dictionary of aliases
239 239 to complete. """
240 240
241 241 Completer.__init__(self,namespace,global_namespace)
242 242 self.magic_prefix = shell.name+'.magic_'
243 243 self.magic_escape = shell.ESC_MAGIC
244 244 self.readline = readline
245 245 delims = self.readline.get_completer_delims()
246 246 delims = delims.replace(self.magic_escape,'')
247 247 self.readline.set_completer_delims(delims)
248 248 self.get_line_buffer = self.readline.get_line_buffer
249 249 self.omit__names = omit__names
250 250 self.merge_completions = shell.rc.readline_merge_completions
251 251
252 252 if alias_table is None:
253 253 alias_table = {}
254 254 self.alias_table = alias_table
255 255 # Regexp to split filenames with spaces in them
256 256 self.space_name_re = re.compile(r'([^\\] )')
257 257 # Hold a local ref. to glob.glob for speed
258 258 self.glob = glob.glob
259
260 # Determine if we are running on 'dumb' terminals, like (X)Emacs
261 # buffers, to avoid completion problems.
262 term = os.environ.get('TERM','xterm')
263 self.dumb_terminal = term in ['dumb','emacs']
264
259 265 # Special handling of backslashes needed in win32 platforms
260 266 if sys.platform == "win32":
261 267 self.clean_glob = self._clean_glob_win32
262 268 else:
263 269 self.clean_glob = self._clean_glob
264 270 self.matchers = [self.python_matches,
265 271 self.file_matches,
266 272 self.alias_matches,
267 273 self.python_func_kw_matches]
268 274
269 275 # Code contributed by Alex Schmolck, for ipython/emacs integration
270 276 def all_completions(self, text):
271 277 """Return all possible completions for the benefit of emacs."""
272 278
273 279 completions = []
274 280 comp_append = completions.append
275 281 try:
276 282 for i in xrange(sys.maxint):
277 283 res = self.complete(text, i)
278 284
279 285 if not res: break
280 286
281 287 comp_append(res)
282 288 #XXX workaround for ``notDefined.<tab>``
283 289 except NameError:
284 290 pass
285 291 return completions
286 292 # /end Alex Schmolck code.
287 293
288 294 def _clean_glob(self,text):
289 295 return self.glob("%s*" % text)
290 296
291 297 def _clean_glob_win32(self,text):
292 298 return [f.replace("\\","/")
293 299 for f in self.glob("%s*" % text)]
294 300
295 301 def file_matches(self, text):
296 302 """Match filneames, expanding ~USER type strings.
297 303
298 304 Most of the seemingly convoluted logic in this completer is an
299 305 attempt to handle filenames with spaces in them. And yet it's not
300 306 quite perfect, because Python's readline doesn't expose all of the
301 307 GNU readline details needed for this to be done correctly.
302 308
303 309 For a filename with a space in it, the printed completions will be
304 310 only the parts after what's already been typed (instead of the
305 311 full completions, as is normally done). I don't think with the
306 312 current (as of Python 2.3) Python readline it's possible to do
307 313 better."""
308 314
309 315 #print 'Completer->file_matches: <%s>' % text # dbg
310 316
311 317 # chars that require escaping with backslash - i.e. chars
312 318 # that readline treats incorrectly as delimiters, but we
313 319 # don't want to treat as delimiters in filename matching
314 320 # when escaped with backslash
315 321
316 322 protectables = ' ()[]{}'
317 323
318 324 def protect_filename(s):
319 325 return "".join([(ch in protectables and '\\' + ch or ch)
320 326 for ch in s])
321 327
322 328 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
323 329 open_quotes = 0 # track strings with open quotes
324 330 try:
325 331 lsplit = shlex_split(lbuf)[-1]
326 332 except ValueError:
327 333 # typically an unmatched ", or backslash without escaped char.
328 334 if lbuf.count('"')==1:
329 335 open_quotes = 1
330 336 lsplit = lbuf.split('"')[-1]
331 337 elif lbuf.count("'")==1:
332 338 open_quotes = 1
333 339 lsplit = lbuf.split("'")[-1]
334 340 else:
335 341 return None
336 342 except IndexError:
337 343 # tab pressed on empty line
338 344 lsplit = ""
339 345
340 346 if lsplit != protect_filename(lsplit):
341 347 # if protectables are found, do matching on the whole escaped
342 348 # name
343 349 has_protectables = 1
344 350 text0,text = text,lsplit
345 351 else:
346 352 has_protectables = 0
347 353 text = os.path.expanduser(text)
348 354
349 355 if text == "":
350 356 return [protect_filename(f) for f in self.glob("*")]
351 357
352 358 m0 = self.clean_glob(text.replace('\\',''))
353 359 if has_protectables:
354 360 # If we had protectables, we need to revert our changes to the
355 361 # beginning of filename so that we don't double-write the part
356 362 # of the filename we have so far
357 363 len_lsplit = len(lsplit)
358 364 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
359 365 else:
360 366 if open_quotes:
361 367 # if we have a string with an open quote, we don't need to
362 368 # protect the names at all (and we _shouldn't_, as it
363 369 # would cause bugs when the filesystem call is made).
364 370 matches = m0
365 371 else:
366 372 matches = [protect_filename(f) for f in m0]
367 373 if len(matches) == 1 and os.path.isdir(matches[0]):
368 374 # Takes care of links to directories also. Use '/'
369 375 # explicitly, even under Windows, so that name completions
370 376 # don't end up escaped.
371 377 matches[0] += '/'
372 378 return matches
373 379
374 380 def alias_matches(self, text):
375 381 """Match internal system aliases"""
376 382 #print 'Completer->alias_matches:',text # dbg
377 383 text = os.path.expanduser(text)
378 384 aliases = self.alias_table.keys()
379 385 if text == "":
380 386 return aliases
381 387 else:
382 388 return [alias for alias in aliases if alias.startswith(text)]
383 389
384 390 def python_matches(self,text):
385 391 """Match attributes or global python names"""
386 392 #print 'Completer->python_matches' # dbg
387 393 if "." in text:
388 394 try:
389 395 matches = self.attr_matches(text)
390 396 if text.endswith('.') and self.omit__names:
391 397 if self.omit__names == 1:
392 398 # true if txt is _not_ a __ name, false otherwise:
393 399 no__name = (lambda txt:
394 400 re.match(r'.*\.__.*?__',txt) is None)
395 401 else:
396 402 # true if txt is _not_ a _ name, false otherwise:
397 403 no__name = (lambda txt:
398 404 re.match(r'.*\._.*?',txt) is None)
399 405 matches = filter(no__name, matches)
400 406 except NameError:
401 407 # catches <undefined attributes>.<tab>
402 408 matches = []
403 409 else:
404 410 matches = self.global_matches(text)
405 411 # this is so completion finds magics when automagic is on:
406 412 if matches == [] and not text.startswith(os.sep):
407 413 matches = self.attr_matches(self.magic_prefix+text)
408 414 return matches
409 415
410 416 def _default_arguments(self, obj):
411 417 """Return the list of default arguments of obj if it is callable,
412 418 or empty list otherwise."""
413 419
414 420 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
415 421 # for classes, check for __init__,__new__
416 422 if inspect.isclass(obj):
417 423 obj = (getattr(obj,'__init__',None) or
418 424 getattr(obj,'__new__',None))
419 425 # for all others, check if they are __call__able
420 426 elif hasattr(obj, '__call__'):
421 427 obj = obj.__call__
422 428 # XXX: is there a way to handle the builtins ?
423 429 try:
424 430 args,_,_1,defaults = inspect.getargspec(obj)
425 431 if defaults:
426 432 return args[-len(defaults):]
427 433 except TypeError: pass
428 434 return []
429 435
430 436 def python_func_kw_matches(self,text):
431 437 """Match named parameters (kwargs) of the last open function"""
432 438
433 439 if "." in text: # a parameter cannot be dotted
434 440 return []
435 441 try: regexp = self.__funcParamsRegex
436 442 except AttributeError:
437 443 regexp = self.__funcParamsRegex = re.compile(r'''
438 444 '.*?' | # single quoted strings or
439 445 ".*?" | # double quoted strings or
440 446 \w+ | # identifier
441 447 \S # other characters
442 448 ''', re.VERBOSE | re.DOTALL)
443 449 # 1. find the nearest identifier that comes before an unclosed
444 450 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
445 451 tokens = regexp.findall(self.get_line_buffer())
446 452 tokens.reverse()
447 453 iterTokens = iter(tokens); openPar = 0
448 454 for token in iterTokens:
449 455 if token == ')':
450 456 openPar -= 1
451 457 elif token == '(':
452 458 openPar += 1
453 459 if openPar > 0:
454 460 # found the last unclosed parenthesis
455 461 break
456 462 else:
457 463 return []
458 464 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
459 465 ids = []
460 466 isId = re.compile(r'\w+$').match
461 467 while True:
462 468 try:
463 469 ids.append(iterTokens.next())
464 470 if not isId(ids[-1]):
465 471 ids.pop(); break
466 472 if not iterTokens.next() == '.':
467 473 break
468 474 except StopIteration:
469 475 break
470 476 # lookup the candidate callable matches either using global_matches
471 477 # or attr_matches for dotted names
472 478 if len(ids) == 1:
473 479 callableMatches = self.global_matches(ids[0])
474 480 else:
475 481 callableMatches = self.attr_matches('.'.join(ids[::-1]))
476 482 argMatches = []
477 483 for callableMatch in callableMatches:
478 484 try: namedArgs = self._default_arguments(eval(callableMatch,
479 485 self.namespace))
480 486 except: continue
481 487 for namedArg in namedArgs:
482 488 if namedArg.startswith(text):
483 489 argMatches.append("%s=" %namedArg)
484 490 return argMatches
485 491
486 492 def complete(self, text, state):
487 493 """Return the next possible completion for 'text'.
488 494
489 495 This is called successively with state == 0, 1, 2, ... until it
490 496 returns None. The completion should begin with 'text'. """
491 497
492 498 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
493 499
494 500 # if there is only a tab on a line with only whitespace, instead
495 501 # of the mostly useless 'do you want to see all million
496 502 # completions' message, just do the right thing and give the user
497 503 # his tab! Incidentally, this enables pasting of tabbed text from
498 504 # an editor (as long as autoindent is off).
499 if not self.get_line_buffer().strip():
505
506 # don't apply this on 'dumb' terminals, such as emacs buffers, so we
507 # don't interfere with their own tab-completion mechanism.
508 if not (self.dumb_terminal or self.get_line_buffer().strip()):
500 509 self.readline.insert_text('\t')
501 510 return None
502 511
503 512 magic_escape = self.magic_escape
504 513 magic_prefix = self.magic_prefix
505 514
506 515 try:
507 516 if text.startswith(magic_escape):
508 517 text = text.replace(magic_escape,magic_prefix)
509 518 elif text.startswith('~'):
510 519 text = os.path.expanduser(text)
511 520 if state == 0:
512 521 # Extend the list of completions with the results of each
513 522 # matcher, so we return results to the user from all
514 523 # namespaces.
515 524 if self.merge_completions:
516 525 self.matches = []
517 526 for matcher in self.matchers:
518 527 self.matches.extend(matcher(text))
519 528 else:
520 529 for matcher in self.matchers:
521 530 self.matches = matcher(text)
522 531 if self.matches:
523 532 break
524 533
525 534 try:
526 535 return self.matches[state].replace(magic_prefix,magic_escape)
527 536 except IndexError:
528 537 return None
529 538 except:
530 539 #from IPython.ultraTB import AutoFormattedTB; # dbg
531 540 #tb=AutoFormattedTB('Verbose');tb() #dbg
532 541
533 542 # If completion fails, don't annoy the user.
534 543 return None
@@ -1,4713 +1,4721 b''
1 1 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2 2
3 * IPython/completer.py (IPCompleter.complete): small patch to help
4 tab-completion under Emacs, after a suggestion by John Barnard
5 <barnarj-AT-ccf.org>.
6
7 * IPython/Magic.py (Magic.extract_input_slices): added support for
8 the slice notation in magics to use N-M to represent numbers N...M
9 (closed endpoints). This is used by %macro and %save.
10
3 11 * IPython/completer.py (Completer.attr_matches): for modules which
4 12 define __all__, complete only on those. After a patch by Jeffrey
5 Collins <jcollins-AT-boulder.net>. Also, clean up and speed up
6 this routine.
13 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
14 speed up this routine.
7 15
8 16 * IPython/Logger.py (Logger.log): fix a history handling bug. I
9 17 don't know if this is the end of it, but the behavior now is
10 18 certainly much more correct. Note that coupled with macros,
11 19 slightly surprising (at first) behavior may occur: a macro will in
12 20 general expand to multiple lines of input, so upon exiting, the
13 21 in/out counters will both be bumped by the corresponding amount
14 22 (as if the macro's contents had been typed interactively). Typing
15 23 %hist will reveal the intermediate (silently processed) lines.
16 24
17 25 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
18 26 pickle to fail (%run was overwriting __main__ and not restoring
19 27 it, but pickle relies on __main__ to operate).
20 28
21 29 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
22 30 using properties, but forgot to make the main InteractiveShell
23 31 class a new-style class. Properties fail silently, and
24 32 misteriously, with old-style class (getters work, but
25 33 setters don't do anything).
26 34
27 35 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
28 36
29 37 * IPython/Magic.py (magic_history): fix history reporting bug (I
30 38 know some nasties are still there, I just can't seem to find a
31 39 reproducible test case to track them down; the input history is
32 40 falling out of sync...)
33 41
34 42 * IPython/iplib.py (handle_shell_escape): fix bug where both
35 43 aliases and system accesses where broken for indented code (such
36 44 as loops).
37 45
38 46 * IPython/genutils.py (shell): fix small but critical bug for
39 47 win32 system access.
40 48
41 49 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
42 50
43 51 * IPython/iplib.py (showtraceback): remove use of the
44 52 sys.last_{type/value/traceback} structures, which are non
45 53 thread-safe.
46 54 (_prefilter): change control flow to ensure that we NEVER
47 55 introspect objects when autocall is off. This will guarantee that
48 56 having an input line of the form 'x.y', where access to attribute
49 57 'y' has side effects, doesn't trigger the side effect TWICE. It
50 58 is important to note that, with autocall on, these side effects
51 59 can still happen.
52 60 (ipsystem): new builtin, to complete the ip{magic/alias/system}
53 61 trio. IPython offers these three kinds of special calls which are
54 62 not python code, and it's a good thing to have their call method
55 63 be accessible as pure python functions (not just special syntax at
56 64 the command line). It gives us a better internal implementation
57 65 structure, as well as exposing these for user scripting more
58 66 cleanly.
59 67
60 68 * IPython/macro.py (Macro.__init__): moved macros to a standalone
61 69 file. Now that they'll be more likely to be used with the
62 70 persistance system (%store), I want to make sure their module path
63 71 doesn't change in the future, so that we don't break things for
64 72 users' persisted data.
65 73
66 74 * IPython/iplib.py (autoindent_update): move indentation
67 75 management into the _text_ processing loop, not the keyboard
68 76 interactive one. This is necessary to correctly process non-typed
69 77 multiline input (such as macros).
70 78
71 79 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
72 80 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
73 81 which was producing problems in the resulting manual.
74 82 (magic_whos): improve reporting of instances (show their class,
75 83 instead of simply printing 'instance' which isn't terribly
76 84 informative).
77 85
78 86 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
79 87 (minor mods) to support network shares under win32.
80 88
81 89 * IPython/winconsole.py (get_console_size): add new winconsole
82 90 module and fixes to page_dumb() to improve its behavior under
83 91 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
84 92
85 93 * IPython/Magic.py (Macro): simplified Macro class to just
86 94 subclass list. We've had only 2.2 compatibility for a very long
87 95 time, yet I was still avoiding subclassing the builtin types. No
88 96 more (I'm also starting to use properties, though I won't shift to
89 97 2.3-specific features quite yet).
90 98 (magic_store): added Ville's patch for lightweight variable
91 99 persistence, after a request on the user list by Matt Wilkie
92 100 <maphew-AT-gmail.com>. The new %store magic's docstring has full
93 101 details.
94 102
95 103 * IPython/iplib.py (InteractiveShell.post_config_initialization):
96 104 changed the default logfile name from 'ipython.log' to
97 105 'ipython_log.py'. These logs are real python files, and now that
98 106 we have much better multiline support, people are more likely to
99 107 want to use them as such. Might as well name them correctly.
100 108
101 109 * IPython/Magic.py: substantial cleanup. While we can't stop
102 110 using magics as mixins, due to the existing customizations 'out
103 111 there' which rely on the mixin naming conventions, at least I
104 112 cleaned out all cross-class name usage. So once we are OK with
105 113 breaking compatibility, the two systems can be separated.
106 114
107 115 * IPython/Logger.py: major cleanup. This one is NOT a mixin
108 116 anymore, and the class is a fair bit less hideous as well. New
109 117 features were also introduced: timestamping of input, and logging
110 118 of output results. These are user-visible with the -t and -o
111 119 options to %logstart. Closes
112 120 http://www.scipy.net/roundup/ipython/issue11 and a request by
113 121 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
114 122
115 123 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
116 124
117 125 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
118 126 better hadnle backslashes in paths. See the thread 'More Windows
119 127 questions part 2 - \/ characters revisited' on the iypthon user
120 128 list:
121 129 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
122 130
123 131 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
124 132
125 133 (InteractiveShell.__init__): change threaded shells to not use the
126 134 ipython crash handler. This was causing more problems than not,
127 135 as exceptions in the main thread (GUI code, typically) would
128 136 always show up as a 'crash', when they really weren't.
129 137
130 138 The colors and exception mode commands (%colors/%xmode) have been
131 139 synchronized to also take this into account, so users can get
132 140 verbose exceptions for their threaded code as well. I also added
133 141 support for activating pdb inside this exception handler as well,
134 142 so now GUI authors can use IPython's enhanced pdb at runtime.
135 143
136 144 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
137 145 true by default, and add it to the shipped ipythonrc file. Since
138 146 this asks the user before proceeding, I think it's OK to make it
139 147 true by default.
140 148
141 149 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
142 150 of the previous special-casing of input in the eval loop. I think
143 151 this is cleaner, as they really are commands and shouldn't have
144 152 a special role in the middle of the core code.
145 153
146 154 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
147 155
148 156 * IPython/iplib.py (edit_syntax_error): added support for
149 157 automatically reopening the editor if the file had a syntax error
150 158 in it. Thanks to scottt who provided the patch at:
151 159 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
152 160 version committed).
153 161
154 162 * IPython/iplib.py (handle_normal): add suport for multi-line
155 163 input with emtpy lines. This fixes
156 164 http://www.scipy.net/roundup/ipython/issue43 and a similar
157 165 discussion on the user list.
158 166
159 167 WARNING: a behavior change is necessarily introduced to support
160 168 blank lines: now a single blank line with whitespace does NOT
161 169 break the input loop, which means that when autoindent is on, by
162 170 default hitting return on the next (indented) line does NOT exit.
163 171
164 172 Instead, to exit a multiline input you can either have:
165 173
166 174 - TWO whitespace lines (just hit return again), or
167 175 - a single whitespace line of a different length than provided
168 176 by the autoindent (add or remove a space).
169 177
170 178 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
171 179 module to better organize all readline-related functionality.
172 180 I've deleted FlexCompleter and put all completion clases here.
173 181
174 182 * IPython/iplib.py (raw_input): improve indentation management.
175 183 It is now possible to paste indented code with autoindent on, and
176 184 the code is interpreted correctly (though it still looks bad on
177 185 screen, due to the line-oriented nature of ipython).
178 186 (MagicCompleter.complete): change behavior so that a TAB key on an
179 187 otherwise empty line actually inserts a tab, instead of completing
180 188 on the entire global namespace. This makes it easier to use the
181 189 TAB key for indentation. After a request by Hans Meine
182 190 <hans_meine-AT-gmx.net>
183 191 (_prefilter): add support so that typing plain 'exit' or 'quit'
184 192 does a sensible thing. Originally I tried to deviate as little as
185 193 possible from the default python behavior, but even that one may
186 194 change in this direction (thread on python-dev to that effect).
187 195 Regardless, ipython should do the right thing even if CPython's
188 196 '>>>' prompt doesn't.
189 197 (InteractiveShell): removed subclassing code.InteractiveConsole
190 198 class. By now we'd overridden just about all of its methods: I've
191 199 copied the remaining two over, and now ipython is a standalone
192 200 class. This will provide a clearer picture for the chainsaw
193 201 branch refactoring.
194 202
195 203 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
196 204
197 205 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
198 206 failures for objects which break when dir() is called on them.
199 207
200 208 * IPython/FlexCompleter.py (Completer.__init__): Added support for
201 209 distinct local and global namespaces in the completer API. This
202 210 change allows us top properly handle completion with distinct
203 211 scopes, including in embedded instances (this had never really
204 212 worked correctly).
205 213
206 214 Note: this introduces a change in the constructor for
207 215 MagicCompleter, as a new global_namespace parameter is now the
208 216 second argument (the others were bumped one position).
209 217
210 218 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
211 219
212 220 * IPython/iplib.py (embed_mainloop): fix tab-completion in
213 221 embedded instances (which can be done now thanks to Vivian's
214 222 frame-handling fixes for pdb).
215 223 (InteractiveShell.__init__): Fix namespace handling problem in
216 224 embedded instances. We were overwriting __main__ unconditionally,
217 225 and this should only be done for 'full' (non-embedded) IPython;
218 226 embedded instances must respect the caller's __main__. Thanks to
219 227 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
220 228
221 229 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
222 230
223 231 * setup.py: added download_url to setup(). This registers the
224 232 download address at PyPI, which is not only useful to humans
225 233 browsing the site, but is also picked up by setuptools (the Eggs
226 234 machinery). Thanks to Ville and R. Kern for the info/discussion
227 235 on this.
228 236
229 237 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
230 238
231 239 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
232 240 This brings a lot of nice functionality to the pdb mode, which now
233 241 has tab-completion, syntax highlighting, and better stack handling
234 242 than before. Many thanks to Vivian De Smedt
235 243 <vivian-AT-vdesmedt.com> for the original patches.
236 244
237 245 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
238 246
239 247 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
240 248 sequence to consistently accept the banner argument. The
241 249 inconsistency was tripping SAGE, thanks to Gary Zablackis
242 250 <gzabl-AT-yahoo.com> for the report.
243 251
244 252 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
245 253
246 254 * IPython/iplib.py (InteractiveShell.post_config_initialization):
247 255 Fix bug where a naked 'alias' call in the ipythonrc file would
248 256 cause a crash. Bug reported by Jorgen Stenarson.
249 257
250 258 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
251 259
252 260 * IPython/ipmaker.py (make_IPython): cleanups which should improve
253 261 startup time.
254 262
255 263 * IPython/iplib.py (runcode): my globals 'fix' for embedded
256 264 instances had introduced a bug with globals in normal code. Now
257 265 it's working in all cases.
258 266
259 267 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
260 268 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
261 269 has been introduced to set the default case sensitivity of the
262 270 searches. Users can still select either mode at runtime on a
263 271 per-search basis.
264 272
265 273 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
266 274
267 275 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
268 276 attributes in wildcard searches for subclasses. Modified version
269 277 of a patch by Jorgen.
270 278
271 279 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
272 280
273 281 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
274 282 embedded instances. I added a user_global_ns attribute to the
275 283 InteractiveShell class to handle this.
276 284
277 285 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
278 286
279 287 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
280 288 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
281 289 (reported under win32, but may happen also in other platforms).
282 290 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
283 291
284 292 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
285 293
286 294 * IPython/Magic.py (magic_psearch): new support for wildcard
287 295 patterns. Now, typing ?a*b will list all names which begin with a
288 296 and end in b, for example. The %psearch magic has full
289 297 docstrings. Many thanks to JΓΆrgen Stenarson
290 298 <jorgen.stenarson-AT-bostream.nu>, author of the patches
291 299 implementing this functionality.
292 300
293 301 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
294 302
295 303 * Manual: fixed long-standing annoyance of double-dashes (as in
296 304 --prefix=~, for example) being stripped in the HTML version. This
297 305 is a latex2html bug, but a workaround was provided. Many thanks
298 306 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
299 307 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
300 308 rolling. This seemingly small issue had tripped a number of users
301 309 when first installing, so I'm glad to see it gone.
302 310
303 311 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
304 312
305 313 * IPython/Extensions/numeric_formats.py: fix missing import,
306 314 reported by Stephen Walton.
307 315
308 316 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
309 317
310 318 * IPython/demo.py: finish demo module, fully documented now.
311 319
312 320 * IPython/genutils.py (file_read): simple little utility to read a
313 321 file and ensure it's closed afterwards.
314 322
315 323 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
316 324
317 325 * IPython/demo.py (Demo.__init__): added support for individually
318 326 tagging blocks for automatic execution.
319 327
320 328 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
321 329 syntax-highlighted python sources, requested by John.
322 330
323 331 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
324 332
325 333 * IPython/demo.py (Demo.again): fix bug where again() blocks after
326 334 finishing.
327 335
328 336 * IPython/genutils.py (shlex_split): moved from Magic to here,
329 337 where all 2.2 compatibility stuff lives. I needed it for demo.py.
330 338
331 339 * IPython/demo.py (Demo.__init__): added support for silent
332 340 blocks, improved marks as regexps, docstrings written.
333 341 (Demo.__init__): better docstring, added support for sys.argv.
334 342
335 343 * IPython/genutils.py (marquee): little utility used by the demo
336 344 code, handy in general.
337 345
338 346 * IPython/demo.py (Demo.__init__): new class for interactive
339 347 demos. Not documented yet, I just wrote it in a hurry for
340 348 scipy'05. Will docstring later.
341 349
342 350 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
343 351
344 352 * IPython/Shell.py (sigint_handler): Drastic simplification which
345 353 also seems to make Ctrl-C work correctly across threads! This is
346 354 so simple, that I can't beleive I'd missed it before. Needs more
347 355 testing, though.
348 356 (KBINT): Never mind, revert changes. I'm sure I'd tried something
349 357 like this before...
350 358
351 359 * IPython/genutils.py (get_home_dir): add protection against
352 360 non-dirs in win32 registry.
353 361
354 362 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
355 363 bug where dict was mutated while iterating (pysh crash).
356 364
357 365 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
358 366
359 367 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
360 368 spurious newlines added by this routine. After a report by
361 369 F. Mantegazza.
362 370
363 371 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
364 372
365 373 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
366 374 calls. These were a leftover from the GTK 1.x days, and can cause
367 375 problems in certain cases (after a report by John Hunter).
368 376
369 377 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
370 378 os.getcwd() fails at init time. Thanks to patch from David Remahl
371 379 <chmod007-AT-mac.com>.
372 380 (InteractiveShell.__init__): prevent certain special magics from
373 381 being shadowed by aliases. Closes
374 382 http://www.scipy.net/roundup/ipython/issue41.
375 383
376 384 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
377 385
378 386 * IPython/iplib.py (InteractiveShell.complete): Added new
379 387 top-level completion method to expose the completion mechanism
380 388 beyond readline-based environments.
381 389
382 390 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
383 391
384 392 * tools/ipsvnc (svnversion): fix svnversion capture.
385 393
386 394 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
387 395 attribute to self, which was missing. Before, it was set by a
388 396 routine which in certain cases wasn't being called, so the
389 397 instance could end up missing the attribute. This caused a crash.
390 398 Closes http://www.scipy.net/roundup/ipython/issue40.
391 399
392 400 2005-08-16 Fernando Perez <fperez@colorado.edu>
393 401
394 402 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
395 403 contains non-string attribute. Closes
396 404 http://www.scipy.net/roundup/ipython/issue38.
397 405
398 406 2005-08-14 Fernando Perez <fperez@colorado.edu>
399 407
400 408 * tools/ipsvnc: Minor improvements, to add changeset info.
401 409
402 410 2005-08-12 Fernando Perez <fperez@colorado.edu>
403 411
404 412 * IPython/iplib.py (runsource): remove self.code_to_run_src
405 413 attribute. I realized this is nothing more than
406 414 '\n'.join(self.buffer), and having the same data in two different
407 415 places is just asking for synchronization bugs. This may impact
408 416 people who have custom exception handlers, so I need to warn
409 417 ipython-dev about it (F. Mantegazza may use them).
410 418
411 419 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
412 420
413 421 * IPython/genutils.py: fix 2.2 compatibility (generators)
414 422
415 423 2005-07-18 Fernando Perez <fperez@colorado.edu>
416 424
417 425 * IPython/genutils.py (get_home_dir): fix to help users with
418 426 invalid $HOME under win32.
419 427
420 428 2005-07-17 Fernando Perez <fperez@colorado.edu>
421 429
422 430 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
423 431 some old hacks and clean up a bit other routines; code should be
424 432 simpler and a bit faster.
425 433
426 434 * IPython/iplib.py (interact): removed some last-resort attempts
427 435 to survive broken stdout/stderr. That code was only making it
428 436 harder to abstract out the i/o (necessary for gui integration),
429 437 and the crashes it could prevent were extremely rare in practice
430 438 (besides being fully user-induced in a pretty violent manner).
431 439
432 440 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
433 441 Nothing major yet, but the code is simpler to read; this should
434 442 make it easier to do more serious modifications in the future.
435 443
436 444 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
437 445 which broke in .15 (thanks to a report by Ville).
438 446
439 447 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
440 448 be quite correct, I know next to nothing about unicode). This
441 449 will allow unicode strings to be used in prompts, amongst other
442 450 cases. It also will prevent ipython from crashing when unicode
443 451 shows up unexpectedly in many places. If ascii encoding fails, we
444 452 assume utf_8. Currently the encoding is not a user-visible
445 453 setting, though it could be made so if there is demand for it.
446 454
447 455 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
448 456
449 457 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
450 458
451 459 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
452 460
453 461 * IPython/genutils.py: Add 2.2 compatibility here, so all other
454 462 code can work transparently for 2.2/2.3.
455 463
456 464 2005-07-16 Fernando Perez <fperez@colorado.edu>
457 465
458 466 * IPython/ultraTB.py (ExceptionColors): Make a global variable
459 467 out of the color scheme table used for coloring exception
460 468 tracebacks. This allows user code to add new schemes at runtime.
461 469 This is a minimally modified version of the patch at
462 470 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
463 471 for the contribution.
464 472
465 473 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
466 474 slightly modified version of the patch in
467 475 http://www.scipy.net/roundup/ipython/issue34, which also allows me
468 476 to remove the previous try/except solution (which was costlier).
469 477 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
470 478
471 479 2005-06-08 Fernando Perez <fperez@colorado.edu>
472 480
473 481 * IPython/iplib.py (write/write_err): Add methods to abstract all
474 482 I/O a bit more.
475 483
476 484 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
477 485 warning, reported by Aric Hagberg, fix by JD Hunter.
478 486
479 487 2005-06-02 *** Released version 0.6.15
480 488
481 489 2005-06-01 Fernando Perez <fperez@colorado.edu>
482 490
483 491 * IPython/iplib.py (MagicCompleter.file_matches): Fix
484 492 tab-completion of filenames within open-quoted strings. Note that
485 493 this requires that in ~/.ipython/ipythonrc, users change the
486 494 readline delimiters configuration to read:
487 495
488 496 readline_remove_delims -/~
489 497
490 498
491 499 2005-05-31 *** Released version 0.6.14
492 500
493 501 2005-05-29 Fernando Perez <fperez@colorado.edu>
494 502
495 503 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
496 504 with files not on the filesystem. Reported by Eliyahu Sandler
497 505 <eli@gondolin.net>
498 506
499 507 2005-05-22 Fernando Perez <fperez@colorado.edu>
500 508
501 509 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
502 510 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
503 511
504 512 2005-05-19 Fernando Perez <fperez@colorado.edu>
505 513
506 514 * IPython/iplib.py (safe_execfile): close a file which could be
507 515 left open (causing problems in win32, which locks open files).
508 516 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
509 517
510 518 2005-05-18 Fernando Perez <fperez@colorado.edu>
511 519
512 520 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
513 521 keyword arguments correctly to safe_execfile().
514 522
515 523 2005-05-13 Fernando Perez <fperez@colorado.edu>
516 524
517 525 * ipython.1: Added info about Qt to manpage, and threads warning
518 526 to usage page (invoked with --help).
519 527
520 528 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
521 529 new matcher (it goes at the end of the priority list) to do
522 530 tab-completion on named function arguments. Submitted by George
523 531 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
524 532 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
525 533 for more details.
526 534
527 535 * IPython/Magic.py (magic_run): Added new -e flag to ignore
528 536 SystemExit exceptions in the script being run. Thanks to a report
529 537 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
530 538 producing very annoying behavior when running unit tests.
531 539
532 540 2005-05-12 Fernando Perez <fperez@colorado.edu>
533 541
534 542 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
535 543 which I'd broken (again) due to a changed regexp. In the process,
536 544 added ';' as an escape to auto-quote the whole line without
537 545 splitting its arguments. Thanks to a report by Jerry McRae
538 546 <qrs0xyc02-AT-sneakemail.com>.
539 547
540 548 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
541 549 possible crashes caused by a TokenError. Reported by Ed Schofield
542 550 <schofield-AT-ftw.at>.
543 551
544 552 2005-05-06 Fernando Perez <fperez@colorado.edu>
545 553
546 554 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
547 555
548 556 2005-04-29 Fernando Perez <fperez@colorado.edu>
549 557
550 558 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
551 559 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
552 560 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
553 561 which provides support for Qt interactive usage (similar to the
554 562 existing one for WX and GTK). This had been often requested.
555 563
556 564 2005-04-14 *** Released version 0.6.13
557 565
558 566 2005-04-08 Fernando Perez <fperez@colorado.edu>
559 567
560 568 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
561 569 from _ofind, which gets called on almost every input line. Now,
562 570 we only try to get docstrings if they are actually going to be
563 571 used (the overhead of fetching unnecessary docstrings can be
564 572 noticeable for certain objects, such as Pyro proxies).
565 573
566 574 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
567 575 for completers. For some reason I had been passing them the state
568 576 variable, which completers never actually need, and was in
569 577 conflict with the rlcompleter API. Custom completers ONLY need to
570 578 take the text parameter.
571 579
572 580 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
573 581 work correctly in pysh. I've also moved all the logic which used
574 582 to be in pysh.py here, which will prevent problems with future
575 583 upgrades. However, this time I must warn users to update their
576 584 pysh profile to include the line
577 585
578 586 import_all IPython.Extensions.InterpreterExec
579 587
580 588 because otherwise things won't work for them. They MUST also
581 589 delete pysh.py and the line
582 590
583 591 execfile pysh.py
584 592
585 593 from their ipythonrc-pysh.
586 594
587 595 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
588 596 robust in the face of objects whose dir() returns non-strings
589 597 (which it shouldn't, but some broken libs like ITK do). Thanks to
590 598 a patch by John Hunter (implemented differently, though). Also
591 599 minor improvements by using .extend instead of + on lists.
592 600
593 601 * pysh.py:
594 602
595 603 2005-04-06 Fernando Perez <fperez@colorado.edu>
596 604
597 605 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
598 606 by default, so that all users benefit from it. Those who don't
599 607 want it can still turn it off.
600 608
601 609 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
602 610 config file, I'd forgotten about this, so users were getting it
603 611 off by default.
604 612
605 613 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
606 614 consistency. Now magics can be called in multiline statements,
607 615 and python variables can be expanded in magic calls via $var.
608 616 This makes the magic system behave just like aliases or !system
609 617 calls.
610 618
611 619 2005-03-28 Fernando Perez <fperez@colorado.edu>
612 620
613 621 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
614 622 expensive string additions for building command. Add support for
615 623 trailing ';' when autocall is used.
616 624
617 625 2005-03-26 Fernando Perez <fperez@colorado.edu>
618 626
619 627 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
620 628 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
621 629 ipython.el robust against prompts with any number of spaces
622 630 (including 0) after the ':' character.
623 631
624 632 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
625 633 continuation prompt, which misled users to think the line was
626 634 already indented. Closes debian Bug#300847, reported to me by
627 635 Norbert Tretkowski <tretkowski-AT-inittab.de>.
628 636
629 637 2005-03-23 Fernando Perez <fperez@colorado.edu>
630 638
631 639 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
632 640 properly aligned if they have embedded newlines.
633 641
634 642 * IPython/iplib.py (runlines): Add a public method to expose
635 643 IPython's code execution machinery, so that users can run strings
636 644 as if they had been typed at the prompt interactively.
637 645 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
638 646 methods which can call the system shell, but with python variable
639 647 expansion. The three such methods are: __IPYTHON__.system,
640 648 .getoutput and .getoutputerror. These need to be documented in a
641 649 'public API' section (to be written) of the manual.
642 650
643 651 2005-03-20 Fernando Perez <fperez@colorado.edu>
644 652
645 653 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
646 654 for custom exception handling. This is quite powerful, and it
647 655 allows for user-installable exception handlers which can trap
648 656 custom exceptions at runtime and treat them separately from
649 657 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
650 658 Mantegazza <mantegazza-AT-ill.fr>.
651 659 (InteractiveShell.set_custom_completer): public API function to
652 660 add new completers at runtime.
653 661
654 662 2005-03-19 Fernando Perez <fperez@colorado.edu>
655 663
656 664 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
657 665 allow objects which provide their docstrings via non-standard
658 666 mechanisms (like Pyro proxies) to still be inspected by ipython's
659 667 ? system.
660 668
661 669 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
662 670 automatic capture system. I tried quite hard to make it work
663 671 reliably, and simply failed. I tried many combinations with the
664 672 subprocess module, but eventually nothing worked in all needed
665 673 cases (not blocking stdin for the child, duplicating stdout
666 674 without blocking, etc). The new %sc/%sx still do capture to these
667 675 magical list/string objects which make shell use much more
668 676 conveninent, so not all is lost.
669 677
670 678 XXX - FIX MANUAL for the change above!
671 679
672 680 (runsource): I copied code.py's runsource() into ipython to modify
673 681 it a bit. Now the code object and source to be executed are
674 682 stored in ipython. This makes this info accessible to third-party
675 683 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
676 684 Mantegazza <mantegazza-AT-ill.fr>.
677 685
678 686 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
679 687 history-search via readline (like C-p/C-n). I'd wanted this for a
680 688 long time, but only recently found out how to do it. For users
681 689 who already have their ipythonrc files made and want this, just
682 690 add:
683 691
684 692 readline_parse_and_bind "\e[A": history-search-backward
685 693 readline_parse_and_bind "\e[B": history-search-forward
686 694
687 695 2005-03-18 Fernando Perez <fperez@colorado.edu>
688 696
689 697 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
690 698 LSString and SList classes which allow transparent conversions
691 699 between list mode and whitespace-separated string.
692 700 (magic_r): Fix recursion problem in %r.
693 701
694 702 * IPython/genutils.py (LSString): New class to be used for
695 703 automatic storage of the results of all alias/system calls in _o
696 704 and _e (stdout/err). These provide a .l/.list attribute which
697 705 does automatic splitting on newlines. This means that for most
698 706 uses, you'll never need to do capturing of output with %sc/%sx
699 707 anymore, since ipython keeps this always done for you. Note that
700 708 only the LAST results are stored, the _o/e variables are
701 709 overwritten on each call. If you need to save their contents
702 710 further, simply bind them to any other name.
703 711
704 712 2005-03-17 Fernando Perez <fperez@colorado.edu>
705 713
706 714 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
707 715 prompt namespace handling.
708 716
709 717 2005-03-16 Fernando Perez <fperez@colorado.edu>
710 718
711 719 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
712 720 classic prompts to be '>>> ' (final space was missing, and it
713 721 trips the emacs python mode).
714 722 (BasePrompt.__str__): Added safe support for dynamic prompt
715 723 strings. Now you can set your prompt string to be '$x', and the
716 724 value of x will be printed from your interactive namespace. The
717 725 interpolation syntax includes the full Itpl support, so
718 726 ${foo()+x+bar()} is a valid prompt string now, and the function
719 727 calls will be made at runtime.
720 728
721 729 2005-03-15 Fernando Perez <fperez@colorado.edu>
722 730
723 731 * IPython/Magic.py (magic_history): renamed %hist to %history, to
724 732 avoid name clashes in pylab. %hist still works, it just forwards
725 733 the call to %history.
726 734
727 735 2005-03-02 *** Released version 0.6.12
728 736
729 737 2005-03-02 Fernando Perez <fperez@colorado.edu>
730 738
731 739 * IPython/iplib.py (handle_magic): log magic calls properly as
732 740 ipmagic() function calls.
733 741
734 742 * IPython/Magic.py (magic_time): Improved %time to support
735 743 statements and provide wall-clock as well as CPU time.
736 744
737 745 2005-02-27 Fernando Perez <fperez@colorado.edu>
738 746
739 747 * IPython/hooks.py: New hooks module, to expose user-modifiable
740 748 IPython functionality in a clean manner. For now only the editor
741 749 hook is actually written, and other thigns which I intend to turn
742 750 into proper hooks aren't yet there. The display and prefilter
743 751 stuff, for example, should be hooks. But at least now the
744 752 framework is in place, and the rest can be moved here with more
745 753 time later. IPython had had a .hooks variable for a long time for
746 754 this purpose, but I'd never actually used it for anything.
747 755
748 756 2005-02-26 Fernando Perez <fperez@colorado.edu>
749 757
750 758 * IPython/ipmaker.py (make_IPython): make the default ipython
751 759 directory be called _ipython under win32, to follow more the
752 760 naming peculiarities of that platform (where buggy software like
753 761 Visual Sourcesafe breaks with .named directories). Reported by
754 762 Ville Vainio.
755 763
756 764 2005-02-23 Fernando Perez <fperez@colorado.edu>
757 765
758 766 * IPython/iplib.py (InteractiveShell.__init__): removed a few
759 767 auto_aliases for win32 which were causing problems. Users can
760 768 define the ones they personally like.
761 769
762 770 2005-02-21 Fernando Perez <fperez@colorado.edu>
763 771
764 772 * IPython/Magic.py (magic_time): new magic to time execution of
765 773 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
766 774
767 775 2005-02-19 Fernando Perez <fperez@colorado.edu>
768 776
769 777 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
770 778 into keys (for prompts, for example).
771 779
772 780 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
773 781 prompts in case users want them. This introduces a small behavior
774 782 change: ipython does not automatically add a space to all prompts
775 783 anymore. To get the old prompts with a space, users should add it
776 784 manually to their ipythonrc file, so for example prompt_in1 should
777 785 now read 'In [\#]: ' instead of 'In [\#]:'.
778 786 (BasePrompt.__init__): New option prompts_pad_left (only in rc
779 787 file) to control left-padding of secondary prompts.
780 788
781 789 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
782 790 the profiler can't be imported. Fix for Debian, which removed
783 791 profile.py because of License issues. I applied a slightly
784 792 modified version of the original Debian patch at
785 793 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
786 794
787 795 2005-02-17 Fernando Perez <fperez@colorado.edu>
788 796
789 797 * IPython/genutils.py (native_line_ends): Fix bug which would
790 798 cause improper line-ends under win32 b/c I was not opening files
791 799 in binary mode. Bug report and fix thanks to Ville.
792 800
793 801 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
794 802 trying to catch spurious foo[1] autocalls. My fix actually broke
795 803 ',/' autoquote/call with explicit escape (bad regexp).
796 804
797 805 2005-02-15 *** Released version 0.6.11
798 806
799 807 2005-02-14 Fernando Perez <fperez@colorado.edu>
800 808
801 809 * IPython/background_jobs.py: New background job management
802 810 subsystem. This is implemented via a new set of classes, and
803 811 IPython now provides a builtin 'jobs' object for background job
804 812 execution. A convenience %bg magic serves as a lightweight
805 813 frontend for starting the more common type of calls. This was
806 814 inspired by discussions with B. Granger and the BackgroundCommand
807 815 class described in the book Python Scripting for Computational
808 816 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
809 817 (although ultimately no code from this text was used, as IPython's
810 818 system is a separate implementation).
811 819
812 820 * IPython/iplib.py (MagicCompleter.python_matches): add new option
813 821 to control the completion of single/double underscore names
814 822 separately. As documented in the example ipytonrc file, the
815 823 readline_omit__names variable can now be set to 2, to omit even
816 824 single underscore names. Thanks to a patch by Brian Wong
817 825 <BrianWong-AT-AirgoNetworks.Com>.
818 826 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
819 827 be autocalled as foo([1]) if foo were callable. A problem for
820 828 things which are both callable and implement __getitem__.
821 829 (init_readline): Fix autoindentation for win32. Thanks to a patch
822 830 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
823 831
824 832 2005-02-12 Fernando Perez <fperez@colorado.edu>
825 833
826 834 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
827 835 which I had written long ago to sort out user error messages which
828 836 may occur during startup. This seemed like a good idea initially,
829 837 but it has proven a disaster in retrospect. I don't want to
830 838 change much code for now, so my fix is to set the internal 'debug'
831 839 flag to true everywhere, whose only job was precisely to control
832 840 this subsystem. This closes issue 28 (as well as avoiding all
833 841 sorts of strange hangups which occur from time to time).
834 842
835 843 2005-02-07 Fernando Perez <fperez@colorado.edu>
836 844
837 845 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
838 846 previous call produced a syntax error.
839 847
840 848 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
841 849 classes without constructor.
842 850
843 851 2005-02-06 Fernando Perez <fperez@colorado.edu>
844 852
845 853 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
846 854 completions with the results of each matcher, so we return results
847 855 to the user from all namespaces. This breaks with ipython
848 856 tradition, but I think it's a nicer behavior. Now you get all
849 857 possible completions listed, from all possible namespaces (python,
850 858 filesystem, magics...) After a request by John Hunter
851 859 <jdhunter-AT-nitace.bsd.uchicago.edu>.
852 860
853 861 2005-02-05 Fernando Perez <fperez@colorado.edu>
854 862
855 863 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
856 864 the call had quote characters in it (the quotes were stripped).
857 865
858 866 2005-01-31 Fernando Perez <fperez@colorado.edu>
859 867
860 868 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
861 869 Itpl.itpl() to make the code more robust against psyco
862 870 optimizations.
863 871
864 872 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
865 873 of causing an exception. Quicker, cleaner.
866 874
867 875 2005-01-28 Fernando Perez <fperez@colorado.edu>
868 876
869 877 * scripts/ipython_win_post_install.py (install): hardcode
870 878 sys.prefix+'python.exe' as the executable path. It turns out that
871 879 during the post-installation run, sys.executable resolves to the
872 880 name of the binary installer! I should report this as a distutils
873 881 bug, I think. I updated the .10 release with this tiny fix, to
874 882 avoid annoying the lists further.
875 883
876 884 2005-01-27 *** Released version 0.6.10
877 885
878 886 2005-01-27 Fernando Perez <fperez@colorado.edu>
879 887
880 888 * IPython/numutils.py (norm): Added 'inf' as optional name for
881 889 L-infinity norm, included references to mathworld.com for vector
882 890 norm definitions.
883 891 (amin/amax): added amin/amax for array min/max. Similar to what
884 892 pylab ships with after the recent reorganization of names.
885 893 (spike/spike_odd): removed deprecated spike/spike_odd functions.
886 894
887 895 * ipython.el: committed Alex's recent fixes and improvements.
888 896 Tested with python-mode from CVS, and it looks excellent. Since
889 897 python-mode hasn't released anything in a while, I'm temporarily
890 898 putting a copy of today's CVS (v 4.70) of python-mode in:
891 899 http://ipython.scipy.org/tmp/python-mode.el
892 900
893 901 * scripts/ipython_win_post_install.py (install): Win32 fix to use
894 902 sys.executable for the executable name, instead of assuming it's
895 903 called 'python.exe' (the post-installer would have produced broken
896 904 setups on systems with a differently named python binary).
897 905
898 906 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
899 907 references to os.linesep, to make the code more
900 908 platform-independent. This is also part of the win32 coloring
901 909 fixes.
902 910
903 911 * IPython/genutils.py (page_dumb): Remove attempts to chop long
904 912 lines, which actually cause coloring bugs because the length of
905 913 the line is very difficult to correctly compute with embedded
906 914 escapes. This was the source of all the coloring problems under
907 915 Win32. I think that _finally_, Win32 users have a properly
908 916 working ipython in all respects. This would never have happened
909 917 if not for Gary Bishop and Viktor Ransmayr's great help and work.
910 918
911 919 2005-01-26 *** Released version 0.6.9
912 920
913 921 2005-01-25 Fernando Perez <fperez@colorado.edu>
914 922
915 923 * setup.py: finally, we have a true Windows installer, thanks to
916 924 the excellent work of Viktor Ransmayr
917 925 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
918 926 Windows users. The setup routine is quite a bit cleaner thanks to
919 927 this, and the post-install script uses the proper functions to
920 928 allow a clean de-installation using the standard Windows Control
921 929 Panel.
922 930
923 931 * IPython/genutils.py (get_home_dir): changed to use the $HOME
924 932 environment variable under all OSes (including win32) if
925 933 available. This will give consistency to win32 users who have set
926 934 this variable for any reason. If os.environ['HOME'] fails, the
927 935 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
928 936
929 937 2005-01-24 Fernando Perez <fperez@colorado.edu>
930 938
931 939 * IPython/numutils.py (empty_like): add empty_like(), similar to
932 940 zeros_like() but taking advantage of the new empty() Numeric routine.
933 941
934 942 2005-01-23 *** Released version 0.6.8
935 943
936 944 2005-01-22 Fernando Perez <fperez@colorado.edu>
937 945
938 946 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
939 947 automatic show() calls. After discussing things with JDH, it
940 948 turns out there are too many corner cases where this can go wrong.
941 949 It's best not to try to be 'too smart', and simply have ipython
942 950 reproduce as much as possible the default behavior of a normal
943 951 python shell.
944 952
945 953 * IPython/iplib.py (InteractiveShell.__init__): Modified the
946 954 line-splitting regexp and _prefilter() to avoid calling getattr()
947 955 on assignments. This closes
948 956 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
949 957 readline uses getattr(), so a simple <TAB> keypress is still
950 958 enough to trigger getattr() calls on an object.
951 959
952 960 2005-01-21 Fernando Perez <fperez@colorado.edu>
953 961
954 962 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
955 963 docstring under pylab so it doesn't mask the original.
956 964
957 965 2005-01-21 *** Released version 0.6.7
958 966
959 967 2005-01-21 Fernando Perez <fperez@colorado.edu>
960 968
961 969 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
962 970 signal handling for win32 users in multithreaded mode.
963 971
964 972 2005-01-17 Fernando Perez <fperez@colorado.edu>
965 973
966 974 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
967 975 instances with no __init__. After a crash report by Norbert Nemec
968 976 <Norbert-AT-nemec-online.de>.
969 977
970 978 2005-01-14 Fernando Perez <fperez@colorado.edu>
971 979
972 980 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
973 981 names for verbose exceptions, when multiple dotted names and the
974 982 'parent' object were present on the same line.
975 983
976 984 2005-01-11 Fernando Perez <fperez@colorado.edu>
977 985
978 986 * IPython/genutils.py (flag_calls): new utility to trap and flag
979 987 calls in functions. I need it to clean up matplotlib support.
980 988 Also removed some deprecated code in genutils.
981 989
982 990 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
983 991 that matplotlib scripts called with %run, which don't call show()
984 992 themselves, still have their plotting windows open.
985 993
986 994 2005-01-05 Fernando Perez <fperez@colorado.edu>
987 995
988 996 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
989 997 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
990 998
991 999 2004-12-19 Fernando Perez <fperez@colorado.edu>
992 1000
993 1001 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
994 1002 parent_runcode, which was an eyesore. The same result can be
995 1003 obtained with Python's regular superclass mechanisms.
996 1004
997 1005 2004-12-17 Fernando Perez <fperez@colorado.edu>
998 1006
999 1007 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1000 1008 reported by Prabhu.
1001 1009 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1002 1010 sys.stderr) instead of explicitly calling sys.stderr. This helps
1003 1011 maintain our I/O abstractions clean, for future GUI embeddings.
1004 1012
1005 1013 * IPython/genutils.py (info): added new utility for sys.stderr
1006 1014 unified info message handling (thin wrapper around warn()).
1007 1015
1008 1016 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1009 1017 composite (dotted) names on verbose exceptions.
1010 1018 (VerboseTB.nullrepr): harden against another kind of errors which
1011 1019 Python's inspect module can trigger, and which were crashing
1012 1020 IPython. Thanks to a report by Marco Lombardi
1013 1021 <mlombard-AT-ma010192.hq.eso.org>.
1014 1022
1015 1023 2004-12-13 *** Released version 0.6.6
1016 1024
1017 1025 2004-12-12 Fernando Perez <fperez@colorado.edu>
1018 1026
1019 1027 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1020 1028 generated by pygtk upon initialization if it was built without
1021 1029 threads (for matplotlib users). After a crash reported by
1022 1030 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1023 1031
1024 1032 * IPython/ipmaker.py (make_IPython): fix small bug in the
1025 1033 import_some parameter for multiple imports.
1026 1034
1027 1035 * IPython/iplib.py (ipmagic): simplified the interface of
1028 1036 ipmagic() to take a single string argument, just as it would be
1029 1037 typed at the IPython cmd line.
1030 1038 (ipalias): Added new ipalias() with an interface identical to
1031 1039 ipmagic(). This completes exposing a pure python interface to the
1032 1040 alias and magic system, which can be used in loops or more complex
1033 1041 code where IPython's automatic line mangling is not active.
1034 1042
1035 1043 * IPython/genutils.py (timing): changed interface of timing to
1036 1044 simply run code once, which is the most common case. timings()
1037 1045 remains unchanged, for the cases where you want multiple runs.
1038 1046
1039 1047 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1040 1048 bug where Python2.2 crashes with exec'ing code which does not end
1041 1049 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1042 1050 before.
1043 1051
1044 1052 2004-12-10 Fernando Perez <fperez@colorado.edu>
1045 1053
1046 1054 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1047 1055 -t to -T, to accomodate the new -t flag in %run (the %run and
1048 1056 %prun options are kind of intermixed, and it's not easy to change
1049 1057 this with the limitations of python's getopt).
1050 1058
1051 1059 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1052 1060 the execution of scripts. It's not as fine-tuned as timeit.py,
1053 1061 but it works from inside ipython (and under 2.2, which lacks
1054 1062 timeit.py). Optionally a number of runs > 1 can be given for
1055 1063 timing very short-running code.
1056 1064
1057 1065 * IPython/genutils.py (uniq_stable): new routine which returns a
1058 1066 list of unique elements in any iterable, but in stable order of
1059 1067 appearance. I needed this for the ultraTB fixes, and it's a handy
1060 1068 utility.
1061 1069
1062 1070 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1063 1071 dotted names in Verbose exceptions. This had been broken since
1064 1072 the very start, now x.y will properly be printed in a Verbose
1065 1073 traceback, instead of x being shown and y appearing always as an
1066 1074 'undefined global'. Getting this to work was a bit tricky,
1067 1075 because by default python tokenizers are stateless. Saved by
1068 1076 python's ability to easily add a bit of state to an arbitrary
1069 1077 function (without needing to build a full-blown callable object).
1070 1078
1071 1079 Also big cleanup of this code, which had horrendous runtime
1072 1080 lookups of zillions of attributes for colorization. Moved all
1073 1081 this code into a few templates, which make it cleaner and quicker.
1074 1082
1075 1083 Printout quality was also improved for Verbose exceptions: one
1076 1084 variable per line, and memory addresses are printed (this can be
1077 1085 quite handy in nasty debugging situations, which is what Verbose
1078 1086 is for).
1079 1087
1080 1088 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1081 1089 the command line as scripts to be loaded by embedded instances.
1082 1090 Doing so has the potential for an infinite recursion if there are
1083 1091 exceptions thrown in the process. This fixes a strange crash
1084 1092 reported by Philippe MULLER <muller-AT-irit.fr>.
1085 1093
1086 1094 2004-12-09 Fernando Perez <fperez@colorado.edu>
1087 1095
1088 1096 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1089 1097 to reflect new names in matplotlib, which now expose the
1090 1098 matlab-compatible interface via a pylab module instead of the
1091 1099 'matlab' name. The new code is backwards compatible, so users of
1092 1100 all matplotlib versions are OK. Patch by J. Hunter.
1093 1101
1094 1102 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1095 1103 of __init__ docstrings for instances (class docstrings are already
1096 1104 automatically printed). Instances with customized docstrings
1097 1105 (indep. of the class) are also recognized and all 3 separate
1098 1106 docstrings are printed (instance, class, constructor). After some
1099 1107 comments/suggestions by J. Hunter.
1100 1108
1101 1109 2004-12-05 Fernando Perez <fperez@colorado.edu>
1102 1110
1103 1111 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1104 1112 warnings when tab-completion fails and triggers an exception.
1105 1113
1106 1114 2004-12-03 Fernando Perez <fperez@colorado.edu>
1107 1115
1108 1116 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1109 1117 be triggered when using 'run -p'. An incorrect option flag was
1110 1118 being set ('d' instead of 'D').
1111 1119 (manpage): fix missing escaped \- sign.
1112 1120
1113 1121 2004-11-30 *** Released version 0.6.5
1114 1122
1115 1123 2004-11-30 Fernando Perez <fperez@colorado.edu>
1116 1124
1117 1125 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1118 1126 setting with -d option.
1119 1127
1120 1128 * setup.py (docfiles): Fix problem where the doc glob I was using
1121 1129 was COMPLETELY BROKEN. It was giving the right files by pure
1122 1130 accident, but failed once I tried to include ipython.el. Note:
1123 1131 glob() does NOT allow you to do exclusion on multiple endings!
1124 1132
1125 1133 2004-11-29 Fernando Perez <fperez@colorado.edu>
1126 1134
1127 1135 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1128 1136 the manpage as the source. Better formatting & consistency.
1129 1137
1130 1138 * IPython/Magic.py (magic_run): Added new -d option, to run
1131 1139 scripts under the control of the python pdb debugger. Note that
1132 1140 this required changing the %prun option -d to -D, to avoid a clash
1133 1141 (since %run must pass options to %prun, and getopt is too dumb to
1134 1142 handle options with string values with embedded spaces). Thanks
1135 1143 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1136 1144 (magic_who_ls): added type matching to %who and %whos, so that one
1137 1145 can filter their output to only include variables of certain
1138 1146 types. Another suggestion by Matthew.
1139 1147 (magic_whos): Added memory summaries in kb and Mb for arrays.
1140 1148 (magic_who): Improve formatting (break lines every 9 vars).
1141 1149
1142 1150 2004-11-28 Fernando Perez <fperez@colorado.edu>
1143 1151
1144 1152 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1145 1153 cache when empty lines were present.
1146 1154
1147 1155 2004-11-24 Fernando Perez <fperez@colorado.edu>
1148 1156
1149 1157 * IPython/usage.py (__doc__): document the re-activated threading
1150 1158 options for WX and GTK.
1151 1159
1152 1160 2004-11-23 Fernando Perez <fperez@colorado.edu>
1153 1161
1154 1162 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1155 1163 the -wthread and -gthread options, along with a new -tk one to try
1156 1164 and coordinate Tk threading with wx/gtk. The tk support is very
1157 1165 platform dependent, since it seems to require Tcl and Tk to be
1158 1166 built with threads (Fedora1/2 appears NOT to have it, but in
1159 1167 Prabhu's Debian boxes it works OK). But even with some Tk
1160 1168 limitations, this is a great improvement.
1161 1169
1162 1170 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1163 1171 info in user prompts. Patch by Prabhu.
1164 1172
1165 1173 2004-11-18 Fernando Perez <fperez@colorado.edu>
1166 1174
1167 1175 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1168 1176 EOFErrors and bail, to avoid infinite loops if a non-terminating
1169 1177 file is fed into ipython. Patch submitted in issue 19 by user,
1170 1178 many thanks.
1171 1179
1172 1180 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1173 1181 autoquote/parens in continuation prompts, which can cause lots of
1174 1182 problems. Closes roundup issue 20.
1175 1183
1176 1184 2004-11-17 Fernando Perez <fperez@colorado.edu>
1177 1185
1178 1186 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1179 1187 reported as debian bug #280505. I'm not sure my local changelog
1180 1188 entry has the proper debian format (Jack?).
1181 1189
1182 1190 2004-11-08 *** Released version 0.6.4
1183 1191
1184 1192 2004-11-08 Fernando Perez <fperez@colorado.edu>
1185 1193
1186 1194 * IPython/iplib.py (init_readline): Fix exit message for Windows
1187 1195 when readline is active. Thanks to a report by Eric Jones
1188 1196 <eric-AT-enthought.com>.
1189 1197
1190 1198 2004-11-07 Fernando Perez <fperez@colorado.edu>
1191 1199
1192 1200 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1193 1201 sometimes seen by win2k/cygwin users.
1194 1202
1195 1203 2004-11-06 Fernando Perez <fperez@colorado.edu>
1196 1204
1197 1205 * IPython/iplib.py (interact): Change the handling of %Exit from
1198 1206 trying to propagate a SystemExit to an internal ipython flag.
1199 1207 This is less elegant than using Python's exception mechanism, but
1200 1208 I can't get that to work reliably with threads, so under -pylab
1201 1209 %Exit was hanging IPython. Cross-thread exception handling is
1202 1210 really a bitch. Thaks to a bug report by Stephen Walton
1203 1211 <stephen.walton-AT-csun.edu>.
1204 1212
1205 1213 2004-11-04 Fernando Perez <fperez@colorado.edu>
1206 1214
1207 1215 * IPython/iplib.py (raw_input_original): store a pointer to the
1208 1216 true raw_input to harden against code which can modify it
1209 1217 (wx.py.PyShell does this and would otherwise crash ipython).
1210 1218 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1211 1219
1212 1220 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1213 1221 Ctrl-C problem, which does not mess up the input line.
1214 1222
1215 1223 2004-11-03 Fernando Perez <fperez@colorado.edu>
1216 1224
1217 1225 * IPython/Release.py: Changed licensing to BSD, in all files.
1218 1226 (name): lowercase name for tarball/RPM release.
1219 1227
1220 1228 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1221 1229 use throughout ipython.
1222 1230
1223 1231 * IPython/Magic.py (Magic._ofind): Switch to using the new
1224 1232 OInspect.getdoc() function.
1225 1233
1226 1234 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1227 1235 of the line currently being canceled via Ctrl-C. It's extremely
1228 1236 ugly, but I don't know how to do it better (the problem is one of
1229 1237 handling cross-thread exceptions).
1230 1238
1231 1239 2004-10-28 Fernando Perez <fperez@colorado.edu>
1232 1240
1233 1241 * IPython/Shell.py (signal_handler): add signal handlers to trap
1234 1242 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1235 1243 report by Francesc Alted.
1236 1244
1237 1245 2004-10-21 Fernando Perez <fperez@colorado.edu>
1238 1246
1239 1247 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1240 1248 to % for pysh syntax extensions.
1241 1249
1242 1250 2004-10-09 Fernando Perez <fperez@colorado.edu>
1243 1251
1244 1252 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1245 1253 arrays to print a more useful summary, without calling str(arr).
1246 1254 This avoids the problem of extremely lengthy computations which
1247 1255 occur if arr is large, and appear to the user as a system lockup
1248 1256 with 100% cpu activity. After a suggestion by Kristian Sandberg
1249 1257 <Kristian.Sandberg@colorado.edu>.
1250 1258 (Magic.__init__): fix bug in global magic escapes not being
1251 1259 correctly set.
1252 1260
1253 1261 2004-10-08 Fernando Perez <fperez@colorado.edu>
1254 1262
1255 1263 * IPython/Magic.py (__license__): change to absolute imports of
1256 1264 ipython's own internal packages, to start adapting to the absolute
1257 1265 import requirement of PEP-328.
1258 1266
1259 1267 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1260 1268 files, and standardize author/license marks through the Release
1261 1269 module instead of having per/file stuff (except for files with
1262 1270 particular licenses, like the MIT/PSF-licensed codes).
1263 1271
1264 1272 * IPython/Debugger.py: remove dead code for python 2.1
1265 1273
1266 1274 2004-10-04 Fernando Perez <fperez@colorado.edu>
1267 1275
1268 1276 * IPython/iplib.py (ipmagic): New function for accessing magics
1269 1277 via a normal python function call.
1270 1278
1271 1279 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1272 1280 from '@' to '%', to accomodate the new @decorator syntax of python
1273 1281 2.4.
1274 1282
1275 1283 2004-09-29 Fernando Perez <fperez@colorado.edu>
1276 1284
1277 1285 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1278 1286 matplotlib.use to prevent running scripts which try to switch
1279 1287 interactive backends from within ipython. This will just crash
1280 1288 the python interpreter, so we can't allow it (but a detailed error
1281 1289 is given to the user).
1282 1290
1283 1291 2004-09-28 Fernando Perez <fperez@colorado.edu>
1284 1292
1285 1293 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1286 1294 matplotlib-related fixes so that using @run with non-matplotlib
1287 1295 scripts doesn't pop up spurious plot windows. This requires
1288 1296 matplotlib >= 0.63, where I had to make some changes as well.
1289 1297
1290 1298 * IPython/ipmaker.py (make_IPython): update version requirement to
1291 1299 python 2.2.
1292 1300
1293 1301 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1294 1302 banner arg for embedded customization.
1295 1303
1296 1304 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1297 1305 explicit uses of __IP as the IPython's instance name. Now things
1298 1306 are properly handled via the shell.name value. The actual code
1299 1307 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1300 1308 is much better than before. I'll clean things completely when the
1301 1309 magic stuff gets a real overhaul.
1302 1310
1303 1311 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1304 1312 minor changes to debian dir.
1305 1313
1306 1314 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1307 1315 pointer to the shell itself in the interactive namespace even when
1308 1316 a user-supplied dict is provided. This is needed for embedding
1309 1317 purposes (found by tests with Michel Sanner).
1310 1318
1311 1319 2004-09-27 Fernando Perez <fperez@colorado.edu>
1312 1320
1313 1321 * IPython/UserConfig/ipythonrc: remove []{} from
1314 1322 readline_remove_delims, so that things like [modname.<TAB> do
1315 1323 proper completion. This disables [].TAB, but that's a less common
1316 1324 case than module names in list comprehensions, for example.
1317 1325 Thanks to a report by Andrea Riciputi.
1318 1326
1319 1327 2004-09-09 Fernando Perez <fperez@colorado.edu>
1320 1328
1321 1329 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1322 1330 blocking problems in win32 and osx. Fix by John.
1323 1331
1324 1332 2004-09-08 Fernando Perez <fperez@colorado.edu>
1325 1333
1326 1334 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1327 1335 for Win32 and OSX. Fix by John Hunter.
1328 1336
1329 1337 2004-08-30 *** Released version 0.6.3
1330 1338
1331 1339 2004-08-30 Fernando Perez <fperez@colorado.edu>
1332 1340
1333 1341 * setup.py (isfile): Add manpages to list of dependent files to be
1334 1342 updated.
1335 1343
1336 1344 2004-08-27 Fernando Perez <fperez@colorado.edu>
1337 1345
1338 1346 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1339 1347 for now. They don't really work with standalone WX/GTK code
1340 1348 (though matplotlib IS working fine with both of those backends).
1341 1349 This will neeed much more testing. I disabled most things with
1342 1350 comments, so turning it back on later should be pretty easy.
1343 1351
1344 1352 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1345 1353 autocalling of expressions like r'foo', by modifying the line
1346 1354 split regexp. Closes
1347 1355 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1348 1356 Riley <ipythonbugs-AT-sabi.net>.
1349 1357 (InteractiveShell.mainloop): honor --nobanner with banner
1350 1358 extensions.
1351 1359
1352 1360 * IPython/Shell.py: Significant refactoring of all classes, so
1353 1361 that we can really support ALL matplotlib backends and threading
1354 1362 models (John spotted a bug with Tk which required this). Now we
1355 1363 should support single-threaded, WX-threads and GTK-threads, both
1356 1364 for generic code and for matplotlib.
1357 1365
1358 1366 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1359 1367 -pylab, to simplify things for users. Will also remove the pylab
1360 1368 profile, since now all of matplotlib configuration is directly
1361 1369 handled here. This also reduces startup time.
1362 1370
1363 1371 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1364 1372 shell wasn't being correctly called. Also in IPShellWX.
1365 1373
1366 1374 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1367 1375 fine-tune banner.
1368 1376
1369 1377 * IPython/numutils.py (spike): Deprecate these spike functions,
1370 1378 delete (long deprecated) gnuplot_exec handler.
1371 1379
1372 1380 2004-08-26 Fernando Perez <fperez@colorado.edu>
1373 1381
1374 1382 * ipython.1: Update for threading options, plus some others which
1375 1383 were missing.
1376 1384
1377 1385 * IPython/ipmaker.py (__call__): Added -wthread option for
1378 1386 wxpython thread handling. Make sure threading options are only
1379 1387 valid at the command line.
1380 1388
1381 1389 * scripts/ipython: moved shell selection into a factory function
1382 1390 in Shell.py, to keep the starter script to a minimum.
1383 1391
1384 1392 2004-08-25 Fernando Perez <fperez@colorado.edu>
1385 1393
1386 1394 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1387 1395 John. Along with some recent changes he made to matplotlib, the
1388 1396 next versions of both systems should work very well together.
1389 1397
1390 1398 2004-08-24 Fernando Perez <fperez@colorado.edu>
1391 1399
1392 1400 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1393 1401 tried to switch the profiling to using hotshot, but I'm getting
1394 1402 strange errors from prof.runctx() there. I may be misreading the
1395 1403 docs, but it looks weird. For now the profiling code will
1396 1404 continue to use the standard profiler.
1397 1405
1398 1406 2004-08-23 Fernando Perez <fperez@colorado.edu>
1399 1407
1400 1408 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1401 1409 threaded shell, by John Hunter. It's not quite ready yet, but
1402 1410 close.
1403 1411
1404 1412 2004-08-22 Fernando Perez <fperez@colorado.edu>
1405 1413
1406 1414 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1407 1415 in Magic and ultraTB.
1408 1416
1409 1417 * ipython.1: document threading options in manpage.
1410 1418
1411 1419 * scripts/ipython: Changed name of -thread option to -gthread,
1412 1420 since this is GTK specific. I want to leave the door open for a
1413 1421 -wthread option for WX, which will most likely be necessary. This
1414 1422 change affects usage and ipmaker as well.
1415 1423
1416 1424 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1417 1425 handle the matplotlib shell issues. Code by John Hunter
1418 1426 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1419 1427 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1420 1428 broken (and disabled for end users) for now, but it puts the
1421 1429 infrastructure in place.
1422 1430
1423 1431 2004-08-21 Fernando Perez <fperez@colorado.edu>
1424 1432
1425 1433 * ipythonrc-pylab: Add matplotlib support.
1426 1434
1427 1435 * matplotlib_config.py: new files for matplotlib support, part of
1428 1436 the pylab profile.
1429 1437
1430 1438 * IPython/usage.py (__doc__): documented the threading options.
1431 1439
1432 1440 2004-08-20 Fernando Perez <fperez@colorado.edu>
1433 1441
1434 1442 * ipython: Modified the main calling routine to handle the -thread
1435 1443 and -mpthread options. This needs to be done as a top-level hack,
1436 1444 because it determines which class to instantiate for IPython
1437 1445 itself.
1438 1446
1439 1447 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1440 1448 classes to support multithreaded GTK operation without blocking,
1441 1449 and matplotlib with all backends. This is a lot of still very
1442 1450 experimental code, and threads are tricky. So it may still have a
1443 1451 few rough edges... This code owes a lot to
1444 1452 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1445 1453 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1446 1454 to John Hunter for all the matplotlib work.
1447 1455
1448 1456 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1449 1457 options for gtk thread and matplotlib support.
1450 1458
1451 1459 2004-08-16 Fernando Perez <fperez@colorado.edu>
1452 1460
1453 1461 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1454 1462 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1455 1463 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1456 1464
1457 1465 2004-08-11 Fernando Perez <fperez@colorado.edu>
1458 1466
1459 1467 * setup.py (isfile): Fix build so documentation gets updated for
1460 1468 rpms (it was only done for .tgz builds).
1461 1469
1462 1470 2004-08-10 Fernando Perez <fperez@colorado.edu>
1463 1471
1464 1472 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1465 1473
1466 1474 * iplib.py : Silence syntax error exceptions in tab-completion.
1467 1475
1468 1476 2004-08-05 Fernando Perez <fperez@colorado.edu>
1469 1477
1470 1478 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1471 1479 'color off' mark for continuation prompts. This was causing long
1472 1480 continuation lines to mis-wrap.
1473 1481
1474 1482 2004-08-01 Fernando Perez <fperez@colorado.edu>
1475 1483
1476 1484 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1477 1485 for building ipython to be a parameter. All this is necessary
1478 1486 right now to have a multithreaded version, but this insane
1479 1487 non-design will be cleaned up soon. For now, it's a hack that
1480 1488 works.
1481 1489
1482 1490 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1483 1491 args in various places. No bugs so far, but it's a dangerous
1484 1492 practice.
1485 1493
1486 1494 2004-07-31 Fernando Perez <fperez@colorado.edu>
1487 1495
1488 1496 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1489 1497 fix completion of files with dots in their names under most
1490 1498 profiles (pysh was OK because the completion order is different).
1491 1499
1492 1500 2004-07-27 Fernando Perez <fperez@colorado.edu>
1493 1501
1494 1502 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1495 1503 keywords manually, b/c the one in keyword.py was removed in python
1496 1504 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1497 1505 This is NOT a bug under python 2.3 and earlier.
1498 1506
1499 1507 2004-07-26 Fernando Perez <fperez@colorado.edu>
1500 1508
1501 1509 * IPython/ultraTB.py (VerboseTB.text): Add another
1502 1510 linecache.checkcache() call to try to prevent inspect.py from
1503 1511 crashing under python 2.3. I think this fixes
1504 1512 http://www.scipy.net/roundup/ipython/issue17.
1505 1513
1506 1514 2004-07-26 *** Released version 0.6.2
1507 1515
1508 1516 2004-07-26 Fernando Perez <fperez@colorado.edu>
1509 1517
1510 1518 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1511 1519 fail for any number.
1512 1520 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1513 1521 empty bookmarks.
1514 1522
1515 1523 2004-07-26 *** Released version 0.6.1
1516 1524
1517 1525 2004-07-26 Fernando Perez <fperez@colorado.edu>
1518 1526
1519 1527 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1520 1528
1521 1529 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1522 1530 escaping '()[]{}' in filenames.
1523 1531
1524 1532 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1525 1533 Python 2.2 users who lack a proper shlex.split.
1526 1534
1527 1535 2004-07-19 Fernando Perez <fperez@colorado.edu>
1528 1536
1529 1537 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1530 1538 for reading readline's init file. I follow the normal chain:
1531 1539 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1532 1540 report by Mike Heeter. This closes
1533 1541 http://www.scipy.net/roundup/ipython/issue16.
1534 1542
1535 1543 2004-07-18 Fernando Perez <fperez@colorado.edu>
1536 1544
1537 1545 * IPython/iplib.py (__init__): Add better handling of '\' under
1538 1546 Win32 for filenames. After a patch by Ville.
1539 1547
1540 1548 2004-07-17 Fernando Perez <fperez@colorado.edu>
1541 1549
1542 1550 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1543 1551 autocalling would be triggered for 'foo is bar' if foo is
1544 1552 callable. I also cleaned up the autocall detection code to use a
1545 1553 regexp, which is faster. Bug reported by Alexander Schmolck.
1546 1554
1547 1555 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1548 1556 '?' in them would confuse the help system. Reported by Alex
1549 1557 Schmolck.
1550 1558
1551 1559 2004-07-16 Fernando Perez <fperez@colorado.edu>
1552 1560
1553 1561 * IPython/GnuplotInteractive.py (__all__): added plot2.
1554 1562
1555 1563 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1556 1564 plotting dictionaries, lists or tuples of 1d arrays.
1557 1565
1558 1566 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1559 1567 optimizations.
1560 1568
1561 1569 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1562 1570 the information which was there from Janko's original IPP code:
1563 1571
1564 1572 03.05.99 20:53 porto.ifm.uni-kiel.de
1565 1573 --Started changelog.
1566 1574 --make clear do what it say it does
1567 1575 --added pretty output of lines from inputcache
1568 1576 --Made Logger a mixin class, simplifies handling of switches
1569 1577 --Added own completer class. .string<TAB> expands to last history
1570 1578 line which starts with string. The new expansion is also present
1571 1579 with Ctrl-r from the readline library. But this shows, who this
1572 1580 can be done for other cases.
1573 1581 --Added convention that all shell functions should accept a
1574 1582 parameter_string This opens the door for different behaviour for
1575 1583 each function. @cd is a good example of this.
1576 1584
1577 1585 04.05.99 12:12 porto.ifm.uni-kiel.de
1578 1586 --added logfile rotation
1579 1587 --added new mainloop method which freezes first the namespace
1580 1588
1581 1589 07.05.99 21:24 porto.ifm.uni-kiel.de
1582 1590 --added the docreader classes. Now there is a help system.
1583 1591 -This is only a first try. Currently it's not easy to put new
1584 1592 stuff in the indices. But this is the way to go. Info would be
1585 1593 better, but HTML is every where and not everybody has an info
1586 1594 system installed and it's not so easy to change html-docs to info.
1587 1595 --added global logfile option
1588 1596 --there is now a hook for object inspection method pinfo needs to
1589 1597 be provided for this. Can be reached by two '??'.
1590 1598
1591 1599 08.05.99 20:51 porto.ifm.uni-kiel.de
1592 1600 --added a README
1593 1601 --bug in rc file. Something has changed so functions in the rc
1594 1602 file need to reference the shell and not self. Not clear if it's a
1595 1603 bug or feature.
1596 1604 --changed rc file for new behavior
1597 1605
1598 1606 2004-07-15 Fernando Perez <fperez@colorado.edu>
1599 1607
1600 1608 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1601 1609 cache was falling out of sync in bizarre manners when multi-line
1602 1610 input was present. Minor optimizations and cleanup.
1603 1611
1604 1612 (Logger): Remove old Changelog info for cleanup. This is the
1605 1613 information which was there from Janko's original code:
1606 1614
1607 1615 Changes to Logger: - made the default log filename a parameter
1608 1616
1609 1617 - put a check for lines beginning with !@? in log(). Needed
1610 1618 (even if the handlers properly log their lines) for mid-session
1611 1619 logging activation to work properly. Without this, lines logged
1612 1620 in mid session, which get read from the cache, would end up
1613 1621 'bare' (with !@? in the open) in the log. Now they are caught
1614 1622 and prepended with a #.
1615 1623
1616 1624 * IPython/iplib.py (InteractiveShell.init_readline): added check
1617 1625 in case MagicCompleter fails to be defined, so we don't crash.
1618 1626
1619 1627 2004-07-13 Fernando Perez <fperez@colorado.edu>
1620 1628
1621 1629 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1622 1630 of EPS if the requested filename ends in '.eps'.
1623 1631
1624 1632 2004-07-04 Fernando Perez <fperez@colorado.edu>
1625 1633
1626 1634 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1627 1635 escaping of quotes when calling the shell.
1628 1636
1629 1637 2004-07-02 Fernando Perez <fperez@colorado.edu>
1630 1638
1631 1639 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1632 1640 gettext not working because we were clobbering '_'. Fixes
1633 1641 http://www.scipy.net/roundup/ipython/issue6.
1634 1642
1635 1643 2004-07-01 Fernando Perez <fperez@colorado.edu>
1636 1644
1637 1645 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1638 1646 into @cd. Patch by Ville.
1639 1647
1640 1648 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1641 1649 new function to store things after ipmaker runs. Patch by Ville.
1642 1650 Eventually this will go away once ipmaker is removed and the class
1643 1651 gets cleaned up, but for now it's ok. Key functionality here is
1644 1652 the addition of the persistent storage mechanism, a dict for
1645 1653 keeping data across sessions (for now just bookmarks, but more can
1646 1654 be implemented later).
1647 1655
1648 1656 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1649 1657 persistent across sections. Patch by Ville, I modified it
1650 1658 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1651 1659 added a '-l' option to list all bookmarks.
1652 1660
1653 1661 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1654 1662 center for cleanup. Registered with atexit.register(). I moved
1655 1663 here the old exit_cleanup(). After a patch by Ville.
1656 1664
1657 1665 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1658 1666 characters in the hacked shlex_split for python 2.2.
1659 1667
1660 1668 * IPython/iplib.py (file_matches): more fixes to filenames with
1661 1669 whitespace in them. It's not perfect, but limitations in python's
1662 1670 readline make it impossible to go further.
1663 1671
1664 1672 2004-06-29 Fernando Perez <fperez@colorado.edu>
1665 1673
1666 1674 * IPython/iplib.py (file_matches): escape whitespace correctly in
1667 1675 filename completions. Bug reported by Ville.
1668 1676
1669 1677 2004-06-28 Fernando Perez <fperez@colorado.edu>
1670 1678
1671 1679 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1672 1680 the history file will be called 'history-PROFNAME' (or just
1673 1681 'history' if no profile is loaded). I was getting annoyed at
1674 1682 getting my Numerical work history clobbered by pysh sessions.
1675 1683
1676 1684 * IPython/iplib.py (InteractiveShell.__init__): Internal
1677 1685 getoutputerror() function so that we can honor the system_verbose
1678 1686 flag for _all_ system calls. I also added escaping of #
1679 1687 characters here to avoid confusing Itpl.
1680 1688
1681 1689 * IPython/Magic.py (shlex_split): removed call to shell in
1682 1690 parse_options and replaced it with shlex.split(). The annoying
1683 1691 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1684 1692 to backport it from 2.3, with several frail hacks (the shlex
1685 1693 module is rather limited in 2.2). Thanks to a suggestion by Ville
1686 1694 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1687 1695 problem.
1688 1696
1689 1697 (Magic.magic_system_verbose): new toggle to print the actual
1690 1698 system calls made by ipython. Mainly for debugging purposes.
1691 1699
1692 1700 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1693 1701 doesn't support persistence. Reported (and fix suggested) by
1694 1702 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1695 1703
1696 1704 2004-06-26 Fernando Perez <fperez@colorado.edu>
1697 1705
1698 1706 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1699 1707 continue prompts.
1700 1708
1701 1709 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1702 1710 function (basically a big docstring) and a few more things here to
1703 1711 speedup startup. pysh.py is now very lightweight. We want because
1704 1712 it gets execfile'd, while InterpreterExec gets imported, so
1705 1713 byte-compilation saves time.
1706 1714
1707 1715 2004-06-25 Fernando Perez <fperez@colorado.edu>
1708 1716
1709 1717 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1710 1718 -NUM', which was recently broken.
1711 1719
1712 1720 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1713 1721 in multi-line input (but not !!, which doesn't make sense there).
1714 1722
1715 1723 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1716 1724 It's just too useful, and people can turn it off in the less
1717 1725 common cases where it's a problem.
1718 1726
1719 1727 2004-06-24 Fernando Perez <fperez@colorado.edu>
1720 1728
1721 1729 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1722 1730 special syntaxes (like alias calling) is now allied in multi-line
1723 1731 input. This is still _very_ experimental, but it's necessary for
1724 1732 efficient shell usage combining python looping syntax with system
1725 1733 calls. For now it's restricted to aliases, I don't think it
1726 1734 really even makes sense to have this for magics.
1727 1735
1728 1736 2004-06-23 Fernando Perez <fperez@colorado.edu>
1729 1737
1730 1738 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1731 1739 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1732 1740
1733 1741 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1734 1742 extensions under Windows (after code sent by Gary Bishop). The
1735 1743 extensions considered 'executable' are stored in IPython's rc
1736 1744 structure as win_exec_ext.
1737 1745
1738 1746 * IPython/genutils.py (shell): new function, like system() but
1739 1747 without return value. Very useful for interactive shell work.
1740 1748
1741 1749 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1742 1750 delete aliases.
1743 1751
1744 1752 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1745 1753 sure that the alias table doesn't contain python keywords.
1746 1754
1747 1755 2004-06-21 Fernando Perez <fperez@colorado.edu>
1748 1756
1749 1757 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1750 1758 non-existent items are found in $PATH. Reported by Thorsten.
1751 1759
1752 1760 2004-06-20 Fernando Perez <fperez@colorado.edu>
1753 1761
1754 1762 * IPython/iplib.py (complete): modified the completer so that the
1755 1763 order of priorities can be easily changed at runtime.
1756 1764
1757 1765 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1758 1766 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1759 1767
1760 1768 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1761 1769 expand Python variables prepended with $ in all system calls. The
1762 1770 same was done to InteractiveShell.handle_shell_escape. Now all
1763 1771 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1764 1772 expansion of python variables and expressions according to the
1765 1773 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1766 1774
1767 1775 Though PEP-215 has been rejected, a similar (but simpler) one
1768 1776 seems like it will go into Python 2.4, PEP-292 -
1769 1777 http://www.python.org/peps/pep-0292.html.
1770 1778
1771 1779 I'll keep the full syntax of PEP-215, since IPython has since the
1772 1780 start used Ka-Ping Yee's reference implementation discussed there
1773 1781 (Itpl), and I actually like the powerful semantics it offers.
1774 1782
1775 1783 In order to access normal shell variables, the $ has to be escaped
1776 1784 via an extra $. For example:
1777 1785
1778 1786 In [7]: PATH='a python variable'
1779 1787
1780 1788 In [8]: !echo $PATH
1781 1789 a python variable
1782 1790
1783 1791 In [9]: !echo $$PATH
1784 1792 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1785 1793
1786 1794 (Magic.parse_options): escape $ so the shell doesn't evaluate
1787 1795 things prematurely.
1788 1796
1789 1797 * IPython/iplib.py (InteractiveShell.call_alias): added the
1790 1798 ability for aliases to expand python variables via $.
1791 1799
1792 1800 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1793 1801 system, now there's a @rehash/@rehashx pair of magics. These work
1794 1802 like the csh rehash command, and can be invoked at any time. They
1795 1803 build a table of aliases to everything in the user's $PATH
1796 1804 (@rehash uses everything, @rehashx is slower but only adds
1797 1805 executable files). With this, the pysh.py-based shell profile can
1798 1806 now simply call rehash upon startup, and full access to all
1799 1807 programs in the user's path is obtained.
1800 1808
1801 1809 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1802 1810 functionality is now fully in place. I removed the old dynamic
1803 1811 code generation based approach, in favor of a much lighter one
1804 1812 based on a simple dict. The advantage is that this allows me to
1805 1813 now have thousands of aliases with negligible cost (unthinkable
1806 1814 with the old system).
1807 1815
1808 1816 2004-06-19 Fernando Perez <fperez@colorado.edu>
1809 1817
1810 1818 * IPython/iplib.py (__init__): extended MagicCompleter class to
1811 1819 also complete (last in priority) on user aliases.
1812 1820
1813 1821 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1814 1822 call to eval.
1815 1823 (ItplNS.__init__): Added a new class which functions like Itpl,
1816 1824 but allows configuring the namespace for the evaluation to occur
1817 1825 in.
1818 1826
1819 1827 2004-06-18 Fernando Perez <fperez@colorado.edu>
1820 1828
1821 1829 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1822 1830 better message when 'exit' or 'quit' are typed (a common newbie
1823 1831 confusion).
1824 1832
1825 1833 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1826 1834 check for Windows users.
1827 1835
1828 1836 * IPython/iplib.py (InteractiveShell.user_setup): removed
1829 1837 disabling of colors for Windows. I'll test at runtime and issue a
1830 1838 warning if Gary's readline isn't found, as to nudge users to
1831 1839 download it.
1832 1840
1833 1841 2004-06-16 Fernando Perez <fperez@colorado.edu>
1834 1842
1835 1843 * IPython/genutils.py (Stream.__init__): changed to print errors
1836 1844 to sys.stderr. I had a circular dependency here. Now it's
1837 1845 possible to run ipython as IDLE's shell (consider this pre-alpha,
1838 1846 since true stdout things end up in the starting terminal instead
1839 1847 of IDLE's out).
1840 1848
1841 1849 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1842 1850 users who haven't # updated their prompt_in2 definitions. Remove
1843 1851 eventually.
1844 1852 (multiple_replace): added credit to original ASPN recipe.
1845 1853
1846 1854 2004-06-15 Fernando Perez <fperez@colorado.edu>
1847 1855
1848 1856 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1849 1857 list of auto-defined aliases.
1850 1858
1851 1859 2004-06-13 Fernando Perez <fperez@colorado.edu>
1852 1860
1853 1861 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1854 1862 install was really requested (so setup.py can be used for other
1855 1863 things under Windows).
1856 1864
1857 1865 2004-06-10 Fernando Perez <fperez@colorado.edu>
1858 1866
1859 1867 * IPython/Logger.py (Logger.create_log): Manually remove any old
1860 1868 backup, since os.remove may fail under Windows. Fixes bug
1861 1869 reported by Thorsten.
1862 1870
1863 1871 2004-06-09 Fernando Perez <fperez@colorado.edu>
1864 1872
1865 1873 * examples/example-embed.py: fixed all references to %n (replaced
1866 1874 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1867 1875 for all examples and the manual as well.
1868 1876
1869 1877 2004-06-08 Fernando Perez <fperez@colorado.edu>
1870 1878
1871 1879 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1872 1880 alignment and color management. All 3 prompt subsystems now
1873 1881 inherit from BasePrompt.
1874 1882
1875 1883 * tools/release: updates for windows installer build and tag rpms
1876 1884 with python version (since paths are fixed).
1877 1885
1878 1886 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1879 1887 which will become eventually obsolete. Also fixed the default
1880 1888 prompt_in2 to use \D, so at least new users start with the correct
1881 1889 defaults.
1882 1890 WARNING: Users with existing ipythonrc files will need to apply
1883 1891 this fix manually!
1884 1892
1885 1893 * setup.py: make windows installer (.exe). This is finally the
1886 1894 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1887 1895 which I hadn't included because it required Python 2.3 (or recent
1888 1896 distutils).
1889 1897
1890 1898 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1891 1899 usage of new '\D' escape.
1892 1900
1893 1901 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1894 1902 lacks os.getuid())
1895 1903 (CachedOutput.set_colors): Added the ability to turn coloring
1896 1904 on/off with @colors even for manually defined prompt colors. It
1897 1905 uses a nasty global, but it works safely and via the generic color
1898 1906 handling mechanism.
1899 1907 (Prompt2.__init__): Introduced new escape '\D' for continuation
1900 1908 prompts. It represents the counter ('\#') as dots.
1901 1909 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1902 1910 need to update their ipythonrc files and replace '%n' with '\D' in
1903 1911 their prompt_in2 settings everywhere. Sorry, but there's
1904 1912 otherwise no clean way to get all prompts to properly align. The
1905 1913 ipythonrc shipped with IPython has been updated.
1906 1914
1907 1915 2004-06-07 Fernando Perez <fperez@colorado.edu>
1908 1916
1909 1917 * setup.py (isfile): Pass local_icons option to latex2html, so the
1910 1918 resulting HTML file is self-contained. Thanks to
1911 1919 dryice-AT-liu.com.cn for the tip.
1912 1920
1913 1921 * pysh.py: I created a new profile 'shell', which implements a
1914 1922 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1915 1923 system shell, nor will it become one anytime soon. It's mainly
1916 1924 meant to illustrate the use of the new flexible bash-like prompts.
1917 1925 I guess it could be used by hardy souls for true shell management,
1918 1926 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1919 1927 profile. This uses the InterpreterExec extension provided by
1920 1928 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1921 1929
1922 1930 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1923 1931 auto-align itself with the length of the previous input prompt
1924 1932 (taking into account the invisible color escapes).
1925 1933 (CachedOutput.__init__): Large restructuring of this class. Now
1926 1934 all three prompts (primary1, primary2, output) are proper objects,
1927 1935 managed by the 'parent' CachedOutput class. The code is still a
1928 1936 bit hackish (all prompts share state via a pointer to the cache),
1929 1937 but it's overall far cleaner than before.
1930 1938
1931 1939 * IPython/genutils.py (getoutputerror): modified to add verbose,
1932 1940 debug and header options. This makes the interface of all getout*
1933 1941 functions uniform.
1934 1942 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1935 1943
1936 1944 * IPython/Magic.py (Magic.default_option): added a function to
1937 1945 allow registering default options for any magic command. This
1938 1946 makes it easy to have profiles which customize the magics globally
1939 1947 for a certain use. The values set through this function are
1940 1948 picked up by the parse_options() method, which all magics should
1941 1949 use to parse their options.
1942 1950
1943 1951 * IPython/genutils.py (warn): modified the warnings framework to
1944 1952 use the Term I/O class. I'm trying to slowly unify all of
1945 1953 IPython's I/O operations to pass through Term.
1946 1954
1947 1955 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1948 1956 the secondary prompt to correctly match the length of the primary
1949 1957 one for any prompt. Now multi-line code will properly line up
1950 1958 even for path dependent prompts, such as the new ones available
1951 1959 via the prompt_specials.
1952 1960
1953 1961 2004-06-06 Fernando Perez <fperez@colorado.edu>
1954 1962
1955 1963 * IPython/Prompts.py (prompt_specials): Added the ability to have
1956 1964 bash-like special sequences in the prompts, which get
1957 1965 automatically expanded. Things like hostname, current working
1958 1966 directory and username are implemented already, but it's easy to
1959 1967 add more in the future. Thanks to a patch by W.J. van der Laan
1960 1968 <gnufnork-AT-hetdigitalegat.nl>
1961 1969 (prompt_specials): Added color support for prompt strings, so
1962 1970 users can define arbitrary color setups for their prompts.
1963 1971
1964 1972 2004-06-05 Fernando Perez <fperez@colorado.edu>
1965 1973
1966 1974 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1967 1975 code to load Gary Bishop's readline and configure it
1968 1976 automatically. Thanks to Gary for help on this.
1969 1977
1970 1978 2004-06-01 Fernando Perez <fperez@colorado.edu>
1971 1979
1972 1980 * IPython/Logger.py (Logger.create_log): fix bug for logging
1973 1981 with no filename (previous fix was incomplete).
1974 1982
1975 1983 2004-05-25 Fernando Perez <fperez@colorado.edu>
1976 1984
1977 1985 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1978 1986 parens would get passed to the shell.
1979 1987
1980 1988 2004-05-20 Fernando Perez <fperez@colorado.edu>
1981 1989
1982 1990 * IPython/Magic.py (Magic.magic_prun): changed default profile
1983 1991 sort order to 'time' (the more common profiling need).
1984 1992
1985 1993 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1986 1994 so that source code shown is guaranteed in sync with the file on
1987 1995 disk (also changed in psource). Similar fix to the one for
1988 1996 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1989 1997 <yann.ledu-AT-noos.fr>.
1990 1998
1991 1999 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1992 2000 with a single option would not be correctly parsed. Closes
1993 2001 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1994 2002 introduced in 0.6.0 (on 2004-05-06).
1995 2003
1996 2004 2004-05-13 *** Released version 0.6.0
1997 2005
1998 2006 2004-05-13 Fernando Perez <fperez@colorado.edu>
1999 2007
2000 2008 * debian/: Added debian/ directory to CVS, so that debian support
2001 2009 is publicly accessible. The debian package is maintained by Jack
2002 2010 Moffit <jack-AT-xiph.org>.
2003 2011
2004 2012 * Documentation: included the notes about an ipython-based system
2005 2013 shell (the hypothetical 'pysh') into the new_design.pdf document,
2006 2014 so that these ideas get distributed to users along with the
2007 2015 official documentation.
2008 2016
2009 2017 2004-05-10 Fernando Perez <fperez@colorado.edu>
2010 2018
2011 2019 * IPython/Logger.py (Logger.create_log): fix recently introduced
2012 2020 bug (misindented line) where logstart would fail when not given an
2013 2021 explicit filename.
2014 2022
2015 2023 2004-05-09 Fernando Perez <fperez@colorado.edu>
2016 2024
2017 2025 * IPython/Magic.py (Magic.parse_options): skip system call when
2018 2026 there are no options to look for. Faster, cleaner for the common
2019 2027 case.
2020 2028
2021 2029 * Documentation: many updates to the manual: describing Windows
2022 2030 support better, Gnuplot updates, credits, misc small stuff. Also
2023 2031 updated the new_design doc a bit.
2024 2032
2025 2033 2004-05-06 *** Released version 0.6.0.rc1
2026 2034
2027 2035 2004-05-06 Fernando Perez <fperez@colorado.edu>
2028 2036
2029 2037 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2030 2038 operations to use the vastly more efficient list/''.join() method.
2031 2039 (FormattedTB.text): Fix
2032 2040 http://www.scipy.net/roundup/ipython/issue12 - exception source
2033 2041 extract not updated after reload. Thanks to Mike Salib
2034 2042 <msalib-AT-mit.edu> for pinning the source of the problem.
2035 2043 Fortunately, the solution works inside ipython and doesn't require
2036 2044 any changes to python proper.
2037 2045
2038 2046 * IPython/Magic.py (Magic.parse_options): Improved to process the
2039 2047 argument list as a true shell would (by actually using the
2040 2048 underlying system shell). This way, all @magics automatically get
2041 2049 shell expansion for variables. Thanks to a comment by Alex
2042 2050 Schmolck.
2043 2051
2044 2052 2004-04-04 Fernando Perez <fperez@colorado.edu>
2045 2053
2046 2054 * IPython/iplib.py (InteractiveShell.interact): Added a special
2047 2055 trap for a debugger quit exception, which is basically impossible
2048 2056 to handle by normal mechanisms, given what pdb does to the stack.
2049 2057 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2050 2058
2051 2059 2004-04-03 Fernando Perez <fperez@colorado.edu>
2052 2060
2053 2061 * IPython/genutils.py (Term): Standardized the names of the Term
2054 2062 class streams to cin/cout/cerr, following C++ naming conventions
2055 2063 (I can't use in/out/err because 'in' is not a valid attribute
2056 2064 name).
2057 2065
2058 2066 * IPython/iplib.py (InteractiveShell.interact): don't increment
2059 2067 the prompt if there's no user input. By Daniel 'Dang' Griffith
2060 2068 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2061 2069 Francois Pinard.
2062 2070
2063 2071 2004-04-02 Fernando Perez <fperez@colorado.edu>
2064 2072
2065 2073 * IPython/genutils.py (Stream.__init__): Modified to survive at
2066 2074 least importing in contexts where stdin/out/err aren't true file
2067 2075 objects, such as PyCrust (they lack fileno() and mode). However,
2068 2076 the recovery facilities which rely on these things existing will
2069 2077 not work.
2070 2078
2071 2079 2004-04-01 Fernando Perez <fperez@colorado.edu>
2072 2080
2073 2081 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2074 2082 use the new getoutputerror() function, so it properly
2075 2083 distinguishes stdout/err.
2076 2084
2077 2085 * IPython/genutils.py (getoutputerror): added a function to
2078 2086 capture separately the standard output and error of a command.
2079 2087 After a comment from dang on the mailing lists. This code is
2080 2088 basically a modified version of commands.getstatusoutput(), from
2081 2089 the standard library.
2082 2090
2083 2091 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2084 2092 '!!' as a special syntax (shorthand) to access @sx.
2085 2093
2086 2094 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2087 2095 command and return its output as a list split on '\n'.
2088 2096
2089 2097 2004-03-31 Fernando Perez <fperez@colorado.edu>
2090 2098
2091 2099 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2092 2100 method to dictionaries used as FakeModule instances if they lack
2093 2101 it. At least pydoc in python2.3 breaks for runtime-defined
2094 2102 functions without this hack. At some point I need to _really_
2095 2103 understand what FakeModule is doing, because it's a gross hack.
2096 2104 But it solves Arnd's problem for now...
2097 2105
2098 2106 2004-02-27 Fernando Perez <fperez@colorado.edu>
2099 2107
2100 2108 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2101 2109 mode would behave erratically. Also increased the number of
2102 2110 possible logs in rotate mod to 999. Thanks to Rod Holland
2103 2111 <rhh@StructureLABS.com> for the report and fixes.
2104 2112
2105 2113 2004-02-26 Fernando Perez <fperez@colorado.edu>
2106 2114
2107 2115 * IPython/genutils.py (page): Check that the curses module really
2108 2116 has the initscr attribute before trying to use it. For some
2109 2117 reason, the Solaris curses module is missing this. I think this
2110 2118 should be considered a Solaris python bug, but I'm not sure.
2111 2119
2112 2120 2004-01-17 Fernando Perez <fperez@colorado.edu>
2113 2121
2114 2122 * IPython/genutils.py (Stream.__init__): Changes to try to make
2115 2123 ipython robust against stdin/out/err being closed by the user.
2116 2124 This is 'user error' (and blocks a normal python session, at least
2117 2125 the stdout case). However, Ipython should be able to survive such
2118 2126 instances of abuse as gracefully as possible. To simplify the
2119 2127 coding and maintain compatibility with Gary Bishop's Term
2120 2128 contributions, I've made use of classmethods for this. I think
2121 2129 this introduces a dependency on python 2.2.
2122 2130
2123 2131 2004-01-13 Fernando Perez <fperez@colorado.edu>
2124 2132
2125 2133 * IPython/numutils.py (exp_safe): simplified the code a bit and
2126 2134 removed the need for importing the kinds module altogether.
2127 2135
2128 2136 2004-01-06 Fernando Perez <fperez@colorado.edu>
2129 2137
2130 2138 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2131 2139 a magic function instead, after some community feedback. No
2132 2140 special syntax will exist for it, but its name is deliberately
2133 2141 very short.
2134 2142
2135 2143 2003-12-20 Fernando Perez <fperez@colorado.edu>
2136 2144
2137 2145 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2138 2146 new functionality, to automagically assign the result of a shell
2139 2147 command to a variable. I'll solicit some community feedback on
2140 2148 this before making it permanent.
2141 2149
2142 2150 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2143 2151 requested about callables for which inspect couldn't obtain a
2144 2152 proper argspec. Thanks to a crash report sent by Etienne
2145 2153 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2146 2154
2147 2155 2003-12-09 Fernando Perez <fperez@colorado.edu>
2148 2156
2149 2157 * IPython/genutils.py (page): patch for the pager to work across
2150 2158 various versions of Windows. By Gary Bishop.
2151 2159
2152 2160 2003-12-04 Fernando Perez <fperez@colorado.edu>
2153 2161
2154 2162 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2155 2163 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2156 2164 While I tested this and it looks ok, there may still be corner
2157 2165 cases I've missed.
2158 2166
2159 2167 2003-12-01 Fernando Perez <fperez@colorado.edu>
2160 2168
2161 2169 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2162 2170 where a line like 'p,q=1,2' would fail because the automagic
2163 2171 system would be triggered for @p.
2164 2172
2165 2173 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2166 2174 cleanups, code unmodified.
2167 2175
2168 2176 * IPython/genutils.py (Term): added a class for IPython to handle
2169 2177 output. In most cases it will just be a proxy for stdout/err, but
2170 2178 having this allows modifications to be made for some platforms,
2171 2179 such as handling color escapes under Windows. All of this code
2172 2180 was contributed by Gary Bishop, with minor modifications by me.
2173 2181 The actual changes affect many files.
2174 2182
2175 2183 2003-11-30 Fernando Perez <fperez@colorado.edu>
2176 2184
2177 2185 * IPython/iplib.py (file_matches): new completion code, courtesy
2178 2186 of Jeff Collins. This enables filename completion again under
2179 2187 python 2.3, which disabled it at the C level.
2180 2188
2181 2189 2003-11-11 Fernando Perez <fperez@colorado.edu>
2182 2190
2183 2191 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2184 2192 for Numeric.array(map(...)), but often convenient.
2185 2193
2186 2194 2003-11-05 Fernando Perez <fperez@colorado.edu>
2187 2195
2188 2196 * IPython/numutils.py (frange): Changed a call from int() to
2189 2197 int(round()) to prevent a problem reported with arange() in the
2190 2198 numpy list.
2191 2199
2192 2200 2003-10-06 Fernando Perez <fperez@colorado.edu>
2193 2201
2194 2202 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2195 2203 prevent crashes if sys lacks an argv attribute (it happens with
2196 2204 embedded interpreters which build a bare-bones sys module).
2197 2205 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2198 2206
2199 2207 2003-09-24 Fernando Perez <fperez@colorado.edu>
2200 2208
2201 2209 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2202 2210 to protect against poorly written user objects where __getattr__
2203 2211 raises exceptions other than AttributeError. Thanks to a bug
2204 2212 report by Oliver Sander <osander-AT-gmx.de>.
2205 2213
2206 2214 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2207 2215 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2208 2216
2209 2217 2003-09-09 Fernando Perez <fperez@colorado.edu>
2210 2218
2211 2219 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2212 2220 unpacking a list whith a callable as first element would
2213 2221 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2214 2222 Collins.
2215 2223
2216 2224 2003-08-25 *** Released version 0.5.0
2217 2225
2218 2226 2003-08-22 Fernando Perez <fperez@colorado.edu>
2219 2227
2220 2228 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2221 2229 improperly defined user exceptions. Thanks to feedback from Mark
2222 2230 Russell <mrussell-AT-verio.net>.
2223 2231
2224 2232 2003-08-20 Fernando Perez <fperez@colorado.edu>
2225 2233
2226 2234 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2227 2235 printing so that it would print multi-line string forms starting
2228 2236 with a new line. This way the formatting is better respected for
2229 2237 objects which work hard to make nice string forms.
2230 2238
2231 2239 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2232 2240 autocall would overtake data access for objects with both
2233 2241 __getitem__ and __call__.
2234 2242
2235 2243 2003-08-19 *** Released version 0.5.0-rc1
2236 2244
2237 2245 2003-08-19 Fernando Perez <fperez@colorado.edu>
2238 2246
2239 2247 * IPython/deep_reload.py (load_tail): single tiny change here
2240 2248 seems to fix the long-standing bug of dreload() failing to work
2241 2249 for dotted names. But this module is pretty tricky, so I may have
2242 2250 missed some subtlety. Needs more testing!.
2243 2251
2244 2252 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2245 2253 exceptions which have badly implemented __str__ methods.
2246 2254 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2247 2255 which I've been getting reports about from Python 2.3 users. I
2248 2256 wish I had a simple test case to reproduce the problem, so I could
2249 2257 either write a cleaner workaround or file a bug report if
2250 2258 necessary.
2251 2259
2252 2260 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2253 2261 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2254 2262 a bug report by Tjabo Kloppenburg.
2255 2263
2256 2264 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2257 2265 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2258 2266 seems rather unstable. Thanks to a bug report by Tjabo
2259 2267 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2260 2268
2261 2269 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2262 2270 this out soon because of the critical fixes in the inner loop for
2263 2271 generators.
2264 2272
2265 2273 * IPython/Magic.py (Magic.getargspec): removed. This (and
2266 2274 _get_def) have been obsoleted by OInspect for a long time, I
2267 2275 hadn't noticed that they were dead code.
2268 2276 (Magic._ofind): restored _ofind functionality for a few literals
2269 2277 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2270 2278 for things like "hello".capitalize?, since that would require a
2271 2279 potentially dangerous eval() again.
2272 2280
2273 2281 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2274 2282 logic a bit more to clean up the escapes handling and minimize the
2275 2283 use of _ofind to only necessary cases. The interactive 'feel' of
2276 2284 IPython should have improved quite a bit with the changes in
2277 2285 _prefilter and _ofind (besides being far safer than before).
2278 2286
2279 2287 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2280 2288 obscure, never reported). Edit would fail to find the object to
2281 2289 edit under some circumstances.
2282 2290 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2283 2291 which were causing double-calling of generators. Those eval calls
2284 2292 were _very_ dangerous, since code with side effects could be
2285 2293 triggered. As they say, 'eval is evil'... These were the
2286 2294 nastiest evals in IPython. Besides, _ofind is now far simpler,
2287 2295 and it should also be quite a bit faster. Its use of inspect is
2288 2296 also safer, so perhaps some of the inspect-related crashes I've
2289 2297 seen lately with Python 2.3 might be taken care of. That will
2290 2298 need more testing.
2291 2299
2292 2300 2003-08-17 Fernando Perez <fperez@colorado.edu>
2293 2301
2294 2302 * IPython/iplib.py (InteractiveShell._prefilter): significant
2295 2303 simplifications to the logic for handling user escapes. Faster
2296 2304 and simpler code.
2297 2305
2298 2306 2003-08-14 Fernando Perez <fperez@colorado.edu>
2299 2307
2300 2308 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2301 2309 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2302 2310 but it should be quite a bit faster. And the recursive version
2303 2311 generated O(log N) intermediate storage for all rank>1 arrays,
2304 2312 even if they were contiguous.
2305 2313 (l1norm): Added this function.
2306 2314 (norm): Added this function for arbitrary norms (including
2307 2315 l-infinity). l1 and l2 are still special cases for convenience
2308 2316 and speed.
2309 2317
2310 2318 2003-08-03 Fernando Perez <fperez@colorado.edu>
2311 2319
2312 2320 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2313 2321 exceptions, which now raise PendingDeprecationWarnings in Python
2314 2322 2.3. There were some in Magic and some in Gnuplot2.
2315 2323
2316 2324 2003-06-30 Fernando Perez <fperez@colorado.edu>
2317 2325
2318 2326 * IPython/genutils.py (page): modified to call curses only for
2319 2327 terminals where TERM=='xterm'. After problems under many other
2320 2328 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2321 2329
2322 2330 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2323 2331 would be triggered when readline was absent. This was just an old
2324 2332 debugging statement I'd forgotten to take out.
2325 2333
2326 2334 2003-06-20 Fernando Perez <fperez@colorado.edu>
2327 2335
2328 2336 * IPython/genutils.py (clock): modified to return only user time
2329 2337 (not counting system time), after a discussion on scipy. While
2330 2338 system time may be a useful quantity occasionally, it may much
2331 2339 more easily be skewed by occasional swapping or other similar
2332 2340 activity.
2333 2341
2334 2342 2003-06-05 Fernando Perez <fperez@colorado.edu>
2335 2343
2336 2344 * IPython/numutils.py (identity): new function, for building
2337 2345 arbitrary rank Kronecker deltas (mostly backwards compatible with
2338 2346 Numeric.identity)
2339 2347
2340 2348 2003-06-03 Fernando Perez <fperez@colorado.edu>
2341 2349
2342 2350 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2343 2351 arguments passed to magics with spaces, to allow trailing '\' to
2344 2352 work normally (mainly for Windows users).
2345 2353
2346 2354 2003-05-29 Fernando Perez <fperez@colorado.edu>
2347 2355
2348 2356 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2349 2357 instead of pydoc.help. This fixes a bizarre behavior where
2350 2358 printing '%s' % locals() would trigger the help system. Now
2351 2359 ipython behaves like normal python does.
2352 2360
2353 2361 Note that if one does 'from pydoc import help', the bizarre
2354 2362 behavior returns, but this will also happen in normal python, so
2355 2363 it's not an ipython bug anymore (it has to do with how pydoc.help
2356 2364 is implemented).
2357 2365
2358 2366 2003-05-22 Fernando Perez <fperez@colorado.edu>
2359 2367
2360 2368 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2361 2369 return [] instead of None when nothing matches, also match to end
2362 2370 of line. Patch by Gary Bishop.
2363 2371
2364 2372 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2365 2373 protection as before, for files passed on the command line. This
2366 2374 prevents the CrashHandler from kicking in if user files call into
2367 2375 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2368 2376 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2369 2377
2370 2378 2003-05-20 *** Released version 0.4.0
2371 2379
2372 2380 2003-05-20 Fernando Perez <fperez@colorado.edu>
2373 2381
2374 2382 * setup.py: added support for manpages. It's a bit hackish b/c of
2375 2383 a bug in the way the bdist_rpm distutils target handles gzipped
2376 2384 manpages, but it works. After a patch by Jack.
2377 2385
2378 2386 2003-05-19 Fernando Perez <fperez@colorado.edu>
2379 2387
2380 2388 * IPython/numutils.py: added a mockup of the kinds module, since
2381 2389 it was recently removed from Numeric. This way, numutils will
2382 2390 work for all users even if they are missing kinds.
2383 2391
2384 2392 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2385 2393 failure, which can occur with SWIG-wrapped extensions. After a
2386 2394 crash report from Prabhu.
2387 2395
2388 2396 2003-05-16 Fernando Perez <fperez@colorado.edu>
2389 2397
2390 2398 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2391 2399 protect ipython from user code which may call directly
2392 2400 sys.excepthook (this looks like an ipython crash to the user, even
2393 2401 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2394 2402 This is especially important to help users of WxWindows, but may
2395 2403 also be useful in other cases.
2396 2404
2397 2405 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2398 2406 an optional tb_offset to be specified, and to preserve exception
2399 2407 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2400 2408
2401 2409 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2402 2410
2403 2411 2003-05-15 Fernando Perez <fperez@colorado.edu>
2404 2412
2405 2413 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2406 2414 installing for a new user under Windows.
2407 2415
2408 2416 2003-05-12 Fernando Perez <fperez@colorado.edu>
2409 2417
2410 2418 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2411 2419 handler for Emacs comint-based lines. Currently it doesn't do
2412 2420 much (but importantly, it doesn't update the history cache). In
2413 2421 the future it may be expanded if Alex needs more functionality
2414 2422 there.
2415 2423
2416 2424 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2417 2425 info to crash reports.
2418 2426
2419 2427 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2420 2428 just like Python's -c. Also fixed crash with invalid -color
2421 2429 option value at startup. Thanks to Will French
2422 2430 <wfrench-AT-bestweb.net> for the bug report.
2423 2431
2424 2432 2003-05-09 Fernando Perez <fperez@colorado.edu>
2425 2433
2426 2434 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2427 2435 to EvalDict (it's a mapping, after all) and simplified its code
2428 2436 quite a bit, after a nice discussion on c.l.py where Gustavo
2429 2437 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2430 2438
2431 2439 2003-04-30 Fernando Perez <fperez@colorado.edu>
2432 2440
2433 2441 * IPython/genutils.py (timings_out): modified it to reduce its
2434 2442 overhead in the common reps==1 case.
2435 2443
2436 2444 2003-04-29 Fernando Perez <fperez@colorado.edu>
2437 2445
2438 2446 * IPython/genutils.py (timings_out): Modified to use the resource
2439 2447 module, which avoids the wraparound problems of time.clock().
2440 2448
2441 2449 2003-04-17 *** Released version 0.2.15pre4
2442 2450
2443 2451 2003-04-17 Fernando Perez <fperez@colorado.edu>
2444 2452
2445 2453 * setup.py (scriptfiles): Split windows-specific stuff over to a
2446 2454 separate file, in an attempt to have a Windows GUI installer.
2447 2455 That didn't work, but part of the groundwork is done.
2448 2456
2449 2457 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2450 2458 indent/unindent with 4 spaces. Particularly useful in combination
2451 2459 with the new auto-indent option.
2452 2460
2453 2461 2003-04-16 Fernando Perez <fperez@colorado.edu>
2454 2462
2455 2463 * IPython/Magic.py: various replacements of self.rc for
2456 2464 self.shell.rc. A lot more remains to be done to fully disentangle
2457 2465 this class from the main Shell class.
2458 2466
2459 2467 * IPython/GnuplotRuntime.py: added checks for mouse support so
2460 2468 that we don't try to enable it if the current gnuplot doesn't
2461 2469 really support it. Also added checks so that we don't try to
2462 2470 enable persist under Windows (where Gnuplot doesn't recognize the
2463 2471 option).
2464 2472
2465 2473 * IPython/iplib.py (InteractiveShell.interact): Added optional
2466 2474 auto-indenting code, after a patch by King C. Shu
2467 2475 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2468 2476 get along well with pasting indented code. If I ever figure out
2469 2477 how to make that part go well, it will become on by default.
2470 2478
2471 2479 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2472 2480 crash ipython if there was an unmatched '%' in the user's prompt
2473 2481 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2474 2482
2475 2483 * IPython/iplib.py (InteractiveShell.interact): removed the
2476 2484 ability to ask the user whether he wants to crash or not at the
2477 2485 'last line' exception handler. Calling functions at that point
2478 2486 changes the stack, and the error reports would have incorrect
2479 2487 tracebacks.
2480 2488
2481 2489 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2482 2490 pass through a peger a pretty-printed form of any object. After a
2483 2491 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2484 2492
2485 2493 2003-04-14 Fernando Perez <fperez@colorado.edu>
2486 2494
2487 2495 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2488 2496 all files in ~ would be modified at first install (instead of
2489 2497 ~/.ipython). This could be potentially disastrous, as the
2490 2498 modification (make line-endings native) could damage binary files.
2491 2499
2492 2500 2003-04-10 Fernando Perez <fperez@colorado.edu>
2493 2501
2494 2502 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2495 2503 handle only lines which are invalid python. This now means that
2496 2504 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2497 2505 for the bug report.
2498 2506
2499 2507 2003-04-01 Fernando Perez <fperez@colorado.edu>
2500 2508
2501 2509 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2502 2510 where failing to set sys.last_traceback would crash pdb.pm().
2503 2511 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2504 2512 report.
2505 2513
2506 2514 2003-03-25 Fernando Perez <fperez@colorado.edu>
2507 2515
2508 2516 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2509 2517 before printing it (it had a lot of spurious blank lines at the
2510 2518 end).
2511 2519
2512 2520 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2513 2521 output would be sent 21 times! Obviously people don't use this
2514 2522 too often, or I would have heard about it.
2515 2523
2516 2524 2003-03-24 Fernando Perez <fperez@colorado.edu>
2517 2525
2518 2526 * setup.py (scriptfiles): renamed the data_files parameter from
2519 2527 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2520 2528 for the patch.
2521 2529
2522 2530 2003-03-20 Fernando Perez <fperez@colorado.edu>
2523 2531
2524 2532 * IPython/genutils.py (error): added error() and fatal()
2525 2533 functions.
2526 2534
2527 2535 2003-03-18 *** Released version 0.2.15pre3
2528 2536
2529 2537 2003-03-18 Fernando Perez <fperez@colorado.edu>
2530 2538
2531 2539 * setupext/install_data_ext.py
2532 2540 (install_data_ext.initialize_options): Class contributed by Jack
2533 2541 Moffit for fixing the old distutils hack. He is sending this to
2534 2542 the distutils folks so in the future we may not need it as a
2535 2543 private fix.
2536 2544
2537 2545 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2538 2546 changes for Debian packaging. See his patch for full details.
2539 2547 The old distutils hack of making the ipythonrc* files carry a
2540 2548 bogus .py extension is gone, at last. Examples were moved to a
2541 2549 separate subdir under doc/, and the separate executable scripts
2542 2550 now live in their own directory. Overall a great cleanup. The
2543 2551 manual was updated to use the new files, and setup.py has been
2544 2552 fixed for this setup.
2545 2553
2546 2554 * IPython/PyColorize.py (Parser.usage): made non-executable and
2547 2555 created a pycolor wrapper around it to be included as a script.
2548 2556
2549 2557 2003-03-12 *** Released version 0.2.15pre2
2550 2558
2551 2559 2003-03-12 Fernando Perez <fperez@colorado.edu>
2552 2560
2553 2561 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2554 2562 long-standing problem with garbage characters in some terminals.
2555 2563 The issue was really that the \001 and \002 escapes must _only_ be
2556 2564 passed to input prompts (which call readline), but _never_ to
2557 2565 normal text to be printed on screen. I changed ColorANSI to have
2558 2566 two classes: TermColors and InputTermColors, each with the
2559 2567 appropriate escapes for input prompts or normal text. The code in
2560 2568 Prompts.py got slightly more complicated, but this very old and
2561 2569 annoying bug is finally fixed.
2562 2570
2563 2571 All the credit for nailing down the real origin of this problem
2564 2572 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2565 2573 *Many* thanks to him for spending quite a bit of effort on this.
2566 2574
2567 2575 2003-03-05 *** Released version 0.2.15pre1
2568 2576
2569 2577 2003-03-03 Fernando Perez <fperez@colorado.edu>
2570 2578
2571 2579 * IPython/FakeModule.py: Moved the former _FakeModule to a
2572 2580 separate file, because it's also needed by Magic (to fix a similar
2573 2581 pickle-related issue in @run).
2574 2582
2575 2583 2003-03-02 Fernando Perez <fperez@colorado.edu>
2576 2584
2577 2585 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2578 2586 the autocall option at runtime.
2579 2587 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2580 2588 across Magic.py to start separating Magic from InteractiveShell.
2581 2589 (Magic._ofind): Fixed to return proper namespace for dotted
2582 2590 names. Before, a dotted name would always return 'not currently
2583 2591 defined', because it would find the 'parent'. s.x would be found,
2584 2592 but since 'x' isn't defined by itself, it would get confused.
2585 2593 (Magic.magic_run): Fixed pickling problems reported by Ralf
2586 2594 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2587 2595 that I'd used when Mike Heeter reported similar issues at the
2588 2596 top-level, but now for @run. It boils down to injecting the
2589 2597 namespace where code is being executed with something that looks
2590 2598 enough like a module to fool pickle.dump(). Since a pickle stores
2591 2599 a named reference to the importing module, we need this for
2592 2600 pickles to save something sensible.
2593 2601
2594 2602 * IPython/ipmaker.py (make_IPython): added an autocall option.
2595 2603
2596 2604 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2597 2605 the auto-eval code. Now autocalling is an option, and the code is
2598 2606 also vastly safer. There is no more eval() involved at all.
2599 2607
2600 2608 2003-03-01 Fernando Perez <fperez@colorado.edu>
2601 2609
2602 2610 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2603 2611 dict with named keys instead of a tuple.
2604 2612
2605 2613 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2606 2614
2607 2615 * setup.py (make_shortcut): Fixed message about directories
2608 2616 created during Windows installation (the directories were ok, just
2609 2617 the printed message was misleading). Thanks to Chris Liechti
2610 2618 <cliechti-AT-gmx.net> for the heads up.
2611 2619
2612 2620 2003-02-21 Fernando Perez <fperez@colorado.edu>
2613 2621
2614 2622 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2615 2623 of ValueError exception when checking for auto-execution. This
2616 2624 one is raised by things like Numeric arrays arr.flat when the
2617 2625 array is non-contiguous.
2618 2626
2619 2627 2003-01-31 Fernando Perez <fperez@colorado.edu>
2620 2628
2621 2629 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2622 2630 not return any value at all (even though the command would get
2623 2631 executed).
2624 2632 (xsys): Flush stdout right after printing the command to ensure
2625 2633 proper ordering of commands and command output in the total
2626 2634 output.
2627 2635 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2628 2636 system/getoutput as defaults. The old ones are kept for
2629 2637 compatibility reasons, so no code which uses this library needs
2630 2638 changing.
2631 2639
2632 2640 2003-01-27 *** Released version 0.2.14
2633 2641
2634 2642 2003-01-25 Fernando Perez <fperez@colorado.edu>
2635 2643
2636 2644 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2637 2645 functions defined in previous edit sessions could not be re-edited
2638 2646 (because the temp files were immediately removed). Now temp files
2639 2647 are removed only at IPython's exit.
2640 2648 (Magic.magic_run): Improved @run to perform shell-like expansions
2641 2649 on its arguments (~users and $VARS). With this, @run becomes more
2642 2650 like a normal command-line.
2643 2651
2644 2652 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2645 2653 bugs related to embedding and cleaned up that code. A fairly
2646 2654 important one was the impossibility to access the global namespace
2647 2655 through the embedded IPython (only local variables were visible).
2648 2656
2649 2657 2003-01-14 Fernando Perez <fperez@colorado.edu>
2650 2658
2651 2659 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2652 2660 auto-calling to be a bit more conservative. Now it doesn't get
2653 2661 triggered if any of '!=()<>' are in the rest of the input line, to
2654 2662 allow comparing callables. Thanks to Alex for the heads up.
2655 2663
2656 2664 2003-01-07 Fernando Perez <fperez@colorado.edu>
2657 2665
2658 2666 * IPython/genutils.py (page): fixed estimation of the number of
2659 2667 lines in a string to be paged to simply count newlines. This
2660 2668 prevents over-guessing due to embedded escape sequences. A better
2661 2669 long-term solution would involve stripping out the control chars
2662 2670 for the count, but it's potentially so expensive I just don't
2663 2671 think it's worth doing.
2664 2672
2665 2673 2002-12-19 *** Released version 0.2.14pre50
2666 2674
2667 2675 2002-12-19 Fernando Perez <fperez@colorado.edu>
2668 2676
2669 2677 * tools/release (version): Changed release scripts to inform
2670 2678 Andrea and build a NEWS file with a list of recent changes.
2671 2679
2672 2680 * IPython/ColorANSI.py (__all__): changed terminal detection
2673 2681 code. Seems to work better for xterms without breaking
2674 2682 konsole. Will need more testing to determine if WinXP and Mac OSX
2675 2683 also work ok.
2676 2684
2677 2685 2002-12-18 *** Released version 0.2.14pre49
2678 2686
2679 2687 2002-12-18 Fernando Perez <fperez@colorado.edu>
2680 2688
2681 2689 * Docs: added new info about Mac OSX, from Andrea.
2682 2690
2683 2691 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2684 2692 allow direct plotting of python strings whose format is the same
2685 2693 of gnuplot data files.
2686 2694
2687 2695 2002-12-16 Fernando Perez <fperez@colorado.edu>
2688 2696
2689 2697 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2690 2698 value of exit question to be acknowledged.
2691 2699
2692 2700 2002-12-03 Fernando Perez <fperez@colorado.edu>
2693 2701
2694 2702 * IPython/ipmaker.py: removed generators, which had been added
2695 2703 by mistake in an earlier debugging run. This was causing trouble
2696 2704 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2697 2705 for pointing this out.
2698 2706
2699 2707 2002-11-17 Fernando Perez <fperez@colorado.edu>
2700 2708
2701 2709 * Manual: updated the Gnuplot section.
2702 2710
2703 2711 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2704 2712 a much better split of what goes in Runtime and what goes in
2705 2713 Interactive.
2706 2714
2707 2715 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2708 2716 being imported from iplib.
2709 2717
2710 2718 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2711 2719 for command-passing. Now the global Gnuplot instance is called
2712 2720 'gp' instead of 'g', which was really a far too fragile and
2713 2721 common name.
2714 2722
2715 2723 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2716 2724 bounding boxes generated by Gnuplot for square plots.
2717 2725
2718 2726 * IPython/genutils.py (popkey): new function added. I should
2719 2727 suggest this on c.l.py as a dict method, it seems useful.
2720 2728
2721 2729 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2722 2730 to transparently handle PostScript generation. MUCH better than
2723 2731 the previous plot_eps/replot_eps (which I removed now). The code
2724 2732 is also fairly clean and well documented now (including
2725 2733 docstrings).
2726 2734
2727 2735 2002-11-13 Fernando Perez <fperez@colorado.edu>
2728 2736
2729 2737 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2730 2738 (inconsistent with options).
2731 2739
2732 2740 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2733 2741 manually disabled, I don't know why. Fixed it.
2734 2742 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2735 2743 eps output.
2736 2744
2737 2745 2002-11-12 Fernando Perez <fperez@colorado.edu>
2738 2746
2739 2747 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2740 2748 don't propagate up to caller. Fixes crash reported by François
2741 2749 Pinard.
2742 2750
2743 2751 2002-11-09 Fernando Perez <fperez@colorado.edu>
2744 2752
2745 2753 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2746 2754 history file for new users.
2747 2755 (make_IPython): fixed bug where initial install would leave the
2748 2756 user running in the .ipython dir.
2749 2757 (make_IPython): fixed bug where config dir .ipython would be
2750 2758 created regardless of the given -ipythondir option. Thanks to Cory
2751 2759 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2752 2760
2753 2761 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2754 2762 type confirmations. Will need to use it in all of IPython's code
2755 2763 consistently.
2756 2764
2757 2765 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2758 2766 context to print 31 lines instead of the default 5. This will make
2759 2767 the crash reports extremely detailed in case the problem is in
2760 2768 libraries I don't have access to.
2761 2769
2762 2770 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2763 2771 line of defense' code to still crash, but giving users fair
2764 2772 warning. I don't want internal errors to go unreported: if there's
2765 2773 an internal problem, IPython should crash and generate a full
2766 2774 report.
2767 2775
2768 2776 2002-11-08 Fernando Perez <fperez@colorado.edu>
2769 2777
2770 2778 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2771 2779 otherwise uncaught exceptions which can appear if people set
2772 2780 sys.stdout to something badly broken. Thanks to a crash report
2773 2781 from henni-AT-mail.brainbot.com.
2774 2782
2775 2783 2002-11-04 Fernando Perez <fperez@colorado.edu>
2776 2784
2777 2785 * IPython/iplib.py (InteractiveShell.interact): added
2778 2786 __IPYTHON__active to the builtins. It's a flag which goes on when
2779 2787 the interaction starts and goes off again when it stops. This
2780 2788 allows embedding code to detect being inside IPython. Before this
2781 2789 was done via __IPYTHON__, but that only shows that an IPython
2782 2790 instance has been created.
2783 2791
2784 2792 * IPython/Magic.py (Magic.magic_env): I realized that in a
2785 2793 UserDict, instance.data holds the data as a normal dict. So I
2786 2794 modified @env to return os.environ.data instead of rebuilding a
2787 2795 dict by hand.
2788 2796
2789 2797 2002-11-02 Fernando Perez <fperez@colorado.edu>
2790 2798
2791 2799 * IPython/genutils.py (warn): changed so that level 1 prints no
2792 2800 header. Level 2 is now the default (with 'WARNING' header, as
2793 2801 before). I think I tracked all places where changes were needed in
2794 2802 IPython, but outside code using the old level numbering may have
2795 2803 broken.
2796 2804
2797 2805 * IPython/iplib.py (InteractiveShell.runcode): added this to
2798 2806 handle the tracebacks in SystemExit traps correctly. The previous
2799 2807 code (through interact) was printing more of the stack than
2800 2808 necessary, showing IPython internal code to the user.
2801 2809
2802 2810 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2803 2811 default. Now that the default at the confirmation prompt is yes,
2804 2812 it's not so intrusive. François' argument that ipython sessions
2805 2813 tend to be complex enough not to lose them from an accidental C-d,
2806 2814 is a valid one.
2807 2815
2808 2816 * IPython/iplib.py (InteractiveShell.interact): added a
2809 2817 showtraceback() call to the SystemExit trap, and modified the exit
2810 2818 confirmation to have yes as the default.
2811 2819
2812 2820 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2813 2821 this file. It's been gone from the code for a long time, this was
2814 2822 simply leftover junk.
2815 2823
2816 2824 2002-11-01 Fernando Perez <fperez@colorado.edu>
2817 2825
2818 2826 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2819 2827 added. If set, IPython now traps EOF and asks for
2820 2828 confirmation. After a request by François Pinard.
2821 2829
2822 2830 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2823 2831 of @abort, and with a new (better) mechanism for handling the
2824 2832 exceptions.
2825 2833
2826 2834 2002-10-27 Fernando Perez <fperez@colorado.edu>
2827 2835
2828 2836 * IPython/usage.py (__doc__): updated the --help information and
2829 2837 the ipythonrc file to indicate that -log generates
2830 2838 ./ipython.log. Also fixed the corresponding info in @logstart.
2831 2839 This and several other fixes in the manuals thanks to reports by
2832 2840 François Pinard <pinard-AT-iro.umontreal.ca>.
2833 2841
2834 2842 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2835 2843 refer to @logstart (instead of @log, which doesn't exist).
2836 2844
2837 2845 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2838 2846 AttributeError crash. Thanks to Christopher Armstrong
2839 2847 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2840 2848 introduced recently (in 0.2.14pre37) with the fix to the eval
2841 2849 problem mentioned below.
2842 2850
2843 2851 2002-10-17 Fernando Perez <fperez@colorado.edu>
2844 2852
2845 2853 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2846 2854 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2847 2855
2848 2856 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2849 2857 this function to fix a problem reported by Alex Schmolck. He saw
2850 2858 it with list comprehensions and generators, which were getting
2851 2859 called twice. The real problem was an 'eval' call in testing for
2852 2860 automagic which was evaluating the input line silently.
2853 2861
2854 2862 This is a potentially very nasty bug, if the input has side
2855 2863 effects which must not be repeated. The code is much cleaner now,
2856 2864 without any blanket 'except' left and with a regexp test for
2857 2865 actual function names.
2858 2866
2859 2867 But an eval remains, which I'm not fully comfortable with. I just
2860 2868 don't know how to find out if an expression could be a callable in
2861 2869 the user's namespace without doing an eval on the string. However
2862 2870 that string is now much more strictly checked so that no code
2863 2871 slips by, so the eval should only happen for things that can
2864 2872 really be only function/method names.
2865 2873
2866 2874 2002-10-15 Fernando Perez <fperez@colorado.edu>
2867 2875
2868 2876 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2869 2877 OSX information to main manual, removed README_Mac_OSX file from
2870 2878 distribution. Also updated credits for recent additions.
2871 2879
2872 2880 2002-10-10 Fernando Perez <fperez@colorado.edu>
2873 2881
2874 2882 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2875 2883 terminal-related issues. Many thanks to Andrea Riciputi
2876 2884 <andrea.riciputi-AT-libero.it> for writing it.
2877 2885
2878 2886 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2879 2887 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2880 2888
2881 2889 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2882 2890 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2883 2891 <syver-en-AT-online.no> who both submitted patches for this problem.
2884 2892
2885 2893 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2886 2894 global embedding to make sure that things don't overwrite user
2887 2895 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2888 2896
2889 2897 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2890 2898 compatibility. Thanks to Hayden Callow
2891 2899 <h.callow-AT-elec.canterbury.ac.nz>
2892 2900
2893 2901 2002-10-04 Fernando Perez <fperez@colorado.edu>
2894 2902
2895 2903 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2896 2904 Gnuplot.File objects.
2897 2905
2898 2906 2002-07-23 Fernando Perez <fperez@colorado.edu>
2899 2907
2900 2908 * IPython/genutils.py (timing): Added timings() and timing() for
2901 2909 quick access to the most commonly needed data, the execution
2902 2910 times. Old timing() renamed to timings_out().
2903 2911
2904 2912 2002-07-18 Fernando Perez <fperez@colorado.edu>
2905 2913
2906 2914 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2907 2915 bug with nested instances disrupting the parent's tab completion.
2908 2916
2909 2917 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2910 2918 all_completions code to begin the emacs integration.
2911 2919
2912 2920 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2913 2921 argument to allow titling individual arrays when plotting.
2914 2922
2915 2923 2002-07-15 Fernando Perez <fperez@colorado.edu>
2916 2924
2917 2925 * setup.py (make_shortcut): changed to retrieve the value of
2918 2926 'Program Files' directory from the registry (this value changes in
2919 2927 non-english versions of Windows). Thanks to Thomas Fanslau
2920 2928 <tfanslau-AT-gmx.de> for the report.
2921 2929
2922 2930 2002-07-10 Fernando Perez <fperez@colorado.edu>
2923 2931
2924 2932 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2925 2933 a bug in pdb, which crashes if a line with only whitespace is
2926 2934 entered. Bug report submitted to sourceforge.
2927 2935
2928 2936 2002-07-09 Fernando Perez <fperez@colorado.edu>
2929 2937
2930 2938 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2931 2939 reporting exceptions (it's a bug in inspect.py, I just set a
2932 2940 workaround).
2933 2941
2934 2942 2002-07-08 Fernando Perez <fperez@colorado.edu>
2935 2943
2936 2944 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2937 2945 __IPYTHON__ in __builtins__ to show up in user_ns.
2938 2946
2939 2947 2002-07-03 Fernando Perez <fperez@colorado.edu>
2940 2948
2941 2949 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2942 2950 name from @gp_set_instance to @gp_set_default.
2943 2951
2944 2952 * IPython/ipmaker.py (make_IPython): default editor value set to
2945 2953 '0' (a string), to match the rc file. Otherwise will crash when
2946 2954 .strip() is called on it.
2947 2955
2948 2956
2949 2957 2002-06-28 Fernando Perez <fperez@colorado.edu>
2950 2958
2951 2959 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2952 2960 of files in current directory when a file is executed via
2953 2961 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2954 2962
2955 2963 * setup.py (manfiles): fix for rpm builds, submitted by RA
2956 2964 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2957 2965
2958 2966 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2959 2967 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2960 2968 string!). A. Schmolck caught this one.
2961 2969
2962 2970 2002-06-27 Fernando Perez <fperez@colorado.edu>
2963 2971
2964 2972 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2965 2973 defined files at the cmd line. __name__ wasn't being set to
2966 2974 __main__.
2967 2975
2968 2976 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2969 2977 regular lists and tuples besides Numeric arrays.
2970 2978
2971 2979 * IPython/Prompts.py (CachedOutput.__call__): Added output
2972 2980 supression for input ending with ';'. Similar to Mathematica and
2973 2981 Matlab. The _* vars and Out[] list are still updated, just like
2974 2982 Mathematica behaves.
2975 2983
2976 2984 2002-06-25 Fernando Perez <fperez@colorado.edu>
2977 2985
2978 2986 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2979 2987 .ini extensions for profiels under Windows.
2980 2988
2981 2989 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2982 2990 string form. Fix contributed by Alexander Schmolck
2983 2991 <a.schmolck-AT-gmx.net>
2984 2992
2985 2993 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2986 2994 pre-configured Gnuplot instance.
2987 2995
2988 2996 2002-06-21 Fernando Perez <fperez@colorado.edu>
2989 2997
2990 2998 * IPython/numutils.py (exp_safe): new function, works around the
2991 2999 underflow problems in Numeric.
2992 3000 (log2): New fn. Safe log in base 2: returns exact integer answer
2993 3001 for exact integer powers of 2.
2994 3002
2995 3003 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2996 3004 properly.
2997 3005
2998 3006 2002-06-20 Fernando Perez <fperez@colorado.edu>
2999 3007
3000 3008 * IPython/genutils.py (timing): new function like
3001 3009 Mathematica's. Similar to time_test, but returns more info.
3002 3010
3003 3011 2002-06-18 Fernando Perez <fperez@colorado.edu>
3004 3012
3005 3013 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3006 3014 according to Mike Heeter's suggestions.
3007 3015
3008 3016 2002-06-16 Fernando Perez <fperez@colorado.edu>
3009 3017
3010 3018 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3011 3019 system. GnuplotMagic is gone as a user-directory option. New files
3012 3020 make it easier to use all the gnuplot stuff both from external
3013 3021 programs as well as from IPython. Had to rewrite part of
3014 3022 hardcopy() b/c of a strange bug: often the ps files simply don't
3015 3023 get created, and require a repeat of the command (often several
3016 3024 times).
3017 3025
3018 3026 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3019 3027 resolve output channel at call time, so that if sys.stderr has
3020 3028 been redirected by user this gets honored.
3021 3029
3022 3030 2002-06-13 Fernando Perez <fperez@colorado.edu>
3023 3031
3024 3032 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3025 3033 IPShell. Kept a copy with the old names to avoid breaking people's
3026 3034 embedded code.
3027 3035
3028 3036 * IPython/ipython: simplified it to the bare minimum after
3029 3037 Holger's suggestions. Added info about how to use it in
3030 3038 PYTHONSTARTUP.
3031 3039
3032 3040 * IPython/Shell.py (IPythonShell): changed the options passing
3033 3041 from a string with funky %s replacements to a straight list. Maybe
3034 3042 a bit more typing, but it follows sys.argv conventions, so there's
3035 3043 less special-casing to remember.
3036 3044
3037 3045 2002-06-12 Fernando Perez <fperez@colorado.edu>
3038 3046
3039 3047 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3040 3048 command. Thanks to a suggestion by Mike Heeter.
3041 3049 (Magic.magic_pfile): added behavior to look at filenames if given
3042 3050 arg is not a defined object.
3043 3051 (Magic.magic_save): New @save function to save code snippets. Also
3044 3052 a Mike Heeter idea.
3045 3053
3046 3054 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3047 3055 plot() and replot(). Much more convenient now, especially for
3048 3056 interactive use.
3049 3057
3050 3058 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3051 3059 filenames.
3052 3060
3053 3061 2002-06-02 Fernando Perez <fperez@colorado.edu>
3054 3062
3055 3063 * IPython/Struct.py (Struct.__init__): modified to admit
3056 3064 initialization via another struct.
3057 3065
3058 3066 * IPython/genutils.py (SystemExec.__init__): New stateful
3059 3067 interface to xsys and bq. Useful for writing system scripts.
3060 3068
3061 3069 2002-05-30 Fernando Perez <fperez@colorado.edu>
3062 3070
3063 3071 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3064 3072 documents. This will make the user download smaller (it's getting
3065 3073 too big).
3066 3074
3067 3075 2002-05-29 Fernando Perez <fperez@colorado.edu>
3068 3076
3069 3077 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3070 3078 fix problems with shelve and pickle. Seems to work, but I don't
3071 3079 know if corner cases break it. Thanks to Mike Heeter
3072 3080 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3073 3081
3074 3082 2002-05-24 Fernando Perez <fperez@colorado.edu>
3075 3083
3076 3084 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3077 3085 macros having broken.
3078 3086
3079 3087 2002-05-21 Fernando Perez <fperez@colorado.edu>
3080 3088
3081 3089 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3082 3090 introduced logging bug: all history before logging started was
3083 3091 being written one character per line! This came from the redesign
3084 3092 of the input history as a special list which slices to strings,
3085 3093 not to lists.
3086 3094
3087 3095 2002-05-20 Fernando Perez <fperez@colorado.edu>
3088 3096
3089 3097 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3090 3098 be an attribute of all classes in this module. The design of these
3091 3099 classes needs some serious overhauling.
3092 3100
3093 3101 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3094 3102 which was ignoring '_' in option names.
3095 3103
3096 3104 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3097 3105 'Verbose_novars' to 'Context' and made it the new default. It's a
3098 3106 bit more readable and also safer than verbose.
3099 3107
3100 3108 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3101 3109 triple-quoted strings.
3102 3110
3103 3111 * IPython/OInspect.py (__all__): new module exposing the object
3104 3112 introspection facilities. Now the corresponding magics are dummy
3105 3113 wrappers around this. Having this module will make it much easier
3106 3114 to put these functions into our modified pdb.
3107 3115 This new object inspector system uses the new colorizing module,
3108 3116 so source code and other things are nicely syntax highlighted.
3109 3117
3110 3118 2002-05-18 Fernando Perez <fperez@colorado.edu>
3111 3119
3112 3120 * IPython/ColorANSI.py: Split the coloring tools into a separate
3113 3121 module so I can use them in other code easier (they were part of
3114 3122 ultraTB).
3115 3123
3116 3124 2002-05-17 Fernando Perez <fperez@colorado.edu>
3117 3125
3118 3126 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3119 3127 fixed it to set the global 'g' also to the called instance, as
3120 3128 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3121 3129 user's 'g' variables).
3122 3130
3123 3131 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3124 3132 global variables (aliases to _ih,_oh) so that users which expect
3125 3133 In[5] or Out[7] to work aren't unpleasantly surprised.
3126 3134 (InputList.__getslice__): new class to allow executing slices of
3127 3135 input history directly. Very simple class, complements the use of
3128 3136 macros.
3129 3137
3130 3138 2002-05-16 Fernando Perez <fperez@colorado.edu>
3131 3139
3132 3140 * setup.py (docdirbase): make doc directory be just doc/IPython
3133 3141 without version numbers, it will reduce clutter for users.
3134 3142
3135 3143 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3136 3144 execfile call to prevent possible memory leak. See for details:
3137 3145 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3138 3146
3139 3147 2002-05-15 Fernando Perez <fperez@colorado.edu>
3140 3148
3141 3149 * IPython/Magic.py (Magic.magic_psource): made the object
3142 3150 introspection names be more standard: pdoc, pdef, pfile and
3143 3151 psource. They all print/page their output, and it makes
3144 3152 remembering them easier. Kept old names for compatibility as
3145 3153 aliases.
3146 3154
3147 3155 2002-05-14 Fernando Perez <fperez@colorado.edu>
3148 3156
3149 3157 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3150 3158 what the mouse problem was. The trick is to use gnuplot with temp
3151 3159 files and NOT with pipes (for data communication), because having
3152 3160 both pipes and the mouse on is bad news.
3153 3161
3154 3162 2002-05-13 Fernando Perez <fperez@colorado.edu>
3155 3163
3156 3164 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3157 3165 bug. Information would be reported about builtins even when
3158 3166 user-defined functions overrode them.
3159 3167
3160 3168 2002-05-11 Fernando Perez <fperez@colorado.edu>
3161 3169
3162 3170 * IPython/__init__.py (__all__): removed FlexCompleter from
3163 3171 __all__ so that things don't fail in platforms without readline.
3164 3172
3165 3173 2002-05-10 Fernando Perez <fperez@colorado.edu>
3166 3174
3167 3175 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3168 3176 it requires Numeric, effectively making Numeric a dependency for
3169 3177 IPython.
3170 3178
3171 3179 * Released 0.2.13
3172 3180
3173 3181 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3174 3182 profiler interface. Now all the major options from the profiler
3175 3183 module are directly supported in IPython, both for single
3176 3184 expressions (@prun) and for full programs (@run -p).
3177 3185
3178 3186 2002-05-09 Fernando Perez <fperez@colorado.edu>
3179 3187
3180 3188 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3181 3189 magic properly formatted for screen.
3182 3190
3183 3191 * setup.py (make_shortcut): Changed things to put pdf version in
3184 3192 doc/ instead of doc/manual (had to change lyxport a bit).
3185 3193
3186 3194 * IPython/Magic.py (Profile.string_stats): made profile runs go
3187 3195 through pager (they are long and a pager allows searching, saving,
3188 3196 etc.)
3189 3197
3190 3198 2002-05-08 Fernando Perez <fperez@colorado.edu>
3191 3199
3192 3200 * Released 0.2.12
3193 3201
3194 3202 2002-05-06 Fernando Perez <fperez@colorado.edu>
3195 3203
3196 3204 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3197 3205 introduced); 'hist n1 n2' was broken.
3198 3206 (Magic.magic_pdb): added optional on/off arguments to @pdb
3199 3207 (Magic.magic_run): added option -i to @run, which executes code in
3200 3208 the IPython namespace instead of a clean one. Also added @irun as
3201 3209 an alias to @run -i.
3202 3210
3203 3211 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3204 3212 fixed (it didn't really do anything, the namespaces were wrong).
3205 3213
3206 3214 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3207 3215
3208 3216 * IPython/__init__.py (__all__): Fixed package namespace, now
3209 3217 'import IPython' does give access to IPython.<all> as
3210 3218 expected. Also renamed __release__ to Release.
3211 3219
3212 3220 * IPython/Debugger.py (__license__): created new Pdb class which
3213 3221 functions like a drop-in for the normal pdb.Pdb but does NOT
3214 3222 import readline by default. This way it doesn't muck up IPython's
3215 3223 readline handling, and now tab-completion finally works in the
3216 3224 debugger -- sort of. It completes things globally visible, but the
3217 3225 completer doesn't track the stack as pdb walks it. That's a bit
3218 3226 tricky, and I'll have to implement it later.
3219 3227
3220 3228 2002-05-05 Fernando Perez <fperez@colorado.edu>
3221 3229
3222 3230 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3223 3231 magic docstrings when printed via ? (explicit \'s were being
3224 3232 printed).
3225 3233
3226 3234 * IPython/ipmaker.py (make_IPython): fixed namespace
3227 3235 identification bug. Now variables loaded via logs or command-line
3228 3236 files are recognized in the interactive namespace by @who.
3229 3237
3230 3238 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3231 3239 log replay system stemming from the string form of Structs.
3232 3240
3233 3241 * IPython/Magic.py (Macro.__init__): improved macros to properly
3234 3242 handle magic commands in them.
3235 3243 (Magic.magic_logstart): usernames are now expanded so 'logstart
3236 3244 ~/mylog' now works.
3237 3245
3238 3246 * IPython/iplib.py (complete): fixed bug where paths starting with
3239 3247 '/' would be completed as magic names.
3240 3248
3241 3249 2002-05-04 Fernando Perez <fperez@colorado.edu>
3242 3250
3243 3251 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3244 3252 allow running full programs under the profiler's control.
3245 3253
3246 3254 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3247 3255 mode to report exceptions verbosely but without formatting
3248 3256 variables. This addresses the issue of ipython 'freezing' (it's
3249 3257 not frozen, but caught in an expensive formatting loop) when huge
3250 3258 variables are in the context of an exception.
3251 3259 (VerboseTB.text): Added '--->' markers at line where exception was
3252 3260 triggered. Much clearer to read, especially in NoColor modes.
3253 3261
3254 3262 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3255 3263 implemented in reverse when changing to the new parse_options().
3256 3264
3257 3265 2002-05-03 Fernando Perez <fperez@colorado.edu>
3258 3266
3259 3267 * IPython/Magic.py (Magic.parse_options): new function so that
3260 3268 magics can parse options easier.
3261 3269 (Magic.magic_prun): new function similar to profile.run(),
3262 3270 suggested by Chris Hart.
3263 3271 (Magic.magic_cd): fixed behavior so that it only changes if
3264 3272 directory actually is in history.
3265 3273
3266 3274 * IPython/usage.py (__doc__): added information about potential
3267 3275 slowness of Verbose exception mode when there are huge data
3268 3276 structures to be formatted (thanks to Archie Paulson).
3269 3277
3270 3278 * IPython/ipmaker.py (make_IPython): Changed default logging
3271 3279 (when simply called with -log) to use curr_dir/ipython.log in
3272 3280 rotate mode. Fixed crash which was occuring with -log before
3273 3281 (thanks to Jim Boyle).
3274 3282
3275 3283 2002-05-01 Fernando Perez <fperez@colorado.edu>
3276 3284
3277 3285 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3278 3286 was nasty -- though somewhat of a corner case).
3279 3287
3280 3288 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3281 3289 text (was a bug).
3282 3290
3283 3291 2002-04-30 Fernando Perez <fperez@colorado.edu>
3284 3292
3285 3293 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3286 3294 a print after ^D or ^C from the user so that the In[] prompt
3287 3295 doesn't over-run the gnuplot one.
3288 3296
3289 3297 2002-04-29 Fernando Perez <fperez@colorado.edu>
3290 3298
3291 3299 * Released 0.2.10
3292 3300
3293 3301 * IPython/__release__.py (version): get date dynamically.
3294 3302
3295 3303 * Misc. documentation updates thanks to Arnd's comments. Also ran
3296 3304 a full spellcheck on the manual (hadn't been done in a while).
3297 3305
3298 3306 2002-04-27 Fernando Perez <fperez@colorado.edu>
3299 3307
3300 3308 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3301 3309 starting a log in mid-session would reset the input history list.
3302 3310
3303 3311 2002-04-26 Fernando Perez <fperez@colorado.edu>
3304 3312
3305 3313 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3306 3314 all files were being included in an update. Now anything in
3307 3315 UserConfig that matches [A-Za-z]*.py will go (this excludes
3308 3316 __init__.py)
3309 3317
3310 3318 2002-04-25 Fernando Perez <fperez@colorado.edu>
3311 3319
3312 3320 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3313 3321 to __builtins__ so that any form of embedded or imported code can
3314 3322 test for being inside IPython.
3315 3323
3316 3324 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3317 3325 changed to GnuplotMagic because it's now an importable module,
3318 3326 this makes the name follow that of the standard Gnuplot module.
3319 3327 GnuplotMagic can now be loaded at any time in mid-session.
3320 3328
3321 3329 2002-04-24 Fernando Perez <fperez@colorado.edu>
3322 3330
3323 3331 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3324 3332 the globals (IPython has its own namespace) and the
3325 3333 PhysicalQuantity stuff is much better anyway.
3326 3334
3327 3335 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3328 3336 embedding example to standard user directory for
3329 3337 distribution. Also put it in the manual.
3330 3338
3331 3339 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3332 3340 instance as first argument (so it doesn't rely on some obscure
3333 3341 hidden global).
3334 3342
3335 3343 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3336 3344 delimiters. While it prevents ().TAB from working, it allows
3337 3345 completions in open (... expressions. This is by far a more common
3338 3346 case.
3339 3347
3340 3348 2002-04-23 Fernando Perez <fperez@colorado.edu>
3341 3349
3342 3350 * IPython/Extensions/InterpreterPasteInput.py: new
3343 3351 syntax-processing module for pasting lines with >>> or ... at the
3344 3352 start.
3345 3353
3346 3354 * IPython/Extensions/PhysicalQ_Interactive.py
3347 3355 (PhysicalQuantityInteractive.__int__): fixed to work with either
3348 3356 Numeric or math.
3349 3357
3350 3358 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3351 3359 provided profiles. Now we have:
3352 3360 -math -> math module as * and cmath with its own namespace.
3353 3361 -numeric -> Numeric as *, plus gnuplot & grace
3354 3362 -physics -> same as before
3355 3363
3356 3364 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3357 3365 user-defined magics wouldn't be found by @magic if they were
3358 3366 defined as class methods. Also cleaned up the namespace search
3359 3367 logic and the string building (to use %s instead of many repeated
3360 3368 string adds).
3361 3369
3362 3370 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3363 3371 of user-defined magics to operate with class methods (cleaner, in
3364 3372 line with the gnuplot code).
3365 3373
3366 3374 2002-04-22 Fernando Perez <fperez@colorado.edu>
3367 3375
3368 3376 * setup.py: updated dependency list so that manual is updated when
3369 3377 all included files change.
3370 3378
3371 3379 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3372 3380 the delimiter removal option (the fix is ugly right now).
3373 3381
3374 3382 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3375 3383 all of the math profile (quicker loading, no conflict between
3376 3384 g-9.8 and g-gnuplot).
3377 3385
3378 3386 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3379 3387 name of post-mortem files to IPython_crash_report.txt.
3380 3388
3381 3389 * Cleanup/update of the docs. Added all the new readline info and
3382 3390 formatted all lists as 'real lists'.
3383 3391
3384 3392 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3385 3393 tab-completion options, since the full readline parse_and_bind is
3386 3394 now accessible.
3387 3395
3388 3396 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3389 3397 handling of readline options. Now users can specify any string to
3390 3398 be passed to parse_and_bind(), as well as the delimiters to be
3391 3399 removed.
3392 3400 (InteractiveShell.__init__): Added __name__ to the global
3393 3401 namespace so that things like Itpl which rely on its existence
3394 3402 don't crash.
3395 3403 (InteractiveShell._prefilter): Defined the default with a _ so
3396 3404 that prefilter() is easier to override, while the default one
3397 3405 remains available.
3398 3406
3399 3407 2002-04-18 Fernando Perez <fperez@colorado.edu>
3400 3408
3401 3409 * Added information about pdb in the docs.
3402 3410
3403 3411 2002-04-17 Fernando Perez <fperez@colorado.edu>
3404 3412
3405 3413 * IPython/ipmaker.py (make_IPython): added rc_override option to
3406 3414 allow passing config options at creation time which may override
3407 3415 anything set in the config files or command line. This is
3408 3416 particularly useful for configuring embedded instances.
3409 3417
3410 3418 2002-04-15 Fernando Perez <fperez@colorado.edu>
3411 3419
3412 3420 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3413 3421 crash embedded instances because of the input cache falling out of
3414 3422 sync with the output counter.
3415 3423
3416 3424 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3417 3425 mode which calls pdb after an uncaught exception in IPython itself.
3418 3426
3419 3427 2002-04-14 Fernando Perez <fperez@colorado.edu>
3420 3428
3421 3429 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3422 3430 readline, fix it back after each call.
3423 3431
3424 3432 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3425 3433 method to force all access via __call__(), which guarantees that
3426 3434 traceback references are properly deleted.
3427 3435
3428 3436 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3429 3437 improve printing when pprint is in use.
3430 3438
3431 3439 2002-04-13 Fernando Perez <fperez@colorado.edu>
3432 3440
3433 3441 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3434 3442 exceptions aren't caught anymore. If the user triggers one, he
3435 3443 should know why he's doing it and it should go all the way up,
3436 3444 just like any other exception. So now @abort will fully kill the
3437 3445 embedded interpreter and the embedding code (unless that happens
3438 3446 to catch SystemExit).
3439 3447
3440 3448 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3441 3449 and a debugger() method to invoke the interactive pdb debugger
3442 3450 after printing exception information. Also added the corresponding
3443 3451 -pdb option and @pdb magic to control this feature, and updated
3444 3452 the docs. After a suggestion from Christopher Hart
3445 3453 (hart-AT-caltech.edu).
3446 3454
3447 3455 2002-04-12 Fernando Perez <fperez@colorado.edu>
3448 3456
3449 3457 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3450 3458 the exception handlers defined by the user (not the CrashHandler)
3451 3459 so that user exceptions don't trigger an ipython bug report.
3452 3460
3453 3461 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3454 3462 configurable (it should have always been so).
3455 3463
3456 3464 2002-03-26 Fernando Perez <fperez@colorado.edu>
3457 3465
3458 3466 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3459 3467 and there to fix embedding namespace issues. This should all be
3460 3468 done in a more elegant way.
3461 3469
3462 3470 2002-03-25 Fernando Perez <fperez@colorado.edu>
3463 3471
3464 3472 * IPython/genutils.py (get_home_dir): Try to make it work under
3465 3473 win9x also.
3466 3474
3467 3475 2002-03-20 Fernando Perez <fperez@colorado.edu>
3468 3476
3469 3477 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3470 3478 sys.displayhook untouched upon __init__.
3471 3479
3472 3480 2002-03-19 Fernando Perez <fperez@colorado.edu>
3473 3481
3474 3482 * Released 0.2.9 (for embedding bug, basically).
3475 3483
3476 3484 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3477 3485 exceptions so that enclosing shell's state can be restored.
3478 3486
3479 3487 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3480 3488 naming conventions in the .ipython/ dir.
3481 3489
3482 3490 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3483 3491 from delimiters list so filenames with - in them get expanded.
3484 3492
3485 3493 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3486 3494 sys.displayhook not being properly restored after an embedded call.
3487 3495
3488 3496 2002-03-18 Fernando Perez <fperez@colorado.edu>
3489 3497
3490 3498 * Released 0.2.8
3491 3499
3492 3500 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3493 3501 some files weren't being included in a -upgrade.
3494 3502 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3495 3503 on' so that the first tab completes.
3496 3504 (InteractiveShell.handle_magic): fixed bug with spaces around
3497 3505 quotes breaking many magic commands.
3498 3506
3499 3507 * setup.py: added note about ignoring the syntax error messages at
3500 3508 installation.
3501 3509
3502 3510 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3503 3511 streamlining the gnuplot interface, now there's only one magic @gp.
3504 3512
3505 3513 2002-03-17 Fernando Perez <fperez@colorado.edu>
3506 3514
3507 3515 * IPython/UserConfig/magic_gnuplot.py: new name for the
3508 3516 example-magic_pm.py file. Much enhanced system, now with a shell
3509 3517 for communicating directly with gnuplot, one command at a time.
3510 3518
3511 3519 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3512 3520 setting __name__=='__main__'.
3513 3521
3514 3522 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3515 3523 mini-shell for accessing gnuplot from inside ipython. Should
3516 3524 extend it later for grace access too. Inspired by Arnd's
3517 3525 suggestion.
3518 3526
3519 3527 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3520 3528 calling magic functions with () in their arguments. Thanks to Arnd
3521 3529 Baecker for pointing this to me.
3522 3530
3523 3531 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3524 3532 infinitely for integer or complex arrays (only worked with floats).
3525 3533
3526 3534 2002-03-16 Fernando Perez <fperez@colorado.edu>
3527 3535
3528 3536 * setup.py: Merged setup and setup_windows into a single script
3529 3537 which properly handles things for windows users.
3530 3538
3531 3539 2002-03-15 Fernando Perez <fperez@colorado.edu>
3532 3540
3533 3541 * Big change to the manual: now the magics are all automatically
3534 3542 documented. This information is generated from their docstrings
3535 3543 and put in a latex file included by the manual lyx file. This way
3536 3544 we get always up to date information for the magics. The manual
3537 3545 now also has proper version information, also auto-synced.
3538 3546
3539 3547 For this to work, an undocumented --magic_docstrings option was added.
3540 3548
3541 3549 2002-03-13 Fernando Perez <fperez@colorado.edu>
3542 3550
3543 3551 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3544 3552 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3545 3553
3546 3554 2002-03-12 Fernando Perez <fperez@colorado.edu>
3547 3555
3548 3556 * IPython/ultraTB.py (TermColors): changed color escapes again to
3549 3557 fix the (old, reintroduced) line-wrapping bug. Basically, if
3550 3558 \001..\002 aren't given in the color escapes, lines get wrapped
3551 3559 weirdly. But giving those screws up old xterms and emacs terms. So
3552 3560 I added some logic for emacs terms to be ok, but I can't identify old
3553 3561 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3554 3562
3555 3563 2002-03-10 Fernando Perez <fperez@colorado.edu>
3556 3564
3557 3565 * IPython/usage.py (__doc__): Various documentation cleanups and
3558 3566 updates, both in usage docstrings and in the manual.
3559 3567
3560 3568 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3561 3569 handling of caching. Set minimum acceptabe value for having a
3562 3570 cache at 20 values.
3563 3571
3564 3572 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3565 3573 install_first_time function to a method, renamed it and added an
3566 3574 'upgrade' mode. Now people can update their config directory with
3567 3575 a simple command line switch (-upgrade, also new).
3568 3576
3569 3577 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3570 3578 @file (convenient for automagic users under Python >= 2.2).
3571 3579 Removed @files (it seemed more like a plural than an abbrev. of
3572 3580 'file show').
3573 3581
3574 3582 * IPython/iplib.py (install_first_time): Fixed crash if there were
3575 3583 backup files ('~') in .ipython/ install directory.
3576 3584
3577 3585 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3578 3586 system. Things look fine, but these changes are fairly
3579 3587 intrusive. Test them for a few days.
3580 3588
3581 3589 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3582 3590 the prompts system. Now all in/out prompt strings are user
3583 3591 controllable. This is particularly useful for embedding, as one
3584 3592 can tag embedded instances with particular prompts.
3585 3593
3586 3594 Also removed global use of sys.ps1/2, which now allows nested
3587 3595 embeddings without any problems. Added command-line options for
3588 3596 the prompt strings.
3589 3597
3590 3598 2002-03-08 Fernando Perez <fperez@colorado.edu>
3591 3599
3592 3600 * IPython/UserConfig/example-embed-short.py (ipshell): added
3593 3601 example file with the bare minimum code for embedding.
3594 3602
3595 3603 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3596 3604 functionality for the embeddable shell to be activated/deactivated
3597 3605 either globally or at each call.
3598 3606
3599 3607 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3600 3608 rewriting the prompt with '--->' for auto-inputs with proper
3601 3609 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3602 3610 this is handled by the prompts class itself, as it should.
3603 3611
3604 3612 2002-03-05 Fernando Perez <fperez@colorado.edu>
3605 3613
3606 3614 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3607 3615 @logstart to avoid name clashes with the math log function.
3608 3616
3609 3617 * Big updates to X/Emacs section of the manual.
3610 3618
3611 3619 * Removed ipython_emacs. Milan explained to me how to pass
3612 3620 arguments to ipython through Emacs. Some day I'm going to end up
3613 3621 learning some lisp...
3614 3622
3615 3623 2002-03-04 Fernando Perez <fperez@colorado.edu>
3616 3624
3617 3625 * IPython/ipython_emacs: Created script to be used as the
3618 3626 py-python-command Emacs variable so we can pass IPython
3619 3627 parameters. I can't figure out how to tell Emacs directly to pass
3620 3628 parameters to IPython, so a dummy shell script will do it.
3621 3629
3622 3630 Other enhancements made for things to work better under Emacs'
3623 3631 various types of terminals. Many thanks to Milan Zamazal
3624 3632 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3625 3633
3626 3634 2002-03-01 Fernando Perez <fperez@colorado.edu>
3627 3635
3628 3636 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3629 3637 that loading of readline is now optional. This gives better
3630 3638 control to emacs users.
3631 3639
3632 3640 * IPython/ultraTB.py (__date__): Modified color escape sequences
3633 3641 and now things work fine under xterm and in Emacs' term buffers
3634 3642 (though not shell ones). Well, in emacs you get colors, but all
3635 3643 seem to be 'light' colors (no difference between dark and light
3636 3644 ones). But the garbage chars are gone, and also in xterms. It
3637 3645 seems that now I'm using 'cleaner' ansi sequences.
3638 3646
3639 3647 2002-02-21 Fernando Perez <fperez@colorado.edu>
3640 3648
3641 3649 * Released 0.2.7 (mainly to publish the scoping fix).
3642 3650
3643 3651 * IPython/Logger.py (Logger.logstate): added. A corresponding
3644 3652 @logstate magic was created.
3645 3653
3646 3654 * IPython/Magic.py: fixed nested scoping problem under Python
3647 3655 2.1.x (automagic wasn't working).
3648 3656
3649 3657 2002-02-20 Fernando Perez <fperez@colorado.edu>
3650 3658
3651 3659 * Released 0.2.6.
3652 3660
3653 3661 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3654 3662 option so that logs can come out without any headers at all.
3655 3663
3656 3664 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3657 3665 SciPy.
3658 3666
3659 3667 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3660 3668 that embedded IPython calls don't require vars() to be explicitly
3661 3669 passed. Now they are extracted from the caller's frame (code
3662 3670 snatched from Eric Jones' weave). Added better documentation to
3663 3671 the section on embedding and the example file.
3664 3672
3665 3673 * IPython/genutils.py (page): Changed so that under emacs, it just
3666 3674 prints the string. You can then page up and down in the emacs
3667 3675 buffer itself. This is how the builtin help() works.
3668 3676
3669 3677 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3670 3678 macro scoping: macros need to be executed in the user's namespace
3671 3679 to work as if they had been typed by the user.
3672 3680
3673 3681 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3674 3682 execute automatically (no need to type 'exec...'). They then
3675 3683 behave like 'true macros'. The printing system was also modified
3676 3684 for this to work.
3677 3685
3678 3686 2002-02-19 Fernando Perez <fperez@colorado.edu>
3679 3687
3680 3688 * IPython/genutils.py (page_file): new function for paging files
3681 3689 in an OS-independent way. Also necessary for file viewing to work
3682 3690 well inside Emacs buffers.
3683 3691 (page): Added checks for being in an emacs buffer.
3684 3692 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3685 3693 same bug in iplib.
3686 3694
3687 3695 2002-02-18 Fernando Perez <fperez@colorado.edu>
3688 3696
3689 3697 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3690 3698 of readline so that IPython can work inside an Emacs buffer.
3691 3699
3692 3700 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3693 3701 method signatures (they weren't really bugs, but it looks cleaner
3694 3702 and keeps PyChecker happy).
3695 3703
3696 3704 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3697 3705 for implementing various user-defined hooks. Currently only
3698 3706 display is done.
3699 3707
3700 3708 * IPython/Prompts.py (CachedOutput._display): changed display
3701 3709 functions so that they can be dynamically changed by users easily.
3702 3710
3703 3711 * IPython/Extensions/numeric_formats.py (num_display): added an
3704 3712 extension for printing NumPy arrays in flexible manners. It
3705 3713 doesn't do anything yet, but all the structure is in
3706 3714 place. Ultimately the plan is to implement output format control
3707 3715 like in Octave.
3708 3716
3709 3717 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3710 3718 methods are found at run-time by all the automatic machinery.
3711 3719
3712 3720 2002-02-17 Fernando Perez <fperez@colorado.edu>
3713 3721
3714 3722 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3715 3723 whole file a little.
3716 3724
3717 3725 * ToDo: closed this document. Now there's a new_design.lyx
3718 3726 document for all new ideas. Added making a pdf of it for the
3719 3727 end-user distro.
3720 3728
3721 3729 * IPython/Logger.py (Logger.switch_log): Created this to replace
3722 3730 logon() and logoff(). It also fixes a nasty crash reported by
3723 3731 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3724 3732
3725 3733 * IPython/iplib.py (complete): got auto-completion to work with
3726 3734 automagic (I had wanted this for a long time).
3727 3735
3728 3736 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3729 3737 to @file, since file() is now a builtin and clashes with automagic
3730 3738 for @file.
3731 3739
3732 3740 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3733 3741 of this was previously in iplib, which had grown to more than 2000
3734 3742 lines, way too long. No new functionality, but it makes managing
3735 3743 the code a bit easier.
3736 3744
3737 3745 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3738 3746 information to crash reports.
3739 3747
3740 3748 2002-02-12 Fernando Perez <fperez@colorado.edu>
3741 3749
3742 3750 * Released 0.2.5.
3743 3751
3744 3752 2002-02-11 Fernando Perez <fperez@colorado.edu>
3745 3753
3746 3754 * Wrote a relatively complete Windows installer. It puts
3747 3755 everything in place, creates Start Menu entries and fixes the
3748 3756 color issues. Nothing fancy, but it works.
3749 3757
3750 3758 2002-02-10 Fernando Perez <fperez@colorado.edu>
3751 3759
3752 3760 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3753 3761 os.path.expanduser() call so that we can type @run ~/myfile.py and
3754 3762 have thigs work as expected.
3755 3763
3756 3764 * IPython/genutils.py (page): fixed exception handling so things
3757 3765 work both in Unix and Windows correctly. Quitting a pager triggers
3758 3766 an IOError/broken pipe in Unix, and in windows not finding a pager
3759 3767 is also an IOError, so I had to actually look at the return value
3760 3768 of the exception, not just the exception itself. Should be ok now.
3761 3769
3762 3770 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3763 3771 modified to allow case-insensitive color scheme changes.
3764 3772
3765 3773 2002-02-09 Fernando Perez <fperez@colorado.edu>
3766 3774
3767 3775 * IPython/genutils.py (native_line_ends): new function to leave
3768 3776 user config files with os-native line-endings.
3769 3777
3770 3778 * README and manual updates.
3771 3779
3772 3780 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3773 3781 instead of StringType to catch Unicode strings.
3774 3782
3775 3783 * IPython/genutils.py (filefind): fixed bug for paths with
3776 3784 embedded spaces (very common in Windows).
3777 3785
3778 3786 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3779 3787 files under Windows, so that they get automatically associated
3780 3788 with a text editor. Windows makes it a pain to handle
3781 3789 extension-less files.
3782 3790
3783 3791 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3784 3792 warning about readline only occur for Posix. In Windows there's no
3785 3793 way to get readline, so why bother with the warning.
3786 3794
3787 3795 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3788 3796 for __str__ instead of dir(self), since dir() changed in 2.2.
3789 3797
3790 3798 * Ported to Windows! Tested on XP, I suspect it should work fine
3791 3799 on NT/2000, but I don't think it will work on 98 et al. That
3792 3800 series of Windows is such a piece of junk anyway that I won't try
3793 3801 porting it there. The XP port was straightforward, showed a few
3794 3802 bugs here and there (fixed all), in particular some string
3795 3803 handling stuff which required considering Unicode strings (which
3796 3804 Windows uses). This is good, but hasn't been too tested :) No
3797 3805 fancy installer yet, I'll put a note in the manual so people at
3798 3806 least make manually a shortcut.
3799 3807
3800 3808 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3801 3809 into a single one, "colors". This now controls both prompt and
3802 3810 exception color schemes, and can be changed both at startup
3803 3811 (either via command-line switches or via ipythonrc files) and at
3804 3812 runtime, with @colors.
3805 3813 (Magic.magic_run): renamed @prun to @run and removed the old
3806 3814 @run. The two were too similar to warrant keeping both.
3807 3815
3808 3816 2002-02-03 Fernando Perez <fperez@colorado.edu>
3809 3817
3810 3818 * IPython/iplib.py (install_first_time): Added comment on how to
3811 3819 configure the color options for first-time users. Put a <return>
3812 3820 request at the end so that small-terminal users get a chance to
3813 3821 read the startup info.
3814 3822
3815 3823 2002-01-23 Fernando Perez <fperez@colorado.edu>
3816 3824
3817 3825 * IPython/iplib.py (CachedOutput.update): Changed output memory
3818 3826 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3819 3827 input history we still use _i. Did this b/c these variable are
3820 3828 very commonly used in interactive work, so the less we need to
3821 3829 type the better off we are.
3822 3830 (Magic.magic_prun): updated @prun to better handle the namespaces
3823 3831 the file will run in, including a fix for __name__ not being set
3824 3832 before.
3825 3833
3826 3834 2002-01-20 Fernando Perez <fperez@colorado.edu>
3827 3835
3828 3836 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3829 3837 extra garbage for Python 2.2. Need to look more carefully into
3830 3838 this later.
3831 3839
3832 3840 2002-01-19 Fernando Perez <fperez@colorado.edu>
3833 3841
3834 3842 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3835 3843 display SyntaxError exceptions properly formatted when they occur
3836 3844 (they can be triggered by imported code).
3837 3845
3838 3846 2002-01-18 Fernando Perez <fperez@colorado.edu>
3839 3847
3840 3848 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3841 3849 SyntaxError exceptions are reported nicely formatted, instead of
3842 3850 spitting out only offset information as before.
3843 3851 (Magic.magic_prun): Added the @prun function for executing
3844 3852 programs with command line args inside IPython.
3845 3853
3846 3854 2002-01-16 Fernando Perez <fperez@colorado.edu>
3847 3855
3848 3856 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3849 3857 to *not* include the last item given in a range. This brings their
3850 3858 behavior in line with Python's slicing:
3851 3859 a[n1:n2] -> a[n1]...a[n2-1]
3852 3860 It may be a bit less convenient, but I prefer to stick to Python's
3853 3861 conventions *everywhere*, so users never have to wonder.
3854 3862 (Magic.magic_macro): Added @macro function to ease the creation of
3855 3863 macros.
3856 3864
3857 3865 2002-01-05 Fernando Perez <fperez@colorado.edu>
3858 3866
3859 3867 * Released 0.2.4.
3860 3868
3861 3869 * IPython/iplib.py (Magic.magic_pdef):
3862 3870 (InteractiveShell.safe_execfile): report magic lines and error
3863 3871 lines without line numbers so one can easily copy/paste them for
3864 3872 re-execution.
3865 3873
3866 3874 * Updated manual with recent changes.
3867 3875
3868 3876 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3869 3877 docstring printing when class? is called. Very handy for knowing
3870 3878 how to create class instances (as long as __init__ is well
3871 3879 documented, of course :)
3872 3880 (Magic.magic_doc): print both class and constructor docstrings.
3873 3881 (Magic.magic_pdef): give constructor info if passed a class and
3874 3882 __call__ info for callable object instances.
3875 3883
3876 3884 2002-01-04 Fernando Perez <fperez@colorado.edu>
3877 3885
3878 3886 * Made deep_reload() off by default. It doesn't always work
3879 3887 exactly as intended, so it's probably safer to have it off. It's
3880 3888 still available as dreload() anyway, so nothing is lost.
3881 3889
3882 3890 2002-01-02 Fernando Perez <fperez@colorado.edu>
3883 3891
3884 3892 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3885 3893 so I wanted an updated release).
3886 3894
3887 3895 2001-12-27 Fernando Perez <fperez@colorado.edu>
3888 3896
3889 3897 * IPython/iplib.py (InteractiveShell.interact): Added the original
3890 3898 code from 'code.py' for this module in order to change the
3891 3899 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3892 3900 the history cache would break when the user hit Ctrl-C, and
3893 3901 interact() offers no way to add any hooks to it.
3894 3902
3895 3903 2001-12-23 Fernando Perez <fperez@colorado.edu>
3896 3904
3897 3905 * setup.py: added check for 'MANIFEST' before trying to remove
3898 3906 it. Thanks to Sean Reifschneider.
3899 3907
3900 3908 2001-12-22 Fernando Perez <fperez@colorado.edu>
3901 3909
3902 3910 * Released 0.2.2.
3903 3911
3904 3912 * Finished (reasonably) writing the manual. Later will add the
3905 3913 python-standard navigation stylesheets, but for the time being
3906 3914 it's fairly complete. Distribution will include html and pdf
3907 3915 versions.
3908 3916
3909 3917 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3910 3918 (MayaVi author).
3911 3919
3912 3920 2001-12-21 Fernando Perez <fperez@colorado.edu>
3913 3921
3914 3922 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3915 3923 good public release, I think (with the manual and the distutils
3916 3924 installer). The manual can use some work, but that can go
3917 3925 slowly. Otherwise I think it's quite nice for end users. Next
3918 3926 summer, rewrite the guts of it...
3919 3927
3920 3928 * Changed format of ipythonrc files to use whitespace as the
3921 3929 separator instead of an explicit '='. Cleaner.
3922 3930
3923 3931 2001-12-20 Fernando Perez <fperez@colorado.edu>
3924 3932
3925 3933 * Started a manual in LyX. For now it's just a quick merge of the
3926 3934 various internal docstrings and READMEs. Later it may grow into a
3927 3935 nice, full-blown manual.
3928 3936
3929 3937 * Set up a distutils based installer. Installation should now be
3930 3938 trivially simple for end-users.
3931 3939
3932 3940 2001-12-11 Fernando Perez <fperez@colorado.edu>
3933 3941
3934 3942 * Released 0.2.0. First public release, announced it at
3935 3943 comp.lang.python. From now on, just bugfixes...
3936 3944
3937 3945 * Went through all the files, set copyright/license notices and
3938 3946 cleaned up things. Ready for release.
3939 3947
3940 3948 2001-12-10 Fernando Perez <fperez@colorado.edu>
3941 3949
3942 3950 * Changed the first-time installer not to use tarfiles. It's more
3943 3951 robust now and less unix-dependent. Also makes it easier for
3944 3952 people to later upgrade versions.
3945 3953
3946 3954 * Changed @exit to @abort to reflect the fact that it's pretty
3947 3955 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3948 3956 becomes significant only when IPyhton is embedded: in that case,
3949 3957 C-D closes IPython only, but @abort kills the enclosing program
3950 3958 too (unless it had called IPython inside a try catching
3951 3959 SystemExit).
3952 3960
3953 3961 * Created Shell module which exposes the actuall IPython Shell
3954 3962 classes, currently the normal and the embeddable one. This at
3955 3963 least offers a stable interface we won't need to change when
3956 3964 (later) the internals are rewritten. That rewrite will be confined
3957 3965 to iplib and ipmaker, but the Shell interface should remain as is.
3958 3966
3959 3967 * Added embed module which offers an embeddable IPShell object,
3960 3968 useful to fire up IPython *inside* a running program. Great for
3961 3969 debugging or dynamical data analysis.
3962 3970
3963 3971 2001-12-08 Fernando Perez <fperez@colorado.edu>
3964 3972
3965 3973 * Fixed small bug preventing seeing info from methods of defined
3966 3974 objects (incorrect namespace in _ofind()).
3967 3975
3968 3976 * Documentation cleanup. Moved the main usage docstrings to a
3969 3977 separate file, usage.py (cleaner to maintain, and hopefully in the
3970 3978 future some perlpod-like way of producing interactive, man and
3971 3979 html docs out of it will be found).
3972 3980
3973 3981 * Added @profile to see your profile at any time.
3974 3982
3975 3983 * Added @p as an alias for 'print'. It's especially convenient if
3976 3984 using automagic ('p x' prints x).
3977 3985
3978 3986 * Small cleanups and fixes after a pychecker run.
3979 3987
3980 3988 * Changed the @cd command to handle @cd - and @cd -<n> for
3981 3989 visiting any directory in _dh.
3982 3990
3983 3991 * Introduced _dh, a history of visited directories. @dhist prints
3984 3992 it out with numbers.
3985 3993
3986 3994 2001-12-07 Fernando Perez <fperez@colorado.edu>
3987 3995
3988 3996 * Released 0.1.22
3989 3997
3990 3998 * Made initialization a bit more robust against invalid color
3991 3999 options in user input (exit, not traceback-crash).
3992 4000
3993 4001 * Changed the bug crash reporter to write the report only in the
3994 4002 user's .ipython directory. That way IPython won't litter people's
3995 4003 hard disks with crash files all over the place. Also print on
3996 4004 screen the necessary mail command.
3997 4005
3998 4006 * With the new ultraTB, implemented LightBG color scheme for light
3999 4007 background terminals. A lot of people like white backgrounds, so I
4000 4008 guess we should at least give them something readable.
4001 4009
4002 4010 2001-12-06 Fernando Perez <fperez@colorado.edu>
4003 4011
4004 4012 * Modified the structure of ultraTB. Now there's a proper class
4005 4013 for tables of color schemes which allow adding schemes easily and
4006 4014 switching the active scheme without creating a new instance every
4007 4015 time (which was ridiculous). The syntax for creating new schemes
4008 4016 is also cleaner. I think ultraTB is finally done, with a clean
4009 4017 class structure. Names are also much cleaner (now there's proper
4010 4018 color tables, no need for every variable to also have 'color' in
4011 4019 its name).
4012 4020
4013 4021 * Broke down genutils into separate files. Now genutils only
4014 4022 contains utility functions, and classes have been moved to their
4015 4023 own files (they had enough independent functionality to warrant
4016 4024 it): ConfigLoader, OutputTrap, Struct.
4017 4025
4018 4026 2001-12-05 Fernando Perez <fperez@colorado.edu>
4019 4027
4020 4028 * IPython turns 21! Released version 0.1.21, as a candidate for
4021 4029 public consumption. If all goes well, release in a few days.
4022 4030
4023 4031 * Fixed path bug (files in Extensions/ directory wouldn't be found
4024 4032 unless IPython/ was explicitly in sys.path).
4025 4033
4026 4034 * Extended the FlexCompleter class as MagicCompleter to allow
4027 4035 completion of @-starting lines.
4028 4036
4029 4037 * Created __release__.py file as a central repository for release
4030 4038 info that other files can read from.
4031 4039
4032 4040 * Fixed small bug in logging: when logging was turned on in
4033 4041 mid-session, old lines with special meanings (!@?) were being
4034 4042 logged without the prepended comment, which is necessary since
4035 4043 they are not truly valid python syntax. This should make session
4036 4044 restores produce less errors.
4037 4045
4038 4046 * The namespace cleanup forced me to make a FlexCompleter class
4039 4047 which is nothing but a ripoff of rlcompleter, but with selectable
4040 4048 namespace (rlcompleter only works in __main__.__dict__). I'll try
4041 4049 to submit a note to the authors to see if this change can be
4042 4050 incorporated in future rlcompleter releases (Dec.6: done)
4043 4051
4044 4052 * More fixes to namespace handling. It was a mess! Now all
4045 4053 explicit references to __main__.__dict__ are gone (except when
4046 4054 really needed) and everything is handled through the namespace
4047 4055 dicts in the IPython instance. We seem to be getting somewhere
4048 4056 with this, finally...
4049 4057
4050 4058 * Small documentation updates.
4051 4059
4052 4060 * Created the Extensions directory under IPython (with an
4053 4061 __init__.py). Put the PhysicalQ stuff there. This directory should
4054 4062 be used for all special-purpose extensions.
4055 4063
4056 4064 * File renaming:
4057 4065 ipythonlib --> ipmaker
4058 4066 ipplib --> iplib
4059 4067 This makes a bit more sense in terms of what these files actually do.
4060 4068
4061 4069 * Moved all the classes and functions in ipythonlib to ipplib, so
4062 4070 now ipythonlib only has make_IPython(). This will ease up its
4063 4071 splitting in smaller functional chunks later.
4064 4072
4065 4073 * Cleaned up (done, I think) output of @whos. Better column
4066 4074 formatting, and now shows str(var) for as much as it can, which is
4067 4075 typically what one gets with a 'print var'.
4068 4076
4069 4077 2001-12-04 Fernando Perez <fperez@colorado.edu>
4070 4078
4071 4079 * Fixed namespace problems. Now builtin/IPyhton/user names get
4072 4080 properly reported in their namespace. Internal namespace handling
4073 4081 is finally getting decent (not perfect yet, but much better than
4074 4082 the ad-hoc mess we had).
4075 4083
4076 4084 * Removed -exit option. If people just want to run a python
4077 4085 script, that's what the normal interpreter is for. Less
4078 4086 unnecessary options, less chances for bugs.
4079 4087
4080 4088 * Added a crash handler which generates a complete post-mortem if
4081 4089 IPython crashes. This will help a lot in tracking bugs down the
4082 4090 road.
4083 4091
4084 4092 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4085 4093 which were boud to functions being reassigned would bypass the
4086 4094 logger, breaking the sync of _il with the prompt counter. This
4087 4095 would then crash IPython later when a new line was logged.
4088 4096
4089 4097 2001-12-02 Fernando Perez <fperez@colorado.edu>
4090 4098
4091 4099 * Made IPython a package. This means people don't have to clutter
4092 4100 their sys.path with yet another directory. Changed the INSTALL
4093 4101 file accordingly.
4094 4102
4095 4103 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4096 4104 sorts its output (so @who shows it sorted) and @whos formats the
4097 4105 table according to the width of the first column. Nicer, easier to
4098 4106 read. Todo: write a generic table_format() which takes a list of
4099 4107 lists and prints it nicely formatted, with optional row/column
4100 4108 separators and proper padding and justification.
4101 4109
4102 4110 * Released 0.1.20
4103 4111
4104 4112 * Fixed bug in @log which would reverse the inputcache list (a
4105 4113 copy operation was missing).
4106 4114
4107 4115 * Code cleanup. @config was changed to use page(). Better, since
4108 4116 its output is always quite long.
4109 4117
4110 4118 * Itpl is back as a dependency. I was having too many problems
4111 4119 getting the parametric aliases to work reliably, and it's just
4112 4120 easier to code weird string operations with it than playing %()s
4113 4121 games. It's only ~6k, so I don't think it's too big a deal.
4114 4122
4115 4123 * Found (and fixed) a very nasty bug with history. !lines weren't
4116 4124 getting cached, and the out of sync caches would crash
4117 4125 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4118 4126 division of labor a bit better. Bug fixed, cleaner structure.
4119 4127
4120 4128 2001-12-01 Fernando Perez <fperez@colorado.edu>
4121 4129
4122 4130 * Released 0.1.19
4123 4131
4124 4132 * Added option -n to @hist to prevent line number printing. Much
4125 4133 easier to copy/paste code this way.
4126 4134
4127 4135 * Created global _il to hold the input list. Allows easy
4128 4136 re-execution of blocks of code by slicing it (inspired by Janko's
4129 4137 comment on 'macros').
4130 4138
4131 4139 * Small fixes and doc updates.
4132 4140
4133 4141 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4134 4142 much too fragile with automagic. Handles properly multi-line
4135 4143 statements and takes parameters.
4136 4144
4137 4145 2001-11-30 Fernando Perez <fperez@colorado.edu>
4138 4146
4139 4147 * Version 0.1.18 released.
4140 4148
4141 4149 * Fixed nasty namespace bug in initial module imports.
4142 4150
4143 4151 * Added copyright/license notes to all code files (except
4144 4152 DPyGetOpt). For the time being, LGPL. That could change.
4145 4153
4146 4154 * Rewrote a much nicer README, updated INSTALL, cleaned up
4147 4155 ipythonrc-* samples.
4148 4156
4149 4157 * Overall code/documentation cleanup. Basically ready for
4150 4158 release. Only remaining thing: licence decision (LGPL?).
4151 4159
4152 4160 * Converted load_config to a class, ConfigLoader. Now recursion
4153 4161 control is better organized. Doesn't include the same file twice.
4154 4162
4155 4163 2001-11-29 Fernando Perez <fperez@colorado.edu>
4156 4164
4157 4165 * Got input history working. Changed output history variables from
4158 4166 _p to _o so that _i is for input and _o for output. Just cleaner
4159 4167 convention.
4160 4168
4161 4169 * Implemented parametric aliases. This pretty much allows the
4162 4170 alias system to offer full-blown shell convenience, I think.
4163 4171
4164 4172 * Version 0.1.17 released, 0.1.18 opened.
4165 4173
4166 4174 * dot_ipython/ipythonrc (alias): added documentation.
4167 4175 (xcolor): Fixed small bug (xcolors -> xcolor)
4168 4176
4169 4177 * Changed the alias system. Now alias is a magic command to define
4170 4178 aliases just like the shell. Rationale: the builtin magics should
4171 4179 be there for things deeply connected to IPython's
4172 4180 architecture. And this is a much lighter system for what I think
4173 4181 is the really important feature: allowing users to define quickly
4174 4182 magics that will do shell things for them, so they can customize
4175 4183 IPython easily to match their work habits. If someone is really
4176 4184 desperate to have another name for a builtin alias, they can
4177 4185 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4178 4186 works.
4179 4187
4180 4188 2001-11-28 Fernando Perez <fperez@colorado.edu>
4181 4189
4182 4190 * Changed @file so that it opens the source file at the proper
4183 4191 line. Since it uses less, if your EDITOR environment is
4184 4192 configured, typing v will immediately open your editor of choice
4185 4193 right at the line where the object is defined. Not as quick as
4186 4194 having a direct @edit command, but for all intents and purposes it
4187 4195 works. And I don't have to worry about writing @edit to deal with
4188 4196 all the editors, less does that.
4189 4197
4190 4198 * Version 0.1.16 released, 0.1.17 opened.
4191 4199
4192 4200 * Fixed some nasty bugs in the page/page_dumb combo that could
4193 4201 crash IPython.
4194 4202
4195 4203 2001-11-27 Fernando Perez <fperez@colorado.edu>
4196 4204
4197 4205 * Version 0.1.15 released, 0.1.16 opened.
4198 4206
4199 4207 * Finally got ? and ?? to work for undefined things: now it's
4200 4208 possible to type {}.get? and get information about the get method
4201 4209 of dicts, or os.path? even if only os is defined (so technically
4202 4210 os.path isn't). Works at any level. For example, after import os,
4203 4211 os?, os.path?, os.path.abspath? all work. This is great, took some
4204 4212 work in _ofind.
4205 4213
4206 4214 * Fixed more bugs with logging. The sanest way to do it was to add
4207 4215 to @log a 'mode' parameter. Killed two in one shot (this mode
4208 4216 option was a request of Janko's). I think it's finally clean
4209 4217 (famous last words).
4210 4218
4211 4219 * Added a page_dumb() pager which does a decent job of paging on
4212 4220 screen, if better things (like less) aren't available. One less
4213 4221 unix dependency (someday maybe somebody will port this to
4214 4222 windows).
4215 4223
4216 4224 * Fixed problem in magic_log: would lock of logging out if log
4217 4225 creation failed (because it would still think it had succeeded).
4218 4226
4219 4227 * Improved the page() function using curses to auto-detect screen
4220 4228 size. Now it can make a much better decision on whether to print
4221 4229 or page a string. Option screen_length was modified: a value 0
4222 4230 means auto-detect, and that's the default now.
4223 4231
4224 4232 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4225 4233 go out. I'll test it for a few days, then talk to Janko about
4226 4234 licences and announce it.
4227 4235
4228 4236 * Fixed the length of the auto-generated ---> prompt which appears
4229 4237 for auto-parens and auto-quotes. Getting this right isn't trivial,
4230 4238 with all the color escapes, different prompt types and optional
4231 4239 separators. But it seems to be working in all the combinations.
4232 4240
4233 4241 2001-11-26 Fernando Perez <fperez@colorado.edu>
4234 4242
4235 4243 * Wrote a regexp filter to get option types from the option names
4236 4244 string. This eliminates the need to manually keep two duplicate
4237 4245 lists.
4238 4246
4239 4247 * Removed the unneeded check_option_names. Now options are handled
4240 4248 in a much saner manner and it's easy to visually check that things
4241 4249 are ok.
4242 4250
4243 4251 * Updated version numbers on all files I modified to carry a
4244 4252 notice so Janko and Nathan have clear version markers.
4245 4253
4246 4254 * Updated docstring for ultraTB with my changes. I should send
4247 4255 this to Nathan.
4248 4256
4249 4257 * Lots of small fixes. Ran everything through pychecker again.
4250 4258
4251 4259 * Made loading of deep_reload an cmd line option. If it's not too
4252 4260 kosher, now people can just disable it. With -nodeep_reload it's
4253 4261 still available as dreload(), it just won't overwrite reload().
4254 4262
4255 4263 * Moved many options to the no| form (-opt and -noopt
4256 4264 accepted). Cleaner.
4257 4265
4258 4266 * Changed magic_log so that if called with no parameters, it uses
4259 4267 'rotate' mode. That way auto-generated logs aren't automatically
4260 4268 over-written. For normal logs, now a backup is made if it exists
4261 4269 (only 1 level of backups). A new 'backup' mode was added to the
4262 4270 Logger class to support this. This was a request by Janko.
4263 4271
4264 4272 * Added @logoff/@logon to stop/restart an active log.
4265 4273
4266 4274 * Fixed a lot of bugs in log saving/replay. It was pretty
4267 4275 broken. Now special lines (!@,/) appear properly in the command
4268 4276 history after a log replay.
4269 4277
4270 4278 * Tried and failed to implement full session saving via pickle. My
4271 4279 idea was to pickle __main__.__dict__, but modules can't be
4272 4280 pickled. This would be a better alternative to replaying logs, but
4273 4281 seems quite tricky to get to work. Changed -session to be called
4274 4282 -logplay, which more accurately reflects what it does. And if we
4275 4283 ever get real session saving working, -session is now available.
4276 4284
4277 4285 * Implemented color schemes for prompts also. As for tracebacks,
4278 4286 currently only NoColor and Linux are supported. But now the
4279 4287 infrastructure is in place, based on a generic ColorScheme
4280 4288 class. So writing and activating new schemes both for the prompts
4281 4289 and the tracebacks should be straightforward.
4282 4290
4283 4291 * Version 0.1.13 released, 0.1.14 opened.
4284 4292
4285 4293 * Changed handling of options for output cache. Now counter is
4286 4294 hardwired starting at 1 and one specifies the maximum number of
4287 4295 entries *in the outcache* (not the max prompt counter). This is
4288 4296 much better, since many statements won't increase the cache
4289 4297 count. It also eliminated some confusing options, now there's only
4290 4298 one: cache_size.
4291 4299
4292 4300 * Added 'alias' magic function and magic_alias option in the
4293 4301 ipythonrc file. Now the user can easily define whatever names he
4294 4302 wants for the magic functions without having to play weird
4295 4303 namespace games. This gives IPython a real shell-like feel.
4296 4304
4297 4305 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4298 4306 @ or not).
4299 4307
4300 4308 This was one of the last remaining 'visible' bugs (that I know
4301 4309 of). I think if I can clean up the session loading so it works
4302 4310 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4303 4311 about licensing).
4304 4312
4305 4313 2001-11-25 Fernando Perez <fperez@colorado.edu>
4306 4314
4307 4315 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4308 4316 there's a cleaner distinction between what ? and ?? show.
4309 4317
4310 4318 * Added screen_length option. Now the user can define his own
4311 4319 screen size for page() operations.
4312 4320
4313 4321 * Implemented magic shell-like functions with automatic code
4314 4322 generation. Now adding another function is just a matter of adding
4315 4323 an entry to a dict, and the function is dynamically generated at
4316 4324 run-time. Python has some really cool features!
4317 4325
4318 4326 * Renamed many options to cleanup conventions a little. Now all
4319 4327 are lowercase, and only underscores where needed. Also in the code
4320 4328 option name tables are clearer.
4321 4329
4322 4330 * Changed prompts a little. Now input is 'In [n]:' instead of
4323 4331 'In[n]:='. This allows it the numbers to be aligned with the
4324 4332 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4325 4333 Python (it was a Mathematica thing). The '...' continuation prompt
4326 4334 was also changed a little to align better.
4327 4335
4328 4336 * Fixed bug when flushing output cache. Not all _p<n> variables
4329 4337 exist, so their deletion needs to be wrapped in a try:
4330 4338
4331 4339 * Figured out how to properly use inspect.formatargspec() (it
4332 4340 requires the args preceded by *). So I removed all the code from
4333 4341 _get_pdef in Magic, which was just replicating that.
4334 4342
4335 4343 * Added test to prefilter to allow redefining magic function names
4336 4344 as variables. This is ok, since the @ form is always available,
4337 4345 but whe should allow the user to define a variable called 'ls' if
4338 4346 he needs it.
4339 4347
4340 4348 * Moved the ToDo information from README into a separate ToDo.
4341 4349
4342 4350 * General code cleanup and small bugfixes. I think it's close to a
4343 4351 state where it can be released, obviously with a big 'beta'
4344 4352 warning on it.
4345 4353
4346 4354 * Got the magic function split to work. Now all magics are defined
4347 4355 in a separate class. It just organizes things a bit, and now
4348 4356 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4349 4357 was too long).
4350 4358
4351 4359 * Changed @clear to @reset to avoid potential confusions with
4352 4360 the shell command clear. Also renamed @cl to @clear, which does
4353 4361 exactly what people expect it to from their shell experience.
4354 4362
4355 4363 Added a check to the @reset command (since it's so
4356 4364 destructive, it's probably a good idea to ask for confirmation).
4357 4365 But now reset only works for full namespace resetting. Since the
4358 4366 del keyword is already there for deleting a few specific
4359 4367 variables, I don't see the point of having a redundant magic
4360 4368 function for the same task.
4361 4369
4362 4370 2001-11-24 Fernando Perez <fperez@colorado.edu>
4363 4371
4364 4372 * Updated the builtin docs (esp. the ? ones).
4365 4373
4366 4374 * Ran all the code through pychecker. Not terribly impressed with
4367 4375 it: lots of spurious warnings and didn't really find anything of
4368 4376 substance (just a few modules being imported and not used).
4369 4377
4370 4378 * Implemented the new ultraTB functionality into IPython. New
4371 4379 option: xcolors. This chooses color scheme. xmode now only selects
4372 4380 between Plain and Verbose. Better orthogonality.
4373 4381
4374 4382 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4375 4383 mode and color scheme for the exception handlers. Now it's
4376 4384 possible to have the verbose traceback with no coloring.
4377 4385
4378 4386 2001-11-23 Fernando Perez <fperez@colorado.edu>
4379 4387
4380 4388 * Version 0.1.12 released, 0.1.13 opened.
4381 4389
4382 4390 * Removed option to set auto-quote and auto-paren escapes by
4383 4391 user. The chances of breaking valid syntax are just too high. If
4384 4392 someone *really* wants, they can always dig into the code.
4385 4393
4386 4394 * Made prompt separators configurable.
4387 4395
4388 4396 2001-11-22 Fernando Perez <fperez@colorado.edu>
4389 4397
4390 4398 * Small bugfixes in many places.
4391 4399
4392 4400 * Removed the MyCompleter class from ipplib. It seemed redundant
4393 4401 with the C-p,C-n history search functionality. Less code to
4394 4402 maintain.
4395 4403
4396 4404 * Moved all the original ipython.py code into ipythonlib.py. Right
4397 4405 now it's just one big dump into a function called make_IPython, so
4398 4406 no real modularity has been gained. But at least it makes the
4399 4407 wrapper script tiny, and since ipythonlib is a module, it gets
4400 4408 compiled and startup is much faster.
4401 4409
4402 4410 This is a reasobably 'deep' change, so we should test it for a
4403 4411 while without messing too much more with the code.
4404 4412
4405 4413 2001-11-21 Fernando Perez <fperez@colorado.edu>
4406 4414
4407 4415 * Version 0.1.11 released, 0.1.12 opened for further work.
4408 4416
4409 4417 * Removed dependency on Itpl. It was only needed in one place. It
4410 4418 would be nice if this became part of python, though. It makes life
4411 4419 *a lot* easier in some cases.
4412 4420
4413 4421 * Simplified the prefilter code a bit. Now all handlers are
4414 4422 expected to explicitly return a value (at least a blank string).
4415 4423
4416 4424 * Heavy edits in ipplib. Removed the help system altogether. Now
4417 4425 obj?/?? is used for inspecting objects, a magic @doc prints
4418 4426 docstrings, and full-blown Python help is accessed via the 'help'
4419 4427 keyword. This cleans up a lot of code (less to maintain) and does
4420 4428 the job. Since 'help' is now a standard Python component, might as
4421 4429 well use it and remove duplicate functionality.
4422 4430
4423 4431 Also removed the option to use ipplib as a standalone program. By
4424 4432 now it's too dependent on other parts of IPython to function alone.
4425 4433
4426 4434 * Fixed bug in genutils.pager. It would crash if the pager was
4427 4435 exited immediately after opening (broken pipe).
4428 4436
4429 4437 * Trimmed down the VerboseTB reporting a little. The header is
4430 4438 much shorter now and the repeated exception arguments at the end
4431 4439 have been removed. For interactive use the old header seemed a bit
4432 4440 excessive.
4433 4441
4434 4442 * Fixed small bug in output of @whos for variables with multi-word
4435 4443 types (only first word was displayed).
4436 4444
4437 4445 2001-11-17 Fernando Perez <fperez@colorado.edu>
4438 4446
4439 4447 * Version 0.1.10 released, 0.1.11 opened for further work.
4440 4448
4441 4449 * Modified dirs and friends. dirs now *returns* the stack (not
4442 4450 prints), so one can manipulate it as a variable. Convenient to
4443 4451 travel along many directories.
4444 4452
4445 4453 * Fixed bug in magic_pdef: would only work with functions with
4446 4454 arguments with default values.
4447 4455
4448 4456 2001-11-14 Fernando Perez <fperez@colorado.edu>
4449 4457
4450 4458 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4451 4459 example with IPython. Various other minor fixes and cleanups.
4452 4460
4453 4461 * Version 0.1.9 released, 0.1.10 opened for further work.
4454 4462
4455 4463 * Added sys.path to the list of directories searched in the
4456 4464 execfile= option. It used to be the current directory and the
4457 4465 user's IPYTHONDIR only.
4458 4466
4459 4467 2001-11-13 Fernando Perez <fperez@colorado.edu>
4460 4468
4461 4469 * Reinstated the raw_input/prefilter separation that Janko had
4462 4470 initially. This gives a more convenient setup for extending the
4463 4471 pre-processor from the outside: raw_input always gets a string,
4464 4472 and prefilter has to process it. We can then redefine prefilter
4465 4473 from the outside and implement extensions for special
4466 4474 purposes.
4467 4475
4468 4476 Today I got one for inputting PhysicalQuantity objects
4469 4477 (from Scientific) without needing any function calls at
4470 4478 all. Extremely convenient, and it's all done as a user-level
4471 4479 extension (no IPython code was touched). Now instead of:
4472 4480 a = PhysicalQuantity(4.2,'m/s**2')
4473 4481 one can simply say
4474 4482 a = 4.2 m/s**2
4475 4483 or even
4476 4484 a = 4.2 m/s^2
4477 4485
4478 4486 I use this, but it's also a proof of concept: IPython really is
4479 4487 fully user-extensible, even at the level of the parsing of the
4480 4488 command line. It's not trivial, but it's perfectly doable.
4481 4489
4482 4490 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4483 4491 the problem of modules being loaded in the inverse order in which
4484 4492 they were defined in
4485 4493
4486 4494 * Version 0.1.8 released, 0.1.9 opened for further work.
4487 4495
4488 4496 * Added magics pdef, source and file. They respectively show the
4489 4497 definition line ('prototype' in C), source code and full python
4490 4498 file for any callable object. The object inspector oinfo uses
4491 4499 these to show the same information.
4492 4500
4493 4501 * Version 0.1.7 released, 0.1.8 opened for further work.
4494 4502
4495 4503 * Separated all the magic functions into a class called Magic. The
4496 4504 InteractiveShell class was becoming too big for Xemacs to handle
4497 4505 (de-indenting a line would lock it up for 10 seconds while it
4498 4506 backtracked on the whole class!)
4499 4507
4500 4508 FIXME: didn't work. It can be done, but right now namespaces are
4501 4509 all messed up. Do it later (reverted it for now, so at least
4502 4510 everything works as before).
4503 4511
4504 4512 * Got the object introspection system (magic_oinfo) working! I
4505 4513 think this is pretty much ready for release to Janko, so he can
4506 4514 test it for a while and then announce it. Pretty much 100% of what
4507 4515 I wanted for the 'phase 1' release is ready. Happy, tired.
4508 4516
4509 4517 2001-11-12 Fernando Perez <fperez@colorado.edu>
4510 4518
4511 4519 * Version 0.1.6 released, 0.1.7 opened for further work.
4512 4520
4513 4521 * Fixed bug in printing: it used to test for truth before
4514 4522 printing, so 0 wouldn't print. Now checks for None.
4515 4523
4516 4524 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4517 4525 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4518 4526 reaches by hand into the outputcache. Think of a better way to do
4519 4527 this later.
4520 4528
4521 4529 * Various small fixes thanks to Nathan's comments.
4522 4530
4523 4531 * Changed magic_pprint to magic_Pprint. This way it doesn't
4524 4532 collide with pprint() and the name is consistent with the command
4525 4533 line option.
4526 4534
4527 4535 * Changed prompt counter behavior to be fully like
4528 4536 Mathematica's. That is, even input that doesn't return a result
4529 4537 raises the prompt counter. The old behavior was kind of confusing
4530 4538 (getting the same prompt number several times if the operation
4531 4539 didn't return a result).
4532 4540
4533 4541 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4534 4542
4535 4543 * Fixed -Classic mode (wasn't working anymore).
4536 4544
4537 4545 * Added colored prompts using Nathan's new code. Colors are
4538 4546 currently hardwired, they can be user-configurable. For
4539 4547 developers, they can be chosen in file ipythonlib.py, at the
4540 4548 beginning of the CachedOutput class def.
4541 4549
4542 4550 2001-11-11 Fernando Perez <fperez@colorado.edu>
4543 4551
4544 4552 * Version 0.1.5 released, 0.1.6 opened for further work.
4545 4553
4546 4554 * Changed magic_env to *return* the environment as a dict (not to
4547 4555 print it). This way it prints, but it can also be processed.
4548 4556
4549 4557 * Added Verbose exception reporting to interactive
4550 4558 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4551 4559 traceback. Had to make some changes to the ultraTB file. This is
4552 4560 probably the last 'big' thing in my mental todo list. This ties
4553 4561 in with the next entry:
4554 4562
4555 4563 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4556 4564 has to specify is Plain, Color or Verbose for all exception
4557 4565 handling.
4558 4566
4559 4567 * Removed ShellServices option. All this can really be done via
4560 4568 the magic system. It's easier to extend, cleaner and has automatic
4561 4569 namespace protection and documentation.
4562 4570
4563 4571 2001-11-09 Fernando Perez <fperez@colorado.edu>
4564 4572
4565 4573 * Fixed bug in output cache flushing (missing parameter to
4566 4574 __init__). Other small bugs fixed (found using pychecker).
4567 4575
4568 4576 * Version 0.1.4 opened for bugfixing.
4569 4577
4570 4578 2001-11-07 Fernando Perez <fperez@colorado.edu>
4571 4579
4572 4580 * Version 0.1.3 released, mainly because of the raw_input bug.
4573 4581
4574 4582 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4575 4583 and when testing for whether things were callable, a call could
4576 4584 actually be made to certain functions. They would get called again
4577 4585 once 'really' executed, with a resulting double call. A disaster
4578 4586 in many cases (list.reverse() would never work!).
4579 4587
4580 4588 * Removed prefilter() function, moved its code to raw_input (which
4581 4589 after all was just a near-empty caller for prefilter). This saves
4582 4590 a function call on every prompt, and simplifies the class a tiny bit.
4583 4591
4584 4592 * Fix _ip to __ip name in magic example file.
4585 4593
4586 4594 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4587 4595 work with non-gnu versions of tar.
4588 4596
4589 4597 2001-11-06 Fernando Perez <fperez@colorado.edu>
4590 4598
4591 4599 * Version 0.1.2. Just to keep track of the recent changes.
4592 4600
4593 4601 * Fixed nasty bug in output prompt routine. It used to check 'if
4594 4602 arg != None...'. Problem is, this fails if arg implements a
4595 4603 special comparison (__cmp__) which disallows comparing to
4596 4604 None. Found it when trying to use the PhysicalQuantity module from
4597 4605 ScientificPython.
4598 4606
4599 4607 2001-11-05 Fernando Perez <fperez@colorado.edu>
4600 4608
4601 4609 * Also added dirs. Now the pushd/popd/dirs family functions
4602 4610 basically like the shell, with the added convenience of going home
4603 4611 when called with no args.
4604 4612
4605 4613 * pushd/popd slightly modified to mimic shell behavior more
4606 4614 closely.
4607 4615
4608 4616 * Added env,pushd,popd from ShellServices as magic functions. I
4609 4617 think the cleanest will be to port all desired functions from
4610 4618 ShellServices as magics and remove ShellServices altogether. This
4611 4619 will provide a single, clean way of adding functionality
4612 4620 (shell-type or otherwise) to IP.
4613 4621
4614 4622 2001-11-04 Fernando Perez <fperez@colorado.edu>
4615 4623
4616 4624 * Added .ipython/ directory to sys.path. This way users can keep
4617 4625 customizations there and access them via import.
4618 4626
4619 4627 2001-11-03 Fernando Perez <fperez@colorado.edu>
4620 4628
4621 4629 * Opened version 0.1.1 for new changes.
4622 4630
4623 4631 * Changed version number to 0.1.0: first 'public' release, sent to
4624 4632 Nathan and Janko.
4625 4633
4626 4634 * Lots of small fixes and tweaks.
4627 4635
4628 4636 * Minor changes to whos format. Now strings are shown, snipped if
4629 4637 too long.
4630 4638
4631 4639 * Changed ShellServices to work on __main__ so they show up in @who
4632 4640
4633 4641 * Help also works with ? at the end of a line:
4634 4642 ?sin and sin?
4635 4643 both produce the same effect. This is nice, as often I use the
4636 4644 tab-complete to find the name of a method, but I used to then have
4637 4645 to go to the beginning of the line to put a ? if I wanted more
4638 4646 info. Now I can just add the ? and hit return. Convenient.
4639 4647
4640 4648 2001-11-02 Fernando Perez <fperez@colorado.edu>
4641 4649
4642 4650 * Python version check (>=2.1) added.
4643 4651
4644 4652 * Added LazyPython documentation. At this point the docs are quite
4645 4653 a mess. A cleanup is in order.
4646 4654
4647 4655 * Auto-installer created. For some bizarre reason, the zipfiles
4648 4656 module isn't working on my system. So I made a tar version
4649 4657 (hopefully the command line options in various systems won't kill
4650 4658 me).
4651 4659
4652 4660 * Fixes to Struct in genutils. Now all dictionary-like methods are
4653 4661 protected (reasonably).
4654 4662
4655 4663 * Added pager function to genutils and changed ? to print usage
4656 4664 note through it (it was too long).
4657 4665
4658 4666 * Added the LazyPython functionality. Works great! I changed the
4659 4667 auto-quote escape to ';', it's on home row and next to '. But
4660 4668 both auto-quote and auto-paren (still /) escapes are command-line
4661 4669 parameters.
4662 4670
4663 4671
4664 4672 2001-11-01 Fernando Perez <fperez@colorado.edu>
4665 4673
4666 4674 * Version changed to 0.0.7. Fairly large change: configuration now
4667 4675 is all stored in a directory, by default .ipython. There, all
4668 4676 config files have normal looking names (not .names)
4669 4677
4670 4678 * Version 0.0.6 Released first to Lucas and Archie as a test
4671 4679 run. Since it's the first 'semi-public' release, change version to
4672 4680 > 0.0.6 for any changes now.
4673 4681
4674 4682 * Stuff I had put in the ipplib.py changelog:
4675 4683
4676 4684 Changes to InteractiveShell:
4677 4685
4678 4686 - Made the usage message a parameter.
4679 4687
4680 4688 - Require the name of the shell variable to be given. It's a bit
4681 4689 of a hack, but allows the name 'shell' not to be hardwire in the
4682 4690 magic (@) handler, which is problematic b/c it requires
4683 4691 polluting the global namespace with 'shell'. This in turn is
4684 4692 fragile: if a user redefines a variable called shell, things
4685 4693 break.
4686 4694
4687 4695 - magic @: all functions available through @ need to be defined
4688 4696 as magic_<name>, even though they can be called simply as
4689 4697 @<name>. This allows the special command @magic to gather
4690 4698 information automatically about all existing magic functions,
4691 4699 even if they are run-time user extensions, by parsing the shell
4692 4700 instance __dict__ looking for special magic_ names.
4693 4701
4694 4702 - mainloop: added *two* local namespace parameters. This allows
4695 4703 the class to differentiate between parameters which were there
4696 4704 before and after command line initialization was processed. This
4697 4705 way, later @who can show things loaded at startup by the
4698 4706 user. This trick was necessary to make session saving/reloading
4699 4707 really work: ideally after saving/exiting/reloading a session,
4700 4708 *everythin* should look the same, including the output of @who. I
4701 4709 was only able to make this work with this double namespace
4702 4710 trick.
4703 4711
4704 4712 - added a header to the logfile which allows (almost) full
4705 4713 session restoring.
4706 4714
4707 4715 - prepend lines beginning with @ or !, with a and log
4708 4716 them. Why? !lines: may be useful to know what you did @lines:
4709 4717 they may affect session state. So when restoring a session, at
4710 4718 least inform the user of their presence. I couldn't quite get
4711 4719 them to properly re-execute, but at least the user is warned.
4712 4720
4713 4721 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now