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